;+ ; NAME: ; smei_frm_findpoint ; PURPOSE: ; Return frames with specified locations in the fov ; CATEGORY: ; ucsd/camera/idl ; CALLING SEQUENCE: PRO smei_frm_findpoint, trange, $ _extra = _extra , $ hdr = hdr , $ theta = theta , $ ccd = ccd , $ list = list , $ camera = camera ; INPUTS: ; trange array[2]; type: time structure ; time range of target frames ; OPTIONAL INPUT PARAMETERS: ; /degrees if set all angles are in degrees (default: radians) ; ; The sky locations can be specified using any one of the methods ; used in href=smei_frm_where=. The simplest is: ; ; points_radec array[2]; type: float ; J2000 RA and dec of locations in the sky. ; The units are degrees or radians depending on the ; setting of keyword /degrees. ; ; list=list scalar; type: string; default: none ; name of an output file where to write the fully-qualified ; file names of all SMEI frames containing the sky location. ; OUTPUTS: ; hdr=hdr array; type: structure ; headers for all identified SMEI frames ; theta=theta see href=smei_frm_where= ; ccd=ccd see href=smei_frm_where= ; OPTIONAL OUTPUT PARAMETERS: ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, IsType, TimeUnit, TimeOp, smei_coriolis, smei_frm_where ; TimeLimits, TimeGet, TimeSet, smei_property, destroyvar ; do_file, CheckDir ; PROCEDURE: ; > Check whole orbit starting at trange[0] for frames with the sky location ; in it. If no frames are found, try the next orbit. ; > If a transit of the sky location is found then determine the start ; and duration of the transit. Use this to estimate when the transit ; in the next orbit is. ; MODIFICATION HISTORY: ; NOV-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- IF IsType(trange,/undefined) THEN BEGIN message, /info, 'Syntax: smei_find_point, trange, radec=radec' RETURN ENDIF usec = TimeUnit(/sec) ; If only a single time is specified, search a whole orbit. ; starting at trange[0] t1 = trange[0] InitVar, trange, count=1, [t1,TimeOp(/add,t1,smei_coriolis(t1,/orbital_period))] REPEAT BEGIN ; Search orbit starting at t1 t2 = TimeOp(/add, t1, smei_coriolis(t1,/orbital_period)) hh = [t1,t2] message, /info, 'searching orbit '+strjoin(TimeGet(hh,upto=usec,/ymd),' - ') smei_frm_where, hh, _extra=_extra, inside=inside, nobject=nobject, camera=camera IF nobject GT 0 THEN BEGIN tmp = where(inside, nobject) IF nobject GT 0 THEN hh = hh[tmp] ENDIF IF nobject EQ 0 THEN t1 = t2 ; Try next orbit ENDREP UNTIL nobject GT 0 OR TimeOp(/subtract,t1,trange[1],usec) GT 0 IF nobject GT 0 THEN BEGIN t_orbit = smei_coriolis(t1,/orbital_period) tmp = smei_property(hh,/camera) i = where(tmp EQ 1, n1) i = where(tmp EQ 2, n2) i = where(tmp EQ 3, n3) IF n1 NE 0 THEN message, /info, 'found in camera 1' IF n2 NE 0 THEN message, /info, 'found in camera 2' IF n3 NE 0 THEN message, /info, 'found in camera 3' i = max([-1,n1,n2,n3],camera) message, /info, 'using camera'+strcompress(camera)+' only' ; Found group of matching frames (covering the transit of a point in the sky). ; Determine the start of the transit and the duration. tt = smei_property(hh,/time) dt = TimeOp(/subtract, tt, TimeLimits(tt, /max), usec) ; Check for the off-chance that the orbit covers a partial transit at the ; start of the orbit and the next transit at the end of the orbit. i = where( dt LT -TimeGet(t_orbit, /diff, /full, usec, /scalar)/2 ) IF i[0] NE -1 THEN tt[i] = TimeOp(/add,tt[i],t_orbit) ; Don't use keyword /range in TimeLimits here ! t1 = TimeLimits(tt, /min) ; Start of transit dt = TimeOp(/subtract,TimeLimits(tt,/max),t1) ; Duration of transit message, /info, 'first transit '+TimeGet(t1,/ymd,upto=usec)+ $ ' ('+strcompress(TimeGet(dt,/diff,/full,usec),/rem)+' sec, '+ $ strcompress(n_elements(tt),/rem)+' frames)' IF arg_present(hdr) THEN destroyvar, hdr REPEAT BEGIN t_orbit = smei_coriolis(t1,/orbital_period) t2 = TimeOp(/add,t1,dt) hh = [t1,t2] ; Covers transit hh = TimeOp(/add, hh, TimeSet(minute=[-1,1])); Extra margin on either side smei_frm_where, hh, camera=camera, _extra=_extra, inside=inside, nobject=nobject, ccd=ccd;, stheta=stheta CASE nobject OF 0 : count = 0 ELSE: BEGIN tmp = where(inside, count) IF count GT 0 THEN BEGIN hh = hh [ tmp] ccd = ccd[*,tmp] ENDIF END ENDCASE CASE count OF 0 : message, /info, strjoin(TimeGet([t1,t2],/ymd,upto=usec),'-')+': no matching frames' ELSE: BEGIN IF arg_present(hdr) THEN boost, hdr, hh IF IsType(list,/string) THEN BEGIN CASE CheckDir(list,/silent) OF 0: BEGIN openw, /get_lun, iu, list, /append FOR i=0,n_elements(hh)-1 DO printf, iu, smei_property(hh[i],/name), ccd[*,i], format='(A,2F8.1)' free_lun, iu END 1: FOR i=0,n_elements(hh)-1 DO tmp = do_file(/copy, smei_property(hh[i],/path)+'.*',list) ENDCASE ENDIF tt = smei_property(hh,/time) dt = TimeOp(/subtract, tt, TimeLimits(tt, /max), usec) i = where( dt lt -TimeGet(t_orbit,/diff,/full,usec)/2 ) IF i[0] NE -1 THEN tt[i] = TimeOp(/add,tt[i],t_orbit) t1 = TimeLimits(tt, /min) ; Start of transit dt = TimeOp(/subtract,TimeLimits(tt,/max),t1) ; Duration of transit tmp = '' IF nobject EQ 1 THEN $ tmp = ', ['+strcompress(round(mean(ccd[0,*],/nan)),/rem)+','+ $ strcompress(round(mean(ccd[1,*],/nan)),/rem)+']' message, /info, 'transit '+TimeGet(t1,/ymd,upto=usec)+ $ ' ('+strcompress(TimeGet(dt,/diff,/full,usec),/rem)+' sec, '+ $ strcompress(n_elements(tt),/rem)+' frames'+tmp+')' END ENDCASE t1 = TimeOp(/add,t1, t_orbit) ; Skip to next orbit ENDREP UNTIL TimeOp(/subtract, t1, trange[1], usec) GT 0 ENDIF RETURN & END