function norh_tim2f,arg0,arg1,arg2 $ ,freq=freq,jst=jst,useinfo=useinfo,event=event ;+ ; NAME: ; NORH_TIM2F ; ; PURPOSE: ; This function interprets the observing time ; into the data frame number. ; ; CALLING SEQUENCE: ; dayfr = norh_tim2f(st_time,ed_time,interval) ; dayfr = norh_tim2f(times) ; ; INPUTS: ; st_time: Start time of the observing sequence. ; An n-element vector of time. ; Any formats supported by 'anytim' function ; is accepted. ; (1) structure wit a .time and .day field, or ; (2) 2xN where the first dimension holds (MSOD, DS79), or ; (3) a double or float array of seconds from 1-jan-79, or ; (4) string, e.g. ; '1992-11-05 12:33:00' (NORH) ; '1992-11-05T12:33:00Z' (ISO 8601) ; '12:33:00 5-nov-92' (Yohkoh) ; '92/11/05 12:33:00' (HXRBS) ; etc. ; ed_time: End time of the sequence. ; An n-element vector of time. ; interval: Interval of the obseving sequence in units of 'second'. ; An n-element vector of integer. ; times: Time of requested data sequence. ; Non-uniform interval is accepted. ; ; OPTIONAL INPUT KEYWORDS: ; event: event mode data ; freq: Observing frequency of the data. ; '17' or '34'. Default is '17'. ; jst: Set if the time in arguments are in JST. ; Default is in UT. ; useinfo: use 'info' file for finding the synthesizing frame ; instead of 'tsx' ; ; OUTPUT ; dayfr: An n-element vector of long-type arrays. ; [[day,frame] ,[ ... ], ] ; The value for 'day' is the same as .day structure. ; ; HISTORY: ; Writtern 1998-05-29 TY ; Modified 1998-09-14 TY ; Modified 1999-1-14 TY for useinfo option ; Modified 1999-02-04 TY /event support ; Modified 1999-07-14 TY bug for data with CALIB ; Modified 1999-11-11 TY bug fix for data with calib ; Modified 1999-12-27 TY bug fix n0=1+intarr(n_files) ; ;- if keyword_set(freq) eq 0 then freq=17 norh_mkst_dayfr,dayfr_el case n_params() of 1: begin daytm=anytim(arg0,/ints) if (keyword_set(jst)) then daytmj=daytm $ else daytmj=norh_ut2jst(daytm,/ints) nx=n_elements(daytm) dayfr=replicate(dayfr_el,nx) dayj_prev=-1 for n=0, nx-1 do begin if (daytmj(n).day ne dayj_prev) then begin if not keyword_set(useinfo) then begin norh_rd_tsx,anytim(daytmj(n),/ccsds),index,data,freq=freq $ ,n_files=n_files,n_frames=n_frames,event=event,status=status daytmj0=norh_gt_timejst(index,/ints) ; n0=0 ; add 99/07/14 ; n0=1 ; add 99/11/11 n0=1+intarr(n_files) ; add 99/12/3 endif else begin norh_pr_info,anytim(daytmj(n),/ccsds) $ ,list=listev,/nodisp,/jst,event=event ; ,list=listev,/nodisp,/jst,/withcarib,event=event ;cmt-out 99/07/14 sz=size(listev) if (sz(0) ne 1) then mx=sz(2) else mx=1 t0=anytim(reform(listev(0,*))) t1=anytim(reform(listev(1,*))) sc= reform(listev(2,*)) n0= long(reform(listev(3,*))) n1= long(reform(listev(4,*))) sid=strmid(sc,6,1) schedule=intarr(mx)-1 n_schedules=mx schedule=indgen(n_schedules) whr=indgen(n_schedules) ; whr=where(sid ne ' ',n_schedules0) ; if (n_schedules0 ge 1) then begin ; schedule(whr)=reform(byte(sid(whr)))-(byte('a'))(0) ; n_schedules=n_schedules0 ; endif else n_schedules=1 daytmj0=daytm(0) n_frames=lonarr(n_schedules) for msc=0,n_schedules-1 do begin whr2=where(schedule eq msc,count) if count eq 1 then begin m=whr(msc) dt=(t1(m)-t0(m))/(n1(m)-n0(m)) ntmp=n1(m)-n0(m)+1 tmp=anytim(t0(m)+dt*lindgen(ntmp),/ints) daytmj0=[daytmj0,tmp] n_frames(msc)=n_frames(msc)+ntmp endif else begin whr3=whr2(sort(n0(whr2))) for mmm=0,count-1 do begin m=whr3(mmm) dt=(t1(m)-t0(m))/(n1(m)-n0(m)) ntmp=n1(m)-n0(m)+1 tmp=anytim(t0(m)+dt*lindgen(ntmp),/ints) daytmj0=[daytmj0,tmp] n_frames(msc)=n_frames(msc)+ntmp endfor endelse endfor daytmj0=daytmj0(1:*) n_files=n_schedules endelse endif whr=where(daytmj0.day eq daytmj(n).day,count) if keyword_set(status) then $ whr=where((daytmj0.day eq daytmj(n).day) and (status eq 2),count) if (count ne 0) then begin tmj=daytmj(n).time tmj0=daytmj0(whr).time tmp=abs(tmj-tmj0) pos=whr(where( min(tmp) eq tmp)) pos_abs=pos(0) if (n_files ge 2) then begin total_frame=0 for nf=0,n_files-1 do begin total_frame_prev=total_frame total_frame=total_frame+n_frames(nf) if (pos_abs lt total_frame) then goto,L100 endfor L100: pos_rel=pos_abs-total_frame_prev ; if (pos_rel eq 0) then pos_rel=1 dayfr(n).schedule=nf dayfr(n).frame=pos_rel+n0(nf) endif else begin dayfr(n).schedule=-1 dayfr(n).frame=pos_abs+n0(0) endelse endif jump: dayfr(n).dayjst=daytmj(n).day dayj_prev=daytmj(n).day endfor end 3: begin interval=arg2 intvl=long(interval*1000L) msmx=86400000L if (intvl ge msmx) then $ message,'interval in sec must be smaller than 86400' st_daytm=anytim(arg0,/ints) ed_daytm=anytim(arg1,/ints) if (keyword_set(jst)) then begin st_daytmj=st_daytm ed_daytmj=ed_daytm endif else begin st_daytmj=norh_ut2jst(st_daytm,/ints) ed_daytmj=norh_ut2jst(ed_daytm,/ints) endelse ndayx=ed_daytmj.day-st_daytmj.day+1 ; number of days for nday=0,ndayx-1 do begin today=st_daytmj.day+nday if (nday eq 0) then begin st_tday=st_daytmj.time endif else begin ed_yday=max(daytmj.time) tmp=ed_yday+intvl st_tday=tmp-tmp/msmx*msmx endelse if (nday eq ndayx-1) then begin ed_tday = ed_daytmj.time endif else begin ed_tday = msmx endelse mx=(ed_tday-st_tday)/intvl+1 daytmj=replicate(st_daytmj,mx) if mx ge 2 then begin daytmj.day=replicate(today,mx) daytmj.time=st_tday+intvl*lindgen(mx) endif else begin daytmj.day=today daytmj.time=st_tday endelse dayfr0=norh_tim2f(daytmj,/jst,useinfo=useinfo,event=event,freq=freq) if (n_elements(dayfr) eq 0) then begin dayfr=dayfr0 endif else begin dayfr=[dayfr,dayfr0] endelse endfor end else: message,'Wrong number of arguments' endcase return,dayfr end