;+ ; NAME: ; IMF_CONF ; PURPOSE: ; Cross-correlation of IMF By and polar cap convection direction, ; December 8, 1993. ; CATEGORY: ; Event specific data analysis ; CALLING SEQUENCE: ; IMF_CONV, IMF_FILE, IMF_COL, CONV_FILE [, CONV_COL] $ ; , START=start, FINISH=finish, PS=ps, NPKS=npks $ ; , TRIPLEX=triplex, SFIT=sfit, CORRSIGN=corrsign ; INPUTS: ; IMF_FILE: Specifies the full pathname of the file containing ; the IMF data (in either Cartesian or polar GSM coordinates). ; IMF_COL: Specifies the column of the IMF_FILE containing the ; coordinate to be used for the cross-correlation. ; CONV_FILE: Specifies the full pathname of the file containing ; the convection parameters to be used. ; OPTIONAL INPUTS: ; CONV_COL: If set, specifies the column of the CONV_FILE containing ; the parameter to be used for the cross-correlation (D = 10). ; KEYWORD PARAMETERS: ; /HELP: If set, displays internal documentation. ; START: If specified, gives the UT start hour of the correlation ; interval. ; FINISH: As above, except the finish hour. ; MAXLAG: If set, specifies the maximum lag between the IMF By and the ; convection direction for which a cross-correlation is to be ; computed. The default is (finish - start). ; /PS: If set, send the plots to a PS file instead of a window. ; NPKS: Specifies the number of cross-correlation peaks to annotate. ; /TRIPLEX: If set, all text is in Triplex Roman instead of Simplex Roman. ; /SFIT: If set, do separate fits of convection direction to IMF By for ; By > 0 and By < 0. ; CORRSIGN: Determines whether positive correlations (CORRSIGN=1) or ; negative correlations (CORRSIGN=-1) are sought. ; OUTPUTS: ; None. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; Two files are read. If /PS is set, a PostScript plot file is created. ; RESTRICTIONS: ; Hardwired to use two specific file names. Could be generalized with ; moderate effort. ; PROCEDURE: ; Straightforward. Data sets are interpolated to 1-min steps. ; EXAMPLE: ; ; SEE ALSO: ; ; MODIFICATION HISTORY: ; Written by: DPS, ISR/ISAS, Sept. 9-18, 1995. ;- PRO imf1plot,imf_file,imf_col,conv_file,conv_col $ ,help=help,start=start,finish=finish,maxlag=maxlag,ps=ps,npks=npks $ ,triplex=triplex,sfit=sfit,corrsign=corrsign IF KEYWORD_SET(help) THEN BEGIN doc_library,'imf_conv' RETURN ENDIF IF N_PARAMS() EQ 3 THEN conv_col=10 IF N_ELEMENTS(start) EQ 0 THEN start=0. IF N_ELEMENTS(finish) EQ 0 THEN finish=24. IF N_ELEMENTS(maxlag) EQ 0 THEN maxlag=finish-start IF N_ELEMENTS(npks) EQ 0 THEN npks=3 IF KEYWORD_SET(triplex) THEN font='!17' ELSE font='!3' IF N_ELEMENTS(sfit) EQ 0 THEN sfit=0 IF N_ELEMENTS(corrsign) EQ 0 THEN corrsign=1 IF ABS(corrsign) NE 1 THEN corrsign=1 ; Read in the IMF data file ; imf=TRANSPOSE(ddread('\images\pgm\dec0893.txt')) imf=TRANSPOSE(ddread(imf_file)) utimf=imf(*,0) by=imf(*,imf_col) butrange=[MIN(utimf,MAX=tmp),tmp] ; Read in the convection velocity file ; conv=qgetfile('\images\pgm\93120802.cmg') conv=qgetfile(conv_file) nl=N_ELEMENTS(conv) lasttext=WHERE(STRPOS(conv,'IM#') EQ 0,nlt) IF nlt LT 1 THEN BEGIN MESSAGE,'Couldn''t find end of text',/INFORMATIONAL RETURN ENDIF ndata=nl-lasttext(0)-1 data=INDGEN(ndata)+lasttext(0)+1 ; Set up convection parameter arrays keep=conv(data) utconv=FLTARR(ndata) dev=utconv ; Extract convection parameters len=STRLEN(keep) maxlen=MAX(len) FOR i=0,ndata-1 DO BEGIN ki=keep(i) utconv(i)=FLOAT(getwrd(ki,2)) IF len(i) EQ maxlen THEN BEGIN dev(i)=FLOAT(getwrd(ki,conv_col)) ENDIF ENDFOR ; Interpolate missing data dutrange=[MIN(utconv,MAX=tmp),tmp] full=WHERE(len EQ maxlen,nfull) omit=WHERE(len LT maxlen,nomit) dev(omit)=interpol(dev(full),utconv(full),utconv(omit)) ; Extend both data sets artificially to a longer time span datarange=[butrange(0)dutrange(1)] fillrange=datarange+[-10000.,+10000.] dutimf=MEDIAN(utimf-SHIFT(utimf,1)) dutconv=MEDIAN(utconv-SHIFT(utconv,1)) utimf=[fillrange(0),utimf(0)-dutimf $ ,utimf $ ,utimf(N_ELEMENTS(utimf)-1)+dutimf,fillrange(1)] by=[0.,0.,by,0.,0.] utconv=[fillrange(0),utconv(0)-dutconv $ ,utconv $ ,utconv(N_ELEMENTS(utconv)-1)+dutconv,fillrange(1)] dev=[0.,0.,dev,0.,0.] ; Interpolate both data sets to a uniform time grid urange=ROUND(fillrange/60.)*60 utime=makex(FLOAT(urange(0)),FLOAT(urange(1)),60.) uby=interpol(by,utimf,utime) udev=interpol(dev,utconv,utime) ; Locate the interval over which to do the cross-correlation first=3600.*start>butrange(0)>dutrange(0) last=3600.*finish