PRO ChopDate,YYMMDD,YY,MM,DD,Error=error tmp=Round(yymmdd+0.D0) ; convert to numeric type if possible IF tmp LT 710000L THEN BEGIN Message,'Date is too early',/Informational yy=-1 & mm=-1 & dd=-1 & error=1 Return ENDIF IF 991231L LT tmp THEN BEGIN Message,'Date is too late',/Informational yy=-1 & mm=-1 & dd=-1 & error=1 Return ENDIF dd=tmp MOD 100 tmp=tmp/100 mm=tmp MOD 100 yy=(tmp/100)+1900 error=0 Return END ;+ ; NAME: ; MERGE_QL ; PURPOSE: ; To merge specified 1-day .ql files (Polar Camera zenith ; brightnesses) into a single time series, with optional ; smoothing. ; CATEGORY: ; ; CALLING SEQUENCE: ; Merge_QL, Cam, Filt, First_Date, Last_Date, Julian_Date $ ; , Brightness [, Smooth = smooth] [, Median = median] ; INPUTS: ; Cam: The number [0|1] of the camera that recorded the data. ; Filt: Ditto for the filter. ; First_Date: The date (in YYMMDD format) of the first file to be ; merged into the time series. ; Last_Date: The date of the last file to be included, formatted ; as above. ; OPTIONAL INPUTS: ; None. ; KEYWORD PARAMETERS: ; Smooth: If non-zero, specifies the width of the running average ; to be used in smoothing the data. ; Median: If non-zero, specifies the width of the median filter to ; be used in smoothing the data. ; OUTPUTS: ; Julian_Date: The time of the observation, expressed as a Julian ; date decimal fraction. ; Brightness: The zenith brightnesses corresponding to the times ; in Julian_Date. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; None. ; RESTRICTIONS: ; None. ; PROCEDURE: ; ; EXAMPLE: ; ; SEE ALSO: ; ; MODIFICATION HISTORY: ; Written by: DPSteele, ISAS, May 24, 1996. ;- PRO Merge_QL,cam,filt,first_date,last_date,julian_Date,brightness $ ,smooth=smo,median=med IF N_Params() LT 5 THEN BEGIN Doc_Library,'Merge_QL' Return ENDIF ; Set up OS-dependent parameters @isitdos ; Check validity of cam and filt IF (cam LT 0) OR (1 LT cam) THEN BEGIN Message,'Camera number must be 0 or 1',/Informational Return END IF (filt LT 0) OR (4 LT filt) THEN BEGIN Message,'Filter number must be 0..4',/Informational Return END ; Check validity of input dates. ChopDate,first_date,fy,fm,fd,error=ferr IF ferr THEN BEGIN Message,'Problem with first date!',/Informational Return ENDIF ChopDate,last_date,ly,lm,ld,error=lerr IF lerr THEN BEGIN Message,'Problem with last date!',/Informational Return ENDIF ; Ensure keyword parameters have useful values. IF N_Elements(smo) EQ 0 THEN smo=0 ELSE smo=Round(smo) IF N_Elements(med) EQ 0 THEN med=0 ELSE med=Round(med) ; Identify the range of dates to process. fjd=JulDay(fm,fd,fy) ljd=JulDay(lm,ld,ly) ndays=ljd-fjd+1 dayfound=BytArr(ndays) jdlist=LonArr(ndays) filelist=StrArr(ndays) ; Determine which files are available. FOR ijd=fjd,ljd DO BEGIN jdlist(ijd-fjd)=ijd CalDat,ijd,month,day,year filename=String(year MOD 100,month,day,cam,filt $ ,Format='(3I2.2,2I1,".ql")') wf=RFindFile(qlroot+dd+filename,Count=nwf) dayfound(ijd-fjd)=(nwf GT 0) filelist(ijd-fjd)=qlroot+dd+filename ENDFOR ; Make output arrays big enough for 4 months of data at 2-min intervals. julian_date=Replicate(0.D0,100000) brightness=Float(Julian_Date) ptr=0 ; Load data into arrays. FOR i=0,ndays-1 DO BEGIN IF dayfound(i) THEN BEGIN data=ddread(filelist(i)) dsize=Size(data) IF dsize(0) NE 2 THEN BEGIN Message,'Something wrong with '+filelist(i),/Informational Return ENDIF npts=dsize(2) julian_date(ptr:ptr+npts-1)=Double(jdlist(i)) $ +Reform((Double(data(0,*))/8.64D4)-0.5D0) brightness(ptr:ptr+npts-1)=Reform(data(1,*)) ptr=ptr+npts ENDIF ENDFOR ; Keep only the non-zero elements of the arrays. keep=WHERE(brightness GT 0,nkeep) IF nkeep GT 0 THEN julian_date=julian_date(keep) ELSE BEGIN Message,'No non-zero brightnesses found for' $ +String(cam,filt,Format='(" camera ",I0,", filter ",I0)') $ ,/Informational Return ENDELSE brightness=brightness(keep) ; Apply the desired smoothing to the brightness array. IF smo GT 0 THEN brightness=Smooth(brightness,smo) IF med GT 0 THEN brightness=Median(brightness,med) Return END