pro norh_rd_tcx,arg0,arg1,arg2,arg3,freq=freq,integer=integer $ ,event=event,infil=infil ;+ ; NAME: ; NORH_RD_TCX ; ; PURPOSE: ; This procedure reads the NORH 'tca' or 'tcz' file. ; ; CALLING SEQUENCE: ; norh_rd_tcx,infil,index,cor ; norh_rd_tcx,st_day,ed_day,index,cor ; norh_rd_tcx,day,index,cor ; ; INPUTS: ; infil: list of 'tca' or 'tcz' files to be read ; st_day: start day to be read ; ed_day: end day to be read ; day: day to be read ; OPTIONAL INPUTS: ; freq: observing frequency, 17 or 34 ; ; OPTIONAL INPUT KEYWORDS: ; event: if set, read event-mode data ; integer: if set, give the correration in longword integer ; with max. of 2^{15}=32768. ; ; OUTPUTS: ; index: index structure ; cor: Correlation. ; ; HISTORY: ; Writtern 1998-09-04 TY ; Modified 1999-01-02 TY for norh_tcx2idx ; Modified 1999-01-13 TY max. cor becomes unity ; Modified 1999-04-14 TY event ; Modified 1999-11-15 TY bug fix for no event-file date ; Modified 1999-12-27 TY bug fix for event (JST & UT confuse) ; ;- if (n_elements(freq) eq 0) then freq=17 if (freq eq 34) then freqst='tcz' else freqst='tca' if ((strpos(arg0(0),'bf') ne -1) or $ (strpos(arg0(0),'cf') ne -1) or $ (strpos(arg0(0),'tc') ne -1)) then begin infil=arg0 endif else begin case n_params() of 4 : begin st_time=arg0 ed_time=arg1 st_daytim=anytim(st_time,/ints) ed_daytim=anytim(ed_time,/ints) end 3 : begin st_time=arg0 st_daytim=anytim(st_time,/ints) ed_daytim=st_daytim ; ed_daytim.day=st_daytim.day end else : message, 'Too small number of arguments' endcase ndayx=ed_daytim.day-st_daytim.day+1 ex=anytim(transpose([[lonarr(ndayx)],[st_daytim.day+lindgen(ndayx)]]),/ex) yyyy=reform(ex(6,*)) mm=reform(ex(5,*)) dd=reform(ex(4,*)) yy=yyyy-yyyy/100*100 yymmdd=$ string(transpose([[yy],[mm],[dd]]),format="(i2.2,i2.2,i2.2)") year=strtrim(string(yyyy),2) dir0=getenv('DIR_NORH_TCX') if not keyword_set(event) then begin files=freqst+yymmdd+'*' dir=[dir0+'/'+year+'/'+string(mm,format="(i2.2)")] dir=dir(uniq(dir)) infil=file_list(dir,files) infil=infil(where(strpos(infil,'_') eq -1)) endif else begin pr_ex=anytim([0,st_daytim.day-1],/ex) pr_yyyy=reform(pr_ex(6,*)) pr_mm=reform(pr_ex(5,*)) pr_dd=reform(pr_ex(4,*)) pr_yy=pr_yyyy-pr_yyyy/100*100 pr_yymmdd=$ string(pr_yy,pr_mm,pr_dd,format="(i2.2,i2.2,i2.2)") files=freqst+[pr_yymmdd+'_2*',yymmdd+'_0*'] dir=[dir0+'/'+year+'/'+string(mm,format="(i2.2)")] if (n_elements(dir) ge 2) then dir=dir(uniq(dir)) infil=file_list(dir,files) endelse endelse if (n_elements(infil) eq 1) then begin if (infil(0) eq '') then begin print,'No files found' return endif endif mx=n_elements(infil) case mx of 1: begin file=infil(0) cor_el=readfits(file,header,/silent) index_el=norh_tcx2idx(header) cor=cor_el index=index_el end else : begin m=0 file=infil(m) cor_el=readfits(file,header,/silent) index_el=norh_tcx2idx(header) cor=cor_el index=index_el for m=1,mx-1 do begin file=infil(m) cor_el=readfits(file,header,/silent) index_el=norh_tcx2idx(header) cor=[cor,cor_el] index=[index,index_el] endfor end endcase if keyword_set(integer) then cor=fix(cor*32760) case n_params() of 4 : begin arg2=index arg3=cor end 3 : begin arg1=index arg2=cor end endcase end