pro El_Polar, intime=inTIME, inchan=inCHAN, $ log=LOG, spline=SPLINE, again=AGAIN, $ search=SEARCH, twospec=TWOSPEC, $ reverse=REVERSE @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; El_Polar ; PURPOSE: ; Plot electron data (Counts vs. Azimuth) and (B vs. Theta) for ; specified time and energy channel ; CATEGORY: ; Plotting ; CALLING SEQUENCE: ; El_Polar, intime=inTIME, log=LOG ; INPUTS: ; inTIME spectrum time (if not present a user will be prompted) ; (in mSec since start of day) ; LOG if present and non-zero a log scale for the counts ; is used (by default a linear scale is used) ; OUTPUTS: ; Plots to !ThePrinter ; CALLS: ; CartesianPolar, StrmSec ; COMMON BLOCKS: ; common I2, CHANSeV,AzNoShift,AzShift,I2_data,in_SC,in_YR,in_DOY ; SIDE EFFECTS: ; Sets hardcopy string OOZE_CMD for use by OOZE ; PROCEDURE: ; User is prompted for time if not specified in keyword INTIME. ; User is also prompted for the energy channel. ; MODIFICATION HISTORY: ; 1992, Jonathan Lang, Paul Hick (UCSD) ;- common I2, CHANSeV,AzNoShift,AzShift,I2_data,in_SC,in_YR,in_DOY common El_Polar_Save, savTIME, savCHAN, savLOG, savSPLINE, $ savSEARCH, savTWOSPEC, savREVERSE if keyword_set(AGAIN) then AGAIN = 1 else AGAIN = 0 if !d.NAME eq !ThePrinter or AGAIN then begin if AGAIN and n_elements(in_YR) eq 0 then message, 'Use EL_READ to read in electron data inTIME = savTIME inCHAN = savCHAN LOG = savLOG SPLINE = savSPLINE SEARCH = savSEARCH TWOSPEC = savTWOSPEC REVERSE = savREVERSE endif else begin if n_elements (in_YR) eq 0 then begin message, /info , 'Use EL_READ to read in electron data el_read endif if keyword_set(inCHAN) then if inCHAN lt 1 or inCHAN gt 32 then inCHAN = 0 if not keyword_set(inCHAN) then begin if n_elements(savCHAN) ne 0 then inCHAN = savCHAN else inCHAN = 24 echo, 'Specify energy channel (1-32)', inCHAN, 1,32 endif if keyword_set(LOG) then LOG = 1 else LOG = 0 if keyword_set(SPLINE) then SPLINE = 1 else SPLINE = 0 if keyword_set(SEARCH) then SEARCH = 1 else SEARCH = 0 if keyword_set(TWOSPEC) then TWOSPEC = 1 else TWOSPEC = 0 if keyword_set(REVERSE) then REVERSE = 1 else REVERSE = 0 ; If the inTime is not specified, prompt for it if n_elements(inTIME) eq 0 then begin ; get input from user NCount = n_elements(I2_data.TIME) ; # spectra in memory print, 'Current spacecraft : Helios ',strcompress(in_SC,/remove_all) print, 'Current start time : ',StrmSec (in_YR, in_DOY, I2_data(0).TIME) print, 'Current end time : ',StrmSec (in_YR, in_DOY, I2_data(NCount-1).TIME) echo, 'Specify time (hour,min)' if n_elements(savTIME) ne 0 then begin savTime = savTime/1000. hTime = round( savTime/3600. ) mTime = round((savTime-3600L*hTime)/60.) endif else begin mTime = 0 & hTime = 0 endelse echo, 'Hour' , hTime, 0,24 & inTIME = hTime*60L echo, 'Minute', mTime, 0,60 & inTIME = (inTIME+mTime)*60000L endif savTIME = inTIME savCHAN = inCHAN savLOG = LOG savSPLINE = SPLINE savSEARCH = SEARCH savTWOSPEC = TWOSPEC savREVERSE = REVERSE endelse NCount = n_elements(I2_data.TIME) ; # spectra in memory inCHANm1 = inCHAN-1 dummy = min(abs(I2_data.TIME-inTIME),Count) ; Find closest time inTIME = I2_data(Count).TIME ; Check electron counts for valid data if total( I2_data(Count).Elec(*,inCHANm1) ) eq 0 then begin message, 'No non-zero data at '+StrmSec(in_YR, in_DOY, inTIME)+ $ ' in chan '+strcompress(inCHAN,/rem) Zp = 1B ; if not SEARCH then $ echo, 'Search for nearest non-zero spectrum', Zp, /log if not Zp then message, 'Bye' Zp = sort(abs(I2_data.TIME-inTIME)) if Zp(0) ne Count then message, 'Oops!! Should not have happened' Go = 1 & Count = 1 while Go and Count lt NCount do begin if total( I2_data(Zp(Count)).Elec(*,inCHANm1) ) ne 0 then $ Go = 0 $ else $ Count = Count+1 endwhile if Count eq NCount then message, $ 'No non-zero data found for chan '+strcompress(inCHAN,/rem) Count = Zp(Count) endif jShift = I2_data(Count).AzShift CountEx = -1 if TWOSPEC then begin i = Count+1 if i lt NCount then $ if total( I2_data(i).Elec(*,inCHANm1) ) ne 0 and $ I2_data(i).AzShift ne jShift then CountEx = i i = Count-1 if CountEx eq -1 and i ge 0 then $ if total( I2_data(i).Elec(*,inCHANm1) ) ne 0 and $ I2_data(i).AzShift ne jShift then CountEx = i message, /info, 'No neighbouring spectrum with opposite shift' endif i = n_elements(AzNoShift)-2 if CountEx eq -1 then begin if jShift eq 0 then begin ; Use proper azimuth angles Azimuth = AzNoShift(0:i) message, /info, 'Azimuthal sectors: UNshifted endif else begin Azimuth = AzShift(0:i) message, /info, 'Azimuthal sectors: SHIFTED endelse Z = I2_data(Count).Elec(*,inCHANm1) endif else begin Azimuth = [AzNoShift(0:i),AzShift(0:i)] Z = [I2_data(Count).Elec(*,inCHANm1),I2_data(Count).Elec(*,inCHANm1)] message, /info, 'Azimuthal sectors: UNshifted and SHIFTED spectra combined Zp = sort(Azimuth) Azimuth = Azimuth(Zp) & Z = Z(Zp) endelse Azimuth = (1-REVERSE)*!pi+Azimuth/!radeg; Put angles in radians for PLOT Azimuth = [Azimuth,Azimuth(0)+2.*!pi] ; Full circle: last = 1st sector Z = float(Z) & Z = [Z,Z(0)] if LOG then begin Zp = where(Z gt 0) Z(Zp) = alog10(Z(Zp)) endif nAZ = fix(n_elements(Azimuth)) AZav = .5*(Azimuth+shift(Azimuth,-1)) AZav(nAZ-1) = AZav(0)+2.*!pi ; Center both axes in middle of plot. Change annotation to absolute values. B = max(Z) & rangeZ = [-B,B] ; X and Y range are the same plot, [0.,0.],[0.,0.], $ xrange=rangeZ,yrange=rangeZ,xstyle=4,ystyle=4, $ xtick_get=B B = strcompress(round(abs(B))) axis, xax=0, 0,0, xtickname=B axis, yax=0, 0,0, ytickname=B ;if not SPLINE then begin Np = 8 Zp = replicate(1.,Np)#Z(1:*) ; Rows of identical Z values Zp = reform(Zp,n_elements(Zp),/overwrite) ; Back to 1 dim array Zp = [Z(0),Zp] AZp = AZav(0) for i=0,nAZ-2 do begin AZp = [AZp,AZav(i)+findgen(Np)/(Np-1)*(AZav(i+1)-AZav(i))] endfor oplot, /polar, Zp, AZp ;endif else begin if SPLINE then begin ; Calculate the derivative of a 2nd degree polynomial through points ; i= 7,(8=0),1. Use the derivative to calulate a cubic spline. x1 = Azimuth(nAZ-2)-2.*!pi & y1 = Z(nAZ-2) x2 = Azimuth(0) & y2 = Z(0) x3 = Azimuth(1) & y3 = Z(1) x12 = x1-x2 & x23 = x2-x3 & x13 = x1-x3 dZdAZ = x23/(x12*x13)*y1-(x23-x12)/(x12*x23)*y2-x12/(x13*x23) dZdAZ2 = 0.*Azimuth stat = call_external('EXEIDL','NR_SPLINE',nAZ,Azimuth,Z,dZdAZ,dZdAZ,dZdAZ2) Np = 72+1 AZp = Azimuth(0)+findgen(Np)/(Np-1)*2.*!pi Zp = fltarr(Np, /nozero) Znew = 0. for i=0,Np-1 do begin stat = call_external('EXEIDL','NR_SPLINT',nAZ,Azimuth,Z,dZdAZ2,AZp(i),Znew) Zp(i) = Znew endfor oplot, /polar, Zp, AZp ;endelse endif if LOG then title = 'log(COUNT) vs. AZIMUTH' $ else title = 'COUNT vs. AZIMUTH BigChar = 1.35 xyouts, /normal, charsize=BigChar, 0.,.98, title xyouts, /normal, charsize=BigChar, $ 0.,.93, 'Channel '+strcompress(inCHAN,/rem)+ $ ' ('+strtrim(string(format='(F7.2)',CHANSev(inCHANm1)),2)+' eV)' xyouts, /data, charsize=BigChar, 1.03*!X.crange(1),0., 'SUN' if not REVERSE then xyouts, /normal, charsize=.8*BigChar, .9,.98, 'STREAM' xyouts, /normal, charsize=.8*BigChar, 0.,.03, StrmSec(in_YR,in_DOY,inTIME) if CountEx ne -1 then $ xyouts, /normal, charsize=.8*BigChar, 0.,.01, StrmSec(in_YR,in_DOY,I2_data(CountEx).TIME) ; Now deal with the magnetic field CartesianPolar, vector=I2_data(Count).B, B,BTheta,BPhi ;Theta,Phi of B field if B ne 0 then begin BPhi = BPhi/!radeg oplot, /polar, thick=2, [.25*!X.crange(1),!X.crange(1)],[BPhi+!pi,BPhi] Zp = -.3*!X.crange(1)*[cos(BPhi),sin(BPhi)] xyouts, /data, charsize=BigChar, Zp(0),Zp(1) , 'B1' xyouts, /normal, $ .4,.03, '!Md!X(B) = '+string(format='(F7.2)',90.-BTheta) endif if CountEx ne -1 then begin CartesianPolar, vector=I2_data(CountEx).B, B,BThetaEx,BPhiEx if B ne 0 then begin oplot, /polar, thick=2, [.25*!X.crange(1),!X.crange(1)],[BPhi+!pi,BPhi] Zp = -.3*!X.crange(1)*[cos(BPhi),sin(BPhi)] xyouts, /data, charsize=1.35, Zp(0),Zp(1) , 'B2' xyouts, /normal, $ .4,.01, '!Md!X(B) = '+string(format='(F7.2)',90.-BTheta) endif endif xyouts, /normal, .7, .0, charsize=1.1, systime() setup_ooze return & end