1.1          (friedel  04-Nov-03): ;******************************************************************************
1.10         (jbf      21-Apr-05): ;* PROCEDURE:
1.1          (friedel  04-Nov-03): ;*      p_papco_cdf_line, panel, type, OUTPUT=OUTPUT, $
1.1          (friedel  04-Nov-03): ;*           OVERPLOT=OVERPLOT,$
1.1          (friedel  04-Nov-03): ;*           PLOTS_ATTHISPOSITION=PLOTS_ATTHISPOSITION,$
1.1          (friedel  04-Nov-03): ;*           SUBTABLE=SUBTABLE, $
1.1          (friedel  04-Nov-03): ;*           _EXTRA=extra_par
1.10         (jbf      21-Apr-05): ;*
1.10         (jbf      21-Apr-05): ;* DESCRIPTION:
1.10         (jbf      21-Apr-05): ;*	This procedure plots data of type data_type for inclusion in papco.
1.1          (friedel  04-Nov-03): ;*      Data must have been read and placed into common blocks before this
1.1          (friedel  04-Nov-03): ;*      routine is called. Behavior is controlled by the vector panel
1.1          (friedel  04-Nov-03): ;*	which controls positioning of the plot (see papco_conventions.text
1.1          (friedel  04-Nov-03): ;*      in $papco). In general, the following plot conventions are used:
1.1          (friedel  04-Nov-03): ;*              - if the panel is at the bottom plot time axis plus any
1.1          (friedel  04-Nov-03): ;*                additional axis (ie ephemeris) needed.
1.1          (friedel  04-Nov-03): ;*              - if panel is at the top also plot a title
1.1          (friedel  04-Nov-03): ;*              - a descriptor for panels is plotted to the right of each
1.1          (friedel  04-Nov-03): ;*                panel, rotated by 90 deg if there is a papco_colorbar.
1.1          (friedel  04-Nov-03): ;*              - panels all have common time
1.1          (friedel  04-Nov-03): ;*              - y-scaling (or z-scaling for color plots) is either
1.10         (jbf      21-Apr-05): ;*              - automatic or manualy set using common yscale or zscale
1.1          (friedel  04-Nov-03): ;*
1.10         (jbf      21-Apr-05): ;* INPUTS:
1.1          (friedel  04-Nov-03): ;*      panel   three element integer vector. Controls positioning of the plot
1.1          (friedel  04-Nov-03): ;*              (see papco_conventions.text in $papco)
1.1          (friedel  04-Nov-03): ;*      type    optional parameter for options. Normally is a four element
1.1          (friedel  04-Nov-03): ;*              integer vector. This is normally equivalent to the field
1.1          (friedel  04-Nov-03): ;*              typeVector of the papco structure papco_PLOTINFO which is set
1.1          (friedel  04-Nov-03): ;*              by the panel editor. Additional fields that can be used if
1.10         (jbf      21-Apr-05): ;*              needed are papco_plotinfo.ioptions (20 element vector) and
1.1          (friedel  04-Nov-03): ;*              papco_PLOTINFO.channel (integer). If your plot routine needs
1.1          (friedel  04-Nov-03): ;*              more input fields than these you have to extend the definition
1.1          (friedel  04-Nov-03): ;*              of the structure papco_PLOTINFO
1.1          (friedel  04-Nov-03): ;*              (procedure papco_getPlotInfoStruct in $papco/papco.pro). Try to
1.1          (friedel  04-Nov-03): ;*              avoid this!
1.10         (jbf      21-Apr-05): ;*
1.10         (jbf      21-Apr-05): ;* OUTPUTS:
1.1          (friedel  04-Nov-03): ;*      none
1.1          (friedel  04-Nov-03): ;*
1.1          (friedel  04-Nov-03): ;* KEYWORDS:
1.1          (friedel  04-Nov-03): ;*      OUTPUT  if set call the papco routine that outputs plot data
1.1          (friedel  04-Nov-03): ;*              to a file.
1.1          (friedel  04-Nov-03): ;*    OVERPLOT  if you support this you can alter the appearance of your
1.1          (friedel  04-Nov-03): ;*              plot if it is an overplot to an existing panel. Standard is
1.1          (friedel  04-Nov-03): ;*              to plot data, no axis, using the y-scaling of the first plot
1.1          (friedel  04-Nov-03): ;*              and to shift the labeling on the left down one line. Useful
1.1          (friedel  04-Nov-03): ;*              to plot model data together with real data, ie mag. field.
1.1          (friedel  04-Nov-03): ;*              see p_crres_mag for an example.
1.1          (friedel  04-Nov-03): ;*    PLOTS_ATTHISPOSITION  used to control the left side labeling for more
1.1          (friedel  04-Nov-03): ;*              than one overplot at the same position.
1.1          (friedel  04-Nov-03): ;*      _EXTRA  the plot structure containing some keyword for calls to
1.10         (jbf      21-Apr-05): ;*              plot. Used to customize color and line style.
1.10         (jbf      21-Apr-05): ;*
1.1          (friedel  04-Nov-03): ;* CALLING SEQUENCE:
1.1          (friedel  04-Nov-03): ;*       p_papco_cdf_line, panel, type, $
1.1          (friedel  04-Nov-03): ;*           OVERPLOT=OVERPLOT, PLOTS_ATTHISPOSITION=PLOTS_ATTHISPOSITION,$
1.1          (friedel  04-Nov-03): ;*           _EXTRA=extra_par
1.1          (friedel  04-Nov-03): ;*
1.10         (jbf      21-Apr-05): ;* MODIFICATION HISTORY:
1.1          (friedel  04-Nov-03): ;*     written December 1995, Reiner Friedel, at Goddard
1.1          (friedel  04-Nov-03): ;*     added OUTPUT support, July 1998, , Reiner Friedel
1.1          (friedel  04-Nov-03): ;******************************************************************************
1.1          (friedel  04-Nov-03): pro p_papco_cdf_line, panel, plotinfo, OUTPUT=OUTPUT, $
1.1          (friedel  04-Nov-03):                       OVERPLOT=OVERPLOT, $
1.1          (friedel  04-Nov-03):                       PLOTS_ATTHISPOSITION=PLOTS_ATTHISPOSITION, $
1.1          (friedel  04-Nov-03):                       SUBTABLE=SUBTABLE, $
1.1          (friedel  04-Nov-03):                       _EXTRA=extra_par
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ; The following common blocks are needed:
1.1          (friedel  04-Nov-03): COMMON mjdt, mjdt_start, mjdt_end               ;time limit in mjdt
1.1          (friedel  04-Nov-03): COMMON yscale, yscl                             ;man/auto yscaling
1.1          (friedel  04-Nov-03): COMMON shift_label, down                        ;for x-axis label shifting
1.1          (friedel  04-Nov-03): COMMON coordinateSystems, plotted_x, plotted_y  ;info on coords
1.1          (friedel  04-Nov-03): COMMON papco_color_names
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): colors = [red, blue, dark_green, black]
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ; One of the common blocks should contain the plot data as returned by the
1.10         (jbf      21-Apr-05): ; data read procedure r_papco_cdf.
1.1          (friedel  04-Nov-03): COMMON papco_cdf_data, input_data
1.10         (jbf      21-Apr-05): 
1.1          (friedel  04-Nov-03): panelset,panel			;sets the panel position viewport
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ;retrieve the control structure for this module.
1.1          (friedel  04-Nov-03): control = *plotinfo.USR_PTR1
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ;time is in CDF Epoch. Need to convert PAPCO start/end to that EPOCH.
1.1          (friedel  04-Nov-03): pos = strpos(tag_names(input_data), 'EPOCH')
1.1          (friedel  04-Nov-03): idx = where(pos NE -1) & epoch_time = input_data.(idx(0)).dat
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ;get data array
1.13         (jbf      28-Apr-05): cdfvar_name = replace_bad_chars( strcompress( control.cdfvar_name , /REMOVE_ALL) )
1.1          (friedel  04-Nov-03): pos = strpos(tag_names(input_data),strupcase(cdfvar_name))
1.14         (jbf      13-May-05): idx = where(pos NE -1)
1.12         (jbf      28-Apr-05): 
1.12         (jbf      28-Apr-05): if ( idx[0] eq -1 ) then begin
1.12         (jbf      28-Apr-05):     draw_error_panel, 'failed to find variable '+cdfvar_name
1.12         (jbf      28-Apr-05):     return
1.12         (jbf      28-Apr-05): endif
1.12         (jbf      28-Apr-05): 
1.12         (jbf      28-Apr-05): data = input_data.(idx(0)).dat
1.1          (friedel  04-Nov-03): nodata = input_data.(idx(0)).FILLVAL
1.1          (friedel  04-Nov-03): 
1.10         (jbf      21-Apr-05): variableStruct= input_data.(idx(0))
1.9          (jbf      13-Dec-04): 
1.10         (jbf      21-Apr-05): convert_t90_to_Date, mjdt_start, year,doy,hr,min,sec,mon,cmon,dom, /mjdt
1.1          (friedel  04-Nov-03): CDF_EPOCH, epoch_1, Year, mon, dom, hr, min, sec, /COMPUTE_EPOCH
1.10         (jbf      21-Apr-05): convert_t90_to_Date, mjdt_end, year,doy,hr,min,sec,mon,cmon,dom, /mjdt
1.1          (friedel  04-Nov-03): CDF_EPOCH, epoch_2, Year, mon, dom, hr, min, sec, /COMPUTE_EPOCH
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ;MATT TAYLOR start
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): time_shift=control.time_shift
1.1          (friedel  04-Nov-03):  if time_shift ne 0 then begin
1.1          (friedel  04-Nov-03):     ;epoch in milliseconds so convert time_shift (which is in minutes to
1.1          (friedel  04-Nov-03):     ;milliseconds)
1.1          (friedel  04-Nov-03):     time_shift=time_shift*60*1000
1.1          (friedel  04-Nov-03):     epoch_1=epoch_1+time_shift
1.1          (friedel  04-Nov-03):     epoch_2=epoch_2+time_shift
1.1          (friedel  04-Nov-03):     CDF_EPOCH, epoch_1, Year, mon, dom, hr, min, sec, /BREAKDOWN_EPOCH
1.1          (friedel  04-Nov-03):     CDF_EPOCH, epoch_2, Year, mon, dom, hr, min, sec, /BREAKDOWN_EPOCH
1.1          (friedel  04-Nov-03): endif
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ;MATT TAYLOR stop
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): tai_1=utc2tai({mjd:mjdt_start.mjd, time:mjdt_start.t*1000})
1.1          (friedel  04-Nov-03): tai_2=utc2tai({mjd:mjdt_end.mjd, time:mjdt_end.t*1000})
1.1          (friedel  04-Nov-03): 
1.10         (jbf      21-Apr-05): ;get dimension of data.
1.1          (friedel  04-Nov-03): data_info = size(data, /struct)
1.1          (friedel  04-Nov-03): 
1.10         (jbf      21-Apr-05): ; restrict data in time
1.1          (friedel  04-Nov-03): index=where((epoch_time GE epoch_1) AND (epoch_time LE epoch_2 ),c)
1.1          (friedel  04-Nov-03): if c ne 0 then BEGIN
1.1          (friedel  04-Nov-03):     IF data_info.N_DIMENSIONS EQ 1 THEN data = data(index) ELSE $
1.10         (jbf      21-Apr-05):       data = data(*, index)
1.10         (jbf      21-Apr-05):     epoch_time = epoch_time(index)
1.1          (friedel  04-Nov-03): ENDIF ELSE GOTO, noplot
1.1          (friedel  04-Nov-03): xut1=0  &  xut2=epoch_2-epoch_1  & time=epoch_time-epoch_1
1.1          (friedel  04-Nov-03): 
1.9          (jbf      13-Dec-04): ; check for outside valid_min, valid_max.  Jeremy Faden Nov 4,2004
1.9          (jbf      13-Dec-04): r= where( data lt variableStruct.validmin or data gt variableStruct.validmax )
1.9          (jbf      13-Dec-04): if r[0] ne -1 then data[r]= nodata
1.9          (jbf      13-Dec-04): 
1.10         (jbf      21-Apr-05): ;re-get dimension of data.
1.1          (friedel  04-Nov-03): data_info = size(data, /struct)
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ;make an array of channels to be plotted. x ,y, z, tot are possible here.
1.1          (friedel  04-Nov-03): coords = control.coord & set = bytarr(4)
1.1          (friedel  04-Nov-03): FOR i = 0, 3 DO IF (coords and 2^i) eq 2^i THEN set(i)=1 else set(i)=0
1.10         (jbf      21-Apr-05): ch_idx = where(set EQ 1, n_ch)
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ;clean up data - limit to within max min range (set outside stuff to nodata)
1.1          (friedel  04-Nov-03): IF data_info.N_DIMENSIONS EQ 2 THEN BEGIN
1.1          (friedel  04-Nov-03):     IF data_info.DIMENSIONS(0) EQ 3 THEN BEGIN
1.1          (friedel  04-Nov-03):         FOR i = 0, 2 DO BEGIN
1.15         (jbf      13-May-05):             nn= n_elements( input_data.(idx(0)).VALIDMAX(*) )
1.15         (jbf      13-May-05):             validmax= input_data.(idx(0)).VALIDMAX(i<(nn-1))
1.15         (jbf      13-May-05):             validmin= input_data.(idx(0)).VALIDMIN(i<(nn-1))
1.15         (jbf      13-May-05):             idx1 = where((data(i, *) GT VALIDMAX ) OR $
1.15         (jbf      13-May-05):                          (data(i, *) LT VALIDMIN ), c)
1.1          (friedel  04-Nov-03):             IF c NE 0 THEN data(i, idx1) = nodata
1.10         (jbf      21-Apr-05):         ENDFOR
1.1          (friedel  04-Nov-03):     ENDIF
1.1          (friedel  04-Nov-03): ENDIF ELSE BEGIN
1.1          (friedel  04-Nov-03):     idx1 = where((data GT input_data.(idx(0)).VALIDMAX) OR $
1.1          (friedel  04-Nov-03):                  (data LT input_data.(idx(0)).VALIDMIN), c)
1.11         (jbf      22-Apr-05):     IF c NE 0 THEN data(idx1) = nodata
1.10         (jbf      21-Apr-05): ENDELSE
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ;If data a vector (x,y,z), add magnitude to array - preserve nodata!
1.1          (friedel  04-Nov-03): IF data_info.N_DIMENSIONS EQ 2 THEN BEGIN
1.1          (friedel  04-Nov-03):     IF data_info.DIMENSIONS(0) EQ 3 THEN BEGIN
1.1          (friedel  04-Nov-03):         idx1 = where(data(0, *) NE nodata, c, complement = idx2)
1.1          (friedel  04-Nov-03):         IF c eq 0 THEN GOTO, noplot
1.1          (friedel  04-Nov-03):         tot = fltarr(data_info.DIMENSIONS(1))
1.1          (friedel  04-Nov-03):         tot(idx1) = sqrt(data(0, idx1)^2+data(1, idx1)^2+data(2, idx1)^2)
1.1          (friedel  04-Nov-03):         IF n_elements(data(0,*)) NE c then  tot(idx2) = nodata
1.1          (friedel  04-Nov-03):         new_data = fltarr(data_info.DIMENSIONS(1), 4)
1.1          (friedel  04-Nov-03):         new_data(*, 3) = tot
1.1          (friedel  04-Nov-03):         new_data(*,0:2) = transpose(data)
1.9          (jbf      13-Dec-04):     ENDIF else begin
1.9          (jbf      13-Dec-04):         new_data= transpose(data) ;; status__01_pp_cis  jbfaden
1.9          (jbf      13-Dec-04):     endelse
1.1          (friedel  04-Nov-03): ENDIF ELSE new_data = data
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): uytitle = input_data.(idx(0)).LABLAXIS+' ('+input_data.(idx(0)).UNITS+')'
1.11         (jbf      22-Apr-05): 
1.11         (jbf      22-Apr-05): if (overplot) then uytitle=''
1.11         (jbf      22-Apr-05): 
1.16         (friedel  23-May-05): utitle = control.cdf_type+'!Cpapco cdf!C'+cdfvar_name
1.16         (friedel  23-May-05): 
1.1          (friedel  04-Nov-03): IF control.smooth GE 2 THEN utitle = utitle+'!Ct smooth = '+$
1.1          (friedel  04-Nov-03):   varprt(control.smooth)
1.11         (jbf      22-Apr-05): 
1.11         (jbf      22-Apr-05): if control.time_shift ne 0 then utitle=utitle+'!Ct shift = '+$
1.11         (jbf      22-Apr-05):   varprt( control.time_shift )+'min'
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ;test for data -ve then set linlog to lin if -ve
1.1          (friedel  04-Nov-03): ;next 2 lines set validmin max values to encompass all possible values
1.1          (friedel  04-Nov-03): ;for vectors
1.1          (friedel  04-Nov-03): input_data.(idx(0)).VALIDMIN(0) = min(input_data.(idx(0)).VALIDMIN)
1.1          (friedel  04-Nov-03): input_data.(idx(0)).VALIDMAX(0) = max(input_data.(idx(0)).VALIDMAX)
1.8          (jniehof  30-Nov-04): ;allow log plot unless plotting under zero (autoscl will truncate)
1.8          (jniehof  30-Nov-04): ;IF input_data.(idx(0)).VALIDMIN(0) LE 0 THEN yscl(panel(0),3) = 0
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ; the variables used above have the following meaning:
1.1          (friedel  04-Nov-03): ; 	uytitle : the y-axis label
1.1          (friedel  04-Nov-03): ;	utitle  : the right-of plot label defining the data
1.1          (friedel  04-Nov-03): ;
1.1          (friedel  04-Nov-03): ; yscl of common block yscale is an array of dimensions (*,4) and contains info
1.1          (friedel  04-Nov-03): ; on the yscaling to be used. The first dimension identifies the panel, and the
1.10         (jbf      21-Apr-05): ; next dimension has three entries:
1.1          (friedel  04-Nov-03): ;         yscl(*,0)  is  0 for "use automatic scaling", 1 for "use manual"
1.1          (friedel  04-Nov-03): ;         yscl(*,1)  is then ymin (or zmin)
1.1          (friedel  04-Nov-03): ;         yscl(*,2)  is then ymax (or zmax)
1.1          (friedel  04-Nov-03): ;         yscl(*,3)  is 0 for "linear" and 1 for "log"  scale
1.1          (friedel  04-Nov-03): ; when scaling is set to automatic, the automatic y-limits are loaded
1.10         (jbf      21-Apr-05): ; in.
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): if (yscl(panel(0),0) eq 1) then begin
1.1          (friedel  04-Nov-03):     yst=yscl(panel(0),1)  &  yen=yscl(panel(0),2)
1.8          (jniehof  30-Nov-04):     IF (yst le 0) then yscl(panel(0),3) = 0
1.1          (friedel  04-Nov-03): endif else BEGIN
1.1          (friedel  04-Nov-03):     IF control.scaling EQ 0 THEN BEGIN ;use cdf scaling info
1.1          (friedel  04-Nov-03):         yst = input_data.(idx(0)).VALIDMIN(0)
1.8          (jniehof  30-Nov-04):         IF (yst le 0) then yscl(panel(0),3) = 0
1.1          (friedel  04-Nov-03):         yen = input_data.(idx(0)).VALIDMAX(0)
1.1          (friedel  04-Nov-03):     ENDIF ELSE BEGIN
1.10         (jbf      21-Apr-05):         exclude = plotinfo.MANUALZSCALING
1.1          (friedel  04-Nov-03):         IF data_info.N_DIMENSIONS EQ 1 THEN $
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03):         papco_autorange, new_data, yst, yen, log=yscl(panel(0),3), $
1.1          (friedel  04-Nov-03):                          exclude=exclude, nodata=nodata,  /verb $
1.1          (friedel  04-Nov-03):         ELSE $
1.1          (friedel  04-Nov-03):         papco_autorange, new_data(*, ch_idx), yst, yen, log=yscl(panel(0),3), $
1.1          (friedel  04-Nov-03):                          exclude=exclude, nodata=nodata,  /verb
1.10         (jbf      21-Apr-05):     ENDELSE
1.10         (jbf      21-Apr-05):     yscl(panel(0),1)=yst  &  yscl(panel(0),2)=yen
1.1          (friedel  04-Nov-03): ENDELSE
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ; use auto y-labeling routine to get "good" y-lables. This sets the
1.1          (friedel  04-Nov-03): ; global IDL graphics system variables !Y.MINOR, !Y.TICKV, !Y.TICKS -
1.1          (friedel  04-Nov-03): ; so if you want to use this feature, avoid setting these or their
1.1          (friedel  04-Nov-03): ; corresponding keywords in your plot.
1.1          (friedel  04-Nov-03): papco_y_label, yst, yen, log=yscl(panel(0),3)
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): extra_plotPar={xrange:[xut1,xut2], yrange:[yst,yen],  $
1.1          (friedel  04-Nov-03):                ylog:yscl(panel(0),3), xtickformat:'noticks'}
1.10         (jbf      21-Apr-05): 
1.1          (friedel  04-Nov-03): ; add keyword structure set here with the one passed in
1.1          (friedel  04-Nov-03): extra_plotPar=create_struct(extra_plotPar, extra_par)
1.10         (jbf      21-Apr-05): 
1.1          (friedel  04-Nov-03): ; use papco routine to draw time axis. This checks for bottom plot
1.1          (friedel  04-Nov-03): ; and uses the user's xtickformat if it is something other than
1.1          (friedel  04-Nov-03): ; 'noticks'.
1.1          (friedel  04-Nov-03): ; If you use this rotuine, make sure your data plot routine uses
1.1          (friedel  04-Nov-03): ; xstyle=5 and ystyle=5 (inhibit axis) so that you don't clobber the
1.10         (jbf      21-Apr-05): ; axes drawn by papco.
1.10         (jbf      21-Apr-05): ; "down" sets the axis labeling level.
1.1          (friedel  04-Nov-03): down=0
1.10         (jbf      21-Apr-05): papco_draw_time_axis, panel, OVERPLOT=OVERPLOT, _extra=extra_plotPar
1.6          (friedel  18-Aug-04): 
1.6          (friedel  18-Aug-04): ; plot info right of the panel. Multiple panel labels are handled.
1.10         (jbf      21-Apr-05): papco_rs_lbl, panel, utitle, /LINE, _extra=extra_Par
1.10         (jbf      21-Apr-05): 
1.1          (friedel  04-Nov-03): ; You might have to add your own xtickformat for time axis
1.10         (jbf      21-Apr-05): ; labeling. If you stick to the papco convention of always having your plot
1.10         (jbf      21-Apr-05): ; time array having consecutive seconds from midnight of the start day, then
1.1          (friedel  04-Nov-03): ; you can use the pre-defined xtickformat functions defined in ticks.pro in
1.1          (friedel  04-Nov-03): ; papco_Lib/axis_label.
1.1          (friedel  04-Nov-03): ; You can at this point also define a custom ytickformat, or leave it out for
1.1          (friedel  04-Nov-03): ; IDL default plot behaviour.
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ; now do the actual data plot, data only, no axis
1.1          (friedel  04-Nov-03): ;case of single line plot
1.1          (friedel  04-Nov-03): 
1.16         (friedel  23-May-05): CASE data_info.N_DIMENSIONS OF
1.16         (friedel  23-May-05):     1: BEGIN
1.16         (friedel  23-May-05):         IF control.smooth GE 2 THEN $
1.16         (friedel  23-May-05):         new_data=papco_smooth(new_data,control.smooth, $
1.1          (friedel  04-Nov-03):                           NODATA=nodata,_extra=extra_plotPar)
1.16         (friedel  23-May-05):         yray=new_data
1.7          (friedel  13-Oct-04): 
1.16         (friedel  23-May-05):         papco_gap_plot, time, yray, nodata, $
1.1          (friedel  04-Nov-03):               xstyle=5, ystyle=5, _extra=extra_plotPar
1.16         (friedel  23-May-05):     END
1.16         (friedel  23-May-05):     2: BEGIN        
1.16         (friedel  23-May-05):         idx2 = where(set EQ 1, n_ch)
1.16         (friedel  23-May-05):         IF n_ch EQ 0 THEN GOTO, noplot
1.16         (friedel  23-May-05): 
1.16         (friedel  23-May-05):         in_label = ['Polar', 'Azimuthal']
1.16         (friedel  23-May-05): 
1.16         (friedel  23-May-05):         FOR i = 0, n_ch-1 DO BEGIN
1.16         (friedel  23-May-05):             yray = new_data(*, idx2(i))
1.16         (friedel  23-May-05):             IF n_ch NE 1 then extra_plotPar.color = colors(i)
1.16         (friedel  23-May-05):             IF control.smooth GE 2 THEN $
1.16         (friedel  23-May-05):               yray=papco_smooth(yray,control.smooth, $
1.16         (friedel  23-May-05):                                 NODATA=nodata,_extra=extra_plotPar)
1.16         (friedel  23-May-05):             papco_gap_plot, time, yray, nodata, $
1.16         (friedel  23-May-05):               xstyle=5, ystyle=5, _extra=extra_plotPar            
1.16         (friedel  23-May-05):     
1.16         (friedel  23-May-05):             IF control.label THEN $
1.16         (friedel  23-May-05):               papco_rs_lbl, panel, in_label(i), /LINE, _extra=extra_plotPar
1.16         (friedel  23-May-05):         
1.16         (friedel  23-May-05):         ENDFOR 
1.16         (friedel  23-May-05): 
1.16         (friedel  23-May-05):     END 
1.16         (friedel  23-May-05):     3: BEGIN
1.16         (friedel  23-May-05):         idx2 = where(set EQ 1, n_ch)
1.16         (friedel  23-May-05):         IF n_ch EQ 0 THEN GOTO, noplot
1.16         (friedel  23-May-05):         in_label = [input_data.(idx(0)).LABL_PTR_1, 'TOT']
1.16         (friedel  23-May-05):         in_label = in_label(idx2)
1.16         (friedel  23-May-05): 
1.16         (friedel  23-May-05):         nelement= ( size( new_data, /dim ))[1]
1.16         (friedel  23-May-05): 
1.16         (friedel  23-May-05):         IF ( idx2[n_ch-1] ge nelement ) THEN BEGIN 
1.16         (friedel  23-May-05):             draw_error_panel, $
1.16         (friedel  23-May-05):               'data only has '+strtrim( nelement,2 )+' dimensions'
1.16         (friedel  23-May-05):             return
1.16         (friedel  23-May-05):         ENDIF  
1.16         (friedel  23-May-05): 
1.16         (friedel  23-May-05):         FOR i = 0, n_ch-1 DO BEGIN
1.16         (friedel  23-May-05):             yray = new_data(*, idx2(i))
1.16         (friedel  23-May-05):             IF n_ch NE 1 then extra_plotPar.color = colors(i)
1.16         (friedel  23-May-05):             IF control.smooth GE 2 THEN $
1.16         (friedel  23-May-05):               yray=papco_smooth(yray,control.smooth, $
1.16         (friedel  23-May-05):                                 NODATA=nodata,_extra=extra_plotPar)
1.1          (friedel  04-Nov-03): 
1.16         (friedel  23-May-05):             papco_gap_plot, time, yray, nodata, $
1.1          (friedel  04-Nov-03):               xstyle=5, ystyle=5, _extra=extra_plotPar
1.6          (friedel  18-Aug-04): 
1.16         (friedel  23-May-05):             IF control.label THEN $
1.16         (friedel  23-May-05):               papco_rs_lbl, panel, in_label(i), /LINE, _extra=extra_plotPar
1.6          (friedel  18-Aug-04): 
1.16         (friedel  23-May-05):         ENDFOR 
1.1          (friedel  04-Nov-03): 
1.16         (friedel  23-May-05):         ; plot channel info inside of panel.
1.16         (friedel  23-May-05):         IF (NOT keyword_set(overplot)) AND (NOT control.label) THEN $
1.16         (friedel  23-May-05):         papco_in_side_label, panel, in_label, $
1.16         (friedel  23-May-05):           NCOL = colors, _extra=extra_plotPar
1.16         (friedel  23-May-05): 
1.16         (friedel  23-May-05):     END
1.16         (friedel  23-May-05): ENDCASE 
1.16         (friedel  23-May-05):     
1.10         (jbf      21-Apr-05): ; plot y-axis label at left of plot. Use scalable routine!
1.3          (friedel  01-Mar-04): left_side_label, panel, uytitle, /rot90
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ; store the coordinate information into common block for slices
1.1          (friedel  04-Nov-03): plotted_x = !x  &  plotted_y = !y
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): ; check if data needs to be output to file. Use the optional keywords
1.1          (friedel  04-Nov-03): ; to add more information to the data file
1.1          (friedel  04-Nov-03): ;      DESCRIPTION   a string or string array describing the data
1.1          (friedel  04-Nov-03): ;      TIME_LABEL    a string decribing the x-axis format
1.1          (friedel  04-Nov-03): ;      CHANNELS      an (ch,2) array giving the channel start/end
1.1          (friedel  04-Nov-03): ;      Y_LABEL       a string with the y-axis label
1.1          (friedel  04-Nov-03): ;      Z_LABEL       a string with the z-axis label
1.1          (friedel  04-Nov-03): ;      RS_LABEL      a string with the righ-side label of the plot
1.10         (jbf      21-Apr-05): 
1.10         (jbf      21-Apr-05): IF KEYWORD_SET(OUTPUT) THEN BEGIN
1.1          (friedel  04-Nov-03):     message,'Writing plot data out to file', /info
1.1          (friedel  04-Nov-03):     description='papco_cdf data'
1.1          (friedel  04-Nov-03):     time_label='TAI'
1.1          (friedel  04-Nov-03):     ;channels=yarr
1.1          (friedel  04-Nov-03):     y_label=uytitle
1.1          (friedel  04-Nov-03):     ;z_label=uztit
1.1          (friedel  04-Nov-03):     rs_label=utitle
1.1          (friedel  04-Nov-03):     t = time/1000.0 + tai_1 ;time converted to TAI
1.4          (jniehof  11-Jun-04):     papco_write_data, t, yray, $
1.1          (friedel  04-Nov-03):                       DESCRIPTION=description, TIME_LABEL=time_label, $
1.1          (friedel  04-Nov-03):                       Y_LABEL=y_label, $
1.1          (friedel  04-Nov-03):                       RS_LABEL=RS_LABEL
1.1          (friedel  04-Nov-03): ENDIF
1.1          (friedel  04-Nov-03): 
1.1          (friedel  04-Nov-03): return
1.1          (friedel  04-Nov-03): 
1.10         (jbf      21-Apr-05): noplot:
1.14         (jbf      13-May-05): 
1.14         (jbf      13-May-05): draw_error_panel, 'No data to plot'
1.1          (friedel  04-Nov-03): message,'No data to plot',/cont
1.1          (friedel  04-Nov-03): 
1.10         (jbf      21-Apr-05): END
