; $Id: tassurf.pro,v 1.2 2002/01/14 20:59:27 amunter Exp $
pro tassurf,d,z,x,y,rot,noerase=noe,xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax,$
      gridsize=gridsize
;+
; NAME:         TASPL
; PURPOSE:
;               Plot a surface TASCOM file read in with TASRDM
; CATEGORY:
; CALLING SEQUENCE:
;               TASPL,tasdata,'x-axis index','y-axis index'
; INPUTS:
;               tasdata = a tascom data structure read in with TASRDM
;		It assumes that you want to plot the intensity, I
; OPTIONAL INPUT PARAMTERS:
;               x,y-axis index= string defining parameter field for x,y-axis
;                        e.g.  taspl,d,'h','l'
;                  
; KEYWORD PARAMETERS:
; OUTPUTS:
;               a graph of x-index vs y-index for data structure d
; OPTIONAL OUTPUT PARAMETERS:
; COMMON BLOCKS:
; SIDE EFFECTS:
; RESTRICTIONS:
;               this routine uses the user contributed (windt) macros symbols
;               and eplot to set the symbol to a solid circle and plot error
;               bars (if i or mon is the y-axis)
; PROCEDURE:
; MODIFICATION HISTORY:
;		This is an adaptation of TASPL written by
;               Thom Mason, Riso National Lab, 1993
;		Paul Schleger, Riso, August 1993
;-
common plot,xrs,yrs

;****** process the keywords ******
if keyword_set(noe) then noerase=noe else noerase=0
IF keyword_set(gridsize) THEN gridsize=gridsize else gridsize=100
IF (gridsize LE 1) THEN gridsize=100

;****** figure out what to plot ******
if (n_params() eq 1) then x='H'
xind=tasid(x,d)
if (xind eq -1) then xind=0
zind=tasid(z,d)
if (n_params() le 2) then begin
  sind=tasid('SIGI',d)
  y='I'
  endif else $
  if (strupcase(y) eq 'I') then sind=tasid('SIGI',d) else $
    if (strupcase(y) eq 'MON') then sind=tasid('SIGM',d) else sind=-1
yind=tasid(y,d)
tind=tasid('TIM',d)

!x.minor=-1
!y.minor=-1
if (tind ge 0) then sd=stdev(d.data(tind,*),mean) else mean=0

;***** Set up min and max x *****
new=((not keyword_set(xmin)) and (not keyword_set(xmax)))
new=(new and (not keyword_set(ymin)) and (not keyword_set(ymax)))
  
minr=(0.001 > 0.01*max(d.data(xind,*)))
dif=((minr) > (0.1*(max(d.data(xind,*))-min(d.data(xind,*)))))
if (new) then xmin=min(d.data(xind,*));-dif
if (new) then xmax=max(d.data(xind,*));+dif

minr=(0.001 > 0.01*max(d.data(yind,*)))
dif=((minr) > (0.1*(max(d.data(yind,*))-min(d.data(yind,*)))))
if (new) then ymin=min(d.data(yind,*));-dif
if (new) then ymax=max(d.data(yind,*));+dif

;***** Set up interpolated surface *****
triangulate,d.data(xind,*),d.data(yind,*),tr,b
rangex = (xmax-xmin)/gridsize
rangey = (ymax-ymin)/gridsize
inter=trigrid(d.data(xind,*),d.data(yind,*),d.data(zind,*),$
	tr,[rangex,rangey],[xmin,ymin,xmax,ymax],/QUINTIC)

xrs=[xmin,xmax]
yrs=[ymin,ymax]
intersize=size(inter)
xvals=rangex*FINDGEN(intersize(1))
yvals=rangey*FINDGEN(intersize(2))
xvals=xvals+xmin
yvals=yvals+ymin 

shade_surf, inter,xvals,yvals,AZ=rot,$
ztitle='!6'+z+'(<Time>='+ string(mean,format='(i4)') + ' seconds)',$
xtitle='!6'+x,ytitle='!6'+y,thick=2,charsize=2.5,$
yrange=yrs,xrange=xrs,zrange=[0,max(d.data(zind,*))],$
xstyle=1,ystyle=1,xtickformat='(F5.2)',ytickformat='(F5.2)',NOERASE=noerase
 
 
return
end

















                                                
