pro ipscorr, group=group, geomagnetic=geomagnetic, $ xx=x,yy=y,xrange=xrange,yrange=yrange,normal=normal @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; IPSCORR ; PURPOSE: ; Correlate G-values with IMP8 data ; CALLING SEQUENCE: ; IPSCORR ; INPUTS: ; OPTIONAL INPUT PARAMETERS: ; /group prompts for file with separate groups (see PROCEDURE) ; OUTPUTS: ; OPTIONAL OUTPUT PARAMETERS: ; CALLS: ; SIDE EFFECTS: ; RESTRICTIONS: ; Data files in X$DATA ; PROCEDURE: ; > If the group keyword is set, user is prompted for a file which contains ; a description of groups of files, in the following format: ; . each record contains a single modified Julian day ; . each group is terminated with a record containing a 0 ; Each group will be plotted seperately (the correlation still pertain to ; all groups combined) ; MODIFICATION HISTORY: ; August 1992, Susan Rappoport (UCSD) ; March 1994, Susan Rappoport (UCSD) ;- common save_ipscorr, fi if keyword_set(group) then group = 1 else group = 0 if keyword_set(geomagnetic) then $ ips_geo, title, titles, tags, data, $ logpos, logshift, invalid, ranges, gparm, nparm, xparm, yparm $ else $ ips_imp, title, titles, tags, data, $ logpos, logshift, invalid, ranges, gparm, nparm, xparm, yparm elongstr = ['30-50','30-80','50-70'] print, ' Elongation (Inner-Outer)?:' l = 1 & echo,'(0=30-50,1=30-80,2=50-70) ',l,0,2 elstr = elongstr(l) print, ' ',data echo, 'X-axis type?', xparm, 0,n_elements(tags)-1 echo, 'Y-axis type?', yparm, 0,n_elements(tags)-1 xlog = logpos(xparm) ylog = logpos(yparm) rxparm = xparm-xlog*logshift(xparm) ryparm = yparm-ylog*logshift(yparm) dayparm = -8 & echo,'Day: Aft,Fore,Current(-8 to 8)',dayparm,-8,8 dayparm = dayparm/2*2 if keyword_set(group) then begin if n_elements(fi) ne 0 then d = fi else d = 'files.lis' echo, /file, 'File name with groups info', d fi = (file_search(d))[0] if fi eq '' then message, 'File not found: '+d n = flt_read( fi, tt ) tt = round( tt ) n = n_elements(tt) d = where(tt eq 0, ngroups) ; Each group is terminated by a 0 j = 0 l = indgen(n) groups = intarr(n) for i=0,ngroups-1 do begin groups ( where(j le l and l lt d[i]) ) = i+1 j = d[i]+1 endfor d = where(tt ne 0) tt = tt(d) groups = groups[d] n = n_elements(tt) endif else begin first = 0 & echo, 'Start at MJD', first last = first & echo, 'Stop at MJD', last n = last-first+1 tt = first+indgen(n) ngroups = 1 groups = replicate(1,n) endelse message, /info, '# groups='+strcompress(ngroups)+' (# files ='+strcompress(n)+')' first = min(tt) last = max(tt) ndays = n x = fltarr(n) y = fltarr(n) for i=0,n-1 do begin ; f(i,*) = day,doy,gval,delg,dens,deldens,vel,delvel ; day = -8,-6,..,6,8 ; doy = day of year if flt_read( filepath(root=getenv('DAT'),strcompress(tt(i)-dayparm,/rem)+'.dat'),/silent) then begin get = where( f(0,*) eq dayparm ) & get = get(0) x(i) = f(2+rxparm,get) y(i) = f(2+ryparm,get) endif else $ ; File probably doesn't exist tt(i) = 0 endfor n0 = where( tt ne 0 and x ne invalid(rxparm) and y ne invalid(ryparm), n ) if n eq 0 then message, 'No data available for this range of days tt = tt(n0) x = x(n0) & if xlog then x = alog10(x) y = y(n0) & if ylog then y = alog10(y) groups = groups(n0) outpr = 0 xtitle = titles(xparm) ytitle = titles(yparm) ips_lsq, first,last,ndays,dayparm,x,y,tt,xtitle, ytitle, elstr subtitle = 'Start MJD:'+strcompress(min(tt))+ $ ' Day:'+strcompress(dayparm)+ $ ' Elongation:'+elstr+' deg' if n gt 2 then subtitle = subtitle+ $ ' Correlation Coeff:'+strcompress(correlate(x,y)) if not keyword_set(xrange) then begin xrange = ranges(xparm,*) if xrange(0) eq xrange(1) then begin xrange = [min(x),max(x)] xstyle = 0 endif else xstyle = 1 endif else xstyle = 1 if not keyword_set(yrange) then begin yrange = ranges(yparm,*) if yrange(0) eq yrange(1) then begin yrange = [min(y),max(y)] ystyle = 0 endif else ystyle = 1 endif else ystyle = 1 AGAIN: plot, xrange, yrange, $ /nodata, $ xrange = xrange, $ yrange = yrange, $ xstyle = xstyle, $ ystyle = ystyle, $ xtitle = xtitle, $ ytitle = ytitle, $ title = title, $ subtitle = subtitle ; charsize = 1.2 for i=1,ngroups do begin d = where ( groups eq i ) if d(0) ne -1 then begin oplot, x(d), y(d), psym=2 ; xyouts, x(d(0)),y(d(0)), strcompress(i,/remove_all) endif endfor if n gt 2 then begin ; plot line of best fit i = sort(x) ; plot symmetric lsq fit if keyword_set(normal) then a = normalfit(x(i),y(i),/oplot) d = poly_fit(x,y,1, fit) oplot, x(i), fit(i), linestyle=3 ; plot lsq fit endif ; Overplot Tappin's result if density and G-values are plotted if rxparm eq gparm and ryparm eq nparm then begin; G on x-axis, N on y-axis if xlog and ylog then $ d = alog10(9.)+2.*x $ else if xlog then $ d = 9.*10^(2.*x) $ else if ylog then $ d = alog10(9.*x*x) $ else $ d = 9.*x*x i = sort(x) oplot, x(i), d(i), linestyle=1 ; n on x-axis, G on y-axis endif else if rxparm eq nparm and ryparm eq gparm then begin if xlog and ylog then $ d = 0.5*(x-alog10(9.)) $ else if xlog then $ d = sqrt(10^x/9.) $ else if ylog then $ d = 0.5*alog10(x/9.) $ else $ d = sqrt(x/9.) i = sort(x) oplot, x(i), d(i), linestyle=1 endif if outpr eq 1 then begin spitplot set_plot, !TheTerminal endif else begin echo,'Hardcopy',outpr, /log if outpr then begin set_plot, !ThePrinter goto, AGAIN endif endelse twin,/hide return & end