;+ ; NAME: ; FCA_LNPT ; PURPOSE: ; Apply LNP_Test to sequences of intensities generated for FCA. ; CATEGORY: ; Time series analysis of images. ; CALLING SEQUENCE: ; FCA_LNPT, Year, Month, Day, Cam, Filt, UT, AFOV, Start, Length $ ; , MinPeriod = minperiod, Detrend=detrend, Show=show $ ; , OFac = ofac ; INPUTS: ; Year, Month, Day: Specify the start (UT) date of the ; observations. ; Cam, Filt: Identify the source of the data. ; UT: Vector of image start times (s since UT midnight). ; AFOV: Array (*,3) of brightnesses from 3 fields of view. ; OPTIONAL INPUTS: ; Start: If supplied, specifies the start time (s) of the ; interval of data to be analyzed. ; Length: IF supplied, specifies the length (s) of the interval ; to be analyzed. ; KEYWORD PARAMETERS: ; MinPeriod: If specified, gives the shortest period (s) for ; which the periodogram is to be plotted. ; /Detrend: If set, remove a linear trend from the data before ; running the LNP_Test. ; /Show: If set, plot the data as well as the periodogram. ; OFac: Determines the degree of spectral oversampling in the ; returned data. Default = 4. ; OUTPUTS: ; None. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; None. ; RESTRICTIONS: ; ; PROCEDURE: ; ; EXAMPLE: ; ; SEE ALSO: ; ; MODIFICATION HISTORY: ; Written by: DPSteele, ISAS, May 1996. ;- PRO FCA_LNPT, year, month, day, cam, filt, ut, afov, start, length $ , minperiod=mp,detrend=dt,show=sh,ofac=uofac IF N_Params() EQ 0 THEN BEGIN Doc_Library,'fca_lnpt' Return END ; Set up OS-dependent parameters. @isitdos utlen=(Size(ut))(1) IF (Size(afov))(1) NE utlen THEN BEGIN Message,'UT and AFOV must have the same first dimension' Return ENDIF IF (Size(afov))(2) NE 3 THEN BEGIN Message,'AFOV must have be Nx3' Return ENDIF ; Identify data limits and default analysis period. secperhr=3600. hrpersec=1./secperhr secperday=24.*secperhr mxut=Max(ut,Min=mnut) IF N_Elements(start) EQ 0 THEN start=Floor(mnut/secperhr)*secperhr IF N_Elements(length) EQ 0 THEN length=Ceil((mxut-mnut)/secperhr)*secperhr IF N_Elements(mp) EQ 0 THEN mp=length/30. IF N_Elements(uofac) EQ 0 THEN uofac=4 ; Identify data to be tested. wtest=Where((start LE ut) AND (ut LE start+length),nwtest) IF nwtest EQ 0 THEN BEGIN Message,'No data in selected interval' Return ENDIF utset=ut(wtest) alldata=FltArr(nwtest,3) ; Apply test. results=FltArr(2,3) jtmp=0L jmax=LonArr(3) FOR i=0,2 DO BEGIN ; Detrend the data if desired. dataset=afov(wtest,i) dytitle='Brightness (R)' IF Keyword_Set(dt) THEN BEGIN coeff=Poly_Fit(utset,dataset,1,trend) dataset=dataset-trend ; Help,dataset dytitle='Detrended Brightness (R)' ENDIF alldata(*,i)=dataset ; Help,alldata results(*,i)=LNP_Test(utset,dataset $ ,HiFac=1,JMax=jtmp,OFac=uofac $ ,Wk1=linfreq,Wk2=lnpval) jmax(i)=jtmp IF i EQ 0 THEN BEGIN nfreqs=N_Elements(linfreq) linfreqs=[[linfreq],[FltArr(nfreqs)],[FltArr(nfreqs)]] lnpvals=[[lnpval],[FltArr(nfreqs)],[FltArr(nfreqs)]] ENDIF ELSE BEGIN linfreqs(*,i)=linfreq lnpvals(*,i)=lnpval ENDELSE ENDFOR ; Determine uniform significance levels. ; Stop ; sigfit=Poly_Fit(Exp(-results(0,*)),results(1,*),1,fval) ; goodfit=Max(Abs(results(1,*)-sigfit(0)-fval)/fval) LT 0.001 ; goodfit=Max((Abs(results(1,*)-fval)-sigfit(0))/fval) LT 0.01 zp=FltArr(3) pl=['0.0001','0.001','0.01'] ; IF goodfit THEN BEGIN m=nwtest FOR lp=-4,-2 DO zp(lp+4)=ALog(m)-ALog(10.^lp) ; ENDIF ELSE Message,'Could not determine significance levels.' ; Plot results. IF !D.Name NE 'PS' THEN BEGIN ss=Screen_Size() goldrat=(1+Sqrt(5))/2 Window,0,XSize=ss(1)/goldrat,YSize=ss(1) ENDIF skipday=Floor(start/secperday) startjday=JulDay(month,day,year)+skipday tstring='Lomb Normalized Periodogram (LNP_Test) ' $ +jd2date(startjday,Form='d$ n$ y$') $ +String((start-secperday*skipday)/secperhr $ ,(start+length-secperday*skipday)/secperhr $ ,Format='(" (",F4.1," - ",F4.1," h UT) ")') $ +filters(5*cam+filt)+' ' IF Keyword_Set(sh) THEN BEGIN !P.Multi=[0,0,6,0,0] pstring=jd2date(startjday,Form='d$ n$ y$') $ +String((start-secperday*skipday)/secperhr $ ,(start+length-secperday*skipday)/secperhr $ ,Format='(" (",F4.1," - ",F4.1," h UT) ")') $ +filters(5*cam+filt)+' ' ENDIF ELSE !P.Multi=[0,0,3,0,0] FOR i=0,2 DO BEGIN IF Keyword_Set(sh) $ THEN Plot,(utset-skipday*secperday)/secperhr,alldata(*,i) $ ,XTitle='Time (UT)' $ ,XRange=[Floor(Min((utset-skipday*secperday)/secperhr)) $ ,Ceil(Max((utset-skipday*secperday)/secperhr))] $ ,YTitle=dytitle,Title=pstring+'FoV '+StrTrim(i,2) Plot,secperhr*linfreqs(*,i),lnpvals(*,i) $ ,XTitle='Linear Frequency (hr!e-1!n)' $ ,XRange=[0.,Max([hrpersec*mp,30000./length])] $ ,YTitle='Spectral Power' $ ,YRange=[0,MAX([length/1800.,1.33*lnpvals(*,i)])] $ ,Title=tstring+'FoV '+StrTrim(i,2) ; Determine character size in DATA units. cc=Convert_Coord([[0,0],[!D.X_Ch_Size,!D.Y_Ch_Size]],/Device,/To_Data) cs=cc(*,1)-cc(*,0) ; If significance levels have been determined, show them. IF Total(zp) GT 0 THEN BEGIN FOR lp=0,2,2 DO BEGIN IF zp(lp) LT !Y.CRange(1) THEN BEGIN PlotS,!X.CRange,[zp(lp),zp(lp)],LineStyle=lp+1 XYOutS,!X.CRange(1)-2*cs(0),zp(lp)+0.25*cs(1),pl(lp) $ ,Alignment=1 ENDIF ENDFOR ENDIF ;; Annotate major peak in periodogram. ; ; XYOutS,secperhr*linfreqs(jmax(i),i)+cs(0),results(0,i)-cs(1) $ ; ,String(hrpersec/linfreqs(jmax(i),i),results(1,i) $ ; ,Format='("Period: ",F6.2," hr; Significance: ",E8.1)') ; Stop ; Locate and label significant (<0.0001) peaks in periodogram. pks=Extremes(lnpvals(*,i),1) spks=Where(lnpvals(pks,i) GT zp(0),nspks) IF nspks GT 0 THEN BEGIN FOR j=0,nspks-1 DO BEGIN XYOutS,secperhr*linfreqs(pks(spks(j)),i)+0.5*cs(0) $ ,lnpvals(pks(spks(j)),i)+0.2*cs(1) $ ,StrTrim(String(hrpersec/linfreqs(pks(spks(j)),i) $ ,Format='(F4.1)'),2) $ ,Alignment=0,Orientation=90 ENDFOR ENDIF IF Keyword_Set(dt) $ THEN XYOutS,!X.CRange(1)-2*cs(0),!Y.CRange(1)-cs(1) $ ,'detrended',Alignment=1 IF (i EQ 2) THEN TimeStmp ENDFOR Return END