;+ ; NAME: ; FCAMEEK ; PURPOSE: ; Concatenate source data files for FCA from different days into a ; single long time series. ; CATEGORY: ; Image analysis ; CALLING SEQUENCE: ; FCACONCAT,YEAR,MONTH,DAY,CAM,FILT $ ; ,n,ut,afov [,ni,uut,iafov,xx,yy,xi,eta,d,psi] ; INPUTS: ; YEAR, MONTH: Specify the (start) year and month of the ; observations. If only these two parameters are supplied ; the routine sets up for multiple-day analysis. ; OPTIONAL INPUTS: ; DAY: Specifies the single UT day of the observations. ; CAM, FILT: Specify the camera and filter numbers. ; KEYWORD PARAMETERS: ; None. ; OUTPUTS: ; N: Number of elements in returned time series of data. ; UT: N-element vector of image start times (s after UT ; midnight) for all data points. ; AFOV: (3,N) array of image data from three fields of view at N ; times. ; OPTIONAL OUTPUTS: ; NI: Number of elements in interpolated time series. ; UUT: NI-elements vector of times, interpolated to 1-min ; intervals. ; IAFOV: Data in AFOV, interpolated to 1-min intervals. ; XX, YY: Distances (in km) of fields of view (at assumed height) ; E and N of Polar Camera location. ; XI, ETA: Distances (in km) of each field of view E and N from ; preceding field of view (at assumed height). ; D: Distance of each field of view from preceding one. ; PSI: Azimuth of line from preceding field of view to present ; one, relative to N. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; One or more FCA data files is read. ; RESTRICTIONS: ; Suitable FCA data file(s) must exist. ; PROCEDURE: ; Straightforward. ; EXAMPLE: ; ; SEE ALSO: ; ; MODIFICATION HISTORY: ; Modified by: DPSteele, ISAS, May 1996 from FCAMEEK.PRO. ;- PRO fcaconcat,year,month,day,cam,filt $ ,n,ut,afov,ni,uut,iafov,xx,yy,xi,eta,d,psi IF N_PARAMS() EQ 0 THEN BEGIN doc_library,'fcaconcat' RETURN ENDIF ; Set up OS-dependent parameters. @isitdos ; ON_ERROR,2 IF N_Elements(day) EQ 0 THEN day=0 IF (N_Params() EQ 2) OR (day EQ 0) THEN BEGIN ; year, month only => multi-day! patt=STRING(year MOD 100,month,fca_suffix $ ,FORMAT='(2I2.2,"????",A)') REPEAT BEGIN tmp=PickFile(/Read,Path=fcaroot,Filter=patt) IF StrLen(tmp) GT 0 THEN BEGIN IF N_Elements(file) EQ 0 THEN BEGIN cfnum=Fix(StrMid(tmp,StrPos(tmp,'.')-2,1)) fcam=cfnum/5 ffilt=cfnum MOD 5 IF (N_Elements(cam) GT 0) AND $ (N_Elements(filt) GT 0) THEN BEGIN discrep=(cam NE fcam) OR (filt NE ffilt) IF discrep THEN Message,'Camera/filter discrepancy!' ENDIF ELSE BEGIN cam=fcam filt=ffilt ENDELSE file=StrUpCase(tmp) ENDIF ELSE BEGIN cfnum=Fix(StrMid(tmp,StrPos(tmp,'.')-2,1)) tcam=cfnum/5 tfilt=cfnum MOD 5 IF (tcam NE cam) OR (tfilt NE filt) $ THEN Message,'Camera/filter discrepancy!' file=[file,StrUpCase(tmp)] ENDELSE ENDIF ENDREP UNTIL StrLen(tmp) EQ 0 ENDIF ELSE BEGIN IF N_Elements(num) EQ 0 THEN nch='?' ELSE nch=String(num,Format='(I1)') patt=String(year MOD 100,month,day,5*cam+filt,nch,fca_suffix $ ,Format='(3I2.2,I1,A1,A)') tmp=pickfile(/read,path=fcaroot,filter=patt) IF STRLEN(tmp) GT 0 THEN file=STRUPCASE(tmp) ELSE BEGIN MESSAGE,'No file found; exiting' RETURN ENDELSE ENDELSE IF NOT dos THEN file=StrLowCase(file) nfiles=N_Elements(file) nlin=INTARR(nfiles) nfov=nlin year=nlin month=nlin day=nlin jday=LONARR(nfiles) allfovparms=FLTARR(4,5*nfiles) ; Data in correct format will fit here match=1B ; Flag to test parameter agreement among multiple files FOR i=0,nfiles-1 DO BEGIN ; How big is the file? nlin(i)=n_lines(file(i)) ; open the file OpenR,corrunit,file(i),/GET_LUN ; read the number of fields of view used READF,corrunit,numfov nfov(i)=FIX(ROUND(numfov)) IF nfov(i) NE 3 THEN BEGIN MESSAGE,'This analysis only applicable to 3-sensor data!' FREE_LUN,corrunit RETURN ENDIF ; read in the field of view parameters fovparms=FLTARR(nfov(i)+1,5) READF,corrunit,fovparms allfovparms(0,5*i)=fovparms ; copy parms for check below fovparms=TRANSPOSE(fovparms(1:*,*)) ; Check whether fovparms agree with first file loaded IF i GT 0 THEN BEGIN thesematch=allfovparms(*,5*i:5*i+4) EQ allfovparms(*,0:4) match=match AND Min(thesematch) IF NOT match THEN BEGIN MESSAGE,'Parameter mismatch in file '+STRTRIM(i,2) $ ,/INFORMATIONAL RETURN ENDIF ENDIF ; read in the data data=FLTARR(nfov(i)+1,nlin(i)-6) READF,corrunit,data FREE_LUN,corrunit ; Determine date parameters from file name IF dos THEN patt='FCA' ELSE patt='fca' inpt=STRPOS(file(i),dd+patt+dd)+5 year(i)=1900+FIX(STRMID(file(i),inpt,2)) month(i)=FIX(STRMID(file(i),inpt+2,2)) day(i)=FIX(STRMID(file(i),inpt+4,2)) jday(i)=JulDay(month(i),day(i),year(i)) ; Concatenate data from several days IF i EQ 0 THEN BEGIN ut=TRANSPOSE(data(0,*)) afov=TRANSPOSE(data(1:*,*)) ENDIF ELSE BEGIN ut=[ut,TRANSPOSE(data(0,*))+(jday(i)-jday(0))*86400.] afov=[afov,TRANSPOSE(data(1:*,*))] ENDELSE ENDFOR ; Check that data are in correct order timesort=Sort(ut) ut=ut(timesort) FOR j=0,(Size(afov))(2)-1 DO afov(*,j)=afov(timesort,j) ; Check data for discontinuities n=(Size(ut))(1) dtime=ut(1:n-1)-ut(0:n-2) resp='' Print,String(Max(dtime,loc),ut(loc)/3600. $ ,Format='("Max. time gap = ",F7.0," sec at ",F5.1," UT")') ; identify first and last UT values mxut=MAX(ut,MIN=mnut) Print,String(mnut,mxut,mnut/3600.,mxut/3600. $ ,Format='("Data span ",F7.0," - ",F7.0," s (",F6.1," - ",F6.1,' $ +'" h UT)")') xx=REFORM(fovparms(3,*)) yy=REFORM(fovparms(4,*)) ; PRINT,"'Sensor' coordinates:" ; fm='(A,'+STRTRIM(nfov(0),2)+'F10.2)' ; PRINT,"xx: ",xx,FORMAT=fm ; PRINT,"yy: ",yy,FORMAT=fm ncross=nfov(0) ; Now identify the FOV pairs involved in the cross-correlations p=INDGEN(ncross) q=FIX((p+1) MOD nfov(0)) xi=xx(q)-xx(p) eta=yy(q)-yy(p) d=SQRT(xi*xi+eta*eta) ; inter-sensor distances psi=(ATAN(xi,eta)+2.*!PI) MOD (2.*!PI) ; inter-sensor azimuths ; PRINT,'xi: ',xi,FORMAT=fm ; PRINT,'eta: ',eta,FORMAT=fm ; PRINT,'d: ',d,FORMAT=fm ; PRINT,'psi: ',psi*!RADEG,FORMAT=fm ; set up uniform UT array for interpolation of observations ni=CEIL(mxut/60.)-FLOOR(mnut/60.)+1 uut=(FINDGEN(ni)+FLOOR(mnut/60.))*60 ; interpolate to 1-minute intervals iafov=FLTARR(ni,nfov(0)) FOR i=0,nfov(0)-1 DO iafov(*,i)=interpol(afov(*,i),ut,uut) Message,'Raw data are in afov; interpolated data in iafov.' $ ,/Informational Help,afov,iafov Return END