Index: trunk/UTIL/IDLplot/ARWpost/call_arwpost.pro
===================================================================
--- trunk/UTIL/IDLplot/ARWpost/call_arwpost.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/ARWpost/call_arwpost.pro	(revision 1185)
@@ -0,0 +1,97 @@
+pro call_arwpost, nam1, nam2, nam3, nam4, nam5, tabnam, nest, datafolder, grads
+
+;
+; YOU MUST HAVE COMPILED ARWPOST.EXE !
+;
+
+;
+; USE:
+;  @plot.def
+;  then: call_arwpost, nam1, nam2, nam3, nam4, nam5, tabnam
+;
+; but you'd rather use the trace.idl script  
+
+
+
+;
+; prepare user_defined namelist part
+;
+param_namelist=[ nam1, "/", " ", "&datetime", nam2, nam3, nam4, "/", " ", "&interp", nam5 ]
+
+if (tabnam(0) ne 999.) then begin
+  ntot = ( 1+tabnam(1)-tabnam(0) ) / float(tabnam(2))
+  ;ntot = ( tabnam(1)-tabnam(0) ) / float(tabnam(2))
+  ntot = ceil(ntot) 
+  temparr =  tabnam(0)+findgen(ntot)*tabnam(2)
+endif else begin
+  temparr = tabnam[1:n_elements(tabnam)-1] 
+endelse
+
+
+        if (n_elements(temparr) le 5.) then begin
+		levelstr=[ " interp_levels = ", '   '+string(temparr,'(F7.3)'), "/"]
+	endif else begin
+		nnnn = floor(n_elements(temparr)/3.)
+		ye = strarr(nnnn)
+	        for i=0,nnnn-2 do begin
+		  ye[i] = string(temparr[3*i],'(F7.3)')+','+string(temparr[3*i+1],'(F7.3)')+','+string(temparr[3*i+2],'(F7.3)')+','
+		endfor
+		ye[nnnn-1] = string(temparr[3*(nnnn-1)],'(F7.3)')+','+string(temparr[3*(nnnn-1)+1],'(F7.3)')+','+string(temparr[3*(nnnn-1)+2],'(F7.3)')
+		levelstr=[ "interp_levels = ", ye, "/"]
+	endelse
+
+param_namelist=[param_namelist,levelstr]
+param_namelist=transpose(param_namelist)
+
+;
+; generate file (not available in demo mode)
+;
+SPAWN, 'touch toto ; \rm toto'
+OPENW, 1, 'toto'
+PRINTF, 1, param_namelist
+CLOSE, 1
+	;;
+	;; fix for demo mode
+	;;	
+	;SPAWN, 'touch toto ; \rm toto ; touch toto'
+	;for i=0, n_elements(param_namelist)-1 do begin
+	;	SPAWN, 'echo "'+param_namelist[i]+'" >> toto'
+	;	print, param_namelist[i]
+	;endfor	
+instru = 'sed s/zenest/'+nest+'/g namelist.ARWpost_ref > namelist.ARWpost_ref_tmp'
+instru = instru + ' ; ' + 'rm -rf zefolder ; ln -sf '+datafolder+' zefolder'
+instru = instru + ' ; ' + 'touch namelist.ARWpost ; \rm namelist.ARWpost ; mv namelist.ARWpost_ref_tmp namelist.ARWpost'
+if (grads eq 'true') then instru = instru + ' ; ' + "sed s/'idl'/'grads'/g namelist.ARWpost > yeye ; \mv yeye namelist.ARWpost"
+instru = instru + ' ; ' + 'cat toto >> namelist.ARWpost ; \rm toto'
+
+;
+; extract data from netcdf file
+;
+instru = instru + ' ; ' + './ARWpost.exe'
+
+;
+; patch for correct time in plots
+;
+instru = instru + " ; " + "touch input_tmp.ctl ; \rm input_tmp.ctl ; touch timefil ; \rm timefil"
+	;;; this line induces problems with variables with Z in the name
+if (grads ne 'true') then instru = instru + " ; " + "sed s/'Z'/' 0 Z'/g input.ctl > input_tmp.ctl ; mv -f input_tmp.ctl input.ctl"
+instru = instru + " ; " + "grep interval_seconds namelist.ARWpost | tail -n 1 | awk '{print $3}' > timefil ; cat timefil"
+SPAWN, instru
+
+;;old ARWpost
+;SPAWN, "sed s/'*'/'9'/g input.dat > yeah ; mv -f yeah input.dat"
+
+
+;; fix debile
+SPAWN, "sed s/'SWDOWN 0 Z'/'SWDOWNZ'/g input.ctl > yeah ; mv -f yeah input.ctl"
+
+;
+; ok
+;
+print, 'ok...'
+print, 'if the extraction was successful, '
+print, 'you can use the input.dat and input.ctl files' 
+
+if (grads eq 'true') then stop
+
+END
Index: trunk/UTIL/IDLplot/ARWpost/gw.def
===================================================================
--- trunk/UTIL/IDLplot/ARWpost/gw.def	(revision 1185)
+++ trunk/UTIL/IDLplot/ARWpost/gw.def	(revision 1185)
@@ -0,0 +1,267 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------------;
+; DATA LOCATION and PLOT DESTINATION  ;
+; default is ./                       ;
+;-------------------------------------;
+datafolder='/d5/aslmd/WRF_Mars/EN_COURS/OM40_ls170/'   
+plotfolder=datafolder
+;; for web anim and tex report (default is 'plot')
+textitle='OM40_month72'
+texcomments='sol3'
+
+;;; load/save ARWpost-generated text files ? default is no
+;backup_data='yes'
+;already_data='yes'
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'tk,HGT,W' "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE FIELDS TO BE EXTRACTED 
+;; ex: tk,HGT,PSFC,U,V,W,T,tk,ICETOT,RAVE,QH2O_ICE,QH2O,PTOT,TSURF
+
+nam2=" start_date = '2024-06-37_20:00:10' " 
+nam3=" end_date   = '2024-06-37_23:00:10' "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE START/END DATE
+
+nam4=" interval_seconds = 11100 "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
+;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s, 12h: 44400s	
+
+nam5=" interp_method = 1 "	
+;nam5=" interp_method = 0 "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 		
+;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+
+tabnam=[-5.,40.,0.5]   ;[2.,30.,0.3]   	
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+;nest='d03'  
+;; ^ ^ ^ ^
+;; SET NEST
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=2		   	;; how many plots ?
+
+
+field1='tk'		;; FILLED
+field2='tk'		;; CONTOURED
+;winds=['U','V']	;; VECTORS
+;topo=1
+
+
+;;; VORTICITY
+;field1='HGT' & winds=['U','V'] & topo=1
+
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+;; first is 1
+;plot='map' & level=15  	
+plot='meridional' & nlon=30
+;plot='zonal' & nlat=66
+
+
+;---------;
+; special ;
+;---------;
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & plot='map' & level=7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1 & plot='map' & level=9
+
+;;useidlfile='true' ;; if you are just changing what is below...
+;;extract='no' ;; SPECIFIC FOR ATLAS
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+;;;
+;;; PLOT TITLES
+;;;
+;subtitle_user='-- LMD Martian Mesoscale Model --'            ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N)'     ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+
+;;;
+;;; COLOR TABLES
+;;;
+;flag_cb='false'                ;; grepALL
+;format='(I0)'                  ;; grepALL
+colors=64                       ;; grepALL
+pal=39                          ;; grepALL
+;; GOOD COLOR TABLES: 4, 18, 22, 16, 37, 33, 39
+
+;;;
+;;; FILL LIMITS
+;;;
+minfield_init=150.      ;; grepALL
+maxfield_init=250.	;; grepALL
+
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+
+;;;
+;;; WINDS
+;;;
+;windex=40.	;; grepALL
+;stride=1.	;; grepALL
+
+;;;
+;;; CONTOUR
+;;;
+;overcontour=overcontour-mean(overcontour)	;; grepALL
+lev=130. + 10.*findgen(20) ;; grepALL
+
+;;;
+;;; AXIS
+;;;
+;isotropic='false'       ;; grepALL
+intervalx=5.            ;; grepALL
+intervaly=5.             ;; grepALL
+
+;;;
+;;; MAP LIMITS 
+;;;
+;windowx=[-150.,-120.]        ;; grepMAP
+;windowy=[5.,35.]       ;; grepMAP
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+minalt=-5.		;; grepSEC
+maxalt=40.		;; grepSEC
+minspace=0.0  		;; grepSEC
+maxspace=35.0  		;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; POUBELLE
+
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+;extract='yes'   ;;   EXECUTE ARWPOST.EXE
+                ;;   WITH THE FOLLOWING PARAMETERS :
+
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='U' & winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='tk' & topo=1
+;field1='tk' & winds=['U','V'] & topo=1
+;field1='T' & field2='T'
+;field1='T' & winds=['U','V'] 
+;field1='HGT' & winds=['HGT','HGT'] 
+
Index: trunk/UTIL/IDLplot/ARWpost/gw.def_last
===================================================================
--- trunk/UTIL/IDLplot/ARWpost/gw.def_last	(revision 1185)
+++ trunk/UTIL/IDLplot/ARWpost/gw.def_last	(revision 1185)
@@ -0,0 +1,284 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------------;
+; DATA LOCATION and PLOT DESTINATION  ;
+; default is ./                       ;
+;-------------------------------------;
+;datafolder='/d5/aslmd/LMD_MM_MARS_SIMUS/LANDING_SITES/GALE/'
+;datafolder='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_160/jour20/'
+;datafolder='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_68.5/jour20/'
+;datafolder='/d5/aslmd/WRF_Mars/EN_COURS/OMG_cstTI/'
+;datafolder='/d5/aslmd/WRF_Mars/EN_COURS/TH20WC_month4'
+datafolder='/tmp7/aslmd/MERIDIANI_FLUSH'
+;datafolder='/d5/aslmd/LMD_MM_MARS_SIMUS/PAVONIS/'
+plotfolder=datafolder
+;; for web anim and tex report (default is 'plot')
+;textitle='takezoomstress'
+;textitle='takezoomhiresstress'
+textitle='atlas_6_meridiani_flush2'
+texcomments='sol'
+
+;;; load/save ARWpost-generated text files ? default is no
+;backup_data='yes'
+;already_data='yes'
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'HGT,U,V,TSURF' "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE FIELDS TO BE EXTRACTED 
+;; ex: tk,HGT,PSFC,U,V,W,T,tk,ICETOT,RAVE,QH2O_ICE,QH2O,PTOT,TSURF
+
+nam2=" start_date = '2024-09-07_06:00:00'
+nam3=" end_date = '2024-09-08_06:00:00'
+;nam3=" end_date   = '2024-09-13_06:00:00'
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE START/END DATE
+
+nam4=" interval_seconds = 3700 "
+;nam4=" interval_seconds = 7400 "
+;nam4=" interval_seconds = 88800 "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
+;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s, 12h: 44400s	
+
+nam5=" interp_method = 1 "	
+;nam5=" interp_method = 0 "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 		
+;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+
+tabnam=[0.0, 5.0, 1.0]
+tabnam=[999.,0.,1.,4.,6.,10.,20.]
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+;nest='d03'  
+;; ^ ^ ^ ^
+;; SET NEST
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=23		   	;; how many plots ?
+;num=7
+;num=1
+
+field1='U'		;; FILLED
+;field2='TSURF'		;; CONTOURED
+winds=['U','V']		;; VECTORS
+topo=1
+
+;;; VORTICITY
+;field1='HGT' & winds=['U','V'] & topo=1
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+;; first is 1
+plot='map' & level=6 ;3	
+;plot='meridional' & nlon=50
+;plot='zonal' & nlat=66
+
+;---------;
+; special ;
+;---------;
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & plot='map' & level=6 ;2 ;7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1 & plot='map' & level=6 ;2 ;9
+
+
+;;useidlfile='true' ;; if you are just changing what is below...
+
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+;;;
+;;; PLOT TITLES
+;;;
+;subtitle_user='-- LMD Martian Mesoscale Model --'            ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N)'     ;; grepALL
+;title_user='Dust opacity' ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+
+;;;
+;;; COLOR TABLES
+;;;
+;flag_cb='false'                 ;; grepALL
+format='(F5.1)'                  ;; grepALL
+;format='(I0)'                   ;; grepALL
+;colors=128                      ;; grepALL
+pal=22                           ;; grepALL
+;pal=33                           ;; grepALL
+poscb=0.85			 ;; grepALL
+poscb=0.68                       ;; grepALL
+;; GOOD COLOR TABLES: 4, 18, 22, 16, 37, 33, 39
+
+;;;
+;;; FILL LIMITS
+;;;
+minfield_init= 0.   	;; grepALL
+maxfield_init= 25.   	;; grepALL
+
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+
+;;;
+;;; WINDS
+;;;
+windex=25.	;; grepALL
+stride=3.	;; grepALL
+
+;;;
+;;; CONTOUR
+;;;
+;overcontour=overcontour-mean(overcontour)	;; grepALL
+lev=-10. + 0.5*findgen(100) ;; grepALL
+;lev=120.+5.*findgen(50) ;; grepALL
+
+;;;
+;;; AXIS
+;;;
+;isotropic='false'       ;; grepALL
+intervalx=2.            ;; grepALL
+intervaly=2.            ;; grepALL
+
+;;;
+;;; MAP LIMITS 
+;;;
+windowx=[-20.,08.]       ;; grepMAP
+windowy=[-16.,12.]       ;; grepMAP
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-4.		;; grepSEC
+;maxalt=16.		;; grepSEC
+;minspace=-30.   	;; grepSEC
+;maxspace=0.   		;; grepSEC
+
+;;
+;; METRIC UNITS FOR VERTICAL SECTION
+;;
+;factor=20.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; POUBELLE
+
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+;extract='yes'   ;;   EXECUTE ARWPOST.EXE
+                ;;   WITH THE FOLLOWING PARAMETERS :
+
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='U' & winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='tk' & topo=1
+;field1='tk' & winds=['U','V'] & topo=1
+;field1='T' & field2='T'
+;field1='T' & winds=['U','V'] 
+;field1='HGT' & winds=['HGT','HGT'] 
+
+dumb=000
Index: trunk/UTIL/IDLplot/ARWpost/gw.def_ref
===================================================================
--- trunk/UTIL/IDLplot/ARWpost/gw.def_ref	(revision 1185)
+++ trunk/UTIL/IDLplot/ARWpost/gw.def_ref	(revision 1185)
@@ -0,0 +1,270 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------------;
+; DATA LOCATION and PLOT DESTINATION  ;
+; default is ./
+;-------------------------------------;
+datafolder='/home/aslmd/ELYSIUM_3NEST/'   
+plotfolder=datafolder
+;; for web anim and tex report (default is 'plot')
+textitle='EM'
+texcomments='sol3'
+
+;;; load/save ARWpost-generated text files ? default is no
+;backup_data='yes'
+;already_data='yes'
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'HGT' "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE FIELDS TO BE EXTRACTED 
+;; ex: tk,HGT,PSFC,U,V,W,T,tk,ICETOT,RAVE,QH2O_ICE,QH2O,PTOT,TSURF
+
+nam2=" start_date = '2024-07-03_01:00:00' " 
+nam3=" end_date   = '2024-07-03_01:00:00' "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE START/END DATE
+
+nam4=" interval_seconds = 14800 "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
+;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s, 12h: 44000s	
+
+nam5=" interp_method = 1 "	
+nam5=" interp_method = 0 "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 		
+;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+
+tabnam=[0.,6.,0.1]   	
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+nest='d01'  
+;; ^ ^ ^ ^
+;; SET NEST
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=1		   	;; how many plots ?
+
+
+field1='HGT'		;; FILLED
+field2='HGT'		;; CONTOURED
+;winds=['U','V']	;; VECTORS
+;topo=1
+
+
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & level=7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1
+;;; VORTICITY
+;field1='T' & winds=['U','V'] & topo=1
+
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+;; first is 1
+plot='map' & level=1 	
+;plot='meridional' & nlon=100
+;plot='zonal' & nlat=100
+
+;---------;
+; special ;
+;---------;
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & plot='map' & level=7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1 & plot='map' & level=9
+
+;;useidlfile='true' ;; if you are just changing what is below...
+;;extract='no' ;; SPECIFIC FOR ATLAS
+
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+;;;
+;;; PLOT TITLES
+;;;
+;subtitle_user='LMD mesoscale model'            ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N)'     ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+
+;;;
+;;; COLOR TABLES
+;;;
+;flag_cb='false'                ;; grepALL
+;format='(I0)'                  ;; grepALL
+;colors=128                      ;; grepALL
+;pal=33                          ;; grepALL
+;; GOOD COLOR TABLES: 4, 18, 22, 16, 37, 33
+
+;;;
+;;; FILL LIMITS
+;;;
+;minfield_init=-80.	;; grepALL
+;maxfield_init=80.	;; grepALL
+
+;lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+;lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;lim_blank = 10 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+
+;;;
+;;; WINDS
+;;;
+;windex=40.	;; grepALL
+;stride=3.	;; grepALL
+
+;;;
+;;; CONTOUR
+;;;
+;overcontour=overcontour-mean(overcontour)	;; grepALL
+;lev=[2.,4.,6.,8.,10.,12.,14.,16.] ;; grepALL 
+
+;;;
+;;; AXIS
+;;;
+;isotropic='false'       ;; grepALL
+;intervalx=1.            ;; grepALL
+;intervaly=2.            ;; grepALL
+
+;;;
+;;; MAP LIMITS 
+;;;
+;windowy=[23.,26.5]       ;; grepMAP
+;windowx=[145.,150.]      ;; grepMAP
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=2.		;; grepSEC
+;maxalt=26.		;; grepSEC
+;minspace=144.0  	;; grepSEC
+;maxspace=151.0  	;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; POUBELLE
+
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+;extract='yes'   ;;   EXECUTE ARWPOST.EXE
+                ;;   WITH THE FOLLOWING PARAMETERS :
+
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='U' & winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='tk' & topo=1
+;field1='tk' & winds=['U','V'] & topo=1
+;field1='T' & field2='T'
+;field1='T' & winds=['U','V'] 
+;field1='HGT' & winds=['HGT','HGT'] 
+
Index: trunk/UTIL/IDLplot/ARWpost/gw.pro
===================================================================
--- trunk/UTIL/IDLplot/ARWpost/gw.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/ARWpost/gw.pro	(revision 1185)
@@ -0,0 +1,597 @@
+pro gw, typeplot
+
+
+;-----------------------------------------
+; Read files generated by ARWpost & plot
+;
+; typeplot is s for see		(.ps are not saved, .def saved)
+;	      t for trace	(.ps are saved, .def saved)
+;	      r for report	(same as t + tex report)
+;	      m for movie	(same as t + gif movie)
+;	      w for web page    (same as t + html animation)
+;             g for simple grads output
+;
+; default is 's'
+;
+; use:
+;  1. set parameters in gw.def
+;  2. @gwc
+;  3. gw, 's' (or 't' or 'r' or 'm' or 'w' or 'g')
+;     or simply: gw
+; 
+;-----------------------------------------
+; A. Spiga, Mars 2008
+;-----------------------------------------
+
+
+nomovie='yes'
+grads='blabla'
+useidlfile='false'
+
+if (n_elements(typeplot) eq 0) then typeplot='s'
+if (typeplot eq 'g') then grads='true'
+
+print, '---------------------'
+print, 'init. please wait ...'
+print, '---------------------'
+
+;
+; init.
+;
+field1='' & field2='' & winds=['','']
+backup_data='no' & already_data='no'
+datafolder='./' & plotfolder='./'
+textitle='plot' & texcomments='plot'
+topo=0
+extract='yes' ;;a question is asked
+
+;
+; defining fields, coordinates, type of plot ... etc ...
+;
+@user.idl
+
+;
+; extracting/interpolating fields from WRF NETCDF files
+;
+if (typeplot eq 'g') then SPAWN, 'cp -f gw.def '+plotfolder+'/grads_gw.def'
+if (useidlfile eq 'true') then extract='no'
+if (extract eq 'yes') then begin
+	print, 'EXTRACT DATA. OK ?'
+        if (n_elements(dumb) eq 0) then begin  ;; give dumb in user.idl if one does not want to be asked questions !
+            if (grads ne 'true') then read, dumb, prompt='type 1 to proceed, 0 to keep the same input >>> ' else dumb=999
+        endif
+	if (dumb ne 0) then begin
+        	print, 'WE WILL EXTRACT DATA USING ARWPOST.EXE'
+		if (n_elements(nest) eq 0) then nest='d01'
+        	call_arwpost, nam1, nam2, nam3, nam4, nam5, tabnam, nest, datafolder, grads
+	endif 
+endif
+if (already_data eq 'yes') then begin
+	if (nam5 eq " interp_method = 0 ") then coord='model_level'
+	if ((nam5 eq " interp_method = 1 ") and (tabnam(0) lt tabnam(1))) then coord='height'
+        SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.ctl input.ctl'
+        SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.dat input.dat'
+endif
+
+;-----------------------------;
+; STARTING TO READ INPUT.CTL  ;
+;-----------------------------;
+
+;
+; get the local time
+;
+interv=0. & openr, 99, 'timefil' & readf,99,interv & close, 99
+
+;
+; get preliminar info on coordinates
+;
+wnx=1 & wny=1 & wnz=1 & wnt=1 & txt='' & param=[0.,0.,0.,0.,0.,0.,0.,0.]
+
+openr, 1, 'input.ctl'
+while not eof(1) do begin
+    readf,1,txt
+    match=STRPOS(txt,'linear')
+	if (match ne -1) then begin
+		wnx=(STRPOS(txt,'xdef') eq -1)*wnx  ;0 if linear
+		wny=(STRPOS(txt,'ydef') eq -1)*wny  ;0 if linear
+                wnz=(STRPOS(txt,'zdef') eq -1)*wnz  ;0 if linear 
+                wnt=(STRPOS(txt,'tdef') eq -1)*wnt  ;0 if linear
+                paramstart=STRSPLIT(txt, 'r', LENGTH=paramlength)
+        	paramchar=STRMID(txt,paramstart(1),paramlength(1))
+		READS, paramchar, start, step
+		param=param+[start*(STRPOS(txt,'xdef') ne -1),$
+			step*(STRPOS(txt,'xdef') ne -1),$
+			start*(STRPOS(txt,'ydef') ne -1),$
+			step*(STRPOS(txt,'ydef') ne -1),$
+			start*(STRPOS(txt,'zdef') ne -1),$
+			step*(STRPOS(txt,'zdef') ne -1),$
+			start*(STRPOS(txt,'tdef') ne -1),$
+			step*(STRPOS(txt,'tdef') ne -1)]
+	endif	
+endwhile
+close, 1
+timebegin=param(6)
+	
+
+;---------------------------------
+; READ .CTL FILE INFORMATIONS
+;---------------------------------
+
+info=read_ascii('input.ctl', missing_value=1e37)
+infodat=info.field1
+
+;
+; second column : dimensions
+;
+
+w=where((infodat(0,*) eq 1e37) and (infodat(1,*) lt 1e37))
+dimensions=reform(infodat(1,w))
+
+nx=round(dimensions(0)) & ny=round(dimensions(1)) 
+nz=round(dimensions(2)) & nt=round(dimensions(3)) 
+fields=round(dimensions(4)) & vertical=intarr(fields)
+for i=0,fields-1 do vertical(i)=round(dimensions(5+i))
+
+;
+; first column : coordinates
+;
+
+w=where((infodat(1,*) eq 1e37) and (infodat(0,*) lt 1e37))
+if (w(0) ne -1) then coordinates=reform(infodat(0,w))
+
+if (wnx ne 0) then begin
+
+	wnx=nx
+	x=coordinates(0:nx-1)
+
+endif else begin
+
+	xmin=param(0)
+	xmax=param(0)+param(1)*(nx-1) MOD 360
+	;inc=param(0)+param(1)*(nx-1)	;cas mercator
+	;x=start+inc*findgen(nx) 
+	x=xmin+(xmax-xmin)*findgen(nx)/(nx-1)
+	
+;param(1)=param(1)-param(0) ;;bricolo plot GCM
+;xmin=param(0)
+;xmax=param(0)+param(1)*(nx-1)
+;x=xmin+(xmax-xmin)*findgen(nx)/(nx-1)
+;;x = x - (LONG(x)/180)*360.0
+;print, x
+
+	;stop
+
+endelse
+
+
+if (wny ne 0) then begin
+        wny=ny
+	y=coordinates(wnx:wnx+wny-1)
+endif else begin
+        start=param(2)
+        step=param(3)
+        y=start+step*findgen(ny)
+endelse
+if (wnz ne 0) then begin
+        wnz=nz
+	z=coordinates(wnx+wny:wnx+wny+wnz-1)
+endif else begin
+        start=param(4)
+        step=param(5)
+        z=start+step*findgen(nz)
+endelse
+t=interv*findgen(nt)/3700. + timebegin + mean(x)/15.
+lct = round(t+24) MOD 24	
+	
+;
+; get info on fields
+;
+openr, 1, 'input.ctl'
+toto=5+wnx+1+wny+1+wnz+2+fields
+infofields=strarr(toto)
+readf, 1, infofields
+close, 1
+desc_field=transpose(infofields(toto-fields:toto-1))
+
+;
+; vert coord
+;
+if (z(0) lt z(1)) then coord='height'
+if (z(0) gt z(1)) then coord='pressure'
+if ((z(0) eq 1.) and (z(nz-1) eq (z(nz-2)+1.))) then coord='model_level'
+
+
+
+;---------------------------------
+; READ .DAT FILE DATA
+;---------------------------------
+; GrADS views gridded data sets as 5-dimensional arrays 
+; varying in longitude, latitude, vertical level, variable, and time.
+;---------------------------------
+
+;-----------------------------;
+; STARTING TO READ INPUT.DATA ;
+;-----------------------------;
+print, '----------------'
+print, 'reading data ...'
+print, '----------------'
+print, 'longitudes: ', min(x), max(x), nx, ' points'
+print, 'latitudes: ', min(y), max(y), ny, ' points' 
+print, 'altitudes: ', min(z), max(z), nz, ' points'
+print, 'local times: ', min(lct), max(lct), nt, ' points'
+print, fields, ' recorded fields :'
+print, desc_field
+print, '----------------'
+
+; see http://www.dfanning.com/tips/ascii_column_data.html	
+OPENR, lun, 'input.dat', /GET_LUN
+
+
+;
+; titles and plot name
+;
+denom=textitle+'_'+plot+'_'+coord+'_'+field1
+if ((field2 ne '') and (topo eq 0)) then denom=denom+'_'+field2
+if (topo eq 1) then denom=denom+'_HGT'
+if (winds(0) ne '') then denom=denom+'_'+winds(0)+winds(1)
+        case coord of
+	'height': charlev='Altitude (km)'
+	;'pressure': begin
+	;               H=10.
+	;               p0=6.1
+	;               z=H*alog(p0/z)
+	;               charlev='Log-Pressure altitude (km)'
+	;end
+	'model_level': charlev='Model level'
+	endcase
+																							
+
+;
+; graphics settings
+;
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+	; plot with topography
+	if (topo eq 1) then field2='HGT'
+
+save_ps='true' ;; hardwired
+;save_ps='false'
+if (save_ps eq 'false') then begin
+		;if (save_ps ne 'false') then begin
+		;	;set_plot, 'ps'
+		;endif else begin
+	set_plot, 'x'
+	!P.MULTI = [0, 2, 3]
+	window, 0, xsize=600, ysize=900
+		;endelse
+endif
+
+no3D='false'	
+;goto, yeye 
+print, 'GENERATE PLOTS ',min([nt-1,num-1])+1
+
+for l=0,min([nt-1,num-1]) do begin 	;time loop
+		print, '************************************************************************'
+		print, 'time loop ...', l+1, ' / ', string(nt,'(I0)')  
+		T = SYSTIME(1)
+	if (useidlfile eq 'true') then $
+		restore,filename=plotfolder+'/'+denom+string(1000+l,'(I0)')+'.idl' $
+	else begin
+  for f=0, fields-1 do begin ;fields (whether 2D or 3D)	;variable loop
+  nzf=vertical(f)
+  print, 'scanning field ...', f+1, ' / ', string(fields,'(I0)')
+
+	data = FLTARR(1,nzf*ny*nx)
+	print, 'read data ...'
+	READF, lun, data	;; the IDL way, two times faster than 3 FOR loops
+	print, 'read data done'
+	
+	recognize=STRSPLIT(desc_field(f), /EXTRACT)
+	recognize=recognize[0]
+	
+;	IF (STRPOS(desc_field(f),field1) ne -1) then begin
+;       IF ( ( STRPOS(desc_field(f),field1) eq 0 ) and ( STRLEN(desc_field(f)) eq STRLEN(field1) ) ) then begin
+	IF (recognize eq field1) then begin
+		data_save=data
+		print, 'found field1 ', field1
+		data=REFORM(data,nx,ny,nzf,/OVERWRITE)
+			w=where(data eq -9999.)	; missing values: -9999 (before, was 1e20)
+			if (w(0) ne -1) then data[w]=1e37
+		CASE (plot) OF
+		'map': what_I_plot=reform(data(*,*,-1+min([level,nzf])))
+		'meridional': what_I_plot=reform(data(-1+min([nlon,nx]),*,*))
+		'zonal': what_I_plot=reform(data(*,-1+min([nlat,ny]),*))
+		ENDCASE
+		if (nzf eq 1) then no3D='true'
+		data=0. & data=data_save & data_save=0.
+	ENDIF
+;	IF ((STRPOS(desc_field(f),field2) ne -1) and (field2 ne '')) then begin
+;       IF ((STRPOS(desc_field(f),field2) eq 0) and (field2 ne '')) then begin
+;       IF ( ( STRPOS(desc_field(f),field2) eq 0 ) and ( field2 ne '' ) and ( STRLEN(desc_field(f)) eq STRLEN(field2) ) ) then begin
+        IF (recognize eq field2) then begin
+		data_save=data
+		print, 'found field2 ', field2
+		if (topo eq 1) then begin
+			data=data/100.
+			data=round(data)
+			data=float(data)/10.
+		endif	
+		data=REFORM(data,nx,ny,nzf,/OVERWRITE)
+                        w=where(data eq -9999.)   ; missing values
+			if (w(0) ne -1) then data[w]=1e37
+		CASE (plot) OF
+		'map': overcontour=reform(data(*,*,-1+min([level,nzf])))
+		'meridional': overcontour=reform(data(-1+min([nlon,nx]),*,*))
+		'zonal': overcontour=reform(data(*,-1+min([nlat,ny]),*))
+		ENDCASE
+		data=0. & data=data_save & data_save=0.
+	ENDIF   
+;	IF (STRPOS(desc_field(f),winds(0)) ne -1 and (winds(0) ne '')) then begin
+;       IF (STRPOS(desc_field(f),winds(0)) eq 0 and (winds(0) ne '')) then begin
+	IF (recognize eq winds(0)) then begin
+		data_save=data
+		print, 'found wind1 ', winds(0)
+	        data=REFORM(data,nx,ny,nzf,/OVERWRITE)
+                        w=where(data eq -9999.)   ; missing values
+			if (w(0) ne -1) then data[w]=!Values.F_NAN
+		CASE (plot) OF
+                'map': overvector_x=reform(data(*,*,-1+min([level,nzf])))
+                'meridional': overvector_x=reform(data(-1+min([nlon,nx]),*,*))
+                'zonal': overvector_x=reform(data(*,-1+min([nlat,ny]),*))
+		ENDCASE
+		data=0. & data=data_save & data_save=0.
+	ENDIF 
+;	IF (STRPOS(desc_field(f),winds(1)) ne -1 and (winds(1) ne '')) then begin
+;       IF (STRPOS(desc_field(f),winds(1)) eq 0 and (winds(1) ne '')) then begin
+        IF (recognize eq winds(1)) then begin
+		data_save=data
+		print, 'found wind2 ', winds(1)
+		data=REFORM(data,nx,ny,nzf,/OVERWRITE)
+                        w=where(data eq -9999.)   ; missing values
+	                if (w(0) ne -1) then data[w]=!Values.F_NAN
+                CASE (plot) OF
+                'map': overvector_y=reform(data(*,*,-1+min([level,nzf])))
+                'meridional': overvector_y=reform(data(-1+min([nlon,nx]),*,*))
+                'zonal': overvector_y=reform(data(*,-1+min([nlat,ny]),*))
+                ENDCASE
+		data=0. & data=data_save & data_save=0.
+	ENDIF
+	data=0.		;; free memory
+	data_save=0.         ;; free memory
+	
+  endfor
+	  save, $
+	 	what_I_plot, $
+	        overcontour, overvector_x, overvector_y, $
+	 	x, y, z, lct, filename=plotfolder+'/'+denom+string(1000+l,'(I0)')+'.idl'
+	  endelse
+
+	if (n_elements(overcontour) eq 0) then overcontour=0.
+	if (n_elements(overvector_x) eq 0) then overvector_x=0.
+	if (n_elements(overvector_y) eq 0) then overvector_y=0.
+
+	@gw_name.idl
+
+;;--------------------------------------------------------
+;; NB: you can use the winds fields to combine variables
+;;--------------------------------------------------------
+@wind_stress.idl	;** WIND STRESS
+@sea_level.idl		;** HYDROSTATIC REDUCTION TO LEVEL OF REFERENCE
+;@ertel_vorticity.idl	;** ERTEL POTENTIAL VORTICITY
+@tau_cloud.idl          ;** CLOUD OPACITY
+@wind_velocity.idl	;** 3D WIND VELOCITY
+@hwind_velocity.idl	;** HORIZONTAL WIND VELOCITY 
+;what_I_plot=what_I_plot-median(what_I_plot)
+;;--------------------------------------------------------
+;; NB: you can use the winds fields to combine variables
+;;--------------------------------------------------------
+
+	title=title+', LT '+string(lct(l),'(I0)')
+
+;;--------------------------------------------------------
+;;--------------------------------------------------------
+;       getcdf, file='zefolder/wrfinput_d01', charvar='MARS_TI', invar=what_I_plot ;;; changer minfield et maxfield
+       ;;print, size(what_I_plot)
+       ;;getcdf, file='../WPS/geo_em.d01.nc', charvar='THERMAL_INERTIA', invar=yeyeye
+       ;;title = 'Thermal Inertia (J m!U-2!N s!U-0.5!N K!U-1!N)' & no3D='true' & pal=3 & format='(I0)'
+       ;;what_I_plot(2:153,2:153)=reform(yeyeye(*,*,0))
+       ;what_I_plot=reform(what_I_plot(*,*,0)) & help, what_I_plot
+;       getcdf, file='zefolder/wrfinput_d01', charvar='MARS_ALB', invar=what_I_plot ;;; changer minfield et maxfield
+;       title = 'Albedo' & no3D='true' & pal=1 & format='(F5.2)'
+;       what_I_plot=reform(what_I_plot(*,*,0)) & help, what_I_plot
+;;--------------------------------------------------------
+;;--------------------------------------------------------
+
+	if (save_ps ne 'false') then begin
+		save_ps=denom+string(1000+l,'(I0)')
+			;        device, filename=save_ps+'.ps', /color, bits=16
+		PS_Start, filename=save_ps+'.ps'
+                !P.Charsize = 1.2
+	endif
+
+;**************************
+smoothampl=2
+smoothampl=0 ;; no smooth
+;**************************
+
+	CASE (plot) OF
+	'map': begin
+        	case coord of
+		   'height': charlev=string(round(z(level-1)*1000.),'(I0)')+' m AMR'
+		   'pressure': charlev=string(round(z(level-1)*100.),'(I0)')+' Pa'
+		   'model_level': charlev=string(round(z(level-1)),'(I0)')
+		endcase
+        	if (no3D ne 'true') then title=title+', at level '+charlev
+		print, title
+	map_latlon, $
+		smooth(what_I_plot,[smoothampl,smoothampl],/EDGE_TRUNCATE), $	; 2D field
+        	x, $                                  ; 1D latitude
+        	y, $                                  ; 1D longitude
+        	minfield=0., $               ; minimum value of plotted field (=0: calculate)
+        	maxfield=0., $               ; maximum value of plotted field (=0: calculate)
+        	overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        	overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        	overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        	ct=pal, $                               ; color table (33-rainbow is default)
+        	colors=colors, $                        ; number of colors/levels (32 is default)
+        	title=title, $                     ; title of the plot ('' is default)
+        	format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+	end
+	'zonal': begin
+		displaylat=float(round(y(nlat-1)*10))/10.
+		title=title+ ', section at latitude '+string(displaylat,format='(1F6.1)')+ '!Uo!N '
+	        print, title
+	section, $
+		smooth(what_I_plot,[smoothampl,smoothampl],/EDGE_TRUNCATE), $   ; 2D field
+                x, $                                ; horizontal coordinate
+                z, $                             ; altitude coordinate
+                minfield=0., $               ; minimum value of plotted field (=0: calculate)
+                maxfield=0., $               ; maximum value of plotted field (=0: calculate)
+                minspace=0., $                    ; minimum value of space window (=0: calculate)
+                maxspace=0., $                    ; maximum value of space window (=0: calculate)
+                overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+                overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+                overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+                colors=colors, $                        ; number of colors/levels (32 is default)
+                title_plot=title, $                ; title of the plot ('Profile' is default)
+                title_axis=['Longitude',charlev], $             ; title of the [x,y] axis (['Field','Altitude'] is default)
+                ct=pal, $                               ; color table (33-rainbow is default)
+                format=format
+ 	end
+        'meridional': begin
+                displaylon=float(round(x(nlon-1)*10))/10.
+                title=title+', section at longitude '+string(displaylon,format='(1F6.1)')+ '!Uo!N '
+                print, title
+        section, $
+                smooth(what_I_plot,[smoothampl,smoothampl],/EDGE_TRUNCATE), $   ; 2D field
+                y, $                                ; horizontal coordinate
+                z, $                             ; altitude coordinate
+                minfield=0., $               ; minimum value of plotted field (=0: calculate)
+                maxfield=0., $               ; maximum value of plotted field (=0: calculate)
+                minspace=0., $                    ; minimum value of space window (=0: calculate)
+                maxspace=0., $                    ; maximum value of space window (=0: calculate)
+                overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+                overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+                overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+                colors=colors, $                        ; number of colors/levels (32 is default)
+                title_plot=title, $                ; title of the plot ('Profile' is default)
+                title_axis=['Latitude',charlev], $             ; title of the [x,y] axis (['Field','Altitude'] is default)
+                ct=pal, $                               ; color table (33-rainbow is default)
+                format=format
+        end
+ 	endcase	 
+
+PS_End, /PNG
+
+;		 if (save_ps ne 'false') then begin
+;	               device, /close
+;	;               SPAWN, './ps2png -a ; \rm '+save_ps+'.ps '+save_ps+'.eps '
+;	               SPAWN, './ps2png ; \rm '+save_ps+'.ps '+save_ps+'.eps '
+	               if (typeplot eq 's') then begin
+	                 SPAWN, 'display '+save_ps+'.png &'
+	               endif 
+;	         endif
+
+;PRINT, 1000*(SYSTIME(1) - T), ' milliSeconds'
+PRINT, SYSTIME(1) - T, ' seconds to process'
+endfor
+
+CLOSE, lun
+print, '...done !'
+help, /memory
+print, '---------'
+
+
+yeye:
+
+CASE (typeplot) OF
+;'g': begin
+;        SPAWN, 'cp -f gw.def '+plotfolder+'/grads_'+denom+'.def' 
+;end
+'s': begin
+	;SPAWN, 'find '+denom+'????.ps -exec display {} \;'
+	SPAWN, 'cp -f gw.def '+plotfolder+'/see_'+denom+'.def' ; \rm ./'+denom+'????.ps ./'+denom+'????.eps ' ;;./'+denom+'????.png'
+end
+'t': begin
+	SPAWN, 'mv -f ./'+denom+'????.ps ./'+denom+'????.png '+plotfolder+'/'
+	SPAWN, 'cp -f gw.def '+plotfolder+'/'+denom+'.def'
+end
+'r': begin
+	SPAWN, 'touch report.comments ; \rm report.comments ; echo '+textitle+' > report.comments ; echo '+texcomments+' >> report.comments'
+	SPAWN, 'rm -f '+denom+'_.ps ; echo executing ... base '+denom+'????.ps < report.comments'
+	SPAWN, 'base '+denom+'????.ps < report.comments ; mv -f base.ps '+denom+'_.ps'
+
+	SPAWN, 'mv -f ./'+denom+'????.ps '+plotfolder+'/'
+	SPAWN, 'mv -f ./'+denom+'_.ps '+plotfolder+'/'
+	SPAWN, 'cp -f gw.def '+plotfolder+'/'+denom+'.def'
+end
+'m': begin
+	print, 'generating movie ...'
+	SPAWN, 'rm -rf temp ; mkdir temp ; mv -f '+denom+'????.ps temp ; cp bigconvert200 temp ; cd temp'
+	SPAWN, 'bigconvert200 *.ps ; convert -delay 60 *.png movie.gif ; cd ..'
+	if (nomovie ne 'yes') then SPAWN, 'animate temp/movie.gif &' 
+	print, 'movie done'
+
+	SPAWN, 'mv -f temp/'+denom+'????.ps '+plotfolder+'/'
+	SPAWN, 'mv -f temp/movie.gif '+plotfolder+'/'+denom+'.gif'
+	SPAWN, 'mv -f temp/'+denom+'????.png '+plotfolder+'/'
+	SPAWN, 'cp -f gw.def '+plotfolder+'/'+denom+'.def'
+end
+'w': begin
+;
+;
+netfolder='/u/aslmd/WWW/ANIMATIONS/'
+;netfolder='/home/aslmd/'
+;
+; set also textitle
+;
+        ;print, 'generating frames ...'
+	;;        SPAWN, 'rm -rf temp ; mkdir temp ; mv -f '+denom+'????.ps temp/ ; ls temp/'
+	;;;        SPAWN, "find temp/* -exec convert -antialias -density 100x100 -crop 0x0 {} '{}.png' \;"
+	;;SPAWN, "cd temp ; ../ps2png ; cd .."
+	;;	SPAWN, 'ls temp/'
+	;;        ;SPAWN, 'mv -f temp/'+denom+'????.ps '+plotfolder+'/'
+        ;SPAWN, 'cp -f gw.def '+plotfolder+'/web_'+denom+'.def'
+	;;; webpage
+	;;SPAWN, 'rm -rf '+netfolder+textitle+'_'+denom+' ; mkdir '+netfolder+textitle+'_'+denom
+	;SPAWN, 'mkdir '+netfolder+textitle
+	;;SPAWN, 'mv -f temp/'+denom+'????.png '+netfolder+textitle+'/'
+	;SPAWN, 'mv -f temp/'+denom+'????.png '+netfolder+textitle+'/'
+	;SPAWN, 'chmod 777 -R '+netfolder+textitle
+	;SPAWN, 'rm -rf '+denom+'.html ; more header.html > '+textitle+'_'+denom+'.html'
+	;genanim, num, textitle, denom 
+	;SPAWN, 'more templist >> '+textitle+'_'+denom+'.html ; rm -rf templist'
+	;SPAWN, 'more body.html >> '+textitle+'_'+denom+'.html'
+	;SPAWN, 'mv -f '+textitle+'_'+denom+'.html '+netfolder+'/'
+
+   print, 'generating frames ...'
+   cmd = 'echo unix'
+   cmd = cmd + ' ; cp -f gw.def '+plotfolder+'/web_'+denom+'.def'
+   ;;; webpage
+   ;cmd = cmd + ' ; mkdir '+netfolder+textitle
+   cmd = cmd + ' ; mv -f ./'+denom+'????.png '+netfolder+'/' ;+textitle+'/'
+   ;cmd = cmd + ' ; chmod 777 -R '+netfolder+textitle
+   cmd = cmd + ' ; rm -rf '+denom+'.html ; cat header.html > '+denom+'.html'
+   SPAWN, cmd
+   genanim, num, textitle, denom 
+   cmd = 'echo unix'
+   cmd = cmd + ' ; cat templist >> '+denom+'.html ; rm -rf templist'
+   cmd = cmd + ' ; cat body.html >> '+denom+'.html'
+   cmd = cmd + ' ; mv -f '+denom+'.html '+netfolder+'/'
+   cmd = cmd + ' ; rm -rf ./*.epsi ./*.ps'
+   SPAWN, cmd
+
+end	
+ENDCASE
+
+if (backup_data eq 'yes') then SPAWN, 'cp -f namelist.ARWpost '+datafolder+'/'+coord+'.namelist.ARWpost'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.ctl '+datafolder+'/'+coord+'.input.ctl'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.dat '+datafolder+'/'+coord+'.input.dat'
+
+
+
+
+end
Index: trunk/UTIL/IDLplot/ARWpost/gw_name.idl
===================================================================
--- trunk/UTIL/IDLplot/ARWpost/gw_name.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/ARWpost/gw_name.idl	(revision 1185)
@@ -0,0 +1,103 @@
+;
+; FILL HERE SOME FIELD-DEPENDENT SETTINGS 
+;
+
+case field1 of
+'HGT': begin 
+        title='Topography (km)'
+        pal=16
+        format='(F7.0)'
+	what_I_plot=what_I_plot/1000.
+end
+'tk': begin
+        title='Temperature (K)'
+        pal=3
+        format='(F4.0)'
+end
+'TSURF': begin
+        title='Surface Temperature (K)'
+        pal=3
+	format='(F4.0)'
+	no3D='true'
+end
+'U': begin
+        title='Zonal wind (!Nm!N.s!U-1!N)'
+        if (winds(0) eq 'U') then title='Wind field (!Nm!N.s!U-1!N)'
+        pal=33
+end
+'V': begin
+        title='Meridional wind (!Nm!N.s!U-1!N)'
+        if (winds(0) eq 'V') then title='Wind field (!Nm!N.s!U-1!N)'
+        pal=33
+end
+'T': begin
+	print, 'coucou'
+	what_I_plot = what_I_plot + 220.
+	title='Potential temperature (K)'
+end
+'W': begin
+        title='Vertical wind (!Nm!N.s!U-1!N)'
+        pal=33  ;;pal=16
+        format='(F6.2)'
+end
+'ICETOT': begin
+	title='Water ice column (!7l!3m-pr)'
+	pal=22
+	format='(F5.1)'
+	what_I_plot=what_I_plot*1000.
+end
+'MTOT': begin
+        title='Water vapor column (!7l!3m-pr)'
+        pal=22
+        format='(F5.1)'
+        what_I_plot=what_I_plot*1000.
+end
+'RAVE': begin
+	title='Average water ice radius (!7l!3m)'
+	pal=22
+	format='(F5.1)'
+	what_I_plot=what_I_plot*1e6
+end
+'RICE': begin
+        title='Water ice radius (!7l!3m)'
+        pal=22
+        format='(F5.1)'
+        what_I_plot=what_I_plot*1e6
+end
+'QH2O': begin
+        title='Water vapor mixing ratio (ppm)'
+        pal=33
+        format='(F5.1)'
+	format='(I0)'
+        what_I_plot=what_I_plot*1e6
+end
+'QH2O_ICE': begin
+        title='Water ice mixing ratio (ppm)'
+        pal=22
+        format='(F5.1)'
+        format='(I0)'
+        what_I_plot=what_I_plot*1e6
+end
+'USTM': begin
+        title='Friction velocity (!Nm!N.s!U-1!N)'
+        pal=22
+        format='(F4.2)'
+        no3D='true'
+end
+else: begin
+	title=''
+	pal=33
+	format='(F6.2)'
+end
+endcase
+
+case field2 of
+'T': begin
+        overcontour = overcontour + 220.
+end
+;'HGT': begin
+;	overcontour = overcontour/1000.
+;end
+else:
+endcase
+
Index: trunk/UTIL/IDLplot/ARWpost/gwc
===================================================================
--- trunk/UTIL/IDLplot/ARWpost/gwc	(revision 1185)
+++ trunk/UTIL/IDLplot/ARWpost/gwc	(revision 1185)
@@ -0,0 +1,47 @@
+
+;
+; every time you modify gw.def, launch @gwc
+;
+
+
+;
+; START FROM SCRATCH
+;
+.reset_session
+
+
+;
+; USER PARAMETERS
+;
+print, 'reading user parameters ...'
+SPAWN, 'touch user.idl ; \rm user.idl ; grep -v grep gw.def > user.idl'
+@user.idl
+
+
+;
+; PLOT PARAMETERS
+;
+what_to_do='\rm param_plot.idl ; grep grepALL gw.def > param_plot.idl'
+
+if ((plot eq 'meridional') or (plot eq 'zonal')) then what_to_do=what_to_do+' ; grep grepSEC gw.def >> param_plot.idl'
+if (plot eq 'map') then what_to_do=what_to_do+' ; grep grepMAP gw.def >> param_plot.idl'
+
+SPAWN, what_to_do
+
+SPAWN, 'grep nam2 gw.def >> param_plot.idl'
+
+print, 'done !'
+
+
+;;;SPAWN, '\rm param_plot.idl ; grep grepALL gw.def > param_plot.idl'
+;;;if ((plot eq 'meridional') or (plot eq 'zonal')) then SPAWN, 'grep grepSEC gw.def >> param_plot.idl'
+;;;if (plot eq 'map') then SPAWN, 'grep grepMAP gw.def >> param_plot.idl'
+
+
+
+;
+; ALWAYS RE-COMPILE
+;
+.compile gw
+.compile map_latlon
+.compile section
Index: trunk/UTIL/IDLplot/ARWpost/namelist.ARWpost_ref
===================================================================
--- trunk/UTIL/IDLplot/ARWpost/namelist.ARWpost_ref	(revision 1185)
+++ trunk/UTIL/IDLplot/ARWpost/namelist.ARWpost_ref	(revision 1185)
@@ -0,0 +1,13 @@
+&io
+!------------------------------------------------------------------------------------
+! do not modify
+!------------------------------------------------------------------------------------
+ io_form_input  = 2,
+ input_root_name = './zefolder/wrfout_zenest'
+ output_root_name = './input'
+ plot = 'list'
+ output_type = 'idl'          !**** or choose 'grads' 
+ mercator_defs = .true.       !**** choose false if grads 
+!------------------------------------------------------------------------------------
+! end do not modify
+!------------------------------------------------------------------------------------
Index: trunk/UTIL/IDLplot/MINIMAL/README
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/README	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/README	(revision 1185)
@@ -0,0 +1,30 @@
+launch
+
+idl> example
+
+[before: cp param_plot.idl.minimal param_plot.idl]
+
+----
+
+I/O
+
+input: IDL save file example.idl
+output: ps and png figure
+
+----
+
+routines
+
+map_latlon.pro: to plot the fields
+param_plot.idl: settings for the plot (not compulsory)
+example.pro: main routine
+
+colorbar.pro, plot_vector.pro, vector.pro: needed by map_latlon.pro (from Coyote IDL and IDL for meteorology, slightly modified)
+fsc/*: to have nice postscript files (from Coyote IDL, slightly modified)(not compulsory, just have to change example.pro and use set_plot)
+
+
+added:
+profile
+section
+getcdf
+reverse_ct
Index: trunk/UTIL/IDLplot/MINIMAL/colorbar.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/colorbar.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/colorbar.pro	(revision 1185)
@@ -0,0 +1,474 @@
+;+
+; NAME:
+;   COLORBAR
+;
+; PURPOSE:
+;
+;       The purpose of this routine is to add a color bar to the current
+;       graphics window.
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;       Graphics, Widgets.
+;
+; CALLING SEQUENCE:
+;
+;       COLORBAR
+;
+; INPUTS:
+;
+;       None.
+;
+; KEYWORD PARAMETERS:
+;
+;       ANNOTATECOLOR: The name of the "annotation color" to use. The names are those for
+;                     FSC_COLOR, and using the keyword implies that FSC_COLOR is also in
+;                     your !PATH. If this keyword is used, the annotation color is loaded
+;                     *after* the color bar is displayed. The color will be represented
+;                     as theColor = FSC_COLOR(ANNOTATECOLOR, COLOR). This keyword is provide
+;                     to maintain backward compatibility, but also to solve the problem of
+;                     and extra line in the color bar when this kind of syntax is used in
+;                     conjunction with the indexed (DEVICE, DECOMPOSED=0) model is used:
+;
+;                          LoadCT, 33
+;                          TVImage, image
+;                          Colorbar, Color=FSC_Color('firebrick')
+;
+;                     The proper syntax for device-independent color is like this:
+;
+;                          LoadCT, 33
+;                          TVImage, image
+;                          Colorbar, AnnotateColor='firebrick', Color=255
+;
+;       BOTTOM:       The lowest color index of the colors to be loaded in
+;                     the bar.
+;
+;       CHARSIZE:     The character size of the color bar annotations. Default is !P.Charsize.
+;
+;       COLOR:        The color index of the bar outline and characters. Default
+;                     is !P.Color..
+;
+;       DIVISIONS:    The number of divisions to divide the bar into. There will
+;                     be (divisions + 1) annotations. The default is 6.
+;
+;       FONT:         Sets the font of the annotation. Hershey: -1, Hardware:0, True-Type: 1.
+;
+;       FORMAT:       The format of the bar annotations. Default is '(I0)'.
+;
+;       INVERTCOLORS: Setting this keyword inverts the colors in the color bar.
+;
+;       MAXRANGE:     The maximum data value for the bar annotation. Default is
+;                     NCOLORS.
+;
+;       MINRANGE:     The minimum data value for the bar annotation. Default is 0.
+;
+;       MINOR:        The number of minor tick divisions. Default is 2.
+;
+;       NCOLORS:      This is the number of colors in the color bar.
+;
+;       NODISPLAY:    COLORBAR uses FSC_COLOR to specify some of it colors. Normally, 
+;                     FSC_COLOR loads "system" colors as part of its palette of colors.
+;                     In order to do so, it has to create an IDL widget, which in turn 
+;                     has to make a connection to the windowing system. If your program 
+;                     is being run without a window connection, then this program will 
+;                     fail. If you can live without the system colors (and most people 
+;                     don't even know they are there, to tell you the truth), then setting 
+;                     this keyword will keep them from being loaded, and you can run
+;                     COLORBAR without a display.
+;
+;       POSITION:     A four-element array of normalized coordinates in the same
+;                     form as the POSITION keyword on a plot. Default is
+;                     [0.88, 0.10, 0.95, 0.90] for a vertical bar and
+;                     [0.10, 0.88, 0.90, 0.95] for a horizontal bar.
+;
+;       RANGE:        A two-element vector of the form [min, max]. Provides an
+;                     alternative way of setting the MINRANGE and MAXRANGE keywords.
+;
+;       REVERSE:      Setting this keyword reverses the colors in the colorbar.
+;
+;       RIGHT:        This puts the labels on the right-hand side of a vertical
+;                     color bar. It applies only to vertical color bars.
+;
+;       TICKNAMES:    A string array of names or values for the tick marks.
+;
+;       TITLE:        This is title for the color bar. The default is to have
+;                     no title.
+;
+;       TOP:          This puts the labels on top of the bar rather than under it.
+;                     The keyword only applies if a horizontal color bar is rendered.
+;
+;       VERTICAL:     Setting this keyword give a vertical color bar. The default
+;                     is a horizontal color bar.
+;
+; COMMON BLOCKS:
+;
+;       None.
+;
+; SIDE EFFECTS:
+;
+;       Color bar is drawn in the current graphics window.
+;
+; RESTRICTIONS:
+;
+;       The number of colors available on the graphics display device (not the
+;       PostScript device) is used unless the NCOLORS keyword is used.
+;
+;       Requires the FSC_COLOR program from the Coyote Library:
+;
+;          http://www.dfanning.com/programs/fsc_color.pro
+;
+; EXAMPLE:
+;
+;       To display a horizontal color bar above a contour plot, type:
+;
+;       LOADCT, 5, NCOLORS=100
+;       CONTOUR, DIST(31,41), POSITION=[0.15, 0.15, 0.95, 0.75], $
+;          C_COLORS=INDGEN(25)*4, NLEVELS=25
+;       COLORBAR, NCOLORS=100, POSITION=[0.15, 0.85, 0.95, 0.90]
+;
+; MODIFICATION HISTORY:
+;
+;       Written by: David W. Fanning, 10 JUNE 96.
+;       10/27/96: Added the ability to send output to PostScript. DWF
+;       11/4/96: Substantially rewritten to go to screen or PostScript
+;           file without having to know much about the PostScript device
+;           or even what the current graphics device is. DWF
+;       1/27/97: Added the RIGHT and TOP keywords. Also modified the
+;            way the TITLE keyword works. DWF
+;       7/15/97: Fixed a problem some machines have with plots that have
+;            no valid data range in them. DWF
+;       12/5/98: Fixed a problem in how the colorbar image is created that
+;            seemed to tickle a bug in some versions of IDL. DWF.
+;       1/12/99: Fixed a problem caused by RSI fixing a bug in IDL 5.2. Sigh... DWF.
+;       3/30/99: Modified a few of the defaults. DWF.
+;       3/30/99: Used NORMAL rather than DEVICE coords for positioning bar. DWF.
+;       3/30/99: Added the RANGE keyword. DWF.
+;       3/30/99: Added FONT keyword. DWF
+;       5/6/99: Many modifications to defaults. DWF.
+;       5/6/99: Removed PSCOLOR keyword. DWF.
+;       5/6/99: Improved error handling on position coordinates. DWF.
+;       5/6/99. Added MINOR keyword. DWF.
+;       5/6/99: Set Device, Decomposed=0 if necessary. DWF.
+;       2/9/99: Fixed a problem caused by setting BOTTOM keyword, but not NCOLORS. DWF.
+;       8/17/99. Fixed a problem with ambiguous MIN and MINOR keywords. DWF
+;       8/25/99. I think I *finally* got the BOTTOM/NCOLORS thing sorted out. :-( DWF.
+;       10/10/99. Modified the program so that current plot and map coordinates are
+;            saved and restored after the colorbar is drawn. DWF.
+;       3/18/00. Moved a block of code to prevent a problem with color decomposition. DWF.
+;       4/28/00. Made !P.Font default value for FONT keyword. DWF.
+;       9/26/00. Made the code more general for scalable pixel devices. DWF.
+;       1/16/01. Added INVERTCOLORS keyword. DWF.
+;       5/11/04. Added TICKNAME keyword. DWF.
+;       9/29/05. Added REVERSE keywords, which does the *exact* same thing as
+;           INVERTCOLORS, but I can never remember the latter keyword name. DWF.
+;       1/2/07. Added ANNOTATECOLOR keyword. DWF.
+;       4/14/07. Changed the default FORMAT to I0. DWF.
+;       5/1/07. Unexpected consequence of default format change is colorbar annotations
+;           no longer match contour plot levels. Changed to explicit formating of
+;           colorbar axis labels before PLOT command. DWF.
+;       5/25/07. Previous change has unanticipated effect on color bars using
+;           logarithmic scaling, which is not really supported, but I have an
+;           article on my web page describing how to do it: http://www.dfanning.com/graphics_tips/logcb.html.
+;           Thus, I've fixed the program to accommodate log scaling, while still not OFFICIALLY
+;           supporting it. DWF.
+;       10/3/07. Method used to calculate TICKNAMES produces incorrect values in certain cases when
+;           the min and max range values are integers. Now force range values to be floats. DWF.
+;       10/17/07. Accidentaly use of INTERP keyword in CONGRID results in wrong bar values for
+;           low NCOLORS numbers when INVERTCOLORS or REVERSE keyword is used. Removed INTERP keyword. DWF.
+;       11/10/07. Finished fixing program to accommodate log scaling in ALL possible permutations. DWF.
+;       8 Feb 2008. Added CRONJOB keyword and decided to use month names when I write the date. DWF.
+;       8 Feb 2008. Renamed CRONJOB to NODISPLAY to better reflect its purpose. DWF.
+;      21 May 2008. Changed the default CHARSIZE to !P.CHARSIZE from 1.0. DWF.
+;-
+;
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright 2000-2008 Fanning Software Consulting.
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+
+
+PRO COLORBAR, BOTTOM=bottom, CHARSIZE=charsize, COLOR=color, DIVISIONS=divisions, $
+   FORMAT=format, POSITION=position, MAXRANGE=maxrange, MINRANGE=minrange, NCOLORS=ncolors, $
+   TITLE=title, VERTICAL=vertical, TOP=top, RIGHT=right, MINOR=minor, $
+   RANGE=range, FONT=font, TICKLEN=ticklen, _EXTRA=extra, INVERTCOLORS=invertcolors, $
+   TICKNAMES=ticknames, REVERSE=reverse, ANNOTATECOLOR=annotatecolor, XLOG=xlog, YLOG=ylog, $
+   NODISPLAY=nodisplay
+
+    compile_opt idl2
+
+    ; Return to caller on error.
+    On_Error, 2
+
+    ; Save the current plot state.
+    bang_p = !P
+    bang_x = !X
+    bang_Y = !Y
+    bang_Z = !Z
+    bang_Map = !Map
+
+    ; Are scalable pixels available on the device?
+    IF (!D.Flags AND 1) NE 0 THEN scalablePixels = 1 ELSE scalablePixels = 0
+
+    ; Which release of IDL is this?
+    thisRelease = Float(!Version.Release)
+
+    ; Check and define keywords.
+    IF N_ELEMENTS(ncolors) EQ 0 THEN BEGIN
+
+       ; Most display devices to not use the 256 colors available to
+       ; the PostScript device. This presents a problem when writing
+       ; general-purpose programs that can be output to the display or
+       ; to the PostScript device. This problem is especially bothersome
+       ; if you don't specify the number of colors you are using in the
+       ; program. One way to work around this problem is to make the
+       ; default number of colors the same for the display device and for
+       ; the PostScript device. Then, the colors you see in PostScript are
+       ; identical to the colors you see on your display. Here is one way to
+       ; do it.
+
+       IF scalablePixels THEN BEGIN
+          oldDevice = !D.NAME
+
+             ; What kind of computer are we using? SET_PLOT to appropriate
+             ; display device.
+
+          thisOS = !VERSION.OS_FAMILY
+          thisOS = STRMID(thisOS, 0, 3)
+          thisOS = STRUPCASE(thisOS)
+          CASE thisOS of
+             'MAC': SET_PLOT, thisOS
+             'WIN': SET_PLOT, thisOS
+             ELSE: SET_PLOT, 'X'
+          ENDCASE
+
+          ; Here is how many colors we should use.
+          ncolors = !D.TABLE_SIZE
+          SET_PLOT, oldDevice
+        ENDIF ELSE ncolors = !D.TABLE_SIZE
+    ENDIF
+    IF N_ELEMENTS(bottom) EQ 0 THEN bottom = 0B
+    IF N_ELEMENTS(charsize) EQ 0 THEN charsize = !P.Charsize
+    IF N_ELEMENTS(format) EQ 0 THEN format = '(I0)'
+    IF N_ELEMENTS(color) EQ 0 THEN color = !P.Color
+    minrange = (N_ELEMENTS(minrange) EQ 0) ? 0. : Float(minrange)
+    maxrange = (N_ELEMENTS(maxrange) EQ 0) ? Float(ncolors) : Float(maxrange)
+    IF N_ELEMENTS(ticklen) EQ 0 THEN ticklen = 0.2
+    IF N_ELEMENTS(minor) EQ 0 THEN minor = 2
+    IF N_ELEMENTS(range) NE 0 THEN BEGIN
+       minrange = Float(range[0])
+       maxrange = Float(range[1])
+    ENDIF
+    IF N_ELEMENTS(divisions) EQ 0 THEN divisions = 6
+    IF N_ELEMENTS(font) EQ 0 THEN font = !P.Font
+    IF N_ELEMENTS(title) EQ 0 THEN title = ''
+    xlog = Keyword_Set(xlog)
+    ylog = Keyword_Set(ylog)
+
+    ; You can't have a format set *and* use ticknames.
+    IF N_ELEMENTS(ticknames) NE 0 THEN format = ""
+
+    ; If the format is NOT null, then format the ticknames yourself.
+    IF (xlog XOR ylog) EQ 0 THEN BEGIN
+        IF format NE "" THEN BEGIN
+           step = (maxrange - minrange) / divisions
+           levels = minrange > (Indgen(divisions+1) * step + minrange) < maxrange
+           IF StrPos(StrLowCase(format), 'i') NE -1 THEN levels = Round(levels)
+           ticknames = String(levels, Format=format)
+           format = "" ; No formats allowed in PLOT call now that we have ticknames.
+        ENDIF
+    ENDIF
+
+    IF KEYWORD_SET(vertical) THEN BEGIN
+       bar = REPLICATE(1B,20) # BINDGEN(ncolors)
+       IF Keyword_Set(invertcolors) THEN bar = Reverse(bar, 2)
+       IF N_ELEMENTS(position) EQ 0 THEN BEGIN
+          position = [0.88, 0.1, 0.95, 0.9]
+       ENDIF ELSE BEGIN
+          IF position[2]-position[0] GT position[3]-position[1] THEN BEGIN
+             position = [position[1], position[0], position[3], position[2]]
+          ENDIF
+          IF position[0] GE position[2] THEN Message, "Position coordinates can't be reconciled."
+          IF position[1] GE position[3] THEN Message, "Position coordinates can't be reconciled."
+       ENDELSE
+    ENDIF ELSE BEGIN
+       bar = BINDGEN(ncolors) # REPLICATE(1B, 20)
+       IF Keyword_Set(invertcolors) THEN bar = Reverse(bar, 1)
+       IF N_ELEMENTS(position) EQ 0 THEN BEGIN
+          position = [0.1, 0.88, 0.9, 0.95]
+       ENDIF ELSE BEGIN
+          IF position[3]-position[1] GT position[2]-position[0] THEN BEGIN
+             position = [position[1], position[0], position[3], position[2]]
+          ENDIF
+          IF position[0] GE position[2] THEN Message, "Position coordinates can't be reconciled."
+          IF position[1] GE position[3] THEN Message, "Position coordinates can't be reconciled."
+       ENDELSE
+    ENDELSE
+
+    ; Scale the color bar.
+     bar = BYTSCL(bar, TOP=(ncolors-1) < (255-bottom)) + bottom
+
+     IF Keyword_Set(reverse) THEN BEGIN
+       IF Keyword_Set(vertical) THEN bar = Reverse(bar,2) ELSE bar = Reverse(bar,1)
+     ENDIF
+
+    ; Get starting locations in NORMAL coordinates.
+    xstart = position[0]
+    ystart = position[1]
+
+    ; Get the size of the bar in NORMAL coordinates.
+    xsize = (position[2] - position[0])
+    ysize = (position[3] - position[1])
+
+    ; Display the color bar in the window. Sizing is
+    ; different for PostScript and regular display.
+    IF scalablePixels THEN BEGIN
+
+       TV, bar, xstart, ystart, XSIZE=xsize, YSIZE=ysize, /Normal
+
+    ENDIF ELSE BEGIN
+
+       bar = CONGRID(bar, CEIL(xsize*!D.X_VSize), CEIL(ysize*!D.Y_VSize))
+
+       ; Decomposed color off if device supports it.
+       CASE  StrUpCase(!D.NAME) OF
+            'X': BEGIN
+                IF thisRelease GE 5.2 THEN Device, Get_Decomposed=thisDecomposed
+                Device, Decomposed=0
+                ENDCASE
+            'WIN': BEGIN
+                IF thisRelease GE 5.2 THEN Device, Get_Decomposed=thisDecomposed
+                Device, Decomposed=0
+                ENDCASE
+            'MAC': BEGIN
+                IF thisRelease GE 5.2 THEN Device, Get_Decomposed=thisDecomposed
+                Device, Decomposed=0
+                ENDCASE
+            ELSE:
+       ENDCASE
+
+       TV, bar, xstart, ystart, /Normal
+
+       ; Restore Decomposed state if necessary.
+       CASE StrUpCase(!D.NAME) OF
+          'X': BEGIN
+             IF thisRelease GE 5.2 THEN Device, Decomposed=thisDecomposed
+             ENDCASE
+          'WIN': BEGIN
+             IF thisRelease GE 5.2 THEN Device, Decomposed=thisDecomposed
+             ENDCASE
+          'MAC': BEGIN
+             IF thisRelease GE 5.2 THEN Device, Decomposed=thisDecomposed
+             ENDCASE
+          ELSE:
+       ENDCASE
+
+    ENDELSE
+
+    ; Annotate the color bar.
+    IF N_Elements(annotateColor) NE 0 THEN $
+      color = FSC_Color(annotateColor, color, NODISPLAY=Keyword_Set(nodisplay))
+
+;SPIGA
+;SPIGA
+loadct, 0, /silent
+color=0
+
+
+    IF KEYWORD_SET(vertical) THEN BEGIN
+
+       IF KEYWORD_SET(right) THEN BEGIN
+
+          PLOT, [minrange,maxrange], [minrange,maxrange], /NODATA, XTICKS=1, $
+             YTICKS=divisions, XSTYLE=1, YSTYLE=9, $
+             POSITION=position, COLOR=color, CHARSIZE=charsize, /NOERASE, $
+             XTICKFORMAT='(A1)', YTICKFORMAT='(A1)', YMINOR=minor, _EXTRA=extra, $
+             YTICKNAME=ticknames, FONT=font, YLOG=ylog
+
+          AXIS, YAXIS=1, YRANGE=[minrange, maxrange], YTICKFORMAT=format, YTICKS=divisions, $
+             YTICKLEN=ticklen, YSTYLE=1, COLOR=color, CHARSIZE=charsize, $
+             FONT=font, YTITLE=title, _EXTRA=extra, YMINOR=minor, YTICKNAME=ticknames, YLOG=ylog
+
+       ENDIF ELSE BEGIN
+
+          PLOT, [minrange,maxrange], [minrange,maxrange], /NODATA, XTICKS=1,  $
+             YTICKS=divisions, YSTYLE=1, XSTYLE=1, TITLE=title, $
+             POSITION=position, COLOR=color, CHARSIZE=charsize, /NOERASE, $
+             XTICKFORMAT='(A1)', YTICKFORMAT=format, YMinor=minor, _EXTRA=extra, $
+             YTICKNAME=ticknames, YLOG=ylog, YTICKLEN=ticklen
+
+       ENDELSE
+
+    ENDIF ELSE BEGIN
+
+       IF KEYWORD_SET(top) THEN BEGIN
+
+          PLOT, [minrange,maxrange], [minrange,maxrange], /NODATA, XTICKS=divisions, $
+             YTICKS=1, XSTYLE=9, YSTYLE=1, $
+             POSITION=position, COLOR=color, CHARSIZE=charsize, /NOERASE, $
+             YTICKFORMAT='(A1)', XTICKFORMAT='(A1)', XTICKLEN=ticklen, $
+             XRANGE=[minrange, maxrange], FONT=font, XMINOR=minor,_EXTRA=extra, $
+             XTICKNAME=ticknames, XLOG=xlog
+
+          AXIS, XTICKS=divisions, XSTYLE=1, COLOR=color, CHARSIZE=charsize, $
+             XTICKFORMAT=format, XTICKLEN=ticklen, XRANGE=[minrange, maxrange], XAXIS=1, $
+             FONT=font, XTITLE=title, _EXTRA=extra, XCHARSIZE=charsize, XMINOR=minor, $
+             XTICKNAME=ticknames, XLOG=xlog
+
+       ENDIF ELSE BEGIN
+
+          PLOT, [minrange,maxrange], [minrange,maxrange], /NODATA, XTICKS=divisions, $
+             YTICKS=1, XSTYLE=1, YSTYLE=1, TITLE=title, $
+             POSITION=position, COLOR=color, CHARSIZE=charsize, /NOERASE, $
+             YTICKFORMAT='(A1)', XTICKFORMAT=format, XTICKLEN=ticklen, $
+             XRANGE=[minrange, maxrange], FONT=font, XMinor=minor, _EXTRA=extra, $
+             XTICKNAME=ticknames, XLOG=xlog
+
+        ENDELSE
+
+    ENDELSE
+
+    ; Restore the previous plot and map system variables.
+    !P = bang_p
+    !X = bang_x
+    !Y = bang_y
+    !Z = bang_z
+    !Map = bang_map
+
+END
Index: trunk/UTIL/IDLplot/MINIMAL/dbltostr.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/dbltostr.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/dbltostr.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/dbltostr.pro
Index: trunk/UTIL/IDLplot/MINIMAL/error_message.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/error_message.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/error_message.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/error_message.pro
Index: trunk/UTIL/IDLplot/MINIMAL/example.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/example.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/example.pro	(revision 1185)
@@ -0,0 +1,26 @@
+
+pro example
+
+name='example'
+PS_Start, filename=name+'.ps'
+!P.Charsize = 1.2
+
+restore, filename='example.idl'
+
+map_latlon, $
+            what_I_plot, $   			  ; 2D field
+            x, $                                  ; 1D latitude
+            y, $                                  ; 1D longitude
+            minfield=0., $                	  ; minimum value of plotted field (=0: calculate)
+            maxfield=0., $               	  ; maximum value of plotted field (=0: calculate)
+            overcontour=overcontour, $            ; another 2D field to overplot with contour lines (=0: no)
+            overvector_x=overvector_x, $          ; wind vector - x component (=0: no)
+            overvector_y=overvector_y, $          ; wind vector - y component (=0: no)
+            ct=pal, $                             ; color table (33-rainbow is default)
+            colors=colors, $                      ; number of colors/levels (32 is default)
+            title=title, $                        ; title of the plot ('' is default)
+            format=format                         ; format of colorbar annotations ('(F6.2)' is default)
+
+PS_End, /PNG
+
+end
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/dbltostr.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/dbltostr.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/dbltostr.pro	(revision 1185)
@@ -0,0 +1,141 @@
+;+
+; NAME:
+;       DBLTOSTR
+;
+; PURPOSE:
+;
+;       This is a program for converting a double precision numerical value
+;       to a string. It was originally offered by BioPhys on the IDL newsgroup.
+;
+; AUTHOR:
+;
+;       FANNING SOFTWARE CONSULTING
+;       David Fanning,  Ph.D.
+;       1645 Sheely Drive
+;       Fort Collins,  CO 80526 USA
+;       Phone: 970-221-0438
+;       E-mail: davidf@dfanning.com
+;       Coyote's Guide to IDL Programming: http://www.dfanning.com
+;
+; CATEGORY:
+;
+;       Utility
+;
+; CALLING SEQUENCE:
+;
+;       stringValue  =  DblToStr(value)
+;
+; INPUTS:
+;
+;       value - A double-precision or floating point value to be converted to a string.
+;
+; OUTPUTS:
+;
+;       stringValue - The converted string value.
+;
+; KEYWORDS:
+;
+;       None.
+;
+; RESTRICTIONS:
+;
+;       Assumes 14 significant digits of precision.
+;
+; MODIFICATION HISTORY:
+;
+;       Written by BioPhys and offered to the IDL newsgroup,  7 November 2005.
+;       Slightly modified and renamed by David Fanning,  30 November,  2005.
+;-
+;
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright © 2005 Fanning Software Consulting.
+;
+; This software is provided "as-is",  without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose,  including commercial applications,  and to alter it and
+; redistribute it freely,  subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product,  an acknowledgment in the product documentation
+;    would be appreciated,  but is not required.
+;
+; 2. Altered source versions must be plainly marked as such,  and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software,  visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+
+
+FUNCTION DBLTOSTR,  value
+
+   ; Error handling.
+   On_Error,  2
+   IF N_Elements(value) EQ 0 THEN Message,  'Double precision or floaing value must be passed to the function.'
+
+   ; Get the data type.
+   theType = Size(value, /Type)
+   IF theType NE 4 AND theType NE 5 THEN BEGIN
+       value = Double(value)
+       theType = 5
+   ENDIF
+
+   ; Data extension.
+   typeExt = theType EQ 4?'E':'D'
+
+   ; Create a string, using the full-widtet G format.
+   rawstr = StrTrim(String(value, Format = '(g)'), 2)
+
+   ; Extract the sign from the string and remove it for the moment.
+   sign = StrMid(rawstr, 0, 1) EQ '-'?'-':''
+   rawstr = sign EQ ''?rawstr:StrMid(rawstr, 1)
+
+   ; Is there an exponent in the string? If so, remove that for the moment.
+   epos = StrPos(rawstr, 'e')
+   indx = epos gt -1?StrMid(rawstr, epos+1):''
+   rawstr = indx EQ ''?rawstr:StrMid(rawstr, 0, epos)
+
+   ; Find the position of the decimal point.
+   dpos = StrPos(rawstr, '.')
+
+   ; Rounding process (assumes 14 significant digits).
+   outstr = StrArr(15)
+   FOR i = 0, 14 DO outstr[i] = StrMid(rawstr, i, 1)
+   aux = Fix(StrMid(rawstr, 16, 1)) GE 5?1:0
+   FOR i = 14,  0,  -1 DO BEGIN
+      IF i NE dpos then BEGIN
+         sumstr = StrTrim(String(aux+fix(outstr[i])), 2)
+         sumlen = StrLen(sumstr)
+         outstr[i] = StrMid(sumstr, sumlen-1, 1)
+         aux = sumlen EQ 1?0:1
+      ENDIF
+   ENDFOR
+
+   ; Throw away '0's at the end.
+   ii = 14
+   WHILE outstr[ii] EQ '0' DO BEGIN
+      ii = ii-1
+   ENDWHILE
+
+   ; Reconstruct the string.
+   saux = aux NE 0?'1':''
+   outstr = sign + saux + StrJoin(outstr[0:ii]) + typeExt + indx
+
+   ; Return it.
+   RETURN, outstr
+
+END
+
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/error_message.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/error_message.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/error_message.pro	(revision 1185)
@@ -0,0 +1,269 @@
+;+
+; NAME:
+;    ERROR_MESSAGE
+;
+; PURPOSE:
+;
+;    The purpose of this function  is to have a device-independent
+;    error messaging function. The error message is reported
+;    to the user by using DIALOG_MESSAGE if widgets are
+;    supported and MESSAGE otherwise.
+;
+;    In general, the ERROR_MESSAGE function is not called directly.
+;    Rather, it is used in a CATCH error handler. Errors are thrown
+;    to ERROR_MESSAGE with the MESSAGE command. A typical CATCH error
+;    handler is shown below.
+;
+;       Catch, theError
+;       IF theError NE 0 THEN BEGIN
+;          Catch, /Cancel
+;          ok = Error_Message()
+;          RETURN
+;       ENDIF
+;
+;    Error messages would get into the ERROR_MESSAGE function by
+;    throwing an error with the MESSAGE command, like this:
+;
+;       IF test NE 1 THEN Message, 'The test failed.'
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;    Utility.
+;
+; CALLING SEQUENCE:
+;
+;    ok = Error_Message(the_Error_Message)
+;
+; INPUTS:
+;
+;    the_Error_Message: This is a string argument containing the error
+;       message you want reported. If undefined, this variable is set
+;       to the string in the !Error_State.Msg system variable.
+;
+; KEYWORDS:
+;
+;    ERROR: Set this keyword to cause Dialog_Message to use the ERROR
+;       reporting dialog. Note that a bug in IDL causes the ERROR dialog
+;       to be used whether this keyword is set to 0 or 1!
+;
+;    INFORMATIONAL: Set this keyword to cause Dialog_Message to use the
+;       INFORMATION dialog instead of the WARNING dialog. Note that a bug
+;       in IDL causes the ERROR dialog to be used if this keyword is set to 0!
+;
+;    TITLE: Set this keyword to the title of the DIALOG_MESSAGE window. By
+;       default the keyword is set to 'System Error' unless !ERROR_STATE.NAME
+;       equals "IDL_M_USER_ERR", in which case it is set to "Trapped Error'.
+;
+;    TRACEBACK: Setting this keyword results in an error traceback
+;       being printed to standard output with the PRINT command. Set to
+;       1 (ON) by default. Use TRACEBACK=0 to turn this functionality off.
+;
+; OUTPUTS:
+;
+;    Currently the only output from the function is the string "OK".
+;
+; RESTRICTIONS:
+;
+;    The WARNING Dialog_Message dialog is used by default.
+;
+; EXAMPLE:
+;
+;    To handle an undefined variable error:
+;
+;    IF N_Elements(variable) EQ 0 THEN $
+;       ok = Error_Message('Variable is undefined')
+;
+; MODIFICATION HISTORY:
+;
+;    Written by: David W. Fanning, 27 April 1999.
+;    Added the calling routine's name in the message and NoName keyword. 31 Jan 2000. DWF.
+;    Added _Extra keyword. 10 February 2000. DWF.
+;    Forgot to add _Extra everywhere. Fixed for MAIN errors. 8 AUG 2000. DWF.
+;    Adding call routine's name to Traceback Report. 8 AUG 2000. DWF.
+;    Added ERROR, INFORMATIONAL, and TITLE keywords. 19 SEP 2002. DWF.
+;    Removed the requirement that you use the NONAME keyword with the MESSAGE
+;      command when generating user-trapped errors. 19 SEP 2002. DWF.
+;    Added distinctions between trapped errors (errors generated with the
+;      MESSAGE command) and IDL system errors. Note that if you call ERROR_MESSAGE
+;      directly, then the state of the !ERROR_STATE.NAME variable is set
+;      to the *last* error generated. It is better to access ERROR_MESSAGE
+;      indirectly in a Catch error handler from the MESSAGE command. 19 SEP 2002. DWF.
+;    Change on 19 SEP 2002 to eliminate NONAME requirement did not apply to object methods.
+;      Fixed program to also handle messages from object methods. 30 JULY 2003. DWF.
+;    Removed obsolete STR_SEP and replaced with STRSPLIT. 27 Oct 2004. DWF.
+;    Made a traceback the default case without setting TRACEBACK keyword. 19 Nov 2004. DWF.
+;    Added check for window connection specifically for CRON jobs. 6 May 2008. DWF.
+;-
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright 1999-2008 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+
+
+FUNCTION ERROR_MESSAGE, theMessage, Error=error, Informational=information, $
+   Traceback=traceback, NoName=noname, Title=title, _Extra=extra
+
+   On_Error, 2
+   
+   ; Check for presence and type of message.
+   
+   IF N_Elements(theMessage) EQ 0 THEN theMessage = !Error_State.Msg
+   s = Size(theMessage)
+   messageType = s[s[0]+1]
+   IF messageType NE 7 THEN BEGIN
+      Message, "The message parameter must be a string.", _Extra=extra
+   ENDIF
+   IF N_Elements(traceback) EQ 0 THEN traceback = 1
+   
+   ; Get the call stack and the calling routine's name.
+   Help, Calls=callStack
+   callingRoutine = (StrSplit(StrCompress(callStack[1])," ", /Extract))[0]
+   
+   
+   
+   
+   ; Are widgets supported?
+   widgetsSupported = ((!D.Flags AND 65536L) NE 0)
+   
+   ; It is not enough to know if widgets are supported. In CRON jobs, widgets are
+   ; supported, but there is no X connection and pop-up dialogs are not allowed.
+   ; Here is a quick test to see if we can connect to a windowing system. If not,
+   ; then we are going to assume widgets are not supported.
+   Catch, theError
+   IF theError NE 0 THEN BEGIN
+      Catch, /CANCEL
+      widgetsSupported = 0
+      GOTO, testWidgetSupport
+   ENDIF
+   theWindow = !D.Window
+   Window, /FREE, XSIZE=5, YSIZE=5, /PIXMAP
+   Catch, /CANCEL
+   
+   testWidgetSupport: ; Come here if you choke on creating a window.
+   IF !D.Window NE theWindow THEN BEGIN
+      WDelete, !D.Window
+      IF theWindow GE 0 THEN WSet, theWindow
+   ENDIF
+   
+   IF widgetsSupported THEN BEGIN
+   
+      ; If this is an error produced with the MESSAGE command, it is a trapped
+      ; error and will have the name "IDL_M_USER_ERR".
+      IF !ERROR_STATE.NAME EQ "IDL_M_USER_ERR" THEN BEGIN
+   
+         IF N_Elements(title) EQ 0 THEN title = 'Trapped Error'
+   
+            ; If the message has the name of the calling routine in it,
+            ; it should be stripped out. Can you find a colon in the string?
+   
+         ; Is the calling routine an object method? If so, special processing
+         ; is required. Object methods will have two colons together.
+         doublecolon = StrPos(theMessage, "::")
+         IF doublecolon NE -1 THEN BEGIN
+   
+            prefix = StrMid(theMessage, 0, doublecolon+2)
+            submessage = StrMid(theMessage, doublecolon+2)
+            colon = StrPos(submessage, ":")
+            IF colon NE -1 THEN BEGIN
+   
+               ; Extract the text up to the colon. Is this the same as
+               ; the callingRoutine? If so, strip it.
+               IF StrMid(theMessage, 0, colon+StrLen(prefix)) EQ callingRoutine THEN $
+                  theMessage = StrMid(theMessage, colon+1+StrLen(prefix))
+            ENDIF
+         ENDIF ELSE BEGIN
+   
+            colon = StrPos(theMessage, ":")
+            IF colon NE -1 THEN BEGIN
+   
+               ; Extract the text up to the colon. Is this the same as
+               ; the callingRoutine? If so, strip it.
+               IF StrMid(theMessage, 0, colon) EQ callingRoutine THEN $
+                  theMessage = StrMid(theMessage, colon+1)
+            ENDIF
+   
+         ENDELSE
+   
+   
+         ; Add the calling routine's name, unless NONAME is set.
+         IF Keyword_Set(noname) THEN BEGIN
+            answer = Dialog_Message(theMessage, Title=title, _Extra=extra, $
+               Error=error, Information=information)
+         ENDIF ELSE BEGIN
+            answer = Dialog_Message(StrUpCase(callingRoutine) + ": " + $
+               theMessage, Title=title, _Extra=extra, $
+               Error=error, Information=information)
+         ENDELSE
+   
+      ENDIF ELSE BEGIN
+   
+         ; Otherwise, this is an IDL system error.
+         IF N_Elements(title) EQ 0 THEN title = 'System Error'
+   
+         IF StrUpCase(callingRoutine) EQ "$MAIN$" THEN $
+            answer = Dialog_Message(theMessage, _Extra=extra, Title=title, $
+               Error=error, Information=information) ELSE $
+         IF Keyword_Set(noname) THEN BEGIN
+            answer = Dialog_Message(theMessage, _Extra=extra, Title=title, $
+               Error=error, Information=information)
+         ENDIF ELSE BEGIN
+            answer = Dialog_Message(StrUpCase(callingRoutine) + "--> " + $
+               theMessage, _Extra=extra, Title=title, $
+               Error=error, Information=information)
+         ENDELSE
+      ENDELSE
+   ENDIF ELSE BEGIN
+         Message, theMessage, /Continue, /NoPrint, /NoName, /NoPrefix, _Extra=extra
+         Print, '%' + callingRoutine + ': ' + theMessage
+         answer = 'OK'
+   ENDELSE
+   
+   ; Provide traceback information if requested and this is NOT an informational message.
+   IF Keyword_Set(traceback) AND ~Keyword_Set(informational)THEN BEGIN
+      Help, /Last_Message, Output=traceback
+      Print,''
+      Print, 'Traceback Report from ' + StrUpCase(callingRoutine) + ':'
+      Print, ''
+      FOR j=0,N_Elements(traceback)-1 DO Print, "     " + traceback[j]
+   ENDIF
+   
+   RETURN, answer
+END ; ----------------------------------------------------------------------------
+
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_base_filename.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_base_filename.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_base_filename.pro	(revision 1185)
@@ -0,0 +1,201 @@
+;+
+; NAME:
+;    FSC_BASE_FILENAME
+;
+; PURPOSE:
+;
+;    The purpose of this is to extract from a long file path, the
+;    base file name. That is, the name of the actual file without
+;    the preceeding directory information or the final file extension.
+;    The directory information and file extension can be obtained via
+;    keywords. The file is named so as not to interfere with FILE_BASENAME,
+;    which was introduced in IDL 6.0 and performs a similar function.
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;    Utility.
+;
+; CALLING SEQUENCE:
+;
+;    baseFilename = FSC_Base_Filename(thePath)
+;
+; INPUTS:
+;
+;    thePath:      This is the file path you wish to extract a base file name from.
+;                  It is a string variable of the sort returned from Dialog_Pickfile.
+;
+; KEYWORDS:
+;
+;    DIRECTORY:      The directory information obtained from the input file path.
+;                    The directory always ends in a directory separator character.
+;
+;    EXTENSION:      The file extension associated with the input file path.
+;
+;    PATH_SEPARATOR: The string to use as a path separator. If undefined, the output
+;                    of PATH_SEP() will be used.
+;
+; RETURN_VALUE:
+;
+;    baseFilename:   The base filename, stripped of directory and file extension information.
+;
+; RESTRICTIONS:
+;
+;    This is a quick and dirty program. It has been tested on Windows machines and *lightly*
+;    tested on UNIX machines. Please contact me at the e-mail address above if you discover
+;    problems.
+;
+; EXAMPLE:
+;
+;    IDL> thePath = "C:\rsi\idl7.8\lib\jester.pro"
+;    IDL> Print, FSC_Base_Filename(thePath, Directory=theDirectory, Extension=theExtension)
+;         jester
+;    IDL> Print, theDirectory
+;         C:\rsi\idl7.8\lib\
+;    IDL> Print, theExtension
+;         pro
+;
+;
+; MODIFICATION HISTORY:
+;
+;    Written by: David W. Fanning, 31 July 2003.
+;    Modified by KaRo, 13 Feb. 2005 to allow dots in the filename.
+;    Added PATH_SEPARATOR keyword. 25 July 2005. DWF.
+;    Added ability to recongnize directory by path separator in last character. 19 Sept 2005. DWF.
+;-
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright © 2003-2005 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+
+
+FUNCTION FSC_Base_Filename, filename, $
+   Directory=directory, $
+   Extension=extension, $
+   Path_Separator=pathsep
+
+   On_Error, 2
+
+   ; Default values.
+   directory = ""
+   extension = ""
+   file = ""
+
+   ; If there is no filename, return NULL.
+   IF (N_Elements(filename) EQ 0) OR (filename EQ "") THEN RETURN, file
+
+   ; Is a path separator specified?
+   IF N_Elements(pathsep) EQ 0 THEN pathsep = Path_Sep()
+
+   ; If the last element of filename is a path separator, then separation is easy.
+   IF StrMid(filename, StrLen(filename)-1, 1) EQ pathsep THEN BEGIN
+      directory = filename
+      RETURN, file
+   ENDIF
+
+   ; Split the file by the path separator and extract into parts.
+   parts = StrSplit(filename, pathsep, /Extract)
+   IF StrMid(filename, 0, 1) EQ pathsep AND N_Elements(parts) GT 1 THEN parts[0] = pathsep + parts[0]
+   numParts = N_Elements(parts)
+
+   ; Put the parts back together after identifying them.
+   CASE numParts OF
+      1: BEGIN
+            subparts = StrSplit(filename, ".", /Extract)
+            numsubParts = N_Elements(subparts)
+            CASE numsubParts OF
+               1: file = subparts[0]
+               2: BEGIN
+                     file = subparts[0]
+                     extension = subparts[1]
+                  END
+               ELSE: BEGIN
+                     file = StrJoin(subparts[0:numsubParts-2],'.')
+                     extension = subparts[numsubParts-1]
+                  END
+            ENDCASE
+         END
+
+      2: BEGIN
+            file = parts[1]
+            directory = parts[0] + pathsep
+            subparts = StrSplit(file, ".", /Extract)
+            numsubParts = N_Elements(subparts)
+            CASE numsubParts OF
+               1: file = subparts[0]
+               2: BEGIN
+                     file = subparts[0]
+                     extension = subparts[1]
+                  END
+               ELSE: BEGIN
+                     file = StrJoin(subparts[0:numsubParts-2],'.')
+                     extension = subparts[numsubParts-1]
+                  END
+            ENDCASE
+         END
+
+      ELSE: BEGIN
+
+            file = parts[numParts-1]
+            subparts = StrSplit(file, ".", /Extract)
+            numsubParts = N_Elements(subparts)
+            CASE numsubParts OF
+               1: file = subparts[0]
+               2: BEGIN
+                     file = subparts[0]
+                     extension = subparts[1]
+                  END
+               ELSE: BEGIN
+                     file = StrJoin(subparts[0:numsubParts-2],'.')
+                     extension = subparts[numsubParts-1]
+                  END
+            ENDCASE
+            directory = parts[0]
+            FOR j=1,numParts-2 DO BEGIN
+               directory = directory + pathsep + parts[j]
+            ENDFOR
+            directory = directory + pathsep
+         END
+
+   ENDCASE
+
+   RETURN, file
+
+END
+
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_droplist.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_droplist.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_droplist.pro	(revision 1185)
@@ -0,0 +1,602 @@
+;+
+; NAME:
+;   FSC_DROPLIST
+;
+; PURPOSE:
+;
+;   The purpose of this compound widget is to provide an alternative
+;   to the DROPLIST widget offered in the IDL distribution. What has
+;   always annoyed me about a droplist is that you can't get the current
+;   "value" of a droplist easily. This compound widget makes this and
+;   other tasks much easier.
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;   General programming.
+;
+; CALLING SEQUENCE:
+;
+;   droplistObj = FSC_Droplist(parent, Title='Animals: ", Value=['Dog'. 'Cat', 'Coyote'], Index=2)
+;
+;   The return value of the FSC_Droplist (droplistObj in this example) is
+;   an object reference. Interaction with the droplist will occur through
+;   object methods.
+;
+; INPUT PARAMETERS:
+;
+;   parent -- The parent widget ID of the compound widget. Required.
+;
+; INPUT KEYWORDS:
+;
+; Any keyword that is appropriate for the Widget_Droplist function can be used.
+; In addition, these keywords are explicitly defined.
+;
+;   EVENT_FUNC -- Set this keyword to the name of an Event Handler Function.
+;   EVENT_PRO -- Set this keyword to the name of an Event Handler Procedure.
+;   FORMAT -- A format specifier for the "format" of the values in the droplist.
+;   INDEX -- The index number of the current selection.
+;   SPACES -- A two-element array that indicates the number of blank spaces to be added
+;             to the the beginning and end of the formatted values. If a single number
+;             is provided, this number of blank spaces is added to both the beginning
+;             and the end of the value.
+;   TITLE -- The title of the droplist widget.
+;   UNAME -- The user name of the droplist widget. (Only available in IDL 5.2 and higher.)
+;   UVALUE -- The normal "user value" of the droplist.
+;   VALUE -- An array of the droplist "selections". May be any data type.
+;
+; COMMON BLOCKS:
+;
+;   None.
+;
+; DEPENDENCIES:
+;
+;   Requires ERROR_MESSAGE from the Coyote Library..
+;
+; EVENT STRUCTURE:
+;
+;   An event is returned each time the droplist value is changed. The event structure
+;   is defined like this:
+;
+;   event = { FSC_DROPLIST_EVENT, $ ; The name of the event structure.
+;             ID: 0L, $             ; The ID of the compound widget's top-level base.
+;             TOP: 0L, $            ; The widget ID of the top-level base of the hierarchy.
+;             HANDLER: 0L, $        ; The event handler ID. Filled out by IDL.
+;             INDEX: 0L, $          ; The index number of the current selection.
+;             SELECTION:Ptr_New() $ ; A pointer to the current selection "value".
+;             SELF:Obj_New() }      ; The object reference of the compound widget.
+;
+; PUBLIC OBJECT METHODS:
+;
+;   GetID -- A function with no arguments that returns the widget identifier
+;      of the droplist widget.
+;
+;      droplistID = droplistObj->GetID()
+;
+;   GetIndex -- A function with no arguments that returns the index
+;      number of the current droplist selection.
+;
+;      currentIndex = droplistObj->GetIndex()
+;
+;   GetSelection -- A function with no arguments that returns the current
+;      droplist selection.
+;
+;      currentSelection = droplistObj->GetSelection()
+;
+;   GetUValue -- A function with no arguments that returns the "user value"
+;      of the compound widget i.e., the value set with the UVALUE keyword).
+;
+;      myUValue = droplistObj->GetUValue()
+;
+;   GetValues -- A function with no arguments that returns the "values" or
+;      "selections" for the droplist.
+;
+;      possibleSelections = droplistObj->GetValues()
+;
+;   Resize -- A procedure that sets the X screen size of the droplist. It is
+;      defined like this:
+;
+;      PRO Resize, newSize, ParentSize=parentSize
+;
+;      The "newSize" keyword is the new X screen size. If this argument is
+;      missing, the screen X size of the compound widget's parent is used.
+;      The parentSize keyword is an output keyword that returns the X screen
+;      size of the compound widget's parent.
+;
+;      droplistObj->Resize, 400
+;
+;      Note that not all devices (e.g., X Windows devices) support droplist resizing.
+;
+;   SetIndex -- A procedure that sets the current droplist selection based on
+;      the given index. This is equivalent to Widget_Control, droplistID, Set_Droplist_Select=newIndex
+;
+;      droplistObj->SetIndex, newIndex
+;
+;   SetSelection -- Whereas a regular droplist widget can only be set by index
+;      number, this compound widget can also be set by a "selection". The new selection
+;      can be any data type and corresponds to one of the "values" of the droplist.
+;
+;      droplistObj->SetSelection, newSelection
+;
+;   SetValues -- Sets the possible selections of the droplist widget. The CurrentIndex keyword
+;      will allow the current index of the selection to be changed to:
+;
+;      newChoices = ['dog', 'cat', 'coyote']
+;      droplistObj->SetValues, newChoices, CurrentIndex=2
+;
+;
+; EXAMPLE:
+;
+;   An example program is provided at the end of the FSC_DROPLIST code. To run it,
+;   type these commands:
+;
+;      IDL> .Compile FSC_DROPLIST
+;      IDL> Example
+;
+; MODIFICATION HISTORY:
+;
+;   Written by: David W Fanning, 17 Jan 2000. DWF.
+;   Added FORMAT and SPACES keywords 28 April 2000. DWF.
+;   Fixed a small problem with event processing when the EVENT_FUNC keyword
+;      was used. 29 Dec 2000. DWF.
+;   Attached the UNAME value to the TLB of the compound widget instead
+;      of to the droplist widget itself. 11 Jan 2001. DWF.
+;   Fixed a problem when the droplist was part of a modal widget and used the
+;      EVENT_PRO keyword. 27 Oct 2003. DWF.
+;   Added a SetValue method for setting all the values in the droplist at once. 12 Nov 2004. DWF.
+;   Fixed type on line 346/ 6 Feb 2008. DWF.
+;-
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright 2000-2008 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+;
+
+
+
+PRO FSC_Droplist_Kill_Notify, droplistID
+
+; This procedure is called automatically when the droplist is destroy. The
+; purpose is to destroy the self object so there are no memory leaks.
+
+Widget_Control,droplistID, Get_UValue=self
+Obj_Destroy, self
+END ;--------------------------------------------------------------------------
+
+
+FUNCTION FSC_Droplist::EventHandler, event
+
+; This is the event handler method of the object. The purpose is to set the
+; object's current selection and index number. If an event handler has
+; been specified, a FSC_DROPLIST event is sent to the proper event handler.
+
+   ; Set the current selection and index number.
+
+*self.selection = (*self.value)[event.index]
+self.index = event.index
+
+   ; If we need to send an event package the event up. Include both
+   ; the index number (what normal droplist events produce), the current
+   ; selection, and the self object reference.
+
+thisEvent = {FSC_Droplist_EVENT, ID:self.tlb, TOP:event.top, HANDLER:event.handler, $
+ INDEX:self.index, SELECTION:self.selection, SELF:self}
+
+   ; Send the event if requested. If it is requested, no events returned.
+
+IF self.event_pro NE "" THEN BEGIN
+   Call_Procedure, self.event_pro, thisEvent
+   thisEvent = 0
+   IF Obj_Valid(self) EQ 0 THEN RETURN, thisEvent ; Modal widget destroyed.
+ENDIF
+
+IF self.event_func NE "" THEN BEGIN
+   ok = Call_Function(self.event_func, thisEvent)
+   thisEvent = 0
+ENDIF
+
+RETURN, thisEvent
+END ;--------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Droplist_Events, event
+
+; This is the droplist event handler. The purpose of this procedure is to
+; get the self object reference and call the object's own event method.
+; The event handler method will return 0 if an event handler procedure or
+; function has been called. Otherwise, it will return the event.
+
+Widget_Control, event.id, Get_UValue=self
+theEvent = self->EventHandler(event)
+RETURN, theEvent
+END ;--------------------------------------------------------------------------
+
+
+
+PRO FSC_Droplist::Sensitive, value
+
+; This method makes the droplist sensitive (value=1) or insensitive (value=0).
+
+Widget_Control, self.droplistID, Sensitive=value
+END ;--------------------------------------------------------------------------
+
+
+
+PRO FSC_Droplist::Resize, newSize,  ParentSize=parentSize
+
+; This method resizes the droplist. If the variable "newSize" is not provided,
+; the new size is set by the parent widget's X screen size. This makes it possible
+; to have the droplist sized to fit it's parent base widget.
+
+   ; Get the parent widget's geometry and X screen size.
+
+parentGeometry = Widget_Info(self.parent, /Geometry)
+parentSize = parentGeometry.scr_xsize
+
+   ; Has a size been provided? In not, use the parent's X screen size.
+
+IF N_Elements(newSize) EQ 0 THEN BEGIN
+   newSize = parentGeometry.scr_xsize
+ENDIF
+
+   ; Resize the droplist widget.
+
+Widget_Control, self.droplistID, Scr_XSize=newSize
+END ;--------------------------------------------------------------------------
+
+
+
+PRO FSC_Droplist::SetSelection, selection
+
+; This method sets the current selection of the droplist by means of
+; the selection "value". With a normal droplist you must set the selection
+; by specifying an index number.
+
+   ; Find the selection in the value. Return it's index number.
+
+IF N_Elements(selection) EQ 0 THEN selection = (*self.value)[0]
+index = Where(StrUpCase( Strtrim(*self.value,2) ) EQ StrUpCase( StrTrim(selection,2) ), count)
+
+   ; If you can't find the selection, print an error message.
+
+IF count EQ 0 THEN BEGIN
+   uname = Widget_Info(self.droplistID,/UName)
+   ok = Error_Message('No item with name "' + uname + ':' + $
+      StrTrim(selection,2) + '" exists. Returning...')
+   RETURN
+ENDIF
+
+   ; Set the current index and selection for the object.
+
+index = 0 > index < (N_Elements(*self.value) - 1)
+self.index = index
+*self.selection = selection
+
+   ; Set the current selection for the droplist widget.
+
+Widget_Control, self.droplistID, Set_Droplist_Select=self.index
+END ;--------------------------------------------------------------------------
+
+
+
+PRO FSC_Droplist::SetIndex, index
+
+; This method sets the current selection by means of its index number.
+
+   ; Make sure the index number is there and valid.
+
+IF N_Elements(index) EQ 0 THEN index = 0
+self.index = 0 > index < (N_Elements(*self.value) - 1)
+
+   ; Set the current selection.
+
+*self.selection = (*self.value)[index]
+
+   ; Set the selection on the droplist widget.
+
+Widget_Control, self.droplistID, Set_Droplist_Select=self.index
+
+END ;--------------------------------------------------------------------------
+
+
+
+PRO FSC_Droplist::SetValues, theValues, CurrentIndex=currentIndex
+
+; This method allows all the values in the droplist to be changed simultaneously.
+
+  IF Ptr_Valid(self.value) THEN *self.value = theValues ELSE self.value = Ptr_New(theValues)
+  Widget_Control, self.droplistID, Set_Value=*self.value
+
+  IF N_Elements(currentIndex) EQ 0 THEN currentIndex = self.index ELSE self.index = currentIndex < (N_Elements(theValues)-1)
+  IF currentIndex GT (N_Elements(*self.value)-1) THEN BEGIN
+     currentIndex = 0
+     self.index = currentIndex
+  ENDIF
+  IF Ptr_Valid(self.selection) THEN *self.selection = (*self.value)[self.index] ELSE $
+    self.selection = Ptr_New((*self.value)[self.index])
+  Widget_Control, self.droplistID, Set_Droplist_Select=self.index
+END ;--------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Droplist::GetIndex
+
+; This method returns the index number of the current selection.
+
+RETURN, self.index
+END ;--------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Droplist::GetSelection
+
+; This method returns the "value" of the current selection.
+
+RETURN, *self.selection
+END ;--------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Droplist::GetValues
+
+; This method returns the current "values" or "selections" of the droplist.
+
+RETURN, *self.value
+END ;--------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Droplist::GetUValue
+
+; This method returns the "user value" of the droplist.
+
+RETURN, *self.storage
+END ;--------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Droplist::GetID
+
+; This method returns the droplist widget identifier.
+
+RETURN, self.droplistID
+END ;--------------------------------------------------------------------------
+
+
+
+PRO FSC_Droplist::CLEANUP
+
+; This is the object's cleanup method. Free's up all the pointers used in the
+; object.
+
+Ptr_Free, self.value
+Ptr_Free, self.selection
+Ptr_Free, self.storage
+END ;--------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Droplist::INIT, $
+   parent, $                    ; The widget ID of the droplist's parent widget. Required.
+   debug=debug, $               ; Turns full error handling on for INIT catch error handler.
+   Event_Func=event_func, $     ; The name of an event handler function.
+   Event_Pro=event_pro, $       ; The name of an event handler procedure.
+   _Extra=extra, $              ; A keyword that allows any droplist keyword to be used in initialization.
+   Format=format, $             ; The format of the "value" of the droplist.
+   Index=index, $               ; The index number of the current selection.
+   Spaces=spaces, $             ; Number of blank spaces to add to formatted "values".
+   Title=title, $               ; The text that goes in the TITLE of the droplist.
+   UName=uname, $               ; A user name. Left for the user of the cw_droplist program.
+   UValue=storage, $            ; A user value. Left for the user of the cw_droplist program.
+   Value=value                  ; The "value" or selections of the droplist. May be any data type.
+
+   ; Catch any errors.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = Error_Message(!Error_State.Msg, Traceback=Keyword_Set(debug))
+   RETURN, 0
+ENDIF
+
+; This is the object's initialization method.
+
+IF N_Elements(parent) EQ 0 THEN BEGIN
+   ok = Error_Message('Parent parameter must be provided. Returning...')
+   RETURN, 0
+ENDIF
+
+   ; Check for presence of keywords.
+
+IF N_Elements(title) EQ 0 THEN title = 'Selection: '
+IF N_Elements(value) EQ 0 THEN value = ['Dog', 'Cat', 'Coyote']
+IF N_Elements(storage) EQ 0 THEN storage = ""
+IF N_Elements(index) EQ 0 THEN index = 0
+IF N_Elements(event_pro) EQ 0 THEN event_pro = ""
+IF N_Elements(event_func) EQ 0 THEN event_func = ""
+IF N_Elements(uname) EQ 0 THEN uname = ""
+IF N_Elements(spaces) EQ 0 THEN BEGIN
+   forwardSpace = ""
+   trailingSpace = ""
+ENDIF ELSE BEGIN
+   IF N_Elements(spaces) EQ 2 THEN BEGIN
+      IF spaces[0] LE 0 THEN forwardSpace = "" ELSE forwardSpace = String(Replicate(32B,spaces[0]))
+      IF spaces[1] LE 0 THEN trailingSpace = "" ELSE trailingSpace = String(Replicate(32B,spaces[1]))
+   ENDIF ELSE BEGIN
+      IF spaces[0] LE 0 THEN forwardSpace = "" ELSE forwardSpace = String(Replicate(32B,spaces[0]))
+      IF spaces[0] LE 0 THEN trailingSpace = "" ELSE trailingSpace = String(Replicate(32B,spaces[0]))
+   ENDELSE
+ENDELSE
+index = 0 > index < (N_Elements(value) - 1)
+
+   ; Create the droplist widget. UName only available for IDL 5.2 and higher.
+
+IF Float(!Version.Release) GE 5.2 THEN BEGIN
+
+   IF Keyword_Set(format) THEN theValue = String(value, Format=format) ELSE theValue = StrTrim(value,2)
+   self.tlb = Widget_Base(parent, UValue=storage, UName=uname)
+   self.droplistID = Widget_Droplist(self.tlb, $
+         Title=title, $
+         Value=forwardSpace + theValue + trailingSpace, $
+         _Extra=extra, $
+         Kill_Notify='FSC_Droplist_Kill_Notify', $
+         Event_Func='FSC_Droplist_Events', $
+         UValue=self)
+
+ ENDIF ELSE BEGIN
+
+   IF Keyword_Set(format) THEN theValue = String(value, Format=format) ELSE theValue = StrTrim(value,2)
+   self.tlb = Widget_Base(parent, UValue=storage)
+   self.droplistID = Widget_Droplist(self.tlb, $
+         Title=title, $
+         Value=forwardSpace + theValue + trailingSpace, $
+         _Extra=extra, $
+         Kill_Notify='FSC_Droplist_Kill_Notify', $
+         Event_Func='FSC_Droplist_Events', $
+         UValue=self)
+
+ENDELSE
+
+   ; Set the current selection on the droplist.
+
+selection = Value[index]
+Widget_Control, self.droplistID, Set_Droplist_Select=index
+
+   ; Populate the object.
+
+self.storage = Ptr_New(storage)
+self.index = index
+self.title = title
+self.parent = parent
+self.selection = Ptr_New(selection)
+self.event_func = event_func
+self.event_pro = event_pro
+self.value = Ptr_New(value)
+
+RETURN, 1
+END ;--------------------------------------------------------------------------
+
+
+
+PRO FSC_Droplist__DEFINE
+
+   struct = { FSC_Droplist, $          ; The FSC_DROPLIST object class definition.
+              title:"", $              ; The droplist title.
+              value:Ptr_New(), $       ; The values or selections on the droplist.
+              parent:0L, $             ; The widget identifer of the parent widget.
+              tlb:0L, $                ; The top-level base of the compound widget. .
+              droplistID:0L, $         ; The droplist widget identifier.
+              selection:Ptr_New(), $   ; The current droplist selection.
+              storage:Ptr_New(), $     ; The storage locaton for the "user value".
+              event_pro:"", $          ; The name of an event handler procedure.
+              event_func:"", $         ; The name of an event handler function.
+              index:0 $                ; The index number of the current selecton.
+            }
+END ;--------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Droplist, parent, Title=title, Value=value, _Extra=extra
+
+   ; This is the compound widget function call. It's purpose is to
+   ; create the compound widget object and return it.
+
+RETURN, Obj_New('FSC_Droplist', parent, Title=title, Value=value, _Extra=extra)
+END ;--------------------------------------------------------------------------
+
+
+
+PRO Example_Events, event
+Widget_Control, event.top, Get_UValue=droplists
+thisEvent = Tag_Names(event, /Structure_Name)
+CASE thisEvent OF
+   'FSC_DROPLIST_EVENT': BEGIN
+      thisDroplist = event.self->GetUValue()
+      Print, ""
+      Print, thisDroplist + ' Selection: ', *event.selection
+      Print, thisDroplist + ' Index Number: ', event.index
+      ENDCASE
+   'WIDGET_BUTTON': BEGIN
+      Widget_Control, event.id, Get_UValue=thisValue
+      CASE thisValue OF ; Set the droplists by "selection".
+         'SET_DROPLIST1': droplists[0]->SetSelection, 'Coyote'
+         'SET_DROPLIST2': droplists[1]->SetSelection, 99.8
+         ELSE: Widget_Control, event.top, /Destroy
+      ENDCASE
+      ENDCASE
+ENDCASE
+END ;---------------------------------------------------------------------------
+
+
+PRO Example
+
+; Droplist 1 is filled with string selections.
+; Droplist 2 is filled with number selections.
+
+tlb = Widget_Base(Title='FSC_Droplist Example', Column=1)
+animals = ['Dog', 'Cat', 'Opposum', 'Coyote']
+numbers = [45.6, 18.3, 21.5, 99.8]
+
+   ; Create the droplists.
+
+droplist1 = FSC_Droplist(tlb, Value=animals, Index=3, UValue='DROPLIST 1')
+droplist2 = FSC_Droplist(tlb, Value=numbers, Index=1, UValue='DROPLIST 2', $
+   Format='(F5.2)', Spaces=[2,0], Debug=1)
+
+   ; Other widgets.
+
+button = Widget_Button(tlb, Value='Set Droplist 1 to "Coyote"', UValue='SET_DROPLIST1')
+button = Widget_Button(tlb, Value='Set Droplist 2 to 99.8', UValue='SET_DROPLIST2')
+button = Widget_Button(tlb, Value='Quit', UValue='QUIT')
+
+   ; Resize the droplists.
+
+droplist1->Resize, 200
+droplist2->Resize, 200
+
+Widget_Control, tlb, /Realize, Set_UValue=[droplist1, droplist2]
+XManager, 'Example', tlb, Event_Handler='Example_Events', /No_Block
+
+; Test of SetValues method:
+;      Wait, 2
+;      newChoices = ['dog', 'cat', 'coyote']
+;      droplist1->SetValues, newChoices, CurrentIndex=2
+
+END ;---------------------------------------------------------------------------
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_field.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_field.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_field.pro	(revision 1185)
@@ -0,0 +1,1734 @@
+;+
+; NAME:
+;   FSC_FIELD
+;
+; PURPOSE:
+;
+;   The purpose of this compound widget is to provide an alternative
+;   to the CW_FIELD widget offered in the IDL distribution. One weakness
+;   of the CW_FIELD compound widget is that the text widgets do not
+;   look editable to the users on Windows platforms. This program
+;   corrects that deficiency and adds some features that I think
+;   will be helpful. For example, you can now assign an event handler
+;   to the compound widget, ask for positive numbers only, and limit
+;   the number of digits in a number, or the number of digits to the
+;   right of a decimal point. The program is written as a widget object,
+;   which allows the user to call object methods directly, affording
+;   even more flexibility in use. This program replaces the earlier
+;   programs FSC_INPUTFIELD and COYOTE_FIELD.
+;
+;   The program consists of a label widget next to a one-line text widget.
+;   The "value" of the compound widget is shown in the text widget. If the
+;   value is a number, it will not be possible (generally) to type
+;   alphanumeric values in the text widget. String values behave like
+;   strings in any one-line text widget.
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;   General programming.
+;
+; TYPICAL CALLING SEQUENCE:
+;
+;   fieldID = FSC_FIELD(parent, Title="X Size:", Value=256, Object=fieldObject, Digits=3)
+;
+; INPUT PARAMETERS:
+;
+;   parent -- The parent widget ID of the compound widget. Required.
+;
+; INPUT KEYWORDS:
+;
+;   COLUMN        Set this keyword to have the Label widget above the Text widget.
+;                 The default is to have the Label widget in a row with the Text widget.
+;
+;   CR_ONLY       Set this keyword if you only want Carriage Return events returned to
+;                 your event handler. If this keyword is not set, all events are returned.
+;                 Setting this keyword has no effect unless either the EVENT_PRO or
+;                 EVENT_FUNC keyword is used.
+;
+;   DECIMAL       Set this keyword to the number of digits to the right of the decimal
+;                 point in floating point or double precision numbers. Ignored for STRING values.
+;
+;   DIGITS        Set this keyword to the number of digits permitted in integer numbers.
+;
+;   EVENT_FUNC    Set this keyword to the name of an event handler function. If this
+;                 keyword is undefined and the Event_Pro keyword is undefined,
+;                 all compound widget events are handled internally and not
+;                 passed on to the parent widget.
+;
+;   EVENT_PRO     Set this keyword to the name of an event handler procedure. If this
+;                 keyword is undefined and the Event_Func keyword is undefined,
+;                 all compound widget events are handled internally and not
+;                 passed on to the parent widget.
+;
+;   FIELDFONT     The font name for the text in the text widget.
+;
+;   FRAME         Set this keyword to put a frame around the compound widget.
+;
+;   FOCUS_EVENTS  Set this keyword to enable event generation for keyboard focus
+;                 events. Ignored unless EVENT_FUNC or EVENT_PRO keywords are specified.
+;
+;   HIGHLIGHT     Set this keyword to highlight the existing text if the widget gain
+;                 the keyboard focus. This keyword MUST be set for tabbing to work naturally
+;                 in IDL 6.2 and higher.
+;
+;   LABEL_LEFT    Set this keyword to align the text on the label to the left.
+;
+;   LABEL_RIGHT   Set this keyword to align the text on the label to the right.
+;
+;   LABELFONT     The font name for the text in the label widget.
+;
+;   LABELSIZE     The X screen size of the label widget.
+;
+;   NAME          A string containing the name of the object. The default is ''.
+;
+;   NOEDIT        Set this keyword to allow no user editing of the input text widget.
+;
+;   NONSENSITIVE  Set this keyword to make the input text widget non-sensitive.
+;
+;   POSITIVE      Set this keyword if you want only positive numbers allowed.
+;
+;   SCR_XSIZE     The X screen size of the compound widget.
+;
+;   SCR_YSIZE     The Y screen size of the compound widget.
+;
+;   TITLE         The string text placed on the label widget.
+;
+;   UNDEFINED     Set this keyword to the value to use for "undefined" values. If
+;                 not set, then !Value.F_NAN is used for numerical fields and a
+;                 NULL string is used for string fields. This applies to values
+;                 obtained with the GET_VALUE method or the GET_VALUE function.
+;
+;   UVALUE        A user value for any purpose.
+;
+;   VALUE         The "value" of the compound widget. Any type of integer, floating, or string
+;                 variable is allowed. The data "type" is determined automatically from the
+;                 value supplied with this keyword. Be sure you set the type appropriately for
+;                 your intended use of the value.
+;
+;   XSIZE         The X size of the text widget in the usual character units.
+;
+; OUTPUT KEYWORDS:
+;
+;   OBJECT        Set this keyword to a named variable to receive the compound widget's
+;                 object reference. This is required if you wish to call methods on the object.
+;                 Note that the object reference is also available in the event structure
+;                 generated by the widget object. Note that the object reference will be
+;                 necessary if you want to get or set values in the compound widget.
+;
+; COMMON BLOCKS:
+;
+;   None.
+;
+; RESTRICTIONS:
+;
+;   Requires DBLTOSTR from the Coyote Library:
+;      http://www.dfanning.com/programs/dbltostr.pro
+;
+; EVENT STRUCTURE:
+;
+;   All events are handled internally unless either the Event_Pro or Event_Func
+;   keywords are used to assign an event handler to the compound widget. By
+;   default all events generated by the text widget are passed to the assigned
+;   event handler. If you wish to receive only Carriage Return events, set the
+;   CR_Only keyword.
+;
+;   event = { FSC_FIELD_EVENT, $   ; The name of the event structure.
+;             ID: 0L, $            ; The ID of the compound widget's top-level base.
+;             TOP: 0L, $           ; The widget ID of the top-level base of the hierarchy.
+;             HANDLER: 0L, $       ; The event handler ID. Filled out by IDL.
+;             OBJECT: Obj_New(), $ ; The "self" object reference. Provided so you can call methods.
+;             VALUE: Ptr_New(), $  ; A pointer to the widget value.
+;             TYPE:""              ; A string indicating the type of data in the VALUE field.
+;           }
+;
+;   Note that if the field is "empty", the VALUE will be a pointer
+;   to an undefined variable. You should check this value before you
+;   use it. You code will look something like this:
+;
+;     IF N_Elements(*event.value) EQ 0 THEN $
+;         Print, 'Current Value UNDEFINED.' ELSE $
+;         Print, 'Current Value: ', *event.value
+;
+; GETTING and SETTING VALUES:
+;
+;   Almost all the properties of the widget can be obtained or set via
+;   the object's GetProperty and SetProperty methods (described below).
+;   Traditional compound widgets have the ability to get and set the "value"
+;   of the compound widget identifier (e.g., fieldID in the calling
+;   sequence above). Unfortunately, it is impossible to retreive a variable
+;   in this way when the variable is undefined. In practical terms, this
+;   means that the undefined variable must be set to *something*. You can
+;   determine what that something is with the UNDEFINED keyword, or I will set
+;   it to !VALUES.F_NAN for numerical fields and to the null string for string
+;   fields. In any case, you will have to check for undefined variables before
+;   you try to do something with the value. For a numerical field, the code
+;   might look something like this:
+;
+;      fieldID = FSC_FIELD(parent, Title="X Size:", Value=256, Object=fieldObject, Digits=3)
+;      currentValue = fieldObject->Get_Value()
+;      IF Finite(currentValue) EQ 0 THEN Print, 'Value is Undefined' ELSE Print, currentValue
+;
+;   Additional examples are provided in the numerical example fields in Example Program below.
+;
+;   Setting the value of the compound widget is the same as calling the Set_Value
+;   method on the object reference. In other words, these two statements are equivalent.
+;
+;        fieldObject->Set_Value, 45.4
+;        Widget_Control, fieldID, Set_Value=45.4
+;
+;   The data type of the value is determined from the value itself. Be sure you set it appropriately.
+;
+; OBJECT PROCEDURE METHODS:
+;
+;   GetProperty -- This method allows various properties of the widget to be
+;       returned via output keywords. The keywords that are available are:
+;
+;       CR_Only -- A flag, if set, means only report carriage return events.
+;       DataType -- The data type of the field variable.
+;       Decimal -- Set this keyword to the number of digits to the right of the decimal
+;              point in FLOATVALUE and DOUBLEVALUE numbers.
+;       Digits -- Set this keyword to the number of digits permitted in INTERGERVALUE and LONGVALUE numbers.
+;       Event_Func -- The name of the event handler function.
+;       Event_Pro -- The name of the event handler function.
+;       Has_Focus -- Set to 1 if the text widget currently has the keyboard focus.
+;       Highlight -- The highlight flag.
+;       NoEdit -- The NoEdit flag.
+;       NonSensitive -- The NonSensitive flag.
+;       Undefined -- The "value" of any undefined value.
+;       UValue -- The user value assigned to the compound widget.
+;       Value -- The "value" of the compound widget.
+;     Name -- A scalar string name of the object.
+;
+;   Resize -- This method allows you to resize the compound widget's text field.
+;        The value parameter is an X screen size for the entire widget. The text
+;        widget is sized by using the value obtained from this value minus the
+;        X screen size of the label widget.
+;
+;          objectRef->Resize, screen_xsize_value
+;
+;   Set_Value -- This method allows you to set the "value" of the field. It takes
+;       one positional parameter, which is the value.
+;
+;          objectRef->Set_Value, 5
+;
+;   SetProperty -- This method allows various properties of the widget to be
+;       set via input keywords. The keywords that are available are:
+;
+;       CR_Only -- Set this keyword if you only want Carriage Return events.
+;       Decimal -- Set this keyword to the number of digits to the right of the decimal
+;              point in FLOAT and DOUBLE numbers.
+;       Digits -- Set this keyword to the number of digits permitted in INTERGER and LONG numbers.
+;       Event_Func -- Set this keyword to the name of an Event Function.
+;       Event_Pro -- Set this keyword to the name of an Event Procedure.
+;       Highlight -- Set this keyword to highlight the existing text
+;                    when the widget gets the keyboard focus
+;       LabelSize --  The X screen size of the Label Widget.
+;       Name -- A scalar string name of the object. (default = '')
+;       NoEdit -- Set this keyword to make the text widget uneditable
+;       NonSensitive -- Set this keyword to make the widget nonsensitive
+;       Scr_XSize -- The X screen size of the text widget.
+;       Scr_YSize -- The Y screen size of the text widget.
+;       Title -- The text to go on the Label Widget.
+;       UValue -- A user value for any purpose.
+;       Value -- The "value" of the compound widget.
+;       XSize -- The X size of the Text Widget.
+;
+;   SetTabNext -- This method allows you to specify which field to go to when a TAB character
+;      is typed in the text widget. See the Example program below for an example of how to
+;      use this method.
+;
+; OBJECT FUNCTIONS METHODS:
+;
+;      Get_Value -- Returns the "value" of the field. No parameters. Will be undefined
+;          if a "number" field is blank. Should be checked before using:
+;
+;          IF N_Elements(objectRef->Get_Value()) NE 0 THEN Print, Value is: ', objectRef->Get_Value()
+;
+;      GetID -- Returns the widget identifier of the compound widget's top-level base.
+;         (The first child of the parent widget.) No parameters.
+;
+;      GetLabelSize -- Returns the X screen size of the label widget. No parameters.
+;
+;      GetTextID -- Returns the widget identifier of the compound widget's text widget.
+;         No parameters.
+;
+;      GetTextSize -- Returns the X screen size of the text widget. No parameters.
+;
+; PRIVATE OBJECT METHODS:
+;
+;   Although there is really no such thing as a "private" method in IDL's
+;   object implementation, some methods are used internally and not meant to
+;   be acessed publicly. Here are a few of those methods. I list them because
+;   it may be these private methods are ones you wish to override in subclassed
+;   objects.
+;
+;      MoveTab -- This method moves the focus to the widget identified in the "next" field,
+;        which must be set with the SetTabNext method. No parameters. Called automatically
+;        when a TAB character is typed in the text widget.
+;
+;      Text_Events -- The main event handler method for the compound widget. All
+;        text widget events are processed here.
+;
+;      ReturnValue -- This function method accepts a string input value and converts
+;        it to the type of data requested by the user.
+;
+;      Validate -- This function method examines all text input and removes unwanted
+;        characters, depending upon the requested data type for the field. It makes it
+;        impossible, for example, to type alphanumeric characters in an INTEGER field.
+;
+; EXAMPLE:
+;
+;   An example program is provided at the end of the FSC_FIELD code. To run it,
+;   type these commands:
+;
+;      IDL> .Compile FSC_Field
+;      IDL> Example
+;
+; MODIFICATION HISTORY:
+;
+;   Written by: David W. Fanning, 18 October 2000. Based heavily on an earlier
+;      FSC_INPUTFIELD program and new ideas about the best way to write
+;      widget objects.
+;   Added LABEL_LEFT, LABEL_RIGHT, and UNDEFINED keywords. 29 Dec 2000. DWF.
+;   Modified the way the value is returned in the GET_VALUE method and the
+;      GET_VALUE function. Modified Example program to demonstrate. 30 Dec 2000. DWF.
+;   Added NOEDIT and NONSENSITIVE keywords, with corresponding SETEDIT and SETSENNSITIVE
+;      methods. 19 Jan 2001. DWF.
+;   Actually followed through with the changes I _said_" I made 29 Dec 2000. (Don't ask....) 13 June 2001. DWF.
+;   Added GetTextSize and GetLabelSize methods for obtaining the X screen
+;      size of the text and label widgets, respectively. 21 July 2001. DWF.
+;   Fixed a problem in SetProperty method where I was setting self.xsize, which doesn't exist. 24 April 2002. DWF.
+;   Small modification to the SetEdit method. 6 August 2003. DWF.
+;   Added Highlight keyword. Ported Focus_Events keyword from
+;      fsc_inputfield.pro. Updated documentation. 17 November
+;      2004. DWF and Benjamin Hornberger
+;   Added Has_Focus keyword to the GetProperty method. 18 November
+;      2004. Benjamin Hornberger
+;   Fixed bug in GetProperty method (set value to *self.undefined if
+;      *self.value is undefined. 24 Feb 2004. Benjamin Hornberger
+;   Modified FOCUS_EVENTS keyword handling so that *all* focus events are now
+;      passed to specified event handlers. Check event.select to see if the
+;      widget is gaining or losing focus. 10 August 2005. DWF.
+;   Added new tabbing functionality, introduced in IDL 6.2. To use tabbing
+;      functionality natually, the HIGHTLIGHT keywords must be set.
+;      See included EXAMPLE program for details. 10 August 2005. DWF.
+;   Added functionality to covert double precision values to strings properly. 30 Nov 2005. DWF.
+;-
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright © 1999-2005 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+;
+
+
+
+FUNCTION FSC_Field_Error_Message, theMessage, Traceback=traceback, NoName=noName, _Extra=extra
+
+On_Error, 2
+
+   ; Check for presence and type of message.
+
+IF N_Elements(theMessage) EQ 0 THEN theMessage = !Error_State.Msg
+s = Size(theMessage)
+messageType = s[s[0]+1]
+IF messageType NE 7 THEN BEGIN
+   Message, "The message parameter must be a string.", _Extra=extra
+ENDIF
+
+   ; Get the call stack and the calling routine's name.
+
+Help, Calls=callStack
+callingRoutine = (StrSplit(StrCompress(callStack[1])," ", /Extract))[0]
+
+   ; Are widgets supported? Doesn't matter in IDL 5.3 and higher.
+
+widgetsSupported = ((!D.Flags AND 65536L) NE 0) OR Float(!Version.Release) GE 5.3
+IF widgetsSupported THEN BEGIN
+   IF Keyword_Set(noName) THEN answer = Dialog_Message(theMessage, _Extra=extra) ELSE BEGIN
+      IF StrUpCase(callingRoutine) EQ "$MAIN$" THEN answer = Dialog_Message(theMessage, _Extra=extra) ELSE $
+         answer = Dialog_Message(StrUpCase(callingRoutine) + ": " + theMessage, _Extra=extra)
+   ENDELSE
+ENDIF ELSE BEGIN
+      Message, theMessage, /Continue, /NoPrint, /NoName, /NoPrefix, _Extra=extra
+      Print, '%' + callingRoutine + ': ' + theMessage
+      answer = 'OK'
+ENDELSE
+
+   ; Provide traceback information if requested.
+
+IF Keyword_Set(traceback) THEN BEGIN
+   Help, /Last_Message, Output=traceback
+   Print,''
+   Print, 'Traceback Report from ' + StrUpCase(callingRoutine) + ':'
+   Print, ''
+   FOR j=0,N_Elements(traceback)-1 DO Print, "     " + traceback[j]
+ENDIF
+
+RETURN, answer
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::GetLabelSize
+
+; This method returns the X screen size of the label widget.
+
+geom = Widget_Info(self.labelID, /Geometry)
+RETURN, geom.scr_xsize
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::GetTextSize
+
+; This method returns the X screen size of the text widget.
+
+geom = Widget_Info(self.textID, /Geometry)
+RETURN, geom.scr_xsize
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field::MoveTab
+
+   ; If the TABNEXT field has a valid widget, will set the
+   ; focus to this widget when a TAB event occurs in the widget.
+
+IF  NOT Widget_Info(self.tabnext, /Valid_ID) THEN RETURN
+Widget_Control, self.tabnext, /Input_Focus
+Widget_Control, self.tabnext, Get_Value=theText
+theText = theText[0]
+Widget_Control, self.tabnext, Set_Text_Select=[0,StrLen(theText)]
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field::SetTabNext, nextID
+
+; This method assigns a text id the TABNEXT field of
+; the object. This is required for the MOVETAB method.
+
+self.tabnext = nextID
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::GetTextID
+
+; This method returns the ID of the text widget of the compound widget.
+
+RETURN, self.textID
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field::Resize, newsize
+
+; This method resizes the widget by making the text widget fit the new size.
+
+l = Widget_Info(self.labelID, /Geometry)
+Widget_Control, self.textID, Scr_XSize = (newsize - l.scr_xsize)
+
+   ; Set the text widget sensitivitiy.
+
+
+Widget_Control, self.textID, Sensitive=1-Keyword_Set(self.nonsensitive)
+
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::GetID
+
+; This method returns the ID of the top-level base of the compound widget.
+
+RETURN, self.tlb
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::Geometry
+
+; This method returns the geometry of the compound widget.
+
+RETURN, Widget_Info(self.tlb,/Geometry)
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::Get_Value
+
+; This method returns the actual value of the compound widget.
+
+IF N_Elements(*self.theValue) EQ 0 THEN RETURN, *self.undefined ELSE RETURN, *self.theValue
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field::Set_Value, value
+
+; This method sets the value of the compound widget.
+
+   ; Error Handling.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_Field_Error_Message(/Traceback)
+   RETURN
+ENDIF
+
+dataType = Size(value, /TNAME)
+CASE dataType OF
+   'BYTE'   : BEGIN
+      genType = 'INTEGER'
+      dataType = 'INT'
+      positive = 1
+      value = Fix(value)
+      Message, 'BYTE data not supported. Value will be converted to INT.', /Informational
+      END
+   'INT'    : genType = 'INTEGER'
+   'LONG'   : genType = 'INTEGER'
+   'LONG64' : genType = 'INTEGER'
+   'UINT'   : genType = 'UNSIGNED'
+   'ULONG'  : genType = 'UNSIGNED'
+   'ULONG64': genType = 'UNSIGNED'
+   'FLOAT'  : genType = 'FLOAT'
+   'DOUBLE' : genType = 'DOUBLE'
+   'STRING' : genType = 'STRING'
+   ELSE     : Message, 'Data type ' + dataType + ' is not supported. Returning.'
+ENDCASE
+self.dataType = dataType
+self.gentype = genType
+
+IF self.gentype EQ 'DOUBLE' THEN theText = DblToStr(value) ELSE theText = StrTrim(value,2)
+theText = self->Validate(theText)
+
+   ; Load the value in the widget.
+
+Widget_Control, self.textID, Set_Value=theText, Set_Text_Select=[StrLen(theText),0]
+self.theText = theText
+
+   ; Set the actual value of the compound widget.
+
+*self.theValue = self->ReturnValue(theText)
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::Validate, value
+
+; This function eliminates illegal characters from a string that represents
+; a number. The return value is a properly formatted string that can be turned into
+; an INT, LONG, FLOAT, or DOUBLE value. This is a "private" method.
+;
+; + 43B
+; - 45B
+; . 46B
+; 0 - 9 48B -57B
+; 'eEdD' [101B, 69B, 100B, 68B]
+
+   ; Error Handling.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_Field_Error_Message(/Traceback)
+   testValue = self->ReturnValue(value)
+   IF String(testValue) NE 'NULLVALUE' THEN numCheck = Finite(testValue) ELSE numCheck = 1
+   IF numCheck THEN BEGIN
+      RETURN, retValue
+   ENDIF ELSE BEGIN
+      ok = Dialog_Message('The requested number is not representable.')
+      RETURN, ""
+   ENDELSE
+ENDIF
+
+   ; A null string should be returned at once.
+
+IF N_Elements(value) EQ 0 THEN value = ""
+value = value[0]
+IF value EQ "" THEN RETURN, String(value)
+
+   ; No leading or trailing blank characters to evaluate.
+
+value = StrTrim(value, 2)
+
+   ; A string value should be returned at once. Nothing to check.
+
+IF StrUpCase(self.gentype) EQ 'STRING' THEN RETURN, String(value)
+
+   ; Check integers and longs. A "-" or "+" in the first character is allowed. Otherwise,
+   ; only number between 0 and 9, or 43B to 57B.
+
+IF self.gentype EQ 'INTEGER' THEN BEGIN
+
+   returnValue = Ptr_New(/Allocate_Heap)
+   asBytes = Byte(value)
+
+   IF self.positive THEN BEGIN
+      IF (asBytes[0] EQ 43B) OR $
+         (asBytes[0] GE 48B AND asBytes[0] LE 57B) THEN *returnValue = [asBytes[0]]
+   ENDIF ELSE BEGIN
+      IF (asBytes[0] EQ 45B) OR (asBytes[0] EQ 43B) OR $
+         (asBytes[0] GE 48B AND asBytes[0] LE 57B) THEN *returnValue = [asBytes[0]]
+   ENDELSE
+   length = StrLen(asBytes)
+   IF length EQ 1 THEN BEGIN
+      IF N_Elements(*returnValue) EQ 0 THEN  *returnValue = [32B] ELSE $
+            *returnValue = [asBytes[0]]
+   ENDIF ELSE BEGIN
+      FOR j=1,length-1 DO BEGIN
+         IF (asBytes[j] GE 48B AND asBytes[j] LE 57B) THEN BEGIN
+            IF N_Elements(*returnValue) EQ 0 THEN  *returnValue = [asBytes[j]] ELSE $
+               *returnValue = [*returnValue, asBytes[j]]
+         ENDIF
+      ENDFOR
+  ENDELSE
+  IF N_Elements(*returnValue) NE 0 THEN retValue = String(*returnValue) ELSE retValue = ""
+  Ptr_Free, returnValue
+
+      ; Check for digit restrictions.
+
+  IF self.digits GT 0 THEN BEGIN
+      retValue = StrTrim(retValue, 2)
+      IF StrMid(retValue, 0, 1) EQ "-" THEN digits = self.digits + 1 ELSE digits = self.digits
+      retValue = StrMid(retValue, 0, digits)
+  ENDIF
+
+  RETURN, retValue
+
+ENDIF
+
+   ; Check unsigned data types.
+
+IF self.gentype EQ 'UNSIGNED' THEN BEGIN
+
+   returnValue = Ptr_New(/Allocate_Heap)
+   asBytes = Byte(value)
+
+   IF self.positive THEN BEGIN
+      IF (asBytes[0] GE 48B AND asBytes[0] LE 57B) THEN *returnValue = [asBytes[0]]
+   ENDIF ELSE BEGIN
+      IF (asBytes[0] GE 48B AND asBytes[0] LE 57B) THEN *returnValue = [asBytes[0]]
+   ENDELSE
+   length = StrLen(asBytes)
+   IF length EQ 1 THEN BEGIN
+      IF N_Elements(*returnValue) EQ 0 THEN  *returnValue = [32B] ELSE $
+            *returnValue = [asBytes[0]]
+   ENDIF ELSE BEGIN
+      FOR j=1,length-1 DO BEGIN
+         IF (asBytes[j] GE 48B AND asBytes[j] LE 57B) THEN BEGIN
+            IF N_Elements(*returnValue) EQ 0 THEN  *returnValue = [asBytes[j]] ELSE $
+               *returnValue = [*returnValue, asBytes[j]]
+         ENDIF
+      ENDFOR
+  ENDELSE
+  IF N_Elements(*returnValue) NE 0 THEN retValue = String(*returnValue) ELSE retValue = ""
+  Ptr_Free, returnValue
+
+      ; Check for digit restrictions.
+
+  IF self.digits GT 0 THEN BEGIN
+      retValue = StrTrim(retValue, 2)
+      digits = self.digits
+      retValue = StrMid(retValue, 0, digits)
+  ENDIF
+
+  RETURN, retValue
+
+ENDIF
+
+   ; Check floating values. (+,-) in first character or after 'eEdD'.
+   ; Only numbers, signs, decimal points, and 'eEdD' allowed.
+
+IF (self.gentype EQ 'FLOAT') OR (self.gentype EQ 'DOUBLE') THEN BEGIN
+   returnValue = Ptr_New(/Allocate_Heap)
+   asBytes = Byte(value)
+   IF self.positive THEN BEGIN
+      IF (asBytes[0] EQ 43B) OR $
+         (asBytes[0] GE 48B AND asBytes[0] LE 57B) OR $
+         (asBytes[0] EQ 46B) THEN *returnValue = [asBytes[0]]
+      IF (asBytes[0] EQ 46B) THEN haveDecimal = 1 ELSE haveDecimal = 0
+   ENDIF ELSE BEGIN
+      IF (asBytes[0] EQ 45B) OR (asBytes[0] EQ 43B) OR $
+         (asBytes[0] GE 48B AND asBytes[0] LE 57B) OR $
+         (asBytes[0] EQ 46B) THEN *returnValue = [asBytes[0]]
+      IF (asBytes[0] EQ 46B) THEN haveDecimal = 1 ELSE haveDecimal = 0
+   ENDELSE
+   haveExponent = 0
+   length = StrLen(asBytes)
+   prevByte = asBytes[0]
+   exponents = Byte('eEdD')
+   IF length EQ 1 THEN BEGIN
+      IF N_Elements(*returnValue) EQ 0 THEN  *returnValue = [32B] ELSE $
+            *returnValue = [asBytes[0]]
+   ENDIF ELSE BEGIN
+      FOR j=1,length-1 DO BEGIN
+         IF (asBytes[j] GE 48B AND asBytes[j] LE 57B) THEN BEGIN
+            IF N_Elements(*returnValue) EQ 0 THEN  *returnValue = [asBytes[j]] ELSE $
+               *returnValue = [*returnValue, asBytes[j]]
+            prevByte = asBytes[j]
+         ENDIF ELSE BEGIN
+
+            ; What kind of thing is it?
+
+            IF (asBytes[j] EQ 46B) THEN BEGIN ; A decimal point.
+               IF haveDecimal EQ 0 THEN BEGIN
+                  *returnValue = [*returnValue, asBytes[j]]
+                  haveDecimal = 1
+                  prevByte = asBytes[j]
+               ENDIF
+            ENDIF
+
+            IF (asBytes[j] EQ 45B) OR (asBytes[j] EQ 43B) THEN BEGIN ; A + or - sign.
+               index = Where(exponents EQ prevByte, count)
+               IF count EQ 1 AND haveExponent THEN BEGIN
+                  *returnValue = [*returnValue, asBytes[j]]
+                  haveDecimal = 1
+                  prevByte = asBytes[j]
+               ENDIF
+            ENDIF
+
+            index = Where(exponents EQ asBytes[j], count)
+            IF count EQ 1 AND haveExponent EQ 0 THEN BEGIN ; An exponent
+               *returnValue = [*returnValue, asBytes[j]]
+               haveExponent = 1
+               prevByte = asBytes[j]
+            ENDIF
+         ENDELSE
+      ENDFOR
+   ENDELSE
+      IF N_Elements(*returnValue) NE 0 THEN BEGIN
+
+      retValue = String(*returnValue)
+      retValue = StrTrim(retValue, 2)
+
+               ; Check for decimal restrictions
+
+      IF self.decimal GE 0 THEN BEGIN
+         theDecimalPt = StrPos(retValue, '.')
+         IF theDecimalPt NE -1 THEN retValue = StrMid(retValue, 0, theDecimalPt + self.decimal + 1)
+      ENDIF
+
+   ENDIF ELSE retValue = ""
+   Ptr_Free, returnValue
+
+      ; Is this a representable number?
+
+   testValue = self->ReturnValue(retValue)
+   IF String(testValue) NE 'NULLVALUE' THEN numCheck = Finite(testValue) ELSE numCheck = 1
+   IF numCheck THEN BEGIN
+      RETURN, retValue
+   ENDIF ELSE BEGIN
+      ok = Dialog_Message('The requested number is not representable.')
+      RETURN, ""
+   ENDELSE
+ENDIF
+
+
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::ReturnValue, inputValue
+
+; This method takes a string and turns it into a number,
+; depending upon the current data type of the compound widget.
+; This is a "private" method. For numbers, if the input value
+; is a null string, then an undefined variable is returned.
+
+   ; Error Handling.
+
+ON_IOERROR, CatchIt
+
+CASE self.datatype OF
+   'BYTE': IF inputValue EQ "" OR inputValue EQ "-" OR inputValue EQ "+" THEN $
+      retValue = 'NULLVALUE' ELSE retValue = Fix(inputValue)
+   'INT': IF inputValue EQ "" OR inputValue EQ "-" OR inputValue EQ "+" THEN $
+      retValue = 'NULLVALUE' ELSE retValue = Fix(inputValue)
+   'LONG': IF inputValue EQ "" OR inputValue EQ "-" OR inputValue EQ "+" THEN $
+      retValue = 'NULLVALUE' ELSE retValue = Long(inputValue)
+   'LONG64': IF inputValue EQ "" OR inputValue EQ "-" OR inputValue EQ "+" THEN $
+      retValue = 'NULLVALUE' ELSE retValue = Long64(inputValue)
+   'UINT': IF inputValue EQ "" OR inputValue EQ "-" OR inputValue EQ "+" THEN $
+      retValue = 'NULLVALUE' ELSE retValue = UInt(inputValue)
+   'ULONG': IF inputValue EQ "" OR inputValue EQ "-" OR inputValue EQ "+" THEN $
+      retValue = 'NULLVALUE' ELSE retValue = ULong(inputValue)
+   'ULONG64': IF inputValue EQ "" OR inputValue EQ "-" OR inputValue EQ "+" THEN $
+      retValue = 'NULLVALUE' ELSE retValue = ULong64(inputValue)
+   'FLOAT' : IF inputValue EQ "" OR inputValue EQ "-" OR inputValue EQ "+" THEN $
+      retValue = 'NULLVALUE' ELSE retValue = Float(inputValue)
+   'DOUBLE': IF inputValue EQ "" OR inputValue EQ "-" OR inputValue EQ "+" THEN $
+      retValue = 'NULLVALUE' ELSE retValue = Double(inputValue)
+   'STRING' : retValue = inputValue
+ENDCASE
+
+RETURN, retValue
+
+CatchIt:
+   retValue = 'NULLVALUE'
+   RETURN, retValue
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::TextEvents, event
+
+; The event handler method for the text widget of the compound widget.
+
+   ; Error Handling.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_Field_Error_Message(/Traceback)
+   RETURN, 0
+ENDIF
+
+   ; Get the previous text, the current cursor location in the text widget,
+   ; and indicate this is not a Carriage Return event.
+
+previousText = self.theText
+textLocation = Widget_Info(event.id, /Text_Select)
+cr_event = 0
+
+; Handle keyboard focus events.
+IF Tag_Names(event, /structure_name) EQ 'WIDGET_KBRD_FOCUS' THEN BEGIN
+    IF event.enter THEN BEGIN
+        self.has_focus = 1L
+        IF self.highlight THEN BEGIN
+            Widget_Control, self.textID, get_value=text
+            text = text[0]
+            Widget_Control, self.textID, set_text_select=[0, Strlen(text)]
+        ENDIF
+
+        IF self.focus THEN BEGIN
+
+              ; Get the current contents of text widget. Validate it.
+
+            Widget_Control, self.textID, Get_Value=newText
+            newText = newText[0]
+            validText = self->Validate(newText)
+
+               ; Load the valid text.
+
+           self.theText = validText
+           testValue  = self->ReturnValue(validText)
+           IF String(testValue) EQ "NULLVALUE" THEN BEGIN
+               Ptr_Free, self.theValue
+               self.theValue = Ptr_New(/Allocate_Heap)
+           ENDIF ELSE *self.theValue = testValue
+
+           ; Send the keyboard focus events if there is an event handler to accept them.
+           IF self.event_func NE "" THEN BEGIN
+              thisEvent = {FSC_Field_Event, self.tlb, event.top, 0L, self.theValue, self.dataType, self}
+              RETURN, thisEvent
+           ENDIF
+
+           IF self.event_pro NE "" THEN BEGIN
+              thisEvent = {FSC_Field_Event, self.tlb, event.top, 0L, self.theValue, self.dataType, self}
+              RETURN, thisEvent
+           ENDIF
+
+       ENDIF
+
+       RETURN, 0
+
+    ENDIF ELSE BEGIN
+
+        self.has_focus = 0L
+        Widget_Control, self.textID, set_text_select=[0]
+
+        IF self.focus THEN BEGIN
+
+              ; Get the current contents of text widget. Validate it.
+
+            Widget_Control, self.textID, Get_Value=newText
+            newText = newText[0]
+            validText = self->Validate(newText)
+
+               ; Load the valid text.
+
+           self.theText = validText
+           testValue  = self->ReturnValue(validText)
+           IF String(testValue) EQ "NULLVALUE" THEN BEGIN
+               Ptr_Free, self.theValue
+               self.theValue = Ptr_New(/Allocate_Heap)
+           ENDIF ELSE *self.theValue = testValue
+
+           ; Send the keyboard focus events if there is an event handler to accept them.
+           IF self.event_func NE "" THEN BEGIN
+              thisEvent = {FSC_Field_Event, self.tlb, event.top, 0L, self.theValue, self.dataType, self}
+              RETURN, thisEvent
+           ENDIF
+
+           IF self.event_pro NE "" THEN BEGIN
+              thisEvent = {FSC_Field_Event, self.tlb, event.top, 0L, self.theValue, self.dataType, self}
+              RETURN, thisEvent
+           ENDIF
+
+       ENDIF
+
+    ENDELSE
+
+   RETURN, 0
+
+ENDIF
+
+   ; What kind of event is this?
+
+possibleTypes = ['INSERT SINGLE CHARACTER', 'INSERT MULTIPLE CHARACTERS', 'DELETE TEXT', 'SELECT TEXT']
+thisType = possibleTypes[event.type]
+
+   ; Branch on event type.
+
+CASE thisType OF
+
+   'INSERT SINGLE CHARACTER': BEGIN
+
+            ; If the character is a TAB see if there is something to do.
+
+         IF event.ch EQ 9B THEN BEGIN
+            self->MoveTab
+            RETURN, 0
+         ENDIF
+
+            ; Get the current contents of text widget. Validate it.
+
+         Widget_Control, self.textID, Get_Value=newText
+         newText = newText[0]
+         validText = self->Validate(newText)
+
+            ; If it is valid, leave it alone. If not, go back to previous text.
+
+         IF validText NE newText THEN BEGIN
+
+            Widget_Control, self.textID, Set_Value=previousText, Set_Text_Select=[textLocation[0]-1,0]
+
+         ENDIF ELSE BEGIN
+
+            self.theText = validText
+            testValue  = self->ReturnValue(validText)
+            IF String(testValue) EQ "NULLVALUE" THEN BEGIN
+               Ptr_Free, self.theValue
+               self.theValue = Ptr_New(/Allocate_Heap)
+            ENDIF ELSE *self.theValue = testValue
+
+         ENDELSE
+
+            ; Is this a Carriage Return event?
+
+         IF event.ch EQ 10B then cr_event = 1
+      ENDCASE
+
+   'INSERT MULTIPLE CHARACTERS': BEGIN
+
+            ; Same as above, but for all the characters you are inserting.
+
+         Widget_Control, self.textID, Get_Value=newText
+         newText = newText[0]
+         validText = self->Validate(newText)
+         IF validText NE newText THEN BEGIN
+            Widget_Control, self.textID, Set_Value=previousText, Set_Text_Select=[textLocation[0]-1,0]
+         ENDIF ELSE BEGIN
+            self.theText = validText
+            testValue  = self->ReturnValue(validText)
+            IF String(testValue) EQ "NULLVALUE" THEN BEGIN
+               Ptr_Free, self.theValue
+               self.theValue = Ptr_New(/Allocate_Heap)
+            ENDIF ELSE *self.theValue = testValue
+         ENDELSE
+      ENDCASE
+
+   'DELETE TEXT': BEGIN
+
+            ; Get the current contents of text widget. Validate it.
+
+         Widget_Control, self.textID, Get_Value=newText
+         newText = newText[0]
+         validText = self->Validate(newText)
+
+            ; Load the valid text.
+
+        Widget_Control, self.textID, Set_Value=validText, Set_Text_Select=[textLocation[0],0]
+        self.theText = validText
+        testValue  = self->ReturnValue(validText)
+        IF String(testValue) EQ "NULLVALUE" THEN BEGIN
+            Ptr_Free, self.theValue
+            self.theValue = Ptr_New(/Allocate_Heap)
+        ENDIF ELSE *self.theValue = testValue
+
+      ENDCASE
+
+   'SELECT TEXT': ; Nothing to do.
+
+ENDCASE
+
+   ; Do you report all events, or only Carriage Return events?
+
+IF self.cr_only THEN BEGIN
+
+   IF self.event_func NE "" THEN BEGIN
+      thisEvent = {FSC_Field_Event, self.tlb, event.top, 0L, self.theValue, self.dataType, self}
+      IF cr_event THEN RETURN, thisEvent
+   ENDIF
+
+   IF self.event_pro NE "" THEN BEGIN
+      thisEvent = {FSC_Field_Event, self.tlb, event.top, 0L, self.theValue, self.dataType, self}
+      IF cr_event THEN RETURN, thisEvent
+   ENDIF
+
+ENDIF ELSE BEGIN
+
+   IF self.event_func NE "" THEN BEGIN
+      thisEvent = {FSC_Field_Event, self.tlb, event.top, 0L, self.theValue, self.dataType, self}
+      RETURN, thisEvent
+   ENDIF
+
+   IF self.event_pro NE "" THEN BEGIN
+      thisEvent = {FSC_Field_Event, self.tlb, event.top, 0L, self.theValue, self.dataType, self}
+      RETURN, thisEvent
+   ENDIF
+
+ENDELSE
+
+RETURN, 0
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field::GetProperty, $
+;
+; This method allows you to obtain various properties of the compound widget via output keywords.
+;
+   CR_Only=cr_only, $               ; Set this keyword if you only want Carriage Return events.
+   DataType=datatype, $             ; The datatype of the compound widget.
+   Decimal=decimal, $               ; The number of digits to the right of the decimal point in FLOAT numbers.
+   Digits=digits, $                 ; The number of digits permitted in INTERGERVALUE and LONGVALUE numbers.
+   Event_Func=event_func, $         ; Set this keyword to the name of an Event Function.
+   Event_Pro=event_pro, $           ; Set this keyword to the name of an Event Procedure.
+   Focus_Events=focus_events, $     ; Set this keyword to inquire whether or not events are reported when the keyboard focus is lost.
+   Has_Focus=has_focus, $           ; Set this keyword to inquire whether of not the widget has the keyboard focus currently.
+   Highlight=highlight, $           ; The highlight flag.
+   Name=Name, $                     ; The name of the object.
+   NoEdit=noedit, $                 ; Setting this keywords makes the text widget non-editable.
+   NonSensitive=nonsensitive, $     ; Setting this keywords makes the text widget non-sensitive.
+   Undefined=undefined, $           ; The "value" of any undefined value.
+   UValue=uvalue, $                 ; A user value for any purpose.
+   Value=value                      ; The "value" of the compound widget.
+
+   ; Error Handling.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_Field_Error_Message(/Traceback)
+   RETURN
+ENDIF
+
+   ; Get the properties.
+
+cr_only = self.cr_only
+datatype = self.datatype
+decimal = self.decimal
+digits = self.digits
+event_func = self.event_func
+event_pro = self.event_pro
+focus_events = self.focus
+has_focus = self.has_focus
+highlight = self.highlight
+name = self.name
+noedit = self.noedit
+nonsensitive = self.nonsensitive
+Widget_Control, self.tlb, Get_UValue=uvalue
+IF N_Elements(*self.theValue) EQ 0 THEN value = *self.undefined ELSE value = *self.thevalue
+undefined = *self.undefined
+
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field::SetProperty, $
+;
+; This method allows you to set various properties of the compound widget.
+;
+   CR_Only=cr_only, $               ; Set this keyword if you only want Carriage Return events.
+   Decimal=decimal, $               ; Set this keyword to the number of digits to the right of the decimal point in FLOAT values..
+   Digits=digits, $                 ; Set this keyword to the number of digits permitted in INTEGER values.
+   Event_Func=event_func, $         ; Set this keyword to the name of an Event Function.
+   Event_Pro=event_pro, $           ; Set this keyword to the name of an Event Procedure.
+   Focus_Events=focus_events, $     ; Set this keyword to turn on or off event reporting when the keyboard focus is lost.
+   Highlight=highlight, $           ; Set this keyword to highlight the text when it gets keyboard focus.
+   LabelSize=labelsize, $           ; The X screen size of the Label Widget.
+   Name=name, $                     ; A scalar string name for the object.
+   NoEdit=noedit, $                 ; Setting this keywords makes the text widget non-editable.
+   NonSensitive=nonsensitive, $     ; Setting this keywords makes the text widget non-sensitive.
+   Scr_XSize=scr_xsize, $           ; The X screen size of the text widget.
+   Scr_YSize=scr_ysize, $           ; The Y screen size of the text widget.
+   Title=title, $                   ; The text to go on the Label Widget.
+   Undefined=undefinded, $          ; Set to "value" of undefined value.
+   UValue=uvalue, $                 ; A user value for any purpose.
+   Value=value, $                   ; The "value" of the compound widget.
+   XSize=xsize                      ; The X size of the Text Widget.
+
+   ; Error Handling.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_Field_Error_Message(/Traceback)
+   RETURN
+ENDIF
+
+   ; Set the properties, if needed.
+
+IF N_Elements(cr_only) NE 0 THEN self.cr_only = cr_only
+IF Keyword_Set(decimal)THEN self.decimal = decimal
+IF Keyword_Set(digits)THEN self.digits = digits
+IF N_Elements(event_func) NE 0 THEN self.event_func = event_func
+IF N_Elements(event_pro) NE 0 THEN self.event_pro = event_pro
+IF N_Elements(focus_events) NE 0 THEN self.focus = keyword_set(focus)
+IF N_Elements(highlight) NE 0 THEN self.highlight = Keyword_Set(highlight)
+IF N_Elements(labelsize) NE 0 THEN BEGIN
+   Widget_Control, self.labelID, XSize=labelsize
+ENDIF
+IF N_Elements(scr_xsize) NE 0 THEN BEGIN
+   Widget_Control, self.textID, Scr_XSize=scr_xsize
+ENDIF
+IF N_Elements(scr_ysize) NE 0 THEN BEGIN
+   Widget_Control, self.textID, Scr_YSize=scr_ysize
+ENDIF
+IF N_Elements(title) NE 0 THEN Widget_Control, self.labelID, Set_Value=title
+IF N_Elements(uvalue) NE 0 THEN Widget_Control, self.tlb, Set_UValue=uvalue
+If N_Elements(name) NE 0 Then self.name = String(name[0])
+IF N_Elements(xsize) NE 0 THEN BEGIN
+   Widget_Control, self.textID, XSize=xsize
+ENDIF
+IF N_Elements(noedit) THEN BEGIN
+   self.noedit = Keyword_Set(noedit)
+   Widget_Control, self.textID, Editable=1-self.noedit
+ENDIF
+IF N_Elements(nonsensitive) THEN BEGIN
+   self.nonsensitive = Keyword_Set(nonsensitive)
+   Widget_Control, self.textID, Sensitive=1-self.nonsensitive
+ENDIF
+
+   ; Set up the value.
+
+IF N_Elements(value) NE 0 THEN BEGIN
+
+   ; Set up data type and general type.
+
+   dataType = Size(value, /TNAME)
+   CASE dataType OF
+      'BYTE'   : BEGIN
+         genType = 'INTEGER'
+         dataType = 'INT'
+         positive = 1
+         *self.theValue = Fix(*self.theValue)
+         Message, 'BYTE data not supported. Value will be converted to INT.', /Informational
+         END
+      'INT'    : genType = 'INTEGER'
+      'LONG'   : genType = 'INTEGER'
+      'LONG64' : genType = 'INTEGER'
+      'UINT'   : genType = 'UNSIGNED'
+      'ULONG'  : genType = 'UNSIGNED'
+      'ULONG64': genType = 'UNSIGNED'
+      'FLOAT'  : genType = 'FLOAT'
+      'DOUBLE' : genType = 'DOUBLE'
+      'STRING' : genType = 'STRING'
+      ELSE     : BEGIN
+         Ptr_Free, self.theValue
+         self.theValue = Ptr_New(/Allocate_Heap)
+         Message, 'Data type ' + dataType + ' is not supported. Returning.', /NoName
+         END
+   ENDCASE
+   self.theText = StrTrim(value, 2)
+   *self.theValue = self->ReturnValue(self.theText)
+   Widget_Control, self.textID, Set_Value=self.theText
+   self.dataType = datatype
+   self.genType = genType
+   IF N_Elements(undefined) EQ 0 THEN BEGIN
+   IF genType EQ 'STRING' THEN undefined = "" ELSE undefined = !VALUES.F_NAN
+ENDIF
+
+ENDIF
+
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field::SetEdit, editvalue
+
+   ; Error Handling.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_Field_Error_Message(/Traceback)
+   RETURN
+ENDIF
+
+IF N_Elements(editvalue) NE 0 THEN $
+   Widget_Control, self.textID, Editable=Keyword_Set(editvalue)
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+PRO FSC_Field::SetSensitive, value
+
+   ; Error Handling.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_Field_Error_Message(/Traceback)
+   RETURN
+ENDIF
+
+IF N_Elements(value) EQ 0 THEN value = 1
+self.nonsensitive = 1-value
+Widget_Control, self.textID, Sensitive=value
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field::INIT, $         ; The compound widget FSC_Field INIT method..
+   parent, $                        ; The parent widget. Required for all compound widgets.
+   Column=column, $                 ; Set this keyword to have Label above Text Widget.
+   CR_Only=cr_only, $               ; Set this keyword if you only want Carriage Return events.
+   Decimal=decimal, $               ; Set this keyword to the number of digits to the right of the decimal point in FLOAT.
+   Digits=digits, $                 ; Set this keyword to the number of digits permitted in INTEGER values.
+   Event_Func=event_func, $         ; Set this keyword to the name of an Event Function.
+   Event_Pro=event_pro, $           ; Set this keyword to the name of an Event Procedure.
+   _Extra=extra, $                  ; Passes along extra keywords to the text widget.
+   FieldFont=fieldfont, $           ; The font name for the text in the Text Widget.
+   Focus_Events=focus_events, $     ; Set this keyword to enable event reporting when the keyboard focus is lost or gained.
+   Frame=frame, $                   ; Set this keyword to put a frame around the compound widget.
+   Highlight=highlight, $           ; If this keyword is set, the text is highlighted.
+   Label_Left=label_left, $         ; Set this keyword to align the label to the left of the label.
+   Label_Right=label_right, $       ; Set this keyword to align the labe to the right of the label.
+   LabelFont=labelfont, $           ; The font name for the text in the Label Widget.
+   LabelSize=labelsize, $           ; The X screen size of the Label Widget.
+   Name=name, $                     ; A scalar string name for the object.
+   NoEdit=noedit, $                 ; Setting this keywords makes the text widget non-editable.
+   NonSensitive=nonsensitive, $     ; Setting this keywords makes the text widget non-sensitive.
+   Positive=positive, $             ; Set this keyword to indicate only positive numbers allowed in the field.
+   Scr_XSize=scr_xsize, $           ; The X screen size of the text widget.
+   Scr_YSize=scr_ysize, $           ; The Y screen size of the text widget.
+   Title=title, $                   ; The text to go on the Label Widget.
+   Undefined=undefined, $           ; Set to the value for "undefined" field values.
+   UValue=uvalue, $                 ; A user value for any purpose.
+   Value=value, $                   ; The "value" of the compound widget.
+   XSize=xsize                      ; The X size of the Text Widget.
+
+   ; Error Handling.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_Field_Error_Message(/Traceback)
+   RETURN, 0
+ENDIF
+
+   ; A parent is required.
+
+IF N_Elements(parent) EQ 0 THEN BEGIN
+   Message, 'A PARENT argument is required. Returning...', /NoName
+ENDIF
+
+   ; Check keyword values.
+
+IF N_Elements(column) EQ 0 THEN column = 0
+IF N_Elements(digits) EQ 0 THEN digits = 0 ELSE digits = Fix(digits)
+IF N_Elements(decimal) EQ 0 THEN decimal = -1 ELSE decimal = Fix(decimal)
+IF N_Elements(event_func) EQ 0 THEN event_func = ""
+IF N_Elements(event_pro) EQ 0 THEN event_pro = ""
+IF N_Elements(fieldfont) EQ 0 THEN fieldfont = ""
+IF N_Elements(frame) EQ 0 THEN frame = 0
+IF N_Elements(labelfont) EQ 0 THEN labelfont = ""
+IF N_Elements(labelsize) EQ 0 THEN labelsize = 0
+IF N_Elements(name) EQ 0 THEN name = ""
+noedit = Keyword_Set(noedit)
+nonsensitive = Keyword_Set(nonsensitive)
+positive = Keyword_Set(positive)
+IF N_Elements(scr_xsize) EQ 0 THEN scr_xsize = 0
+IF N_Elements(scr_ysize) EQ 0 THEN scr_ysize = 0
+IF N_Elements(title) EQ 0 THEN title = "Input Value: "
+IF N_Elements(uvalue) EQ 0 THEN uvalue = ""
+IF N_Elements(value) EQ 0 THEN value = ""
+IF N_Elements(xsize) EQ 0 THEN xsize = 0
+
+   ; What data type are we looking for?
+
+dataType = Size(value, /TNAME)
+CASE dataType OF
+   'BYTE'   : BEGIN
+      genType = 'INTEGER'
+      dataType = 'INT'
+      positive = 1
+      value = Fix(value)
+      Message, 'BYTE data not supported. Value will be converted to INT.', /Informational
+      END
+   'INT'    : genType = 'INTEGER'
+   'LONG'   : genType = 'INTEGER'
+   'LONG64' : genType = 'INTEGER'
+   'UINT'   : genType = 'UNSIGNED'
+   'ULONG'  : genType = 'UNSIGNED'
+   'ULONG64': genType = 'UNSIGNED'
+   'FLOAT'  : genType = 'FLOAT'
+   'DOUBLE' : genType = 'DOUBLE'
+   'STRING' : genType = 'STRING'
+   ELSE     : Message, 'Data type ' + dataType + ' is not supported. Returning.', /NoName
+ENDCASE
+
+IF N_Elements(undefined) EQ 0 THEN BEGIN
+   IF genType EQ 'STRING' THEN undefined = "" ELSE undefined = !VALUES.F_NAN
+ENDIF
+
+   ; Populate the object.
+
+self.cr_only = Keyword_Set(cr_only)
+self.datatype = datatype
+self.decimal = decimal
+self.digits = digits
+self.focus = Keyword_Set(focus_events)
+self.highlight = Keyword_Set(highlight)
+self.gentype = genType
+self.parent = parent
+self.event_pro = event_pro
+self.event_func = event_func
+self.positive = positive
+self.undefined = Ptr_New(undefined)
+self.noedit = noedit
+self.nonsensitive = nonsensitive
+If N_Elements(name) NE 0 Then self.name = String(name[0])
+IF Keyword_Set(column) THEN row = 0 ELSE row = 1
+
+   ; Validate the input value.
+
+IF self.gentype EQ 'DOUBLE' THEN value = DblToStr(value) ELSE value = StrTrim(value,2)
+value = self->Validate(value)
+self.theText = value
+
+   ; Create the widgets.
+
+self.tlb = Widget_Base( parent, $  ; The top-level base of the compound widget.
+   Frame=frame, $
+   Row=row, $
+   Column=Keyword_Set(column), $
+   Base_Align_Center=1, $
+   UName=name, $
+   UValue=uvalue, $
+   Event_Pro=event_pro, $
+   Func_Get_Value='FSC_Field_Get_Compound_Widget_Value', $
+   Pro_Set_Value='FSC_Field_Set_Compound_Widget_Value', $
+   Event_Func=event_func )
+
+; Update for tabbing in IDL 6.2.
+IF Float(!Version.Release) GT 6.1 THEN BEGIN
+   Widget_Control, self.tlb, TAB_MODE=1
+ENDIF
+
+self.labelID = Widget_Label( self.tlb, Value=title, Font=labelfont, $ ; The Label Widget.
+  Scr_XSize=labelsize, UValue=self, Align_Left=Keyword_Set(label_left), Align_Right=Keyword_Set(label_right))
+
+self.textID = Widget_Text( self.tlb, $  ; The Text Widget.
+   Value=value, $
+   XSize=xsize, $
+   YSize=1, $
+   Scr_XSize=scr_xsize, $
+   Scr_YSize=scr_ysize, $
+   sensitive=1-self.nonsensitive, $
+   Font=fieldfont, $
+   All_Events=1, $
+   _Extra=extra, $
+   kbrd_focus_events=1, $
+   Event_Func='FSC_Field_Event_Handler', $
+   UValue={Method:"TextEvents", Object:self}, $
+   Kill_Notify='FSC_Field_Kill_Notify', $
+   Editable=1-noedit )
+
+self.theValue = Ptr_New(self->ReturnValue(value))
+
+   ; If CR_ONLY or FOCUS_EVENTS are turned on and EVENT_PRO and EVENT_FUNC keywords are
+   ; unspecified, issue a warning message to the command log.
+
+IF self.cr_only AND (self.event_pro EQ "" AND self.event_func EQ "") THEN $
+   Message, /Information, 'WARNING: There is no specified event handler for carriage return events for this widget. Events will be swallowed.'
+IF self.focus AND (self.event_pro EQ "" AND self.event_func EQ "") THEN $
+   Message, /Information, 'WARNING: There is no specified event handler for keyboard focus events for this widget. Events will be swallowed.'
+
+RETURN, 1
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field::CLEANUP
+
+; This method makes sure there are not pointers left on the heap.
+
+Ptr_Free, self.theValue
+Ptr_Free, self.undefined
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field_Event_Handler, event
+
+; The main event handler for the compound widget. It reacts
+; to "messages" in the UValue of the text widget.
+; The message indicates which object method to call. A message
+; consists of an object method and the self object reference.
+
+Widget_Control, event.ID, Get_UValue=theMessage
+event = Call_Method(theMessage.method, theMessage.object, event)
+
+RETURN, event
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field_Event__Define
+
+; The FSC_Field Event Structure. Sent only if EVENT_PRO or EVENT_FUNC keywords
+; have defined an event handler for the top-level base of the compound widget.
+
+   event = { FSC_Field_Event, $   ; The name of the event structure.
+             ID: 0L, $            ; The ID of the compound widget's top-level base.
+             TOP: 0L, $           ; The widget ID of the top-level base of the hierarchy.
+             HANDLER: 0L, $       ; The event handler ID. Filled out by IDL.
+             Value: Ptr_New(), $  ; A pointer to the widget value.
+             Type: "", $          ; A string indicating the type of data in the VALUE field.
+             Object: Obj_New()}   ; The "self" object.
+
+
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field_Set_Compound_Widget_Value, tlb, value
+
+; This utilty routine is invoked when the user tries to set
+; the value of the compound widget using the base widget
+; identifier of the top-level base of the compound widget.
+; The self object is located, and the Set_Value method is called
+; on the object.
+
+firstChildID = Widget_Info(tlb, /Child)
+Widget_Control, firstChildID, Get_UValue=self
+self->Set_Value, value
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_Field_Get_Compound_Widget_Value, tlb
+
+; This utilty routine is invoked when the user tries to get
+; the value of the compound widget using the base widget
+; identifier of the top-level base of the compound widget.
+; The self object is located, and the Get_Value method is called
+; on the object.
+
+firstChildID = Widget_Info(tlb, /Child)
+Widget_Control, firstChildID, Get_UValue=self
+IF N_Elements(self->Get_Value()) EQ 0 THEN RETURN, *self.undefined ELSE RETURN, self->Get_Value()
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field_Kill_Notify, textID
+
+; This widget call-back procedure makes sure the self object is
+; destroyed when the widget is destroyed.
+
+Widget_Control, textID, Get_UValue=message
+Obj_Destroy, message.object
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_Field__Define
+
+   objectClass = { FSC_FIELD, $             ; The object class name.
+                   parent: 0L, $            ; The parent widget ID.
+                   tlb: 0L, $               ; The top-level base of the compound widget.
+                   labelID: 0L, $           ; The label widget ID.
+                   textID: 0L, $            ; The text widget ID.
+                   theText: "", $           ; The actual text in the text widget.
+                   theValue: Ptr_New(), $   ; The actual "value" of the text in the text widget. :-)
+                   event_func: "", $        ; The name of the specified event handler function.
+                   event_pro: "", $         ; The name of the specified event handler procedrue
+                   cr_only: 0L, $           ; A flag meaning send only carriage return events.
+                   focus: 0L, $             ; A flag to indicate that events should be reported if the keyboard focus is lost
+                   has_focus: 0L, $         ; A flag to indicate that the widget has the keyboard focus currently.
+                   highlight: 0L, $         ; A flag for highlighting.
+                   tabnext: 0L, $           ; The identifier of a widget to receive the cursor focus if a TAB character is detected.
+                   decimal: 0, $            ; The number of decimals points in FLOAT and DOUBLE numbers.
+                   digits: 0, $             ; The number of digits in INT and LONG numbers.
+                   positive: 0, $           ; A flag meaning only positive numbers allowed.
+                   datatype: "",$           ; The type of data to be returned from the text widget.
+                   gentype: "", $           ; The "general" type of data: INTEGER, UNSIGNED, FLOAT, or STRING.
+                   undefined: Ptr_New(), $  ; The "undefined" value. Used in Get_Value methods, etc.
+                   noedit: 0L, $            ; A flag indicating whether text widget is editable (0) or not (1).
+                   nonsensitive: 0L, $      ; A flag indicating whether text widget is sensitive (0) or not (1).
+                   name:"" $                ; a scalar string name for the object
+                  }
+
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FIELD, $               ; The compound widget FSC_Field.
+   parent, $                        ; The parent widget. Required for all compound widgets.
+   Column=column, $                 ; Set this keyword to have Label above Text Widget.
+   CR_Only=cr_only, $               ; Set this keyword if you only want Carriage Return events.
+   Decimal=decimal, $               ; Set this keyword to the number of digits to the right of the decimal point in FLOAT numbers.
+   Digits=digits, $                 ; Set this keyword to the number of digits permitted in INTEGER numbers.
+   Event_Func=event_func, $         ; Set this keyword to the name of an Event Function.
+   Event_Pro=event_pro, $           ; Set this keyword to the name of an Event Procedure.
+   _Extra=extra, $                  ; Passes along extra keywords to the text widget.
+   FieldFont=fieldfont, $           ; The font name for the text in the Text Widget.
+   Focus_Events=focus_events, $     ; Set this keyword to enable event reporting when the keyboard focus is lost.
+   Frame=frame, $                   ; Set this keyword to put a frame around the compound widget.
+   Highlight=highlight, $           ; If this keyword is set, the text is highlighted.
+   Label_Left=label_left, $         ; Set this keyword to align the label to the left of the label.
+   Label_Right=label_right, $       ; Set this keyword to align the labe to the right of the label.
+   LabelFont=labelfont, $           ; The font name for the text in the Label Widget.
+   LabelSize=labelsize, $           ; The X screen size of the Label Widget.
+   Name=name, $                     ; The name of the object.
+   NoEdit=noedit, $                 ; Setting this keywords makes the text widget non-editable.
+   NonSensitive=nonsensitive, $     ; Setting this keywords makes the text widget non-sensitive.
+   Object = obj, $                  ; An output keyword that contains the object reference.
+   Positive=positive, $             ; Set this keyword to indicate only positive numbers allowed in the field.
+   Scr_XSize=scr_xsize, $           ; The X screen size of the text widget.
+   Scr_YSize=scr_ysize, $           ; The Y screen size of the text widget.
+   Title=title, $                   ; The text to go on the Label Widget.
+   Undefined=undefined, $           ; Set to the value for "undefined" field values.
+   UValue=uvalue, $                 ; A user value for any purpose.
+   Value=value, $                   ; The "value" of the compound widget.
+   XSize=xsize                      ; The X size of the Text Widget.
+
+obj = Obj_New("FSC_FIELD", $
+   parent, $                        ; The parent widget. Required for all compound widgets.
+   Column=column, $                 ; Set this keyword to have Label above Text Widget.
+   CR_Only=cr_only, $               ; Set this keyword if you only want Carriage Return events.
+   Decimal=decimal, $               ; Set this keyword to the number of digits to the right of the decimal point in FLOAT numbers.
+   Digits=digits, $                 ; Set this keyword to the number of digits permitted in INTEGER numbers.
+   Event_Func=event_func, $         ; Set this keyword to the name of an Event Function.
+   Event_Pro=event_pro, $           ; Set this keyword to the name of an Event Procedure.
+   _Extra=extra, $                  ; Passes along extra keywords to the text widget.
+   FieldFont=fieldfont, $           ; The font name for the text in the Text Widget.
+   Focus_events=focus_events, $     ; Set this keyword to enable event reporting when the keyboard focus is lost.
+   Frame=frame, $                   ; Set this keyword to put a frame around the compound widget.
+   Highlight=highlight, $           ; If this keyword is set, the text is highlighted.
+   Label_Left=label_left, $         ; Set this keyword to align the label to the left of the label.
+   Label_Right=label_right, $       ; Set this keyword to align the labe to the right of the label.
+   LabelFont=labelfont, $           ; The font name for the text in the Label Widget.
+   LabelSize=labelsize, $           ; The X screen size of the Label Widget.
+   Name=name, $                     ; The name of the object.
+   NoEdit=noedit, $                 ; Setting this keywords makes the text widget non-editable.
+   NonSensitive=nonsensitive, $     ; Setting this keywords makes the text widget non-sensitive.
+   Positive=positive, $             ; Set this keyword to indicate only positive numbers allowed in the field.
+   Scr_XSize=scr_xsize, $           ; The X screen size of the text widget.
+   Scr_YSize=scr_ysize, $           ; The Y screen size of the text widget.
+   Title=title, $                   ; The text to go on the Label Widget.
+   Undefined=undefined, $           ; Set to the value for "undefined" field values.
+   UValue=uvalue, $                 ; A user value for any purpose.
+   Value=value, $                   ; The "value" of the compound widget.
+   XSize=xsize)                     ; The X size of the Text Widget.
+
+IF Obj_Valid(obj) THEN RETURN, obj->GetID() ELSE RETURN, -1L
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+PRO Example_Event, event
+
+
+; An example event handler for FSC_Field.
+
+Widget_Control, event.top, Get_UValue=info
+Widget_Control, event.id, Get_UValue=thisEvent
+
+
+; Not interested in losing keyboard focus events.
+theName = Tag_Names(event, /Structure_Name)
+IF theName EQ 'WIDGET_KBRD_EVENT' THEN BEGIN
+   IF event.type EQ 0 THEN RETURN
+ENDIF
+
+; What kind of event is this?
+CASE thisEvent OF
+   'Field 1 Event': BEGIN
+
+      ; Demonstate various ways to test if the value from this field is undefined.
+
+      Print, ''
+      IF N_Elements(*event.value) EQ 0 THEN Print, 'Field 1 Value is Undefined from Event Structure' ELSE $
+         Print, 'Field 1 Value from Event Structure: ', *event.value
+
+      Widget_Control, info.field1id, Get_Value=theValue
+      IF Finite(theValue) EQ 0 THEN Print, 'Field 1 Value is Undefined and Assigned Value: ', theValue ELSE $
+         Print, 'Field 1 Value via Widget Get_Value Function: ', theValue
+
+
+      IF Finite(info.field1->Get_Value()) EQ 0 THEN Print, 'Field 1 Value is Undefined from Object Get_Value Function' ELSE $
+         Print, 'Field 1 Value via Object Get_Value Function: ', info.field1->Get_Value()
+
+      END
+   'Field 2 Event': BEGIN
+      Print, ''
+      IF N_Elements(*event.value) EQ 0 THEN Print, 'Field 2 Value is Undefined' ELSE $
+         Print, 'Field 2 Value: ', *event.value
+
+      theValue = info.field2->Get_Value()
+      IF theValue EQ -9999.0 THEN Print, 'Field 2 Value is Undefined and Assigned Value: ', theValue ELSE $
+         Print, 'Field 2 Value via Object Get_Value Function: ', theValue
+
+      END
+
+   'Print It': BEGIN
+      theValue =info.field3->Get_Value()
+      Print, ''
+      Print, 'Field 3 Value: ', theValue
+      END
+   'Set It': BEGIN
+      info.field3->Set_Value, 'Coyote Rules!'
+      END
+   'Quit': Widget_Control, event.top, /Destroy
+   'ChangeToUInt': BEGIN
+      info.field1->SetProperty, Title='Unsigned:', Value=UINT(RandomU(seed, 1)*100)
+      END
+   'ChangeToFloat': BEGIN
+      info.field1->SetProperty, Title='Float:', Value=RandomU(seed, 1)*100
+      END
+   'ChangeToString': BEGIN
+      info.field1->SetProperty, Title='String:', Value='Coyote Jules'
+      END
+   'PrintFloat': BEGIN
+      IF N_Elements(info.field2->Get_Value()) EQ 0 THEN Print, 'Field 2 Value is Undefined' ELSE $
+         Print, 'Field 2 Value: ', info.field2->Get_Value()
+      END
+   'LabelSize': BEGIN
+      Widget_Control, event.top, Update=0
+      currentSize = info.labelsize
+      info.field1->SetProperty, LabelSize=info.labelsize
+      info.field2->SetProperty, LabelSize=info.labelsize
+      info.field3->SetProperty, LabelSize=info.labelsize
+      IF currentsize EQ 75 THEN info.labelsize = 50 ELSE info.labelsize = 75
+      Widget_Control, event.top, Update=1
+      END
+   'MakeEditable': BEGIN
+      Widget_Control, event.id, Get_Value=buttonValue
+      CASE buttonValue OF
+         'Make String Field Editable': BEGIN
+            info.field3->SetEdit, 1
+            Widget_Control, event.id, Set_Value='Make String Field Non-Editable'
+            END
+         'Make String Field Non-Editable': BEGIN
+            info.field3->SetEdit, 0
+            Widget_Control, event.id, Set_Value='Make String Field Editable'
+            END
+      ENDCASE
+      END
+   'MakeSensitive': BEGIN
+      Widget_Control, event.id, Get_Value=buttonValue
+      CASE buttonValue OF
+         'Make String Field Sensitive': BEGIN
+            info.field3->SetSensitive, 1
+            Widget_Control, event.id, Set_Value='Make String Field Non-Sensitive'
+            END
+         'Make String Field Non-Sensitive': BEGIN
+            info.field3->SetSensitive, 0
+            Widget_Control, event.id, Set_Value='Make String Field Sensitive'
+            END
+      ENDCASE
+      END
+ENDCASE
+
+IF Widget_Info(event.top, /Valid_ID) THEN Widget_Control, event.top, Set_UValue=info
+END ;--------------------------------------------------------------------------------------------------------------
+
+
+
+PRO Example, field1, field2, field3
+
+; An example program to exercise some of the features of FSC_FIELD.
+
+tlb = Widget_Base(Column=1)
+button = Widget_Button(tlb, Value='Change First Field to Float', $
+   UValue='ChangeToFloat')
+button = Widget_Button(tlb, Value='Change First Field to String', $
+   UValue='ChangeToString')
+button = Widget_Button(tlb, Value='Change First Field to Unsigned Integer', $
+   UValue='ChangeToUInt')
+
+   ; Create an integer field, no more than 4 digits in the value.
+
+field1id = FSC_FIELD(tlb, Title='Integer:', LabelSize=50, Digits=4, Object=field1, $
+   Value=5, UValue='Field 1 Event', Event_Pro='Example_Event', /CR_Only, /Highlight)
+
+   ; Create a floating point field. Only two decimal points to the right of the decimal.
+   ; Set the Undefined value to -9999.0.
+
+field = FSC_FIELD(tlb, Title='Double:', LabelSize=50, Value=-123456789.1234567891234D, Object=field2, Undefined=-9999.0, $
+   /CR_Only, UValue='Field 2 Event', Event_Pro='Example_Event', Decimal=8, /Highlight)
+
+   ; Create a string field.
+
+field = FSC_FIELD(tlb, Title='String:', LabelSize=50, Value='Coyote Rules!', Object=field3, /Nonsensitive, /Highlight)
+
+   ; Set up TABing between fields.
+
+;field1->SetTabNext, field2->GetTextID()
+;field2->SetTabNext, field3->GetTextID()
+;field3->SetTabNext, field1->GetTextID()
+
+button = Widget_Button(tlb, Value='Print Value of String', UValue="Print It")
+button = Widget_Button(tlb, Value='Set Value of String', UValue='Set It')
+button = Widget_Button(tlb, Value='Change Size of Labels', UValue='LabelSize')
+button = Widget_Button(tlb, Value='Print Floating Value', UValue='PrintFloat')
+button = Widget_Button(tlb, Value='Make String Field Editable', UValue='MakeEditable')
+button = Widget_Button(tlb, Value='Make String Field Sensitive', UValue='MakeSensitive')
+button = Widget_Button(tlb, Value='Quit', UValue='Quit')
+Widget_Control, tlb, /Realize, Set_UValue={field1:field1, field2:field2, field3:field3, field1id:field1id, labelsize:75}
+XManager, 'example', tlb, /No_Block
+END
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_fileselect.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_fileselect.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_fileselect.pro	(revision 1185)
@@ -0,0 +1,1170 @@
+;+
+; NAME:
+;   FSC_FILESELECT
+;
+; PURPOSE:
+;
+;   The purpose of this compound widget is to provide a means
+;   by which the user can type or select a file name. The
+;   program is written as an "object widget", meaning that
+;   the guts of the program is an object of class FSC_FILESELECT.
+;   This is meant to be an example of the obvious advantages of
+;   writing compound widget programs as objects.
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;   General programming.
+;
+; CALLING SEQUENCE:
+;
+;   filenameID = FSC_FileSelect(parent)
+;
+; INPUT PARAMETERS:
+;
+;   parent -- The parent widget ID of the compound widget. Required.
+;
+; INPUT KEYWORDS:
+;
+;   Event_Pro -- The event handler procedure for this compound widget.By default: "".
+;   Event_Func -- The event handler function for this compound widget. By default: "".
+;
+;      If neither EVENT_PRO or EVENT_FUNC is defined, program events are handled internally by the compound widget.
+;
+;   DirectoryName -- The initial name of the directory. By defaut: current directory.
+;   Filename -- The initial file name in the filename text widget.
+;   Filter -- The file filter. By default: "*".
+;   Frame -- Set this keyword for a frame around the compound widget.
+;   LabelFont -- The font for the label widget. By default: "".
+;   LabelName -- The text on the label widgt. By default: "Filename: ".
+;   LabelSize -- The X screen size of the label widget. By default: 0.
+;   MustExist -- A flag that indicates selected files must exist. By default: 0.
+;   NoMaxSize -- A flag to prohibit automatic text widget sizing. By default: 0.
+;
+;     If this keyword is not set, the compound widget will automatically resize itself to
+;     the largest widget in its parent base widget. It will do this by changing the size of
+;     the text widgets holding the file and directory names.
+;
+;   Read -- Set this keyword to have file selection for reading a file. By default: 1.
+;   SelectDirectory -- The default directory for file selection. In other words, this is the
+;     default directory for DIALOG_PICKFILE, which is accessed via the BROWSE buttons.
+;   SelectFont -- The font for the "Browse" button. By default: "".
+;   SelectTitle -- The title bar text on the file selection dialog. By default: "Select a File...".
+;   TextFont -- The font for the filename text widget. By default: "".
+;   UValue -- User value for any purpose.
+;   Write -- Set this keyword to open a file for writing. By default: 0.
+;   XSize -- The X size of the text widget holding the filename. By default: StrLen(filename) * 1.5 > 40.
+;
+; OUTPUT KEYWORDS:
+;
+;   ObjectRef -- Assign this keyword to an output variable that will hold the internal object reference.
+;                With the object reference you can call object methods to easily change many properties of
+;                the compound widget.
+;
+; COMMON BLOCKS:
+;
+;   None.
+;
+; RESTRICTIONS:
+;
+;   Requires the folling files from the Coyote Library:
+;
+;      http://www.dfanning.com/programs/error_message.pro
+;
+; EVENT STRUCTURE:
+;
+;   All events are handled internally unless either the Event_Pro or Event_Func
+;   keywords are used to assign an event handler to the compound widget. All events
+;   generated by the text widgets are passed to the assigned event handler.
+;
+;   event = { CW_FILESELECT, $     ; The name of the event structure.
+;             ID: 0L, $            ; The ID of the compound widget's top-level base.
+;             TOP: 0L, $           ; The widget ID of the top-level base of the hierarchy.
+;             HANDLER: 0L, $       ; The event handler ID. Filled out by IDL.
+;             Basename: "", $      ; The base filename without directory specifiers.
+;             Filename: "", $      ; The fully qualified filename.
+;             Directory: "", $     ; The name of the current file directory.
+;           }
+;
+; EXAMPLE:
+;
+;   An example program is provided at the end of the FSC_FILESELECT code. To run it,
+;   type these commands:
+;
+;      IDL> .Compile fsc_fileselect
+;      IDL> Example
+;
+;   Or, if you want to obtain the object reference, type this:
+;
+;      IDL> Example, theObject
+;
+;   Now you can call the object's methods. For example:
+;
+;      IDL theObject->SetProperty, XSize=150
+;
+; GETTING and SETTING VALUES:
+;
+;   So as not to disrupt the accepted paradigm in using compound widgets, you
+;   can use the return value of the FSC_FILESELECT function with WIDGET_CONTROL to
+;   get and set the "value" of the widget.
+;
+;       Widget_Control, filenameID, Set_Value='C:\RSI\IDL52\DATA\cyclone.dat'
+;
+;   The program will automatically separate the file name portion of the value
+;   from the directory portion and put things in the correct text widgets.
+;
+;   Similarly, you can get the "value" of the widget:
+;
+;       Widget_Control, filenameID, Get_Value=theValue
+;       Print, theValue
+;
+;           C:\RSI\IDL52\DATA\cyclone.dat
+;
+;   The return value is the fully qualified file path to the file.
+;
+; USING OBJECT METHODS to CHANGE PROGRAM PROPERTIES:
+;
+;   If you obtain the object reference, you have a great deal more control
+;   over the properties of the compound widget. You obtain the object reference
+;   by calling the function like this:
+;
+;      filenameID = FSC_FILESELECT(parent, ObjectRef=theObject)
+;
+; OBJECT PROCEDURE METHODS:
+;
+;   GetProperty -- This method allows various properties of the widget to be
+;       returned via output keywords. The keywords that are available are:
+;
+;      DirectoryName -- The current directory.
+;      Event_Func -- The name of the event handler function for this compound widget.
+;      Event_Pro -- The name of the event handler procedure for this compound widget.
+;      Filename -- The current base filename.
+;      Filter -- The current file filter.
+;      LabelName -- The text on the label widget.
+;      LabelSize -- The X screen size of the label widget.
+;      MustExist -- A flag that indicates selected files must exist to be selected.
+;      Parent -- The parent widget of the compound widget.
+;      Read=read -- The file selection for reading flag.
+;      SelectTitle -- The title bar text on the file selection dialog.
+;      TLB -- The top-level base of the compound widget.
+;      UValue -- The user value of the compound widget.
+;      Write -- The file selection for writing flag.
+;      XSize -- The X size of the text widget holding the filename.
+;
+;   LabelSize -- This method makes sure that the directory name and file name labels
+;      are the same size. Normally, this procedure is called internally. No parameters.
+;
+;   MatchSize -- This method resizes the compound widget so that it is as long as the
+;      the longest widget in the parent base widget. This is done automatically upon
+;      realization unless the NOMAXSIZE keyword is set. The method aids in writing
+;      resizeable widget programs.
+;
+;   SetProperty -- This method allows various properties of the widget to be
+;       set via input keywords. The keywords that are available are:
+;
+;      DirectoryName -- The current directory.
+;      Event_Func -- The name of the event handler function for this compound widget.
+;      Event_Pro -- The name of the event handler procedure for this compound widget.
+;      Filename -- The current base filename.
+;      Filter -- The current file filter.
+;      LabelName -- The text on the label widget.
+;      LabelSize -- The X screen size of the label widget.
+;      MustExist -- A flag that indicates selected files must exist to be selected.
+;      Read -- The file selection for reading flag.
+;      SelectTitle -- The title bar text on the file selection dialog.
+;      UValue -- The user value of the compound widget.
+;      Write -- The file selection for writing flag.
+;      XSize -- The X size of the text widget holding the filename.
+;
+;   TextSelect - Allows you to create a selection in filename text widget. See the
+;                documentation for the SET_TEXT_SELECT keyword to Widget_Control.
+;
+;      selection -- A two-element array containing the starting position and selection length.
+;
+; OBJECT FUNCTION METHODS:
+;
+;      GetFileName -- Returns the fully qualified filename. No parameters.
+;
+;      GetTLB -- Returns the top-level base ID of the compound widget. No Parameters.
+;
+;      Inspect_DirectoryName -- Inspects the directory name for correctness. Requires one positional parameter.
+;
+;        directoryName -- The name of the directory from the directory text widget.
+;        textSelection -- The current text selection position.
+;
+;        At the moment all this does is remove any blank characters from either
+;        end of the directory name and makes sure the last character of the directory
+;        name does not end in a subdirectory specifier (except for VMS).
+;
+;     Inspect_Filename -- Inspects the file name for correctness. Requires one positional parameter.
+;
+;        filename -- The name of the file from the filename text widget.
+;        textSelection -- The current text selection position.
+;
+;        At the moment all this does is remove any blank characters from either
+;        end of the file name
+;
+; MODIFICATION HISTORY:
+;
+;   Written by: David W. Fanning, 21 NOV 1999.
+;   Fixed bug in File Name selection button. 18 MAR 2000. DWF.
+;   Fixed an error in which directory the Browse buttons should start
+;       searching. 29 SEP 2000. DWF.
+;   Previously returned events only for typing in text widgets. Now
+;       Browse button events are also returned. 29 SEP 2000. DWF.
+;   Fixed a bug in setting the file filter. 29 SEP 2000. DWF.
+;   Removed the Directory Browse button 10 AUG 2002. DWF.
+;   Added ERROR_MESSAGE to error handling. 10 AUG 2002. DWF.
+;   Changed the ability to specify a file filter as a string array, instead
+;       of just as a scalar string. This required the use of a pointer, which
+;       meant that I had to remove the FILTER field from the CW_FILESELECT
+;       event structure to avoid likely memory leakage. This is a dangerous
+;       change because it means programs that relied on this (I expect there
+;       are very, very few) will break and it goes against my philosopy of
+;       keeping my programs backward compatible. Let me know if you have
+;       problems. In testing, I discoved no problems in my own code. 31 OCT 2002. DWF.
+;   Fixed a problem with DIALOG_PICKFILE that sometimes allowed users to change
+;       directories without selecting a file. 3 Nov 2002. DWF.
+;   Fixed a problem with widget resizing with the help of Bob Portman that had plagued
+;       me from the beginning. Thanks, Bob! 5 August 2003. DWF
+;   Added TEXTSELECT method. 5 Aug 2003. DWF.
+;   Had to add FORWARD_FUNCTION statement to get error handler compiled when using
+;       DIRECTORY keyword. 24 Nov 2003. DWF.
+;   Fixed a problem with too many events going to an event handler specified with
+;       the EVENT_PRO or EVENT_FUNC keyword from the text widget. Now only Carriage
+;       Return events are passed on to the user-specified event handler. 8 July 2004. DWF.
+;   Replace all "\" characters with "/" characters in directory names. 8 Januay 2006. DWF.
+;-
+;
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright © 2000-2006 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+
+
+
+PRO FSC_FileSelect::Directory_Events, event
+
+; This method handles any typing in the directory name text widget.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message(/Traceback)
+   RETURN
+ENDIF
+
+   ; Don't deal with selection events.
+
+IF event.type EQ 3 THEN RETURN
+
+   ; Inspect the directory name and set it.
+
+Widget_Control, self.dirtextID, Get_Value=dirname
+dirname = dirname[0]
+textSelection = Widget_Info(self.dirtextID, /Text_Select)
+dirname = self->Inspect_DirectoryName(dirname, textSelection[0])
+dirname = StrJoin( StrSplit(dirname, '\\', /Regex, /Extract, /Preserve_Null), '/')
+
+self.directoryname = dirname
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect::Filename_Events, event
+
+; This method handles any typing in the file name text widget.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message(/Traceback)
+   RETURN
+ENDIF
+
+   ; Don't deal with selection events.
+
+IF event.type EQ 3 THEN RETURN
+
+   ; Inspect the file name and set it.
+
+Widget_Control, self.filetextID, Get_Value=filename
+filename = filename[0]
+textSelection = Widget_Info(self.filetextID, /Text_Select)
+filename = self->Inspect_Filename(filename, textSelection[0])
+filename = StrJoin( StrSplit(filename, '\\', /Regex, /Extract, /Preserve_Null), '/')
+self.filename = filename
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect::GetFilename
+
+; This method returns the fully-qualified filename. Checks to be
+; sure the last character in the directory name is not a directory
+; specifier.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN, -1
+ENDIF
+
+   ; Get the correct directory separator.
+
+CASE StrUpCase(!Version.OS_Family) OF
+   'MACOS'   : sep = ':'    ; Macintoshes
+   'VMS'     : sep = ']'    ; VMS machines
+   ELSE      : sep = '/'    ; Unix machines
+ENDCASE
+
+IF StrUpCase(!Version.OS_Family) NE "VMS" THEN BEGIN
+   length = StrLen(self.directoryName)
+   WHILE StrMid(self.directoryName, length-1, 1) EQ sep DO BEGIN
+      self.directoryName = StrMid(self.directoryName, 0, length-1)
+      Widget_Control, self.dirTextID, Set_Value=self.directoryName
+      length = StrLen(self.directoryName)
+   ENDWHILE
+ENDIF
+
+filename = Filepath(Root_Dir=self.directoryName, self.filename)
+filename = StrJoin( StrSplit(filename, '\\', /Regex, /Extract, /Preserve_Null), '/')
+RETURN, filename
+END ;-------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect::GetNoMaxSize
+RETURN, self.nomaxsize
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect::GetProperty, $
+   DirectoryName=dirname, $        ; The current directory.
+   Event_Func=event_func, $        ; The name of the event handler function for this compound widget.
+   Event_Pro=event_pro, $          ; The name of the event handler procedure for this compound widget.
+   Filename=filename, $            ; The current filename.
+   Filter=filter, $                ; The current file filter.
+   LabelName=labelname, $          ; The text on the label widget.
+   LabelSize=labelsize, $          ; The X screen size of the label widget.
+   MustExist=mustexist, $          ; A flag that indicates selected files must exist to be selected.
+   Parent=parent, $                ; The parent widget of the compound widget.
+   Read=read, $                    ; The file selection for reading flag.
+   SelectTitle=selecttitle, $      ; The title bar text on the file selection dialog.
+   TLB=tlb, $                      ; The top-level base of the compound widget.
+   UValue=uvalue, $                ; The user value of the compound widget.
+   Write=write, $                  ; The file selection for writing flag.
+   XSize=xsize                     ; The X size of the text widget holding the filename.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN
+ENDIF
+
+dirname = self.directoryname
+event_pro = self.event_pro
+event_func = self.event_func
+filename = self.filename
+filter = *self.filter
+labelname = self.labelname
+labelsize = self.labelsize
+mustexist = self.mustexist
+parent=self.parent
+read = self.read
+selecttitle = self.selecttitle
+tlb = self.tlb
+uvalue = *self.uvalue
+wirte = self.write
+xsize = self.xsize
+
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect::GetTLB
+RETURN, self.tlb
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect::Inspect_DirectoryName, dirname, textSelection
+
+; This method removes leading and trailing blank characters
+; in the directory name.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN, -1
+ENDIF
+
+thisDir = StrTrim(dirname, 2)
+IF StrLen(thisDir) NE StrLen(dirname) THEN $
+   textSelection = textSelection-( StrLen(dirname) - StrLen(thisDir) )
+Widget_Control, Set_Value=thisDir, self.dirtextID, Set_Text_Select=[textSelection, 0]
+RETURN, thisDir
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect::Inspect_Filename, filename, textSelection
+
+; This method removes leading and trailing blank characters
+; in the filename.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = Error_Message()
+   RETURN, -1
+ENDIF
+
+thisFile = StrTrim(filename, 2)
+IF StrLen(thisFile) NE StrLen(filename) THEN $
+   textSelection = textSelection-( StrLen(filename) - StrLen(thisFile) )
+Widget_Control, Set_Value=thisFile, self.filetextID, Set_Text_Select=[textSelection, 0]
+RETURN, thisFile
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect::LabelSize
+
+; This method ensures the directory and filename labels are the same size.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN
+ENDIF
+
+fgeo = Widget_Info(self.filelabelID, /Geometry)
+dgeo = Widget_Info(self.dirlabelID, /Geometry)
+bestSize = fgeo.scr_xsize > dgeo.scr_xsize
+Widget_Control, self.fileLabelID, Scr_XSize=bestSize
+Widget_Control, self.dirLabelID, Scr_XSize=bestSize
+END ;-------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect::MatchSize
+
+; This method makes the compound widget the same size as the largest
+; widget in the parent base widget. It does this by adjusting
+; the text widget sizes.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN
+ENDIF
+
+   ; Get the geometries of the filename widgets.
+
+tgeo = Widget_Info(self.tlb, /Geometry)
+fgeo = Widget_Info(self.filetextID, /Geometry)
+bbgeo = Widget_Info(self.filebaseID, /Geometry)
+lbgeo = Widget_Info(Widget_Info(self.dirbaseID, /Parent), /Geometry)
+rbgeo = Widget_Info(Widget_Info(self.filebrowseID, /Parent), /Geometry)
+
+   ; Add the bits and bobs together.
+
+fspacing = tgeo.space
+fpadding = 2*tgeo.xpad + 2*lbgeo.xpad
+ffixedsize = ( bbgeo.scr_xsize - 2*bbgeo.margin - (fgeo.scr_xsize) + $
+               rbgeo.scr_xsize - 2*rbgeo.margin )
+
+   ; Get the geometries of the directory name widgets.
+
+fgeo = Widget_Info(self.dirtextID, /Geometry)
+bbgeo = Widget_Info(self.dirbaseID, /Geometry)
+
+   ; Add the bits and bobs together.
+
+dspacing = tgeo.space
+dpadding = 2*tgeo.xpad + 2*lbgeo.xpad
+dfixedsize = ( bbgeo.scr_xsize - 2*bbgeo.margin - (fgeo.scr_xsize) + $
+               rbgeo.scr_xsize - 2*rbgeo.margin )
+
+   ; Go find all the children and find the biggest one of them.
+
+thisSize = 0
+childID = Widget_Info(self.parent, /Child)
+geom = Widget_Info(childID, /Geometry)
+testSize = geom.scr_xsize - 2*geom.margin
+thisSize = thisSize > testSize
+WHILE childID NE 0 DO BEGIN
+   childID = Widget_Info(childID, /Sibling)
+   IF childID GT 0 THEN BEGIN
+      geom = Widget_Info(childID, /Geometry)
+      testSize = geom.scr_xsize - 2*geom.margin
+      thisSize = thisSize > testSize
+   ENDIF
+ENDWHILE
+
+   ; Resize the widgets
+
+ftextsize = thisSize - (fspacing + fpadding + ffixedsize)
+Widget_Control, self.filetextID, Scr_XSize=ftextsize
+
+dtextsize = thisSize - (dspacing + dpadding + dfixedsize)
+Widget_Control, self.dirtextID, Scr_XSize=dtextsize
+
+END ;-------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect_RStrPos, Expr, SubStr, Pos
+
+  ON_ERROR, 2
+  N = N_PARAMS()
+  if (n lt 2) then message, 'Incorrect number of arguments.'
+
+  ; Is expr an array or a scalar? In either case, make a result
+  ; that matches.
+  if (size(expr, /n_dimensions) eq 0) then result = 0 $
+  else result = make_array(dimension=size(expr,/dimensions), /INT)
+
+  RSubStr = STRING(REVERSE(BYTE(SubStr))) ; Reverse the substring
+
+  for i = 0, n_elements(expr) - 1 do begin
+    Len = STRLEN(Expr[i])
+    IF (N_ELEMENTS(Pos) EQ 0) THEN Start=0 ELSE Start = Len - Pos
+
+    RString = STRING(REVERSE(BYTE(Expr[i]))) ; Reverse the string
+
+    SubPos = STRPOS(RString, RSubStr, Start)
+    IF SubPos NE -1 THEN SubPos = Len - SubPos - STRLEN(SubStr)
+    result[i] = SubPos
+  endfor
+
+  RETURN, result
+END ;-------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect::Select_File, event
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN
+ENDIF
+
+; Use the file selection dialog to obtain a filename.
+
+currentFilename = self.filename
+self.filename = ""
+filename = Dialog_Pickfile( File=self.filename, $
+                            Filter=*self.filter, $
+                            Path=self.directoryname, $
+                            Get_Path=thePath, $
+                            Must_Exist=self.mustexist, $
+                            Read=self.read, $
+                            Title=self.selecttitle, $
+                            Write=self.write )
+
+IF filename EQ "" THEN BEGIN
+   self.filename = currentFilename
+   RETURN
+ENDIF
+
+   ; Remove the directory from the name.
+
+index = StrLen(thePath)
+theFilename = StrMid(filename, index)
+
+   ; Strip the last directory separator.
+
+length = StrLen(thePath)
+thePath = StrMid(thePath, 0, length-1)
+
+   ; Inspect the file name to make sure it is valid.
+
+textSelection = Widget_Info(self.filetextID, /Text_Select)
+filename = self->Inspect_Filename(filename, textSelection[0])
+
+   ; Update the display.
+
+self->SetProperty, Filename=theFilename, DirectoryName=thePath
+
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect::SetFilename, theName
+
+; This method separates the filename into directory and filename
+; and adds them to the interface.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN
+ENDIF
+
+; Change back slashes to forward slashes.
+theName = StrJoin( StrSplit(theName, '\\', /Regex, /Extract, /Preserve_Null), '/')
+
+   ; Get the correct directory separator.
+
+CASE StrUpCase(!Version.OS_Family) OF
+   'MACOS'   : sep = ':'    ; Macintoshes
+   'VMS'     : sep = ']'    ; VMS machines
+   ELSE      : sep = '/'    ; Unix machines
+ENDCASE
+
+index = FSC_FileSelect_RStrPos(theName, sep)
+IF index EQ -1 THEN BEGIN
+   self->SetProperty, Filename=theName
+   self.filename = theName
+ENDIF ELSE BEGIN
+   directoryName = StrMid(theName, 0, index)
+   filename = StrMid(theName, index+1)
+   self->SetProperty, Filename=filename, Directory=directoryName
+   self.filename = filename
+   self.directoryName = directoryName
+ENDELSE
+END ;-------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect::SetProperty, $
+   DirectoryName=dirname, $        ; The initial name of the directory. By defaut: current directory.
+   Event_Func=event_func, $        ; The event handler function for this compound widget.
+   Event_Pro=event_pro, $          ; The event handler procedure for this compound widget.
+   Filename=filename, $            ; The initial file name in the filename text widget.
+   Filter=filter, $                ; The file filter.
+   LabelName=labelname, $          ; The text on the label widgt.
+   LabelSize=labelsize, $          ; The X screen size of the label widget.
+   MustExist=mustexist, $          ; A flag that indicates selected files must exist.
+   Read=read, $                    ; Set this keyword to have file selection for reading a file.
+   SelectTitle=selecttitle, $      ; The title bar text on the file selection dialog.
+   UValue=uvalue, $                ; User value for any purpose.
+   Write=write, $                  ; Set this keyword to open a file for writing.
+   XSize=xsize                     ; The X size of the text widget holding the filename.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN
+ENDIF
+
+IF N_Elements(dirname) NE 0 THEN BEGIN
+   dirname = StrJoin( StrSplit(dirname, '\\', /Regex, /Extract, /Preserve_Null), '/')
+   self.directoryname = dirname
+   Widget_Control, self.dirtextID, Set_Value=dirname
+ENDIF
+
+IF N_Elements(event_pro) NE 0 THEN BEGIN
+   self.event_pro = event_pro
+   Widget_Control, self.tlb, Event_Pro=event_pro
+ENDIF
+
+IF N_Elements(event_func) NE 0 THEN BEGIN
+   self.event_func = event_func
+   Widget_Control, self.tlb, Event_Func=event_func
+ENDIF
+
+IF N_Elements(filename) NE 0 THEN BEGIN
+   self.filename = filename
+   strlength = StrLen(filename)
+   Widget_Control, self.filetextID, Set_Value=filename
+ENDIF
+
+IF N_Elements(labelname) NE 0 THEN BEGIN
+   self.labelname = labelname
+   Widget_Control, self.filelabelID, Set_Value=labelname
+ENDIF
+
+IF N_Elements(labelsize) NE 0 THEN BEGIN
+   Widget_Control, self.filelabelID, Scr_XSize=labelsize
+ENDIF
+
+IF N_Elements(filter) NE 0 THEN *self.filter = filter
+IF N_Elements(mustexist) NE 0 THEN self.mustexist = mustexist
+IF N_Elements(read) NE 0 THEN self.read = read
+IF N_Elements(selecttitle) NE 0 THEN self.selecttitle = selecttitle
+IF N_Elements(uvalue) NE 0 THEN *self.uvalue = uvalue
+IF N_Elements(write) NE 0 THEN self.write = write
+
+IF N_Elements(xsize) NE 0 THEN BEGIN
+   Widget_Control, self.filetextID, XSize=xsize
+   Widget_Control, self.dirtextID, XSize=xsize
+ENDIF
+
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect::TextSelect, selection
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN
+ENDIF
+
+IF N_Elements(selection) NE 2 THEN Message, 'Text selection array is not a two-element array: [beginSelection, selectionLength]'
+Widget_Control, self.fileTextID, Set_Text_Select=selection
+
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect::CLEANUP
+Ptr_Free, self.uvalue
+Ptr_Free, self.filter
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect::INIT, $
+   parent, $                       ; The parent widget ID of the compound widget.
+   DirectoryName=dirname, $        ; The initial name of the directory. By defaut: current directory.
+   Event_Pro=event_pro, $          ; The event handler procedure for this compound widget.By default: "".
+   Event_Func=event_func, $        ; The event handler function for this compound widget. By default: "".
+   Filename=filename, $            ; The initial file name in the filename text widget.
+   Filter=filter, $                ; The file filter. By default: "*".
+   Frame=frame, $                  ; Set this keyword for a frame around the compound widget.
+   LabelFont=labelfont, $          ; The font for the label widget. By default: "".
+   LabelName=labelname, $          ; The text on the label widgt. By default: "Filename: ".
+   LabelSize=labelsize, $          ; The X screen size of the label widget. By default: 0.
+   MustExist=mustexist, $          ; A flag that indicates selected files must exist. By default: 0.
+   NoMaxSize=nomaxsize, $          ; A flag to prohibit automatica text widget sizing. By default: 0.
+   Read=read, $                    ; Set this keyword to have file selection for reading a file. By default: 1.
+   Scr_XSize=scr_xsize, $          ; The X screen size of the compound widget. By default: 0
+   SelectFont=selectfont, $        ; The font for the "Browse" button. By default: "".
+   Selectdir=selectdir, $          ; The inital directory for file and directory selections.
+   SelectTitle=selecttitle, $      ; The title bar text on the file selection dialog. By default: "Select a File...".
+   TextFont=textfont, $            ; The font for the filename text widget. By default: "".
+   UValue=uvalue, $                ; User value for any purpose.
+   Write=write, $                  ; Set this keyword to open a file for writing. By default: 0.
+   XSize=xsize                     ; The X size of the text widget holding the filename. By default: StrLen(filename) * 1.5 > 40.
+
+Catch, theError
+;theError = 0
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = Error_Message()
+   RETURN, 0
+ENDIF
+
+   ; Populate self object.
+
+self.parent = parent
+self.directoryname = dirname
+self.event_pro = event_pro
+self.event_func = event_func
+self.filename = filename
+self.filter = Ptr_New(filter)
+self.frame = frame
+self.labelfont = labelfont
+self.labelname = labelname
+self.labelsize = labelsize
+self.mustexist = mustexist
+self.nomaxsize = nomaxsize
+self.read = read
+self.selectdir = selectdir
+self.selectfont = selectfont
+self.selecttitle = selecttitle
+self.textfont = textfont
+self.uvalue = Ptr_New(uvalue)
+self.write = write
+self.xsize = xsize
+
+
+   ; Build widgets.
+
+self.tlb = Widget_Base( self.parent, $
+                        Event_Func = self.event_func, $
+                        Event_Pro = self.event_pro, $
+                        Frame = self.frame, $
+                        Func_Get_Value='FSC_FileSelect_Get_Value', $
+                        Pro_Set_Value='FSC_FileSelect_Set_Value', $
+                        Row = 1, $
+                        Base_Align_Center=1, $
+                        UValue=*self.uvalue )
+
+   ; Put the self object in the first child of the TLB.
+
+leftbase = Widget_Base(self.tlb, Row=2, UValue=self)
+
+self.dirbaseID = Widget_Base(leftbase, Row=1)
+
+self.dirlabelID = Widget_Label( self.dirbaseID, $
+                             Font=self.labelfont, $
+                             Scr_XSize=self.labelsize, $
+                             Value='Directory: ' )
+
+
+self.dirtextID = Widget_Text( self.dirbaseID, $
+                           All_Events=1, $
+                           Editable=1, $
+                           Event_Func='FSC_FileSelect_Event_Handler', $
+                           Font=self.textfont, $
+                           UValue={method:'Directory_Events', object:self}, $
+                           Value=self.directoryname, $
+                           XSize=self.xsize, $
+                           YSize=1 )
+
+
+self.filebaseID = Widget_Base(leftbase, Row=1)
+
+self.filelabelID = Widget_Label( self.filebaseID, $
+                             Font=self.labelfont, $
+                             Kill_Notify='FSC_FileSelect_Kill_Notify', $
+                             Notify_Realize='FSC_FileSelect_Notify_Realize', $
+                             Scr_XSize=self.labelsize, $
+                             UValue=self, $
+                             Value=self.labelname )
+
+
+self.filetextID = Widget_Text( self.filebaseID, $
+                           All_Events=1, $
+                           Editable=1, $
+                           Event_Func='FSC_FileSelect_Event_Handler', $
+                           Font=self.textfont, $
+                           UValue={method:'Filename_Events', object:self}, $
+                           Value=self.filename, $
+                           XSize=self.xsize, $
+                           YSize=1 )
+
+rightbase = Widget_Base(self.tlb, Row=1, Base_Align_Center=1)
+self.filebrowseID = Widget_Button( rightbase, $
+                               Event_Func='FSC_FileSelect_Event_Handler', $
+                               UValue={method:'Select_File', object:self}, $
+                               Value='Browse')
+
+
+RETURN, 1
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect__Define
+
+   objectClass = { FSC_FileSelect, $      ; The object class FSC_FILESELECT.
+                   parent: 0L, $          ; The ID of the parent widget.
+                   tlb: 0L, $             ; The ID of the top-level base widget for the compound widget.
+                   filebaseID: 0L, $      ; The ID of the filename base widget.
+                   dirbaseID: 0L, $       ; The ID of the directory base widget.
+                   filelabelID: 0L, $     ; The ID of the filename label widget.
+                   dirlabelID: 0L, $      ; The ID of the directory label widget.
+                   filetextID: 0L, $      ; The ID of the filename text widget.
+                   dirtextID: 0L, $       ; The ID of the directory text widget.
+                   filebrowseID: 0L, $    ; The ID of the file browse button widget.
+                   dirbrowseID: 0L, $     ; Unused currently. Left here for compatibility reasons..
+                   event_pro: "", $       ; The user-defined name of the event procedure for the widget.
+                   event_func: "", $      ; The user-defined name of the event function for the widget.
+                   filename: "", $        ; The current contents of the filename text widget.
+                   directoryname: "", $   ; The current contents of the directory text widget.
+                   frame: 0L, $           ; A flag to indicate a frame around the compound widget.
+                   filter: Ptr_New(), $   ; The current file filter used in file selection.
+                   labelfont: "", $       ; The font for the label widgets.
+                   labelname: "", $       ; The VALUE of the file name label widget.
+                   labelsize: 0L, $       ; The X screen size fo the label widgets.
+                   mustexist: 0L, $       ; If this field is 1, the user can only select files that exist.
+                   nomaxsize: 0L, $       ; This widget sizes itself to the largest widget in the base, unless this is set.
+                   read: 0L, $            ; Set this keyword to select a file for reading.
+                   selectdir: "", $       ; The inital directory used for file selection.
+                   selectfont: "", $      ; The font used for the Browse buttons.
+                   selecttitle: "", $     ; The text on the Dialog_Pickfile widget.
+                   textfont: "", $        ; The font used in the text widgets.
+                   uvalue: Ptr_New(), $   ; The user's user value. Unused by the program.
+                   write: 0L, $           ; Set this keyword to select a file for writing.
+                   xsize: 0L $            ; The X size of the text widgets.
+                 }
+
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect_Set_Value, id, filename
+
+; This function sets the filename of the widget, using the
+; traditional "Widget_Control, fieldID, Set_Value=filename" syntax.
+; The directory will be stripped off the filename, if required.
+
+firstChild = Widget_Info(id, /Child)
+Widget_Control, firstChild, Get_UValue=self
+self->SetFilename,filename
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect_Get_Value, id
+
+; This function returns the filename of the widget, using the
+; traditional "Widget_Control, fieldID, Get_Value=filename" syntax.
+
+firstChild = Widget_Info(id, /Child)
+Widget_Control, firstChild, Get_UValue=self
+RETURN, self->GetFilename()
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO CW_FileSelect__Define
+
+; The event structure definition. This is the event structure returned by the compound widget.
+
+   eventStructure = { CW_FileSelect, $     ; The name of the event structure.
+                      ID: 0L,  $           ; The ID of the top-level base of the compound widget.
+                      TOP: 0L, $           ; The ID of the top-level base.
+                      HANDLER: 0L, $       ; The ID of the event handler widget.
+                      Filename: "", $      ; The fully qualified file name.
+                      Basename: "", $      ; The base file name without directory attached.
+                      Directory: "" }      ; The file directory.
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect_Event_Handler, event
+
+; The main event handler for the compound widget. It reacts
+; to "messages" in the UValues of widgets that generate events.
+; The messages indicate which object method to call. A message
+; consists of an object method and the self object reference.
+
+Widget_Control, event.ID, Get_UValue=theMessage
+
+Call_Method, theMessage.method, theMessage.object, event
+
+   ; Events will be sent only if there is an assigned event handler.
+
+self = theMessage.object
+self->GetProperty, Filename=filename, DirectoryName=directory, $
+   Event_Pro=event_pro, Event_Func=event_func
+IF event_pro NE "" OR event_func NE "" THEN BEGIN
+
+    pseudoevent = {CW_FileSelect, self->GetTLB(), event.top, 0L, $
+      Filepath(Root_Dir=directory, filename),  filename, directory}
+
+    ; Don't return events from text widgets, unless the user has typed
+    ; a cariage return.
+    eventName = Tag_Names(event, /Structure_Name)
+    IF eventName NE "" THEN BEGIN
+
+       IF StrMid(eventName, 0, 11) EQ 'WIDGET_TEXT' THEN BEGIN
+          IF (eventName EQ 'WIDGET_TEXT_CH') THEN BEGIN
+            IF (event.ch EQ 10) THEN RETURN, pseudoevent ELSE RETURN, 0
+          ENDIF ELSE RETURN, 0
+       ENDIF
+    ENDIF
+    RETURN, pseudoevent
+ENDIF ELSE RETURN, 0
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+PRO FSC_FileSelect_Notify_Realize, labelID
+
+; When the compound widget is realized, make sure sizes are correct.
+
+Widget_Control, labelID, Get_UValue=self
+IF self->GetNoMaxSize() THEN RETURN
+self->Matchsize
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_FileSelect_Kill_Notify, labelID
+
+; When the compound widget dies, destroy the self object.
+
+Widget_Control, labelID, Get_UValue=self
+Obj_Destroy, self
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_FileSelect, $
+   parent, $                       ; The parent widget ID of the compound widget.
+   Event_Pro=event_pro, $          ; The event handler procedure for this compound widget.By default: "".
+   Event_Func=event_func, $        ; The event handler function for this compound widget. By default: "".
+   DirectoryName=dirname, $        ; The initial name of the directory. By defaut: current directory.
+   Filename=filename, $            ; The initial file name in the filename text widget.
+   Filter=filter, $                ; The file filter. By default: "*".
+   Frame=frame, $                  ; Set this keyword for a frame around the compound widget.
+   LabelFont=labelfont, $          ; The font for the label widget. By default: "".
+   LabelName=labelname, $          ; The text on the label widgt. By default: "Filename: ".
+   LabelSize=labelsize, $          ; The X screen size of the label widget. By default: 0.
+   MustExist=mustexist, $          ; A flag that indicates selected files must exist. By default: 0.
+   NoMaxSize=nomaxsize, $          ; A flag to prohibit automatica text widget sizing. By default: 0.
+   ObjectRef=objectref, $          ; An output keyword containing the object reference.
+   Read=read, $                    ; Set this keyword to have file selection for reading a file. By default: 1.
+   SelectDirectory=selectdir, $    ; The default directory for file selection.
+   SelectFont=selectfont, $        ; The font for the "Browse" button. By default: "".
+   SelectTitle=selecttitle, $      ; The title bar text on the file selection dialog. By default: "Select a File...".
+   TextFont=textfont, $            ; The font for the filename text widget. By default: "".
+   UValue=uvalue, $                ; User value for any purpose.
+   Write=write, $                  ; Set this keyword to open a file for writing. By default: 0.
+   XSize=xsize                     ; The X size of the text widget holding the filename. By default: StrLen(filename) * 1.5 > 40.
+
+Catch, theError
+;theError = 0
+IF theError NE 0 THEN BEGIN
+   ok = Error_Message()
+   RETURN, 0
+ENDIF
+
+   ; Need a parent parameter.
+
+IF N_Elements(parent) EQ 0 THEN BEGIN
+   ok = Dialog_Message('FSC_FILESELECT: A parent parameter is required.')
+   RETURN, -1
+ENDIF
+
+   ; Check keyword arguments.
+
+IF N_Elements(dirname) EQ 0 THEN CD, Current=dirname
+dirname = StrJoin( StrSplit(dirname, '\\', /Regex, /Extract, /Preserve_Null), '/')
+IF N_Elements(event_pro) EQ 0 THEN event_pro = ""
+IF N_Elements(event_func) EQ 0 THEN event_func = ""
+IF N_Elements(filename) EQ 0 THEN filename = ""
+IF N_Elements(filter) EQ 0 THEN filter = '*'
+IF N_Elements(Frame) EQ 0 THEN Frame = 0
+IF N_Elements(labelfont) EQ 0 THEN labelfont = ""
+IF N_Elements(labelname) EQ 0 THEN labelname = "Filename: "
+IF N_Elements(labelsize) EQ 0 THEN labelsize = 0
+IF N_Elements(mustexist) EQ 0 THEN mustexist = 0
+IF N_Elements(nomaxsize) EQ 0 THEN nomaxsize = 0
+IF N_Elements(read) EQ 0 THEN read = 0
+IF N_Elements(selectdir) EQ 0 THEN selectdir = dirname
+IF N_Elements(selectfont) EQ 0 THEN selectfont = ""
+IF Keyword_Set(read) EQ 0 AND Keyword_Set(write) EQ 0 AND $
+   N_Elements(selecttitle) EQ 0 THEN selecttitle = "Select a File..." ELSE selecttitle = ""
+IF N_Elements(textfont) EQ 0 THEN textfont = ""
+IF N_Elements(uvalue) EQ 0 THEN uvalue = ""
+IF N_Elements(write) EQ 0 THEN write = 0
+IF N_Elements(xsize) EQ 0 THEN xsize = Long(StrLen(dirname) * 1.20 > 40)
+
+   ; Create the underlying structure.
+
+objectref = Obj_New('FSC_FileSelect', $
+   parent, $
+   DirectoryName=dirname, $
+   Event_Pro=event_pro, $
+   Event_Func=event_func, $
+   Filename=filename, $
+   Filter=filter, $
+   Frame=frame, $
+   LabelFont=labelfont, $
+   LabelName=labelname, $
+   LabelSize=labelsize, $
+   MustExist=mustexist, $
+   NoMaxSize=nomaxsize, $
+   Read=read, $
+   Scr_XSize=scr_xsize, $
+   SelectFont=selectfont, $
+   SelectTitle=selecttitle, $
+   Selectdir=selectdir, $
+   TextFont=textfont, $
+   UValue=uvalue, $
+   Write=write, $
+   XSize=xsize )
+
+   ; Return the ID of the top-level base of the compound widget.
+
+  RETURN, objectref->GetTLB()
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO Example_Set_Size, event
+Widget_Control, event.top, Get_UValue=theObject
+theObject->MatchSize
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO Example_Set_Filter, event
+Widget_Control, event.top, Get_UValue=theObject
+theObject->SetProperty, Filter='*.pro', Filename='cyclone.pro'
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO Example_Set_Filename, event
+Widget_Control, event.top, Get_UValue=theObject
+filename = Filepath(Subdir=['examples', 'data'], 'worldelv.dat')
+theObject->SetFilename, filename
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO Example_Shrink, event
+Widget_Control, event.top, Get_UValue=theObject
+theObject->SetProperty, XSize=40
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO Example_Print_Filename, event
+Widget_Control, event.top, Get_UValue=theObject
+Print, theObject->GetFilename()
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO Example_Quit, event
+Widget_Control, event.top, /Destroy
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
+
+
+PRO Example, theObject
+
+tlb = Widget_Base(Title='Exercise FSC_FILESELECT...', Column=1)
+button = Widget_Button(tlb, Value='Make Compound Widget As Big As Me', $
+   Event_Pro='Example_Set_Size', Scr_XSize=500)
+button = Widget_Button(tlb, Value='Set Filename to worldelv.data in Data Directory', $
+   Event_Pro='Example_Set_Filename')
+button = Widget_Button(tlb, Value='Print Filename', $
+   Event_Pro='Example_Print_Filename')
+button = Widget_Button(tlb, Value="Shrink the Text Fields", $
+   Event_Pro='Example_Shrink')
+CD, Current=thisDir
+filenameID = FSC_FileSelect(tlb, Directory=thisDir, Filename='fileselect.pro', $
+   /NoMaxSize, ObjectRef=theObject)
+button = Widget_Button(tlb, Value='Quit', Event_Pro='Example_Quit')
+Widget_Control, tlb, /Realize, Set_UValue=theObject
+XManager, 'example', tlb, /No_Block
+END ;-----------------------------------------------------------------------------------------------------------------------------
+
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_plotwindow.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_plotwindow.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_plotwindow.pro	(revision 1185)
@@ -0,0 +1,1085 @@
+;+
+; NAME:
+;   FSC_PLOTWINDOW
+;
+; PURPOSE:
+;
+;   The purpose of this compound widget is to create a resizeable
+;   "plot window" inside a larger "page window". I'm not sure it
+;   has any value except as a utility routine for the PostScript
+;   configuration object FSC_PSCONFIG__DEFINE, but it's a neat
+;   program anyway. :-)
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;   Utility routine for FSC_PSCONFIG__DEFINE.
+;
+; CALLING SEQUENCE:
+;
+;   plotwindowObject = CW_PlotWindow(parent)
+;
+; REQUIRED INPUT PARAMETERS:
+;
+;   parent - The parent base widget of this compound widget.
+;
+; RETURN VALUE:
+;
+;   plotwindowObject - The object reference of the compound widget.
+;
+; KEYWORDS:
+;
+;   COLOR - If set, display the window in "color". This is the default on 24-bit devices.
+;   DEBUG - Set this keyword to turn traceback error handling on in the error handling code.
+;   EVENT_PRO - The event procedure for the widget. Required for events to be generated. Otherwise, all events are handled internally.
+;   LANDSCAPE - If set, display the page in landscape mode. Otherwise the page is display in portrait mode.
+;   PAGESIZE - The "pagesize" of the widget. Possible values are: "LETTER", "LEDGER", "LEGAL", "A4", and "DISPLAY".
+;   UNITS - A string indicating INCHES or CENTIMETER units. DEVICE units represented by a null string, "".
+;   UVALUE - A user value for the caller of this program.
+;   WINDOWCOLOR - A three-element array specifying the background window color (RGB).
+;   WINDOWSIZE - The size of the "window" on the page. A four-element array of normalized coordinates in the form [x0, y0, x1, y1].
+;
+; EVENT STRUCTURE:
+;
+;   The event structure that is returned from this compound widget is defined like this,
+;   where the sizes and offsets locate the target "window" on the page in normalized units:
+;
+;      event = {ID:0L, TOP:0L, HANDLER:0L, XSize:0.0, YSize:0.0, XOffset:0.0, YOffset:0.0}
+;
+; MODIFICATIONS:
+;
+;   Written by David Fanning, 31 January 2000.
+;   Fixed a small bug that prevented it working on Macintosh computers. 26 Sept 2000. DWF.
+;   Added a "DISPLAY" page size, so the program can be used to position
+;      plots and other graphics in a display window. The "page area" will
+;      have the same aspect ratio is the current graphics window. 17 March 2001. DWF.
+;   Changed some of the tolerances for "closeness" from 0.1 to 0.025 to allow smaller
+;      sizing for colorbars and other small objects. 6 July 2005. DWF.
+;-
+;
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright © 2000-2001 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+;
+
+
+FUNCTION FSC_PLOTWINDOW_Error_Message, theMessage, Traceback=traceback, NoName=noName
+
+On_Error, 2
+
+   ; Check for presence and type of message.
+
+IF N_Elements(theMessage) EQ 0 THEN theMessage = !Error_State.Msg
+s = Size(theMessage)
+messageType = s[s[0]+1]
+IF messageType NE 7 THEN BEGIN
+   Message, "The message parameter must be a string."
+ENDIF
+
+   ; Get the call stack and the calling routine's name.
+
+Help, Calls=callStack
+callingRoutine = (StrSplit(StrCompress(callStack[1])," ", /Extract))[0]
+
+   ; Are widgets supported? Doesn't matter in IDL 5.3 and higher.
+
+widgetsSupported = ((!D.Flags AND 65536L) NE 0) OR Float(!Version.Release) GE 5.3
+IF widgetsSupported THEN BEGIN
+   IF Keyword_Set(noName) THEN answer = Dialog_Message(theMessage) ELSE BEGIN
+      IF StrUpCase(callingRoutine) EQ "$MAIN$" THEN answer = Dialog_Message(theMessage) ELSE $
+         answer = Dialog_Message(StrUpCase(callingRoutine) + ": " + theMessage)
+   ENDELSE
+ENDIF ELSE BEGIN
+      Message, theMessage, /Continue, /NoPrint, /NoName, /NoPrefix
+      Print, '%' + callingRoutine + ': ' + theMessage
+      answer = 'OK'
+ENDELSE
+
+   ; Provide traceback information if requested.
+
+IF Keyword_Set(traceback) THEN BEGIN
+   Help, /Last_Message, Output=traceback
+   FOR j=0,N_Elements(traceback)-1 DO Print, traceback[j]
+ENDIF
+
+RETURN, answer
+END ;----------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PLOTWINDOW_Normalize, range, Position=position
+
+On_Error, 1
+IF N_Params() EQ 0 THEN Message, 'Please pass range vector as argument.'
+
+IF (N_Elements(position) EQ 0) THEN position = [0.0, 1.0] ELSE $
+    position=Float(position)
+range = Float(range)
+
+scale = [((position[0]*range[1])-(position[1]*range[0])) / $
+    (range[1]-range[0]), (position[1]-position[0])/(range[1]-range[0])]
+
+RETURN, scale
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::Refresh
+self.theWindow->Draw, self.theView
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::SetWindowColor, theColor
+
+; Set the background color of the view.
+
+self.theView->SetProperty, Color=theColor
+self.theWindow->Draw, self.theView
+END ;----------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PLOTWINDOW::GetUValue
+
+; Get the user value of the compound widget.
+
+parent = Widget_Info(self.drawID, /Parent)
+Widget_Control, parent, Get_UValue=theValue
+RETURN, theValue
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::SetColor, on_off
+
+; Sets the color of the plot window. Different colors
+; depending on depth of visual class.
+
+IF on_off THEN BEGIN
+   self.theBackground->SetProperty, Color=[255,255,150]
+   self.thePlot->SetProperty, Color=[255, 0, 0]
+ENDIF ELSE BEGIN
+   Device, Get_Visual_Depth=theDepth
+   IF theDepth GT 8 THEN backColor = [210, 200, 180] ELSE backColor = [220, 220, 220]
+   self.theBackground->SetProperty, Color=backColor
+   self.thePlot->SetProperty, Color=[0, 0, 0]
+ENDELSE
+
+   ; Draw the view.
+
+IF Obj_Valid(self.theWindow) THEN self.theWindow->Draw, self.theView
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::SetUnits, units
+
+; Sets the type of units to report in.
+
+possibleUnits = ["INCHES", "CENTIMETERS", ""]
+units = StrUpCase(units)
+index = WHERE(possibleUnits EQ units, count)
+IF count EQ 0 THEN BEGIN
+   ok = Dialog_Message('Unknown units: ' + units + '. Returning...')
+   RETURN
+ENDIF
+self.units = units
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::GetWindowLocation, xsize, ysize, xoffset, yoffset
+
+; Returns the current size and offsets of the plot window in
+; units of inches or centimeters, as appropriate.
+
+xsize = self.xlength
+ysize = self.ylength
+xoffset = self.x1
+yoffset = self.y1
+
+factor = Float(self.pixels_per_inch)
+
+CASE self.units OF
+   'INCHES': BEGIN
+      xsize_in_pixels = (xsize * self.xsize)
+      ysize_in_pixels = (ysize * self.ysize)
+      xoff_in_pixels = (xoffset * self.xsize)
+      yoff_in_pixels = (yoffset * self.ysize)
+      xsize = (xsize_in_pixels / factor)
+      ysize = (ysize_in_pixels / factor)
+      xoffset = (xoff_in_pixels / factor)
+      yoffset = (yoff_in_pixels / factor)
+      ENDCASE
+   'CENTIMETERS': BEGIN
+      xsize_in_pixels = (xsize * self.xsize)
+      ysize_in_pixels = (ysize * self.ysize)
+      xoff_in_pixels = (xoffset * self.xsize)
+      yoff_in_pixels = (yoffset * self.ysize)
+      xsize = (xsize_in_pixels / factor * 2.54)
+      ysize = (ysize_in_pixels / factor * 2.54)
+      xoffset = (xoff_in_pixels / factor * 2.54)
+      yoffset = (yoff_in_pixels / factor * 2.54)
+      ENDCASE
+   "" :
+   ELSE: ok = Dialog_Message('Unknown units: ' + self.units + '. Returning...')
+ENDCASE
+
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::SetWindowLocation, xsize, ysize, xoffset, yoffset
+
+; Sets the location of the plot window in the view.
+; Converts inches or centimeters to pixels.
+
+factor = Float(self.pixels_per_inch)
+
+CASE self.units OF
+   'INCHES': BEGIN
+      xsize_in_pixels = (xsize * factor)
+      ysize_in_pixels = (ysize * factor)
+      xoff_in_pixels = (xoffset * factor)
+      yoff_in_pixels = (yoffset * factor)
+      x1 = 0.0 > (xoff_in_pixels / self.xsize) < 0.85
+      y1 = 0.0 > (yoff_in_pixels / self.ysize) < 0.85
+      x2 = (x1 + (xsize_in_pixels / self.xsize)) < 1.0
+      y2 = (y1 + (ysize_in_pixels / self.ysize)) < 1.0
+      ENDCASE
+   'CENTIMETERS': BEGIN
+      xsize_in_pixels = (xsize * factor / 2.54)
+      ysize_in_pixels = (ysize * factor / 2.54)
+      xoff_in_pixels = (xoffset * factor / 2.54)
+      yoff_in_pixels = (yoffset * factor / 2.54)
+      x1 = 0.0 > (xoff_in_pixels / self.xsize) < 0.85
+      y1 = 0.0 > (yoff_in_pixels / self.ysize) < 0.85
+      x2 = (x1 + (xsize_in_pixels / self.xsize)) < 1.0
+      y2 = (y1 + (ysize_in_pixels / self.ysize)) < 1.0
+      ENDCASE
+   "" :
+   ELSE: ok = Dialog_Message('Unknown units: ' + self.units + '. Returning...')
+ENDCASE
+
+self.xlength = x2 - x1
+self.ylength = y2 - y1
+self.x1 = x1
+self.x2 = x2
+self.y1 = y1
+self.y2 = y2
+self->SetWindowSize, [x1, y1, x2, y2]
+
+END ;----------------------------------------------------------------------------------
+
+PRO FSC_PLOTWINDOW::SetWindowSize, position
+
+; Set the size of the plot window. Axes have to be
+; rescaled appropriately.
+
+IF N_Elements(position) EQ 0 THEN position = [0.2, 0.2, 0.8, 0.8]
+
+x1 = position[0]
+y1 = position[1]
+x2 = position[2]
+y2 = position[3]
+
+new = FltArr(2,5)
+new[0,*] = [x1, x1, x2, x2, x1]
+new[1,*] = [y1, y2, y2, y1, y1]
+
+   ; Modify the graphics objects.
+
+self.theBackground->SetProperty, Data=new
+xs = FSC_PlotWindow_Normalize([0,100], Position=[new[0,0]+0.05, new[0,2]-0.05])
+ys = FSC_PlotWindow_Normalize([-1,1], Position=[new[1,0]+0.05, new[1,1]-0.05])
+
+self.theXAxis->SetProperty, XCoord_Conv=xs, Location=[1000, new[1,0]+0.05, 0]
+self.theYAxis->SetProperty, YCoord_Conv=ys, Location=[new[0,0]+.05, 1000, 0]
+self.thePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys
+self.x1 = new[0,0]
+self.x2 = new[0,2]
+self.y1 = new[1,0]
+self.y2 = new[1,1]
+self.xlength = self.x2 - self.x1
+self.ylength = self.y2 - self.y1
+
+   ; Draw the view after resetting the transformation matrix.
+
+self.theModel->Reset
+self.theWindow->Draw, self.theView
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::SetPageSize, pagesize, Landscape=landscape, TLB=tlb
+
+; Sets the page size of the window.
+
+; 200 pixels = 11 inches.
+; Letter 8.5 x 11.
+; Ledger 11 x 17.
+; Legal 8.5 x 14.
+; A4 8.27 x 11.7.
+
+STANDARD_SIZE = self.pixels_per_inch * 11.0
+
+IF N_Elements(pagesize) EQ 0 THEN pagesize = "LETTER"
+pagesize = StrUpCase(pagesize)
+IF N_Elements(tlb) EQ 0 THEN tlb = self.base
+
+CASE pagesize OF
+   'LETTER': BEGIN
+         xsize = STANDARD_SIZE * (8.5/11.0)
+         ysize = STANDARD_SIZE
+      ENDCASE
+   'LEDGER': BEGIN
+         xsize = STANDARD_SIZE
+         ysize = STANDARD_SIZE * (17.0/11.0)
+      ENDCASE
+   'LEGAL': BEGIN
+         xsize = STANDARD_SIZE * (8.5/11.0)
+         ysize = STANDARD_SIZE * (14.0/11.0)
+      ENDCASE
+   'A4': BEGIN
+         xsize = STANDARD_SIZE * (8.27/11.0)
+         ysize = STANDARD_SIZE * (11.7/11.0)
+      ENDCASE
+   'DISPLAY': BEGIN
+         xsize = 300
+         ratio = Float(!D.Y_Size) / !D.X_Size
+         ysize = 300 * ratio
+      ENDCASE
+   ELSE: BEGIN
+         ok = Dialog_Message('Unknown page size: ' + pagesize + '. Returning...')
+         RETURN
+      ENDCASE
+ENDCASE
+
+IF Keyword_Set(landscape) THEN BEGIN
+   temp = xsize
+   xsize = ysize
+   ysize = temp
+ENDIF
+
+self.xsize = ROUND(xsize)
+self.ysize = ROUND(ysize)
+self.pagesize = pagesize
+
+   ; Bugs in X windows implementation of window resizing necessitate
+   ; destroying and re-creating the draw widget window.
+
+IF !D.Name NE 'X' THEN BEGIN
+
+   self.theWindow->SetProperty, Dimensions=[xsize, ysize]
+
+ENDIF ELSE BEGIN
+
+   Widget_Control, tlb, Update=0
+   Widget_Control, self.drawID, Kill_Notify=""
+   Widget_Control, self.drawID, /Destroy
+   self.drawID = Widget_Draw(self.base, Button_Events=1, Expose_Events=1, $
+      Retain=0, Graphics_Level=2, XSize=xsize, YSize=ysize, $
+      Event_Pro='FSC_PLOTWINDOW_Events', UValue=self, Renderer=1, $
+      Kill_Notify='FSC_PLOTWINDOW_Kill_Notify', Motion_Events=1)
+   Widget_Control, self.drawID, /Realize
+   Widget_Control, self.drawID, Get_Value=theWindow
+   self.theWindow = theWindow
+   Widget_Control, tlb, Update=1
+
+ENDELSE
+
+self.thewindow->Draw, self.theView
+
+END ;----------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PLOTWINDOW::GetPagePixels, pagesize, Landscape=landscape
+
+; Given the page size or type, returns the xsize and ysize
+; of the draw widget in pixels.
+
+; 198 pixels = 11 inches.
+; Letter 8.5 x 11.
+; Ledger 11 x 17.
+; Legal 8.5 x 14.
+; A4 8.27 x 11.7.
+
+STANDARD_SIZE = self.pixels_per_inch * 11.0
+
+IF N_Elements(pagesize) EQ 0 THEN pagesize = "LETTER"
+pagesize = StrUpCase(pagesize)
+
+CASE pagesize OF
+   'LETTER': BEGIN
+         xsize = STANDARD_SIZE * (8.5/11.0)
+         ysize = STANDARD_SIZE
+      ENDCASE
+   'LEDGER': BEGIN
+         xsize = STANDARD_SIZE
+         ysize = STANDARD_SIZE * (17.0/11.0)
+      ENDCASE
+   'LEGAL': BEGIN
+         xsize = STANDARD_SIZE * (8.5/11.0)
+         ysize = STANDARD_SIZE * (14.0/11.0)
+      ENDCASE
+   'A4': BEGIN
+         xsize = STANDARD_SIZE * (8.27/11.0)
+         ysize = STANDARD_SIZE * (11.7/11.0)
+      ENDCASE
+   'DISPLAY': BEGIN
+         xsize = 300
+         ratio = Float(!D.Y_Size) / !D.X_Size
+         ; Check for *very* strange windows.
+         IF ratio LT 0.2 THEN ratio = 1.0
+         IF ratio GT 5 THEN ratio = 1.0
+         ysize = 300 * ratio
+      ENDCASE
+ENDCASE
+
+IF Keyword_Set(landscape) THEN BEGIN
+   temp = xsize
+   xsize = ysize
+   ysize = temp
+ENDIF
+
+RETURN, [ROUND(xsize), ROUND(ysize)]
+
+END ;----------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PLOTWINDOW::GetPosition
+
+; Returns the current position of the plot window in
+; the view. Normalized coordinates.
+
+RETURN, [self.x1, self.y1, self.x2, self.y2]
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::Resize, event, direction
+
+; Performs window resizing, depending upon which of eight
+; possible directions you can move the window.
+
+IF direction EQ 'NONE' OR direction EQ 'MOVE' THEN BEGIN
+   RETURN
+ENDIF
+
+   ; Calculate movement in normalized coordinates. Update start coords.
+
+deltax = (event.x - self.currentX) / self.xsize
+deltay = (event.y - self.currentY) / self.ysize
+self.currentX = event.x
+self.currentY = event.y
+
+CASE direction OF
+   'SE': BEGIN
+         x1 = self.x1
+         x2 = (self.x2 + deltax) < 1.0
+         y1 = (self.y1 + deltay) > 0.0
+         y2 = self.y2
+         IF x2 LE x1 + 0.025 THEN x2 = x1 + 0.025
+         IF y1 GE y2 - 0.025 THEN y1 = y2 - 0.025
+         END
+   'E' : BEGIN
+         x1 = self.x1
+         x2 = (self.x2 + deltax) < 1.0
+         y1 = self.y1
+         y2 = self.y2
+         IF x2 LE x1 + 0.025 THEN x2 = x1 + 0.1
+         END
+   'SW': BEGIN
+         x1 = (self.x1 + deltax) > 0.0
+         x2 = self.x2
+         y1 = (self.y1 + deltay) > 0.0
+         y2 = self.y2
+         IF x1 GE x2 - 0.025 THEN x1 = x2 - 0.025
+         IF y1 GE y2 - 0.025 THEN y1 = y2 - 0.025
+         END
+   'S' : BEGIN
+         x1 = self.x1
+         x2 = self.x2
+         y1 = (self.y1 + deltay) > 0.0
+         y2 = self.y2
+         IF y1 GE y2 - 0.025 THEN y1 = y2 - 0.025
+         END
+   'N' : BEGIN
+         x1 = self.x1
+         x2 = self.x2
+         y1 = self.y1
+         y2 = (self.y2  + deltay) < 1.0
+         IF y2 LE y1 + 0.025 THEN y2 = y1 + 0.025
+         END
+   'NE': BEGIN
+         x1 = self.x1
+         x2 = (self.x2 + deltax) < 1.0
+         y1 = self.y1
+         y2 = (self.y2 + deltay) < 1.0
+         IF x2 LE x1 + 0.025 THEN x2 = x1 + 0.025
+         IF y2 LE y1 + 0.025 THEN y2 = y1 + 0.025
+         END
+   'W' : BEGIN
+         x1 = (self.x1  + deltax) > 0.0
+         x2 = self.x2
+         y1 = self.y1
+         y2 = self.y2
+         IF x1 GE x2 - 0.025 THEN x1 = x2 - 0.025
+         END
+   'NW': BEGIN
+         x1 = (self.x1 + deltax) > 0.0
+         x2 = self.x2
+         y1 = self.y1
+         y2 = (self.y2 + deltay) < 1.0
+         IF x1 GE x2 - 0.025 THEN x1 = x2 - 0.025
+         IF y2 LE y1 + 0.025 THEN y2 = y1 + 0.025
+
+         END
+ENDCASE
+
+new = FltArr(2,5)
+new[0,*] = [x1, x1, x2, x2, x1]
+new[1,*] = [y1, y2, y2, y1, y1]
+
+   ; Modify the graphics objects.
+
+self.theBackground->SetProperty, Data=new
+
+xs = FSC_PlotWindow_Normalize([0,100], Position=[new[0,0]+0.05, new[0,2]-0.05]) > 10e-6
+ys = FSC_PlotWindow_Normalize([-1,1], Position=[new[1,0]+0.05, new[1,1]-0.05]) > 10e-6
+
+self.theXAxis->SetProperty, XCoord_Conv=xs, Location=[1000, new[1,0]+0.05, 0]
+self.theYAxis->SetProperty, YCoord_Conv=ys, Location=[new[0,0]+.05, 1000, 0]
+self.thePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys
+self.x1 = new[0,0]
+self.x2 = new[0,2]
+self.y1 = new[1,0]
+self.y2 = new[1,1]
+self.xlength = self.x2 - self.x1
+self.ylength = self.y2 - self.y1
+
+   ; Draw the view after resetting the transformation matrix.
+
+self.theModel->Reset
+self.theWindow->Draw, self.theView
+
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::CenterPlot, event
+
+   ; Centers the plot in the window.
+
+new = FltArr(2,5)
+self.x1 = (1.0 - self.xlength) / 2.0
+self.x2 = self.x1 + self.xlength
+self.y1 = (1.0 - self.ylength) / 2.0
+self.y2 = self.y1 + self.ylength
+
+new[0,*] = [self.x1, self.x1, self.x2, self.x2, self.x1]
+new[1,*] = [self.y1, self.y2, self.y2, self.y1, self.y1]
+
+   ; Modify the graphics objects.
+
+self.theBackground->SetProperty, Data=new
+
+xs = FSC_PlotWindow_Normalize([0,100], Position=[new[0,0]+0.05, new[0,2]-0.05])
+ys = FSC_PlotWindow_Normalize([-1,1], Position=[new[1,0]+0.05, new[1,1]-0.05])
+
+self.theXAxis->SetProperty, XCoord_Conv=xs, Location=[1000, new[1,0]+0.05, 0]
+self.theYAxis->SetProperty, YCoord_Conv=ys, Location=[new[0,0]+.05, 1000, 0]
+self.thePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys
+self.x1 = new[0,0]
+self.x2 = new[0,2]
+self.y1 = new[1,0]
+self.y2 = new[1,1]
+
+   ; Draw the view after resetting the transformation matrix.
+
+self.theModel->Reset
+self.theWindow->Draw, self.theView
+
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::MovePlot, event
+
+   ; Calculate movement in normalized coordinates. Update start coords.
+
+deltax = (event.x - self.currentX) / self.xsize
+deltay = (event.y - self.currentY) / self.ysize
+self.currentX = event.x
+self.currentY = event.y
+
+   ; Translate the selected model.
+
+self.theModel->Translate, deltax, deltay, 0
+
+   ; Get the current transformation matrix.
+
+matrix = self.theModel->GetCTM()
+
+   ; Get the vertices of the polygon object.
+
+self.theBackground->GetProperty, Data=vertices
+
+   ; Apply the transformation matrix to the vertices.
+
+new = FltArr(2,5)
+FOR j=0,4 DO BEGIN
+   v = [vertices[*, j], 0.0, 1.0]
+   new[*, j] = (matrix ## v)[0:1]
+ENDFOR
+
+IF new[0,0] LT 0.0 THEN new[0,*] = [0.0, 0.0, self.xlength, self.xlength, 0.0]
+IF new[0,2] GT 1.0 THEN new[0,*] = [1.0-self.xlength, 1.0-self.xlength, 1.0, 1.0, 1.0-self.xlength]
+IF new[1,0] LT 0.0 THEN new[1,*] = [0.0, self.ylength, self.ylength, 0.0, 0.0]
+IF new[1,1] GT 1.0 THEN new[1,*] = [1.0-self.ylength, 1.0, 1.0, 1.0-self.ylength, 1.0-self.ylength]
+
+   ; Modify the graphics objects.
+
+self.theBackground->SetProperty, Data=new
+
+xs = FSC_PlotWindow_Normalize([0,100], Position=[new[0,0]+0.05, new[0,2]-0.05])
+ys = FSC_PlotWindow_Normalize([-1,1], Position=[new[1,0]+0.05, new[1,1]-0.05])
+
+self.theXAxis->SetProperty, XCoord_Conv=xs, Location=[1000, new[1,0]+0.05, 0]
+self.theYAxis->SetProperty, YCoord_Conv=ys, Location=[new[0,0]+.05, 1000, 0]
+self.thePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys
+self.x1 = new[0,0]
+self.x2 = new[0,2]
+self.y1 = new[1,0]
+self.y2 = new[1,1]
+
+   ; Draw the view after resetting the transformation matrix.
+
+self.theModel->Reset
+self.theWindow->Draw, self.theView
+
+END ;----------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PLOTWINDOW::WhichButtonReleased, event
+
+; Determines which button was used.
+
+buttons = ['NONE', 'LEFT', 'MIDDLE', 'NONE', 'RIGHT']
+RETURN, buttons[event.release]
+END ;----------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PLOTWINDOW::WhichButtonPressed, event
+
+; Determines which button was used.
+
+buttons = ['NONE', 'LEFT', 'MIDDLE', 'NONE', 'RIGHT']
+RETURN, buttons[event.press]
+END ;----------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PLOTWINDOW::InTarget, x, y, DIRECTION=direction
+
+; Given a location of the cursor in the window returns the
+; target location and the direction the window should be
+; resized in. Have to be within 2.5% of window edge to be
+; in moveable target.
+
+x = x / self.xsize
+y = y / self.ysize
+
+xtest = -1
+IF x GE self.x1 AND x LE self.x1 + 0.025 THEN xtest = 0
+IF x GT self.x1 + 0.025 AND x LT self.x2 - 0.025 THEN xtest = 1
+IF x GE self.x2 - 0.025 AND x LE self.x2 THEN xtest = 2
+ytest = -1
+IF y GE self.y1 AND y LE self.y1 + 0.1 THEN ytest = 0
+IF y GT self.y1 + 0.025 AND y LT self.y2 - 0.025 THEN ytest = 1
+IF y GE self.y2 - 0.025 AND y LE self.y2 THEN ytest = 2
+
+IF xtest EQ -1 OR ytest EQ -1 THEN BEGIN
+   retVal = 'ORIGINAL'
+   direction = 'NONE'
+ENDIF
+IF xtest EQ 0 AND ytest EQ  0 THEN BEGIN
+   retVal = 'SIZE_SW'
+   direction = 'SW'
+ENDIF
+IF xtest EQ 0 AND ytest EQ  1 THEN BEGIN
+    retVal = 'SIZE_EW'
+   direction = 'W'
+ENDIF
+IF xtest EQ 0 AND ytest EQ  2 THEN BEGIN
+    retVal = 'SIZE_NW'
+   direction = 'NW'
+ENDIF
+IF xtest EQ 1 AND ytest EQ  0 THEN BEGIN
+    retVal = 'SIZE_NS'
+   direction = 'S'
+ENDIF
+IF xtest EQ 1 AND ytest EQ  1 THEN BEGIN
+    retVal = 'MOVE'
+   direction = 'MOVE'
+ENDIF
+IF xtest EQ 1 AND ytest EQ  2 THEN BEGIN
+    retVal = 'SIZE_NS'
+   direction = 'N'
+ENDIF
+IF xtest EQ 2 AND ytest EQ  0 THEN BEGIN
+    retVal = 'SIZE_SE'
+   direction = 'SE'
+ENDIF
+IF xtest EQ 2 AND ytest EQ  1 THEN BEGIN
+    retVal = 'SIZE_EW'
+   direction = 'E'
+ENDIF
+IF xtest EQ 2 AND ytest EQ  2 THEN BEGIN
+    retVal = 'SIZE_NE'
+   direction = 'NE'
+ENDIF
+
+RETURN, retVal
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::Realize
+
+Widget_Control, self.drawID, Get_Value=theWindow
+self.theWindow = theWindow
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW_Notify_Realize, drawID
+Widget_Control, drawID, Get_UValue=self
+self->Realize
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::Process_Events, event
+
+; Handles draw widget events.
+
+possibleEvents = ['DOWN', 'UP', 'MOTION', 'SCROLL', 'EXPOSE']
+thisEvent = possibleEvents[event.type]
+
+   ; Are we inside a target? If so, change cursor.
+
+target = self->InTarget(event.x, event.y, Direction=direction)
+self.theWindow->SetCurrentCursor, target
+
+
+   ; What kind of event is this?
+
+CASE thisEvent OF
+   'EXPOSE': self.theWindow->Draw, self.theView
+   'UP': BEGIN
+         thisButton = self->WhichButtonReleased(event)
+         Widget_Control, event.id, Clear_Events=1
+         CASE self.action OF
+            'MOVE': BEGIN
+               self.currentX = -1
+               self.currentY = -1
+               self.action = ""
+               self->GetWindowLocation, xsize, ysize, xoffset, yoffset
+               IF self.event_pro NE "" THEN BEGIN
+                  thisEvent = {ID:event.id, TOP:event.top, HANDLER:event.handler, $
+                     xsize:xsize, ysize:ysize, xoffset:xoffset, yoffset:yoffset}
+                  Call_Procedure, self.event_pro, thisEvent
+               ENDIF
+               ENDCASE
+            'ORIGINAL':
+            'RESIZE': BEGIN
+               self.currentX = -1
+               self.currentY = -1
+               self.action = ""
+               self.direction = "NONE"
+               self->GetWindowLocation, xsize, ysize, xoffset, yoffset
+               IF self.event_pro NE "" THEN BEGIN
+                  thisEvent = {ID:event.id, TOP:event.top, HANDLER:event.handler, $
+                     xsize:xsize, ysize:ysize, xoffset:xoffset, yoffset:yoffset}
+                  Call_Procedure, self.event_pro, thisEvent
+               ENDIF
+               ENDCASE
+            ELSE:
+         ENDCASE
+         ENDCASE
+   'DOWN': BEGIN
+         thisButton = self->WhichButtonPressed(event)
+         IF thisButton EQ 'MIDDLE' THEN BEGIN
+            self->CenterPlot, event
+            self->GetWindowLocation, xsize, ysize, xoffset, yoffset
+            IF self.event_pro NE "" THEN BEGIN
+                  thisEvent = {ID:event.id, TOP:event.top, HANDLER:event.handler, $
+                     xsize:xsize, ysize:ysize, xoffset:xoffset, yoffset:yoffset}
+                  Call_Procedure, self.event_pro, thisEvent
+            ENDIF
+            RETURN
+         ENDIF
+         CASE target OF
+            'ORIGINAL': RETURN
+            'MOVE': BEGIN
+               self.currentX = event.x
+               self.currentY = event.y
+               self.action = 'MOVE'
+               ENDCASE
+            ELSE: BEGIN
+               self.currentX = event.x
+               self.currentY = event.y
+               self.action = 'RESIZE'
+               self.direction = direction
+               ENDCASE
+         ENDCASE
+         ENDCASE
+   'MOTION': BEGIN
+         CASE self.action OF
+            'MOVE': self->MovePlot, event
+            'RESIZE': self->Resize, event, self.direction
+            ELSE:
+         ENDCASE
+         ENDCASE
+ENDCASE
+
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW_Events, event
+
+; Widget event handler. Calls event handler method.
+
+Widget_Control, event.id, Get_UValue=self
+self->Process_Events, event
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW_Kill_Notify, drawID
+
+; Destroy the plot window object when the window is destroyed.
+
+Widget_Control, drawID, Get_UValue=self
+Obj_Destroy, self
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW::CLEANUP
+Obj_Destroy, self.theModel
+Obj_Destroy, self.theWindow
+Obj_Destroy, self.theView
+Obj_Destroy, self.plotModel
+END ;----------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PLOTWINDOW::INIT, $
+   parent, $                  ; The parent base widget of this compound widget. Required.
+   PageSize=pagesize, $       ; The "pagesize" of the widget. Possible values are: "LETTER", "LEDGER", "LEGAL", "A4", and "DISPLAY".
+   WindowSize=windowsize, $   ; The size of the "window" on the page. A four-element array of normalized coordinates in the form [x0, y0, x1, y1].
+   Event_Pro=event_pro, $     ; The event procedure for the widget.
+   Units=units, $             ; A string indicating INCHES or CENTIMETER units. DEVICE units represented by a null string, "".
+   UValue=uvalue, $           ; A user value for the caller of this program.
+   Landscape=landscape, $     ; If set, display the page in landscape mode. Otherwise the page is display in portrait mode.
+   Color=color, $             ; If set, display the window in "color". This is the default on 24-bit devices.
+   Debug=debug, $             ; Set this keyword to turn traceback error handling on in the error handling code.
+   WindowColor=windowColor    ; A three-element array specifying the background window color (RGB).
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PlotWindow_Error_Message(Traceback=Keyword_Set(debug))
+   RETURN, 0
+ENDIF
+
+IF N_Elements(pagesize) EQ 0 THEN pageSize = 'LETTER'
+IF N_Elements(windowsize) EQ 0 THEN windowsize = [0.2, 0.2, 0.8, 0.8]
+IF N_Elements(event_pro) EQ 0 THEN event_pro = ""
+IF N_Elements(units) EQ 0 THEN units=""
+IF N_Elements(uvalue) EQ 0 THEN uvalue=""
+IF N_Elements(landscape) EQ 0 THEN landscape = 0
+Device, Get_Visual_Depth=theDepth
+self.pixels_per_inch = 18
+sizes = self->GetPagePixels(pageSize, Landscape=landscape)
+xsize = sizes[0]
+ysize = sizes[1]
+IF N_Elements(windowColor) EQ 0 THEN $
+   IF theDepth GT 8 THEN windowColor = [60, 140, 140] ELSE windowColor = [80, 80, 80]
+
+IF N_Elements(color) EQ 0 THEN BEGIN
+   Device, Get_Visual_Depth=theDepth
+   IF theDepth GT 8 THEN color = 1 ELSE color = 0
+ENDIF ELSE color = Keyword_Set(color)
+
+x1 = windowsize[0]
+x2 = windowsize[2]
+y1 = windowsize[1]
+y2 = windowsize[3]
+
+data = Findgen(101)
+data = Sin(data/5) / Exp(data/20)
+
+self.thePlot = Obj_New('IDLgrPlot', data, Color=[0,0,0])
+self.thePlot->SetProperty, XCoord_Conv=FSC_PlotWindow_Normalize([0,100], $
+   Position=[x1+0.05, x2-0.05]) > 10e-6, $
+   YCoord_Conv=FSC_PlotWindow_Normalize([-1,1], Position=[y1+0.05, y2-0.05]) > 10e-6
+
+self.theXAxis = Obj_New('IDLgrAxis', 0, Color=[0,0,0], Ticklen=0.025, $
+   Minor=4, Range=[0,100], Location=[1000, y1+0.05 , 0.0], /NoText)
+self.theXAxis->SetProperty, XCoord_Conv=FSC_PlotWindow_Normalize([0,100], $
+   Position=[x1+0.05, x2-0.05]) > 10e-6
+
+self.theYAxis = Obj_New('IDLgrAxis', 1, Color=[0,0,0], Ticklen=0.025, $
+   Minor=4, Range=[-1,1], Location=[x1+0.05, 1000, 0.0], /NoText)
+self.theYAxis->SetProperty, YCoord_Conv=FSC_PlotWindow_Normalize([-1,1], $
+   Position=[y1+0.05, y2-0.05]) > 10e-6
+
+self.plotModel = Obj_New('IDLgrModel')
+
+IF theDepth GT 8 THEN theColor = [210, 200, 180] ELSE theColor = [255,255,255]
+self.theBackground = Obj_New('IDLgrPolygon', Color=theColor, $
+   [x1, x1, x2, x2, x1], [y1, y2, y2, y1, y1])
+
+self.theModel = Obj_New('IDLgrModel', Select_Target=1)
+self.theModel->Add, self.theBackground
+
+self.plotModel->Add, self.theXAxis
+self.plotModel->Add, self.theYAxis
+self.plotModel->Add, self.thePlot
+self.plotModel->Translate, 0, 0, 0.1
+
+self.theView = Obj_New('IDLgrView', Color=windowColor,  Viewplane_Rect=[0,0,1,1])
+self.theView->Add, self.theModel
+self.theView->Add, self.plotModel
+
+self.base = Widget_Base(parent, UValue=uvalue)
+self.drawID = Widget_Draw(self.base, Button_Events=1, Expose_Events=1, $
+   Retain=0, Graphics_Level=2, XSize=xsize, YSize=ysize, $
+   Event_Pro='FSC_PLOTWINDOW_Events', UValue=self, Renderer=1, $
+   Kill_Notify='FSC_PLOTWINDOW_Kill_Notify', Motion_Events=1, $
+   Notify_Realize='FSC_PLOTWINDOW_Notify_Realize')
+
+self.pagesize = pagesize
+self.landscape = Keyword_Set(landscape)
+self.x1 = x1
+self.x2 = x2
+self.y1 = y1
+self.y2 = y2
+self.xsize = Float(xsize)
+self.ysize = Float(ysize)
+self.currentX = -1
+self.currentY = -1
+self.xlength = x2 - x1
+self.ylength = y2 - y1
+self.units = units
+self.event_pro = event_pro
+self.color = color
+self->SetColor, color
+RETURN, 1
+END ;----------------------------------------------------------------------------------
+
+
+
+PRO FSC_PLOTWINDOW__DEFINE
+
+   struct = { FSC_PLOTWINDOW,          $ ; The object class name.
+              action:"",               $ ; A flag to indicate whether you are moving or resizing the plot window.
+              base: 0L,                $ ; The top-level base of the compound widget.
+              color:0,                 $ ; A flag to indicate if the window is in "color" or not.
+              currentX:0,              $ ; The starting X location for resizing.
+              currentY:0,              $ ; The starting Y location for resizing.
+              direction:"",            $ ; The direction of resizing movement.
+              event_pro:"",            $ ; The name of an event handler to call.
+              drawID:0L,               $ ; The draw widget identifier.
+              pageSize:"",             $ ; A string to indicate the "type" of page: Letter, A4, etc.
+              pixels_per_inch:0,       $ ; The pixel per inch scaling. 18 pixels/inch hardcoded.
+              landscape: 0,            $ ; A flag to indicate the window should be in landscape mode.
+              plotModel:Obj_New(),     $ ; The model for the plot and axes objects.
+              theBackground:Obj_New(), $ ; The background filled polygon.
+              thePlot:Obj_New(),       $ ; The plot object.
+              theModel:Obj_New(),      $ ; The model for the background object.
+              theView:Obj_New(),       $ ; The object view.
+              theWindow:Obj_New(),     $ ; The object window.
+              theXAxis:Obj_New(),      $ ; The X axis object.
+              theYAxis:Obj_New(),      $ ; The Y axis object.
+              units:"",                $ ; A string indicating INCHES or CENTIMETER units.
+              x1:0.0,                  $ ; The x location of lower-left corner of plot window. (Normalized coordinates.)
+              x2:0.0,                  $ ; The x location of upper-right corner of plot window. (Normalized coordinates.)
+              xlength:0.0,             $ ; The length of the plot window in x. (Normalized coordinates.)
+              xsize:0.0,               $ ; The current X size of the draw widget. (Device coordinates.)
+              y1:0.0,                  $ ; The y location of lower-left corner of plot window. (Normalized coordinates.)
+              y2:0.0,                  $ ; The yx location of upper-right corner of plot window. (Normalized coordinates.)
+              ylength:0.0,             $ ; The length of the plot window in y. (Normalized coordinates.)
+              ysize:0.0                $ ; The current X size of the draw widget. (Device coordinates.)
+            }
+END ;----------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PLOTWINDOW, parent, PageSize=pagesize, WindowSize=windowsize, $
+   Event_Pro=event_pro, Units=units, UValue=uvalue, Landscape=landscape, $
+   Color=color
+
+; A wrapper function so this object can be treated as a compound
+; widget function.
+
+IF N_Elements(pagesize) EQ 0 THEN pageSize = 'LETTER'
+IF N_Elements(windowsize) EQ 0 THEN windowsize = [0.15, 0.15, 0.85, 0.85]
+IF N_Elements(event_pro) EQ 0 THEN event_pro = ""
+IF N_Elements(units) EQ 0 THEN units=""
+color = Keyword_Set(color)
+landscape = Keyword_Set(landscape)
+IF N_Elements(parent) EQ 0 THEN BEGIN
+   ok = Dialog_Message('Parent parameter is required. Returning...')
+   RETURN, Obj_New()
+ENDIF
+
+RETURN, Obj_New('FSC_PLOTWINDOW', parent, PageSize=pagesize, WindowSize=windowsize, $
+   Event_Pro=event_pro, Units=units, UValue=uvalue, Landscape=landscape, Color=color)
+END ;----------------------------------------------------------------------------------
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_psconfig.html
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_psconfig.html	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_psconfig.html	(revision 1185)
@@ -0,0 +1,1194 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+
+<html>
+
+<!-- ************** HEADER INFORMATION ************-->
+
+<head>
+<META name="Description" content="FSC_PSConfig Program for Configuring the IDL PostScript Device">
+<META name="Author" content="David W. Fanning, Ph.D.">
+<META name="Keywords" content="IDL, PostScript, configure, configuring, PostScript Device">
+<title>Configuring the IDL PostScript Device</title>
+</head>
+
+
+
+<!-- ************** CONSULTING BANNER ************-->
+
+<BODY VLINK="#FF0000" BACKGROUND="http://www.dfanning.com/images/graymarble.gif">
+<CENTER><IMG SRC="http://www.dfanning.com/images/banner.gif" WIDTH=443
+HEIGHT=111 ALT="Fanning Consulting Services (25K)"></CENTER>
+
+
+
+<!-- ************** BODY ************-->
+
+<CENTER><h1>Configuring the PostScript Device</h1></CENTER>
+
+<p>The <B>FSC_PSConfig</B> program is a 
+program for configuring the IDL PostScript device. The
+program is similar to (but much more powerful than) <B>PS_Form</B>, an older program offered 
+by Fanning Software Consulting. The <B>FSC_PSConfig</B> program is written as an object. 
+
+<p>In addition to configuring
+the PostScript device, the <B>FSC_PSConfig</B> program 
+allows you to keep track of the current state of the PostScript device at all times. 
+European users will be pleased to know that support for the A4 page and
+centimeter units are built into the program and can easily be set as program defaults.
+One of the most useful features of the <B>FSC_PSConfig</B> program 
+is its ability to collect user input via a graphical user interface, which--on a Windows
+machine with a 24-bit graphics display--looks similar to the illustration below. 
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic1.jpg" 
+ALT="The FSC_PSConfig graphical user interface for gathering user input."></CENTER>
+
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+<H2><A NAME="TOC">Table of Contents</A></H2>
+<UL>
+<LI><A HREF="#OVERVIEW">Program Overview</A>
+<LI><A HREF="#METHODS">Using the Program</A>
+	<UL>
+	<LI><A HREF="#INIT">Initializing the Program</A>
+      <LI><A HREF="#GUI">Description of the Graphical User Interface</A>
+      <LI><A HREF="#SETPROPERTY">Setting Program Properties</A>
+      <LI><A HREF="#KEYWORDS">Setting PostScript Configuration Keywords</A>
+      <LI><A HREF="#CLEANUP">Cleaning Up the Program</A>
+	</UL>
+<LI><A HREF="#EXAMPLE">Example Program Using <b>FSC_PSConfig</B></A>
+<LI><A HREF="#WRAPPER">A Wrapper Function for <b>FSC_PSConfig</B></A>
+<LI><A HREF="#CUSTOMIZING">Customizing Your Source Code</A>
+<LI><A HREF="#OTHERCODE">Other FSC Programs Needed to Run this Program</A>
+<LI><A HREF="#ORDERING">Disclaimer and Licensing Information</A>
+</UL>
+
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+
+<H2><A NAME="OVERVIEW">Program Overview</A></H2>
+
+<p>How you use the <B>FSC_PSConfig</B> program is completely up to you.
+It has been designed to accommodate  different programming styles. For example, it can be
+called from the IDL command line or from within other IDL programs. Typically,
+the program is used by initializing the object (you can have as many of the objects as you
+like, so each program can have its own PostScript configuration setup), 
+gathering user input via the built-in Graphical User Interface (GUI), configuring the PostScript device, 
+and drawing your PostScript plot.
+Here is a typical sequence of commands. Each step will be explained in detail below,
+but this is a short overview of a typical session. (Users uninterested in the power
+of the <B>FSC_PSConfig</B> object can access most of the functionality through the
+<A HREF="#WRAPPER"><b>PSConfig</b></A> wrapper function described below.)
+
+<H3>Initializing the Object</H3>
+
+<P>The first step is to initialize the object. There are a number of keywords
+that can be used to set properties of the <B>FSC_PSConfig</B> object, but suppose you are going
+to leave it up to the user to determine exactly how the PostScript device should
+be configured. Then you might simply initialize the object like this:
+
+<PRE>
+   psObject = Obj_New("FSC_PSConfig")
+</PRE>
+
+<P>If you typically display PostScript output on an A4 page and prefer
+size and offset units to be displayed in centimeters rather than inches,
+then you can initialize the object with the <B>European</B> keyword set, like
+this. 
+<PRE>
+   psObject = Obj_New("FSC_PSConfig", /European)
+</PRE>
+
+<P>The A4 page and centimeter units are now the default for this object.
+Selecting a European style can also be selected via a check box
+on the graphical user interface.
+
+<H3>Gathering User Input</H3>
+
+<P>Next, you might gather the user's input into how he or she would
+like the PostScript device to be configured. You can do this
+with a graphical user interface in either modal (blocking) or 
+non-modal mode. Suppose you wish the program to wait for the user's input.
+You would invoke the graphical user interface in blocking mode with this command:
+
+<PRE>
+   psObject->GUI
+</PRE>
+
+<H3>Configuring the PostScript Device</H3>
+
+<P>The real purpose of the <B>FSC_PSConfig</B> object is to return
+keywords that are appropriate for the PostScript device. The way the
+PostScript device is configured is to make the PostScript device the
+current graphics device, and then pass these keywords to the PostScript
+device via the <B>Device</B> command using the "keyword inheritance"
+mechanism and the <B>_Extra</B> keyword. The keywords are obtained from the
+object by calling the <b>GetKeywords</b> method. A typical sequence of
+commands looks like this:
+
+<PRE>
+   thisDevice = !D.Name
+   Set_Plot, "PS"
+   Device, _Extra=psObject->GetKeywords()
+</PRE>
+
+<H3>Drawing the PostScript Graphics</H3>
+
+<p>The PostScript graphics are now written to the PostScript file in
+the normal way. (Here a simple <b>Plot</b> command is used, but the graphics command
+or commands can be as elaborate as you like.)
+
+<PRE>
+   Plot, data
+</PRE>
+
+<H3>Cleaning Up</H3>
+
+<P>The final step is to clean up. Note that you do not have to
+destroy the object, as shown here. In fact, you may want to keep
+the object around for the entire IDL session, so you always know
+the current configuration of the PostScript device. Repeated calls
+to invoke the graphical user interface will show the current
+state of the PostScript device. Typical clean-up commands will be
+similar to these:
+
+<PRE>
+   Device, /Close_File
+   Set_Plot, thisDevice
+   Obj_Destroy, psObject
+</PRE>
+
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+<H2><A NAME="METHODS">Using the Program</A></H2>
+
+<p>The <B>FSC_PSConfig</B> program is used by calling the program's object methods. This section
+provides a detailed description of the object methods available to the user. (There are
+a number of other methods in the object that are used internally to run the program and 
+should not normally be accessed by the user of the program. These are not described here,
+although they are extensively documented in the source code.)
+
+<H3><A NAME="INIT">Initializing the Program</A></H3>
+
+<P>The object is initialized by creating an object of the <B>FSC_PSCONFIG</B> object class:
+
+<PRE>
+   psObject = Obj_New("FSC_PSConfig")
+</PRE>
+
+<p>At the time the object is initialized, various keywords can be used to set
+properties of the object. These keywords are typically (but not exclusively) the same keywords that
+can be used to configure the PostScript device (i.e., the keywords appropriate
+for the <B>Device</B> command when the PostScript device is the current graphics
+device). Here is a complete description of the <B>INIT</B> method keywords you can use.
+
+<UL>
+<LI><B>AvantGarde</B> - Set this keyword to select the AvantGarde font. Turned off by default.
+<LI><B>Bits_per_Pixel</B> - The number of image bits saved for each image pixel: 2, 4, or 8. The default is 8.
+<LI><B>Bold</B> - Set this keyword to select the Bold font style. Turned off by default.
+<LI><B>BookStyle</B> - Set this keyword to select the Book font style. Turned off by default.
+<LI><B>Bookman</B> - Set this keyword to select the Bookman font. Turned off by default.
+<LI><B>Color</B> - Set this keyword to select Color PostScript output. Turned off by default.
+<LI><B>Courier</B> - Set this keyword to select the Courier font. Turned off by default.
+<LI><B>Debug</B> - Set this keyword to turn traceback information on for error messages. 
+This is useful for debugging program code. Turned off by default.
+<LI><B>DefaultSetup</B> - Set this keyword to the "name" of a default style. Current styles (you
+can easily create and add your own to the source code) are the following:
+	<UL>
+      <LI><B>"System (Portrait)"</B> - The normal "default" system set-up. Also, <B>"System"</B>.
+      <LI><B>"System (Landcape)"</B> - The normal "default" landscape system set-up. 
+      <LI><B>"Centered (Portrait)"</B> - The window centered on the page. Also, <B>"Center"</B> or "Centered".
+      <LI><B>"Centered (Landscape)"</B> - The window centered on the landscape page. Also, <B>"Landscape"</B>.
+      <LI><B>"Square (Portrait)"</B> - A square plot, centered on the page. 
+      <LI><B>"Square (Landscape)"</B> - A square plot, centered on the landscape page. 
+      <LI><B>"Figure (Small)"</B> - A small encapsulated figure size, centered on page. Also, <B>"Encapsulated"</B> or <B>"Encapsulate"</B>.
+      <LI><B>"Figure (Large)"</B> - A larger encapsulated figure size, centered on page. Also, <B>"Figure"</B>.
+      <LI><B>"Color (Portrait)"</B> - A "centered" plot, with color turned on. Also, <B>"Color"</B>.
+     <LI><B>"Color (Landscape)"</B> - A "centered" landscape plot, with color turned on.
+	</UL>
+<LI><B>Demi</B> - Set this keyword to select the Demi font style. Turned off by default.
+<LI><B>Directory</B> - Set thie keyword to the name of the starting directory. The current directory is used by default.
+<LI><B>Encapsulate</B> - Set this keyword to select Encapsulated PostScript output. Turned off by default.
+<LI><B>European</B> - Set this keyword to indicate "european" mode (i.e., A4 page and centimeter units). Turned off by default.
+<LI><B>Filename</B> - Set thie keyword to the name of the PostScript file. In the source code version the default is "idl.ps", but
+in the shareware version this keyword cannot be set and is always "coyote.ps". 
+<LI><B>FontSize</B> - ; Set this keyword to the font size. Between 6 and 36. Default is 12.
+<LI><B>FontType</B> - ; Set this keyword to indicate the type of fon
+you want selected. Hershey Fonts: -1, Hardward Fonts: 0, and True-Type Fonts: 1.<LI><B>Helvetica</B> - Set this keyword to select the Helvetica font. This is the default selection.
+<LI><B>Inches</B> - Set this keyword to indicate sizes and offsets are in inches as opposed to centimeters.  
+Set by <B>European</B> keyword by default.
+<LI><B>Italic</B> - Set this keyword to select the Italic font style. Turned off by default.
+<LI><B>Isolatin</B> - Set this keyword to select ISOlatin1 encoding. Turned off by default.
+<LI><B>Landscape</B> - Set this keyword to select Landscape page output. Portrait page output is the default.
+<LI><B>Light</B> - Set this keyword to select the Light font style. Turned off by default.
+<LI><B>Medium</B> - Set this keyword to select the Medium font style. Turned off by default.
+<LI><B>Name</B> - Set this keyword to the "name" of the object. This can be anything you like. 
+Objects that have different names can display their graphical user interfaces simultaneously. The
+object name appears on the title of the graphical user interface.
+<LI><B>Narrow</B> - Set this keyword to select the Narrow font style. Turned off by default.
+<LI><B>Oblique</B> - Set this keyword to select the Oblique font style. Turned off by default.
+<LI><B>PageType</B> - Set this keyword to the "type" of page. Possible values are:
+	<UL>
+	<LI><B>"Letter"</B> - 8.5 by 11 inches. (Default, unless the <B>European</B> keyword is set.)
+	<LI><B>"Legal"</B> - 8.5 by 14 inches.
+	<LI><B>"Ledger"</B> - 11 by 17 inches.
+	<LI><B>"A4"</B> - 21.0 by 29.7 centimeters. (Default, if the <B>European</B> keyword is set.)
+	</UL>
+<LI><B>Palatino</B> - Set this keyword to select the Palatino font.  Turned off by default.
+<LI><B>Preview</B> - Set this keyword to select Preview mode: 0 is "none", 1 is "EPSI", or 2 is "EPSF".
+<LI><B>Schoolbook</B> - Set this keyword to select the Schoolbook font. Turned off by default.
+<LI><B>Set_Font</B> - Set this keyword to the name of a font passed to PostScript with Set_Plot keyword.
+<LI><B>Symbol</B> - Set this keyword to select the Symbol font. Turned off by default.
+<LI><B>Times</B> - Set this keyword to select the Times font. Turned off by default.
+<LI><B>TrueType</B> - Set this keyword to select True-Type fonts. Turned off by default.
+<LI><B>XOffset</B> - Set this keyword to the X Offset.  Uses "System (Portrait)" defaults. (Note: offset calculated from lower-left corner of page.)
+<LI><B>XSize</B> - Set this keyword to the X size of the PostScript "window". Uses "System (Portrait)" defaults.
+<LI><B>YOffset</B> - Set this keyword to the Y Offset.  Uses "System (Portrait)" defaults. (Note: offset calculated from lower-left corner of page.)
+<LI><B>YSize</B> - Set this keyword to the Y size of the PostScript "window". Uses "System (Portrait)" defaults.
+<LI><B>ZapfChancery</B> - Set this keyword to select the ZapfChancery font. Turned off by default.
+<LI><B>ZapfDingbats</B> - Set this keyword to select the ZapfDingbats font. Turned off by default.
+</UL>
+
+<p>For example, to select a centered, color, encapsulated PostScript file, using the Times Bold PostScript
+font, and named <em>myplot.eps</em>, you can initialize the object like this:
+
+<PRE>
+   psObject = Obj_New("FSC_PSConfig", /Color, /Encapsulate, /Times, /Bold, Filename="myplot.eps")
+</PRE>
+
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+
+<H3><A NAME="GUI">Description of the Graphical User Interface</A></H3>
+
+<P>The program's graphical user interface is invoked by calling the object's <B>GUI</B>
+method, like this:
+
+<PRE>
+   psObject->GUI
+</PRE>
+
+<p>Keywords are available with this method that control how the
+graphical user interfaces appears and what properties it has. Called as above,
+the interface is a blocking widget. This means the IDL command line will block
+and user will be unable to enter IDL commands at the command line until the widget
+is dismissed by clicking either the <em>Cancel</em> or the <em>Accept</em> button.
+Valid keywords for this method are these:
+
+<UL>
+<LI><B>Cancel</B> - Set this output keyword to a named variable that will be set to 1 if the user
+selected the <em>Cancel</em> button, and to 0 if the user selected the <em>Accept</Em> button. Note that
+this value only has meaning when the widget is is blocking (or modal) mode. In non-modal mode, the value
+is always set to 0.
+
+<PRE>
+      psObject->GUI, Group_Leader=event.top, Cancel=cancelled
+</PRE>
+
+<LI><B>FontInfo</B> - This keyword is set if you want the user to be able to
+configure the PostScript device with font information as well. Please see the
+description of how to use font information below, but the graphical interface will
+look similar to this.
+
+<PRE>
+      psObject->GUI, FontInfo=1
+</PRE>
+
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic3.jpg" 
+ALT="The FSC_PSConfig graphical user interface with the font information displayed."></CENTER>
+
+<p>Users have the ability to select Hershey, Hardware, or True-Type fonts, as well as many
+font "properties".
+
+
+<LI><B>Group_Leader</B> - Set this keyword to the identifier of a widget which is the group leader for
+the graphical user interface. This keyword <em>must</em> be set if you want modal (as opposed to just 
+blocking) behavior from the program. In other words, you will probably <em>always</em> set this keyword
+if you are calling the GUI from within another widget program. For example, from within a widget program,
+the graphical user interface should be invoked like this:
+
+<PRE>
+      psObject->GUI, Group_Leader=event.top
+</PRE>
+
+
+<LI><B>NoBlock</B> - This keyword is set if you want non-modal, and non-blocking
+behavior from the program. This is the mode you would use, for example, if you want
+the graphical user interface to stay on the display so you can change the PostScript
+set-up at will. Notice that in this mode the <em>Cancel</em> button is named <em>Dismiss</em>
+and the <em>Accept</em> button is named <em>Apply</em>.
+
+<PRE>
+      psObject->GUI, /NoBlock
+</PRE>
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic2.jpg" 
+ALT="The FSC_PSConfig graphical user interface in non-modal and non-saved mode."></CENTER>
+
+
+<p>In non-modal mode, selecting the <em>Apply</em> button will save the current PostScript
+configuration. Note that the PostScript graphics window changes background color if the
+current configuration shown on the form is not currently saved. (The program is shown in its
+ unsaved condition in the illustration
+above.) Upon saving the configuration,
+the background color will change back to its default color. The <em>Revert</em> button will
+revert to the last saved configuration.
+</UL>
+
+<H4>The Left Panel</H4>
+
+<p>The left panel of the graphical user interface contains eight droplist widgets
+and looks like this. A description of each droplist follows the illustration.
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic4.jpg" 
+ALT="The left panel of the FSC_PSConfig graphical user interface."></CENTER>
+
+
+
+<UL>
+<LI><B>Page Size</B> - This droplist controls the page size. It should be set to the type of output
+you intend to print, since offsets and sizes will be based on the page size selected. This will be
+set to "Letter" by default, unless the <b>European</b> keyword has been set, in which case 
+the "A4" option is the default.
+<LI><B>Orientation</B> - This droplist controls whether the page will be in portrait or landscape
+oreintation. The <b>Portrait</b> and <b>Landscape</b> Device keywords are set from this droplist.
+<LI><B>Units</B> - This droplist controls whether the size and offsets are measured in inches or centimeters.
+The <b>Inches</b> Device keyword is set from this droplist.
+<LI><B>Encapsulation</B> - This droplist controls whether <b>Encapsulated</b> Device keyword is set. If
+encapsulation is turned <em>Off</em>, then the <b>Preview Mode</b> droplist is insensitive.
+
+<LI><B>Preview Mode</B> - This droplist selects the value of the <b>Preview</b> Device keyword. 
+It is sensitive to user input only if the <em>Encapsulation</em> droplist is turned <em>On</em>
+"None" sets the keyword to 0, "ESPI" sets the keyword to 1, and "ESPF" sets the
+keyword to 2. If you wish IDL to create a preview image for Macintoshs or PCs, then you should choose
+the "ESPF" option.
+
+<LI><B>Color Output</B> - This droplist controls whether <b>Color</b> Device keyword is set. 
+<LI><B>Bits Per Image Pixel</B> - This droplist controls the value of the <b>Bits_Per_Pixel</b> 
+Device keyword. 
+<LI><B>Default Setups</B> - This droplist selects the various default set-ups, which 
+change multiple program settings at once. The choices in this droplist are easily modified by
+the user in the source code. Typically they would be choices in use at your facility.
+<LI><B>European Style</B> - This checkbox controls the Page Size and Units keywords. If checked,
+an A4 page size is used, and centimeters are used for Units. 
+</UL>
+
+<H4>The Center Panel</H4>
+
+<P>The center panel of the graphical user interface contains the size and offset
+information, directions for operating the PostScript "plot", and fields to
+indicate the output directory and file names. It looks similar to the
+illustration below. An explanation of each item follows the illustration.
+
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic5.jpg" 
+ALT="The center panel of the FSC_PSConfig graphical user interface."></CENTER>
+
+<UL>
+<LI><B>X Size</B> - This text field contains the X size of the PostScript "window". Its value is
+used to set the <B>XSize</B> Device keyword. After entering a value in this field you <em>must</em>
+enter a carriage return in the field for the new information to be transmitted to the plot window
+in the right panel.
+
+<LI><B>Y Size</B> - This text field contains the Y size of the PostScript "window". Its value is
+used to set the <B>YSize</B> Device keyword. After entering a value in this field you <em>must</em>
+enter a carriage return in the field for the new information to be transmitted to the plot window
+in the right panel.
+
+<LI><B>X Offset</B> - This text field contains the X offset of the PostScript "window". Its value is
+used to set the <B>XOffset</B> Device keyword. After entering a value in this field you <em>must</em>
+enter a carriage return in the field for the new information to be transmitted to the plot window
+in the right panel. Offsets are always calculated from the lower-left corner of the page regardless of
+the orientation, unlike the way you configure the PostScript device. The complexities of PostScript
+are handled behind the scenes and are not passed along to unsuspecting end-users. 
+
+<LI><B>Y Offset</B> - This text field contains the Y offset of the PostScript "window". Its value is
+used to set the <B>YOffset</B> Device keyword. After entering a value in this field you <em>must</em>
+enter a carriage return in the field for the new information to be transmitted to the plot window
+in the right panel. Offsets are always calculated from the lower-left corner of the page regardless of
+the orientation, unlike the way you configure the PostScript device. The complexities of PostScript
+are handled behind the scenes and are not passed along to unsuspecting end-users. 
+
+<LI><B>Directory</B> - The name of the directory where the PostScript file is to be
+written. The <em>Browse</em> button following the text field calls the IDL <b>Dialog_Pickfile</b>
+command with the <b>Directory</B> keyword set for directory selection.
+
+<LI><B>Filename</B> - The name of the output PostScript file. The <em>Browse</em> button 
+following the text field calls the IDL <b>Dialog_Pickfile</b>
+command for file selection. The <em>Directory</em> and
+<em>Filename</em> values are put together to constuct the value of the Device <B>Filename</B>
+keyword. 
+
+</UL>
+
+<p>If the <b>FontInfo</b> keyword is set when the graphical user interface is invoked, the
+center panel may also contain graphical elements allowing user input into font selections.
+These additional fields are described below the illustration.
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic6.jpg" 
+ALT="The center panel of the FSC_PSConfig graphical user interface with font information turned on."></CENTER>
+
+<UL>
+<LI><B>Font Type</B> - This droplist sets the font type. The other font options 
+are available only if the <em>Font Type</Em> droplist
+selection is set to something other than the "Vector (Hershey)".
+Note that the <em>Font Type</Em> droplist default selection depends upon the
+value of the <B>!P.Font</B> system variable when the graphical user interface
+is invoked, although it can be also be set via a <b>FontType</b> keyword when the grahical
+user interface is invoked. For example, the illustration above was produced with
+this syntax:
+<PRE>
+   IDL> psObject->GUI, /FontInfo, FontType=1
+</PRE>
+
+<LI><B>Font</B> - This droplist allows selection of one of the 10 font families
+available on most PostScript printers. A selection here sets the corresponding
+Device keyword.
+
+<LI><B>Font Style Box</B> - This non-exclusive base allows you to set the eight
+font styles that can be set for the PostScript device. These font styles are applied
+to the font selection described above to modify it with the selected style. 
+Note that which font styles are available for
+which font family is not controlled by IDL, but is a function of the fonts installed
+on your computer or printer. Thus, you must use this information carefully. The corresponding
+Device keyword is set according to each style selection.
+
+<LI><B>Clear Font Styles</B> - This button clears all the font style attributes
+selections described above.
+
+<LI><B>Font Size</B> - This droplist allows you to select the font size in point
+sizes from 6 to 36. The default size is 12. The <b>FontSize</B> Device keyword is
+set to this value.
+
+<LI><B>True-Type</B> - This droplist sets the Device <b>True_Type</B> keyword. If it is
+turned on true-type fonts are used for output if they are available.
+
+<LI><B>ISOlatin1</B> - This droplist sets the Device <b>ISOlatin1</B> keyword. If it is
+turned on isolatin encoding is used for output. This allows output in many languages other
+than English.
+
+</UL>
+
+<H4>The Right Panel</H4>
+
+<P>The right panel of the graphical user interface contains the representation of
+the PostScript page. This window will change shape and size as different page sizes and orientations
+are selected. It looks similar to the illustration below. (Note that the colors you see here will only
+appear on 24-bit displays. On 8-bit displays the colors are less exciting.)
+
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic7.jpg" 
+ALT="The righ panel of the FSC_PSConfig graphical user interface."></CENTER>
+
+<p>The "plot" in the window can be moved and resized by the user. It represents
+the "window" on the PostScript page where graphics will be drawn. As such, it controls
+the <B>XSize</B>, <B>YSize</B>, <B>XOffset</B>, and <B>YOffset</B> Device keywords.
+The plot window can be moved by clicking somewhere inside it and dragging. If you locate
+the cursor near an edge of the plot, you can click and drag to resize the window. Cursor changes
+will occur to indicate whether you are in drag or resize mode. Notice
+as you do that the size and offset fields in the right panel are updated with the new
+window sizes and offsets. Notice that the background color of the window changes if
+the current configuration shown on the form hasn't been saved and the program is in non-blocking
+mode. It will look similar to
+the illustration below. The backgound color does not change if the graphical user interface
+is in blocking mode. (Non-blocking mode is selected with the <b>NoBlock</B> keyword when the
+graphical user interface is invoked.)
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic11.jpg" 
+ALT="The righ panel of the FSC_PSConfig graphical user interface."></CENTER>
+
+
+
+<p>The plot window can be centered in the page by clicking the middle mouse button
+anywhere inside the PostScript page representation. Note that the middle mouse button
+can be simulated if you don't have a three-button mouse. For example, on PCs a <em>Ctrl-Click</em>
+is interpreted as a middle mouse click. <em>Option-Click</em> on a Macintosh will do the same.
+
+<p>If the <em>Color Output</em> droplist is turned <em>On</em>, then the plot
+is shown in color as a visual clue to the color property. 
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic8.jpg" 
+ALT="The center panel of the FSC_PSConfig graphical user interface in color."></CENTER>
+
+<H4>The Action Button Panel</H4>
+
+<p>The action button panel looks different, depending upon whether the graphical user
+interface is is blocking (modal) mode or in  non-blocking mode. Here is what it looks
+like in non-blocking mode.
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic9.jpg" 
+ALT="The button panel of the FSC_PSConfig graphical user interface in non-blocking mode."></CENTER>
+
+<P>Here is how it appears in blocking mode. 
+
+<!-- ************** GRAPHIC EXAMPLE ************-->
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic10.jpg" 
+ALT="The button panel of the FSC_PSConfig graphical user interface in blocking mode."></CENTER>
+
+<p>Notice that in blocking mode the <em>Dismiss</em> button is named <em>Cancel</em> and
+the <em>Apply</em> button is named <em>Accept</em>, but they have similar functions. The only
+real difference is that the <em>Accept</em> button destroys the widget (as do the <em>Dismiss</em>
+and <em>Cancel</em> buttons), while the <em>Apply</em> button does not. 
+
+<UL>
+<LI><B>Dismiss</B> or <B>Cancel</B> - This button destroys the graphical user interface.
+The last saved configuration of the graphical user interface is in effect.
+
+<LI><B>Revert</B> - This button restores the last saved configuration of the graphical
+user interface. A configuration is saved when the <em>Apply</em> or <em>Accept</em>
+button is selected.
+
+<LI><B>Help</B> - This button provides a Help message to the user and points the
+user to the program documentation. This action may have been customized for your facility.
+
+<LI><B>Apply</B> or <B>Accept</B> - This button saves the current configuration of the 
+graphical user interface. If the button is the <em>Accept</em> button, the graphical user
+interface is also destroyed and the block released.
+
+<P> Note that the name of this button can be changed by using the <B>Accept_Button_Name</B>
+keyword when the graphical user interface is invoked. For example, you might want to name
+the button "Print". You would do it like this:
+
+<PRE>
+   IDL> psObject->GUI, Accept_Button_Name='Print'
+</PRE>
+</UL>
+
+<p>The buttons would now look like this:
+
+<P><CENTER><IMG SRC="http://www.dfanning.com/programs/docs/fsc_psconfig_pic12.jpg" 
+ALT="The button panel of the FSC_PSConfig graphical user interface in blocking mode."></CENTER>
+
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+
+<H2><A NAME="SETPROPERTY">Setting Program Properties</A></H2>
+
+<p>The current configuration of the <b>FSC_PSConfig</B> object can be set at any time by
+using the <b>SetProperty</B> method of the object. The keywords that can be used to set
+properties are nearly identical to the keywords avaiable for the <b>INIT</b> method. Here is 
+a list of the keywords and thier meaning.
+
+<UL>
+<LI><B>AvantGarde</B> - Set this keyword to select the AvantGarde font.
+<LI><B>Bits_per_Pixel</B> - The number of image bits saved for each image pixel: 2, 4, or 8.
+<LI><B>Bold</B> - Set this keyword to select the Bold font style. 
+<LI><B>BookStyle</B> - Set this keyword to select the Book font style. 
+<LI><B>Bookman</B> - Set this keyword to select the Bookman font. T
+<LI><B>Color</B> - Set this keyword to select Color PostScript output. 
+<LI><B>Courier</B> - Set this keyword to select the Courier font. 
+<LI><B>DefaultSetup</B> - Set this keyword to the "name" of a default style. Factory styles (you
+can easily create and add your own to the source code) are the following:
+	<UL>
+      <LI><B>"System (Portrait)"</B> - The normal "default" system set-up. Also, <B>"System"</B>.
+      <LI><B>"System (Landcape)"</B> - The normal "default" landscape system set-up. 
+      <LI><B>"Centered (Portrait)"</B> - The window centered on the page. Also, <B>"Center"</B> or "Centered".
+      <LI><B>"Centered (Landscape)"</B> - The window centered on the landscape page. Also, <B>"Landscape"</B>.
+      <LI><B>"Square (Portrait)"</B> - A square plot, centered on the page. 
+      <LI><B>"Square (Landscape)"</B> - A square plot, centered on the landscape page. 
+      <LI><B>"Figure (Small)"</B> - A small encapsulated figure size, centered on page. Also, <B>"Encapsulated"</B> or <B>"Encapsulate"</B>.
+      <LI><B>"Figure (Large)"</B> - A larger encapsulated figure size, centered on page. Also, <B>"Figure"</B>.
+      <LI><B>"Color (Portrait)"</B> - A "centered" plot, with color turned on. Also, <B>"Color"</B>.
+     <LI><B>"Color (Landscape)"</B> - A "centered" landscape plot, with color turned on.
+	</UL>
+<LI><B>Demi</B> - Set this keyword to select the Demi font style. 
+<LI><B>Directory</B> - Set thie keyword to the name of the starting directory. 
+<LI><B>Encapsulate</B> - Set this keyword to select Encapsulated PostScript output.
+<LI><B>European</B> - Set this keyword to indicate "european" mode (i.e., A4 page and centimeter units). 
+<LI><B>Filename</B> - Set thie keyword to the name of the PostScript file. In the source code version the default is "idl.ps", but
+in the shareware version this keyword cannot be set and is always "coyote.ps". 
+<LI><B>FontSize</B> - ; Set this keyword to the font size. Between 6 and 36. 
+<LI><B>FontType</B> - ; Set this keyword to indicate the type of fon
+you want selected. Hershey Fonts: -1, Hardward Fonts: 0, and True-Type Fonts: 1.<LI><B>Helvetica</B> - Set this keyword to select the Helvetica font. This is the default selection.
+<LI><B>Helvetica</B> - Set this keyword to select the Helvetica font. 
+<LI><B>Inches</B> - Set this keyword to indicate sizes and offsets are in inches as opposed to centimeters.  
+<LI><B>Italic</B> - Set this keyword to select the Italic font style. 
+<LI><B>Isolatin</B> - Set this keyword to select ISOlatin1 encoding. 
+<LI><B>Landscape</B> - Set this keyword to select Landscape page output. 
+<LI><B>Light</B> - Set this keyword to select the Light font style. 
+<LI><B>Medium</B> - Set this keyword to select the Medium font style. 
+<LI><B>Name</B> - Set this keyword to the "name" of the object. This can be anything you like. 
+Objects that have different names can display their graphical user interfaces simultaneously. The
+object name appears on the title of the graphical user interface.
+<LI><B>Narrow</B> - Set this keyword to select the Narrow font style. 
+<LI><B>Oblique</B> - Set this keyword to select the Oblique font style. 
+<LI><B>PageType</B> - Set this keyword to the "type" of page. Possible values are:
+	<UL>
+	<LI><B>"Letter"</B> - 8.5 by 11 inches. (Default, unless the <B>European</B> keyword is set.)
+	<LI><B>"Legal"</B> - 8.5 by 14 inches.
+	<LI><B>"Ledger"</B> - 11 by 17 inches.
+	<LI><B>"A4"</B> - 21.0 by 29.7 centimeters. (Default, if the <B>European</B> keyword is set.)
+	</UL>
+<LI><B>Palatino</B> - Set this keyword to select the Palatino font.  
+<LI><B>Preview</B> - Set this keyword to select Preview mode: 0 is "none", 1 is "EPSI", or 2 is "EPSF".
+<LI><B>Schoolbook</B> - Set this keyword to select the Schoolbook font. 
+<LI><B>Set_Font</B> - Set this keyword to the name of a font passed to PostScript with Set_Plot keyword.
+<LI><B>Symbol</B> - Set this keyword to select the Symbol font. 
+<LI><B>Times</B> - Set this keyword to select the Times font. 
+<LI><B>TrueType</B> - Set this keyword to select True-Type fonts. 
+<LI><B>Update</B> - Set this keyword if you wish to immediately update the graphical user
+interface after setting a property. The default is to set the property without updating the
+display.
+<LI><B>XOffset</B> - Set this keyword to the X Offset. 
+<LI><B>XSize</B> - Set this keyword to the X size of the PostScript "window".
+<LI><B>YOffset</B> - Set this keyword to the Y Offset.  Uses "System (Portrait)" defaults. 
+<LI><B>YSize</B> - Set this keyword to the Y size of the PostScript "window". 
+<LI><B>ZapfChancery</B> - Set this keyword to select the ZapfChancery font. 
+<LI><B>ZapfDingbats</B> - Set this keyword to select the ZapfDingbats font.
+</UL>
+
+<p>For example, to create a 7 x 5 inch window on a PostScript 
+landscape page, with color output turned on, and immediately update the display, you can type this:
+
+<PRE>
+  psObject->SetProperty, /Landscape, /Color, /Update, XSize=7, YSize=5, /Inches, XOffset=1, YOffset=1
+</PRE>
+
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+<H3><A NAME="KEYWORDS">Setting PostScript Configuration Keywords</A></H3>
+
+<P>The whole purpose of the <B>FSC_PSConfig</B> program is to configure the PostScript device
+by setting the appropriate <b>Device</B> command keywords. This is done by obtaining a structure in which
+the fields of the structure are the names of the appropriate keywords, and the values of the fields are
+appropriate for configuring the device the way you want it configured. You pass this structure to the 
+<b>Device</B> command  by means of <em>keyword inheritance</em>. In other words, you use the <b>_Extra</b>
+keyword to accept the structure. 
+
+<p>The keyword structure is obtained from the object by calling the <b>GetKeywords</b> method, like
+this:
+
+<PRE>
+   keywordStructure = psObject->GetKeywords()
+</PRE>
+
+<p>To verify what this structure looks like, type this:
+
+<PRE>
+   IDL> Help, keywordStructure, /Structure
+</PRE>
+
+<P>Depending upon how your object is configured, you should see something like this:
+
+<PRE>
+   ** Structure <15037f8>, 24 tags, length=68, refs=1:
+      BITS_PER_PIXEL  INT              8
+      COLOR           INT              0
+      ENCAPSULATED    INT              0
+      FILENAME        STRING    'D:\RSI\IDL53\DAVID\coyote.ps'
+      FONT_SIZE       INT             12
+      INCHES          INT              1
+      ISOLATIN1       INT              0
+      PREVIEW         INT              0
+      TT_FONT         INT              0
+      XOFFSET         FLOAT           1.75000
+      XSIZE           FLOAT           5.00000
+      YOFFSET         FLOAT           3.50000
+      YSIZE           FLOAT           4.00000
+      PORTRAIT        INT              1
+      LANDSCAPE       INT              0
+      HELVETICA       INT              1
+      BOLD            INT              1
+      BOOK            INT              0
+      DEMI            INT              0
+      ITALIC          INT              1
+      LIGHT           INT              0
+      MEDIUM          INT              0
+      NARROW          INT              0
+      OBLIQUE         INT              0
+</PRE>
+
+<p>Note that your structure may have other keywords defined, depending upon
+how your object is configured. This is typical.
+
+<p>These keywords are passed to the PostScript device via the <b>_Extra</b> keyword
+to the <b>Device</B> command. Be sure to select the PostScript device first. The code
+will typically look something like this:
+
+<PRE>
+   thisDevice = !D.Name
+   Set_Plot, "PS"
+   Device, _Extra=psObject->GetKeywords()
+</PRE>
+
+<P>Once the PostScript device is configured, you issue your graphics
+command or commands as normal. They will go into the PostScript "window" you
+have described on the PostScript page. Then, be sure to close the file. The code might look
+something like this:
+
+<PRE>
+   Plot, data, Title='Experiment 5A'
+   Device, /Close_File
+   Set_Plot, thisDevice
+</PRE>
+
+<H4>A Note About Fonts</H4> 
+
+<p>Although the PostScript device allows you to set information about PostScript fonts 
+(if you set the <b>FontInfo</B> keyword when you invoked the GUI),
+there is no guarantee that your graphics commands will be rendered in PostScript fonts.
+In fact, this is a function of the <b>!P.Font</b> system variable or the <b>Font</B> keyword
+on a graphics command, and has nothing to do with how the PostScript device
+is configured <em>per se</em>. This makes it a bit tricky to put font property widgets on a graphical
+user interface, since the unaware user may be surprised that the output doesn't look like
+the configuration he or she selected.
+
+<p>I've attempted to get around this problem by letting you know of the
+user's wishes for font type. But this information doesn't come back in the
+device keyword structure. Rather, it is returned in a <b>FontType</B> output keyword
+from the <b>GetKeywords</b> method. In fact, I recommend you always call the method
+like this when you have asked the user to specify font information in the GUI:
+
+<PRE>
+   thisDevice = !D.Name
+   Set_Plot, "PS"
+   Device, _Extra=psObject->GetKeywords(<B>FontType=fonttype</B>)
+</PRE>
+
+<p>This allows you to set the font type correctly on your graphics commands. For example,
+you could write code like this:
+
+<PRE>
+   currentFontType = !P.Font
+   <b>!P.Font = fonttype</b>
+   Plot, data, Title='Experiment 5A'
+   Device, /Close_File
+   Set_Plot, thisDevice
+   !P.Font = currentFontType
+</PRE>
+
+<p>Or, even more simply, you could write code like this:
+
+<PRE>
+   Plot, data, Title='Experiment 5A', <b>Font=fonttype</B>
+   Device, /Close_File
+   Set_Plot, thisDevice
+</PRE>
+
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+<H3><A NAME="CLEANUP">Cleaning Up the Program</A></H3>
+
+<P>Since the <b>FSC_PSConfig</B> program is an object, it is persistent in
+the IDL session. This is one of the huge advantages of objects. For example,
+you can create an PostScript configuration object in a start-up file and
+always have it available in your IDL session. You will always have access
+to the current configuration of the PostScript device.
+
+<p>But as a persistent entity, you must destroy it when you are done with
+it or you will have heap memory leaking in your IDL session. This is especially
+true if you create these objects in other program modules. This is no different for
+other memory-leaking entities: pointers, pixmaps, etc. The way you clean up an object
+is to destroy it with the <b>Obj_Destroy</b> command, like this:
+
+<PRE>
+   Obj_Destroy, psObject
+</PRE>
+
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+
+<H2><A NAME="EXAMPLE">Example Program using <b>FSC_PSConfig</B></A></H2>
+
+<P>Sometimes the best way to see how to use a new program is to see an example.
+Here is an example program, named <A HREF="http://www.dfanning.com/tip_examples/ps_plotter.pro">PS_Plotter</A>,
+that uses the <b>FSC_PSConfig</B> object to create a window on the PostScript page 
+for two plots: an image plot
+and a histogram plot of the image data. You will need another useful program from
+my library to run the program: <A HREF="http://www.dfanning.com/programs/tvimage.pro">TVImage</A>. 
+(<B>TVImage</b> is needed because the normal IDL <b>TV</B> command doesn't honor
+the <b>!P.Multi</b> system variable. Nor is the <b>TV</B> command written in the
+device-independent way required here.) Here is the compete code for the <b>PS_Plotter</b>
+program.
+
+<PRE>
+   PRO PS_Plotter, image, $
+      European=european, $   ; Set this keyword if you want European measurements.
+      Object=object          ; Output variable to return FSC_PSConfig object.
+
+      ; Get an image if one is not passed in.
+
+   IF N_Elements(image) EQ 0 THEN BEGIN
+      image = BytArr(360, 360)
+      file = Filepath(SubDirectory=['examples', 'data'], 'worldelv.dat')
+      OpenR, lun, file, /Get_Lun
+      ReadU, lun, image
+      Free_Lun, lun
+   ENDIF 
+
+      ; Create the PostScript configuration object.
+
+   object = Obj_New('FSC_PSConfig', European=Keyword_Set(european))
+
+      ; We want hardware fonts.
+
+   thisFontType = !P.Font
+   !P.Font = 1
+
+      ; Get user input to PostScript configuration.
+
+   object->GUI
+
+      ; Configure the PostScript Device.
+
+   thisDevice = !D.Name
+   Set_Plot, 'PS'
+   keywords = object->GetKeywords(FontType=fonttype)
+   Device, _Extra=keywords
+
+      ; Draw the example plots.
+
+   !P.Multi = [ 0, 1, 2]
+   TVImage, image
+   Plot, Histogram(image), Title='Example Histogram Plot', XTitle='Pixel Value', $
+      YTitle='Number of Pixels', XStyle=1, Max_Value=5000
+
+      ; Clean up.
+
+   !P.Multi = 0
+   Device, /Close_File
+   Set_Plot, thisDevice
+   !P.Font = thisfontType
+
+      ; Return the PS_Configuration object or destroy it.
+
+   IF Arg_Present(object) EQ 0 THEN Obj_Destroy, object
+   END
+</PRE>
+
+<p>If you will be printing on letter-size paper, you want to run the program
+like this. You will see the graphical user interface of the object in the
+middle of your display. Fill out the form the way you would like the output
+file to be configured and click the <em>Accept</em> button.
+
+<PRE>
+   IDL> PS_Plotter
+</PRE>
+
+<P>If you are in a country that uses A4 paper, you might want to
+call the program like this:
+
+<PRE>
+   IDL> PS_Plotter, /European
+</PRE>
+
+<p>A PostScript file will be created in the specified directory. You 
+can print it or use a PostScript file viewer (e.g., Ghostview) to view
+the file.
+
+<p>Called as above, the <b>FSC_PSConfig</b> object is created and destroyed
+when the program exits. However, you may wish to play around with some of the
+object's properties. You can return the object from the <b>PS_Plotter</b> program by
+using the optional <b>Object</b> keyword, like this:
+
+<PRE>
+   IDL> PS_Plotter, Object=psObject
+</PRE>
+
+<p>If you want to see how the PostScript file
+was just configured, you can examine the PostScript Device keywords
+that were used to create the file:
+
+<PRE>
+   IDL> Help, psObject->GetKeywords(), /Structure
+</PRE>
+
+<P>Be sure to destroy the object when you are finished with it.
+
+<PRE>
+   IDL> Obj_Destroy, psObject
+</PRE>
+
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+
+<H2><A NAME="WRAPPER">A Wrapper Function for <b>FSC_PSConfig</b></A></H2>
+
+<P>A number of people are still uncomfortable using objects. So for those
+people, I have written a function named <A HREF="http://www.dfanning.com/programs/psconfig.pro">PSConfig</A>,
+which acts very much like (in fact, can probably be used as a replacement for)
+the old PostScript configuration program, <b>PS_Form</B>.
+
+<p>The <B>PSConfig</b> program creates the <b>FSC_PSConfig</b> object, calls
+the graphical user interface in blocking mode, and then returns the device
+keywords necessary to configure the PostScript device. The program can be used
+with commands similar to these:
+
+<PRE>
+   keywords = PSConfig(Cancel=cancelled)
+   IF NOT cancelled THEN BEGIN
+      thisDevice = !D.Name
+      Set_Plot, "PS"
+      Device, _Extra=keywords
+      Plot, Findgen(11)
+      Device, /Close_File
+      Set_Plot, thisDevice
+   ENDIF
+</PRE>
+
+<p> You can use the same keywords with <b>PSConfig</B> that 
+you use for the <b>FSC_PSConfig</B> object.
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+<H2><A NAME="CUSTOMIZING">Customizing Your Source Code</A></H2>
+
+<P>I've tried to write the <B>FSC_PSConfig</B> program in such a way that it can be
+easily customized and extended by you at your site. In particular, it will be easy to
+add new default set-ups and other page types to the program. The
+code itself is extensively documented to indicate how this can
+be done. But, to give you an example, here is how you would add another
+default set-up, named <em>Company Viewgraph</em> to the code.
+
+<h3>Step 1: Add the Name to the Set-Up List</H3>
+
+<P>Open the <em>fsc_psconfig__define.pro</em> file and find the
+<em>DefaultList</em> method. (For example, search for "::DefaultList".)
+Add your new default name to the list shown there. For example, you would find this code:
+
+<PRE>
+defaultlist = [ 'System (Portrait)', $
+                'System (Landscape)', $
+                'Centered (Portrait)', $
+                'Centered (Landscape)', $
+                'Square (Portrait)', $
+                'Square (Landscape)', $
+                'Figure (Small)', $
+                'Figure (Large)', $
+                'Color (Portrait)', $
+                'Color (Landscape)' ]
+</PRE>
+
+<p>and change it to this:
+
+<PRE>
+defaultlist = [ 'System (Portrait)', $
+                'System (Landscape)', $
+                'Centered (Portrait)', $
+                'Centered (Landscape)', $
+                'Square (Portrait)', $
+                'Square (Landscape)', $
+                'Figure (Small)', $
+                'Figure (Large)', $
+                'Color (Portrait)', $
+                'Color (Landscape)' <b>, $
+                'Company Viewgraph'</b>]
+</PRE>
+
+<H3>Step 2: Create the New Set-Up</H3>
+
+<p>Next, find the <em>SetDefault</em> method (it will be just below the
+<em>DefaultList</em> method you just found) and copy one of the defualt
+setups you find in the CASE statement in that code. For example, here
+is the <em>System (Portrait)</em> method found there:
+
+<PRE>
+CASE thisDefault OF
+
+   'System (Portrait)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 0
+         self.directorySet = directoryName
+         self.encapsulationSet = 0
+         self.filenameSet = defaultFilename + ".ps"
+         self.fonttypeSet = !P.Font
+         self.fontsizeSet = 12
+         self.fontStyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 0
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.previewSet = 0
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 1.61 ELSE self.xoffsetSet = 0.75
+         IF self.european THEN self.yoffsetSet = 14.65 ELSE self.yoffsetSet = 5.0
+         IF self.european THEN self.xsizeSet = 17.80 ELSE self.xsizeSet = 7.0
+         IF self.european THEN self.ysizeSet = 12.70 ELSE self.ysizeSet = 5.0
+         self.defaultsSet = 'System (Portrait)'
+      ENDCASE
+</PRE>
+
+<p>Modify each of the fields you want to change there, and add your changed
+values to the CASE statement. For example, your
+<em>Company Viewgraph</em> set-up might be defined like this. Note that you
+will have to provide both inches and centimeter units for the sizes and offsets.
+
+<PRE>
+   'Company Viewgraph': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 1
+         self.directorySet = "C:\Company\Viewgraphs"
+         self.encapsulationSet = 0
+         self.filenameSet = "viewgraph_1.view"
+         self.fonttypeSet = 1
+         self.fontsizeSet = 18
+         self.fontStyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 0
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.previewSet = 0
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 0.75 * 2.54 ELSE self.xoffsetSet = 0.75
+         IF self.european THEN self.yoffsetSet = 0.75 * 2.54ELSE self.yoffsetSet = 0.75
+         IF self.european THEN self.xsizeSet = 7.0 * 2.54 ELSE self.xsizeSet = 7.0
+         IF self.european THEN self.ysizeSet = 9.5 *2.54 ELSE self.ysizeSet = 9.5
+         self.defaultsSet = 'Company Viewgraph'
+      ENDCASE
+</PRE>
+
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+<H2><A NAME="OTHERCODE">Other FSC Programs Needed to Run this Program</A></H2>
+
+<P>This <B>FSC_PSConfig</B> program uses a number of other programs from the Coyote library. 
+Here are the programs you will need.
+
+<UL>
+<LI><A HREF="http://www.dfanning.com/programs/fsc_psconfig__define.pro">fsc_psconfig__define.pro</A> - The 
+main PostScript configuration object program. (What I call <b>FSC_PSConfig</B>.)
+<LI><A HREF="http://www.dfanning.com/programs/fsc_field.pro">fsc_field.pro</A> - A CW_Field replacement compound widget, written as an object.
+<LI><A HREF="http://www.dfanning.com/programs/fsc_fileselect.pro">fsc_fileselect.pro</A> - A file selection compound widget, written as an object.
+<LI><A HREF="http://www.dfanning.com/programs/fsc_droplist.pro">fsc_droplist.pro</A> - A droplist compound widget, written as an object.
+<LI><A HREF="http://www.dfanning.com/programs/fsc_plotwindow.pro">fsc_plotwindw.pro</A> - A 
+utility object program required by <b>FSC_PSConfig</B>.
+</UL>
+
+<p>In addition, you may want the following wrapper and example programs, respectively:
+
+<UL>
+<LI><A HREF="http://www.dfanning.com/programs/psconfig.pro">psconfig.pro</A> - A wrapper function for the
+<B>FSC_PSConfig</B> object.
+<LI><A HREF="http://www.dfanning.com/tip_examples/ps_plotter.pro">ps_plotter.pro</A> - An example
+program that uses the <B>FSC_PSConfig</B> object.
+<LI><A HREF="http://www.dfanning.com/programs/tvimage.pro">tvimage.pro</A> - A device-independent image display program, which
+honors the !P.Multi system variable.</UL>
+
+<p>If you would like to download all these programs at once,
+you can download this <A HREF="../fsc_psconfig.zip">zip file</A> (56KB).
+
+<P><CENTER>[<A HREF="#TOC">Return to Contents</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+<H2><A NAME="ORDERING">Disclaimer and Licensing Information</A></H2>
+
+<H3>Warranties</H3>
+
+<P>Fanning Software Consulting makes no warranties, either express or implied, as
+to the condition of the software described here or its fitness for any particular purpose. All software
+code is provided as is. IDL is a registered trademark of <A HREF="http://www.rsinc.com/">Research Systems, Inc.</A>
+for the computer software used to created these programs. A licensed version of IDL is required to 
+run these programs.
+
+<H3>Licensing the Software</H3>
+
+<p>All programs written by Fanning Software Consulting and described
+in this article are issued under a license certified and approved by the 
+Open Source Initiative. The following license is attached to the header of
+each program. Please do not removed the license information if you distribute
+this source code in any form.
+
+<PRE>
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright © 2000 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+</PRE>
+
+<H3>Reporting Program Bugs</H3>
+
+<P>Every attempt is made to keep these programs accurate and bug
+free. If you find a bug, I will be happy to attempt to fix it. Please
+report any bugs or feature requests to:
+
+<P>David Fanning<br>
+Fanning Software Consulting <br>
+1645 Sheely Drive <br>
+Fort Collins, CO 80526 USA <br>
+Phone: 970-221-0438<br>
+Fax: 970-221-4762<br>
+E-Mail: david@dfanning.com
+
+<P><CENTER>[<A HREF="http://www.dfanning.com/documents/programs.html">Return to Programs Page</A>]</CENTER>
+<!-- ************** HORIZONTAL RULE IMAGE ************-->
+<P ALIGN=CENTER><IMG SRC="http://www.dfanning.com/images/hruler.gif" WIDTH=782 HEIGHT=3
+   ALT="-------"></P>
+
+
+<!-- ************** UPDATE NOTICE ************-->
+
+<P><CENTER>
+Copyright &copy; 1997-2002 David W. Fanning<BR>
+Last Updated 30 October 2002</CENTER>
+
+</body>
+</html>
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_psconfig__define.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_psconfig__define.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/fsc_psconfig__define.pro	(revision 1185)
@@ -0,0 +1,2724 @@
+;+
+; NAME:
+;   FSC_PSCONFIG__DEFINE
+;
+; PURPOSE:
+;
+;   The purpose of this program is to implement an object that
+;   can keep track of--and allow the user to change--the current
+;   configuration of the PostScript device.
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;   General programming.
+;
+; DOCUMENTATION:
+;
+;   Complete documentation for the FSC_PSCONFIG object, including
+;   keyword and method descriptions, and example programs using the object
+;   can be found on the Coyote's Guide to IDL Programming web page:
+;
+;     http://www.dfanning.com/programs/docs/fsc_psconfig.html
+;
+;   Or, if you would prefer, you can download a self-contained PDF file:
+;
+;     http://www.dfanning.com/programs/docs/fsc_psconfig.pdf
+;
+; KEYWORDS:
+;
+;   Any keyword accepted by the FSC_PSCONFIG object can be used with
+;   this program. Here are a few of the most popular keywords.
+;
+;   Bits_per_Pixel - The number of image bits saved for each image pixel: 2, 4, or 8. The default is 8.
+;   Color - Set this keyword to select Color PostScript output. Turned on by default.
+;   DefaultSetup - Set this keyword to the "name" of a default style. Current styles (you can easily
+;     create and add your own to the source code) are the following:
+;
+;       "System (Portrait)" - The normal "default" system set-up. Also, "System".
+;       "System (Landscape)" - The normal "default" landscape system set-up.
+;       "Centered (Portrait)" - The window centered on the page. Also, "Center" or "Centered".
+;       "Centered (Landscape)" - The window centered on the landscape page. Also, "Landscape".
+;       "Square (Portrait)" - A square plot, centered on the page.
+;       "Square (Landscape)" - A square plot, centered on the landscape page.
+;       "Figure (Small)" - A small encapsulated figure size, centered on page. Also, "Encapsulated" or "Encapsulate".
+;       "Figure (Large)" - A larger encapsulated figure size, centered on page. Also, "Figure".
+;       "Color (Portrait)" - A "centered" plot, with color turned on. Also, "Color".
+;       "Color (Landscape)" - A "centered" landscape plot, with color turned on.
+;
+;   Directory - Set this keyword to the name of the starting directory. The current directory is used by default.
+;   Encapsulate - Set this keyword to select Encapsulated PostScript output. Turned off by default.
+;   European - Set this keyword to indicate "european" mode (i.e., A4 page and centimeter units). Turned off by default.
+;   Filename - Set thie keyword to the name of the PostScript file. The default is "idl.ps".
+;   Inches - Set this keyword to indicate sizes and offsets are in inches as opposed to centimeters. Set by European keyword by default.
+;   Landscape - Set this keyword to select Landscape page output. Portrait page output is the default.
+;   PageType - Set this keyword to the "type" of page. Possible values are:
+;       "Letter" - 8.5 by 11 inches. (Default, unless the European keyword is set.)
+;       "Legal" - 8.5 by 14 inches.
+;       "Ledger" - 11 by 17 inches.
+;       "A4" - 21.0 by 29.7 centimeters. (Default, if the European keyword is set.)
+;   XOffset - Set this keyword to the X Offset. Uses "System (Portrait)" defaults. (Note: offset calculated from lower-left corner of page.)
+;   XSize - Set this keyword to the X size of the PostScript "window". Uses "System (Portrait)" defaults.
+;   YOffset - Set this keyword to the Y Offset. Uses "System (Portrait)" defaults. (Note: offset calculated from lower-left corner of page.)
+;   YSize - Set this keyword to the Y size of the PostScript "window". Uses "System (Portrait)" defaults.
+;
+;   In addition, the following keywords can be used:
+;
+;   CANCEL -- An output keyword that will be set to 1 if the user
+;   chooses the Cancel button on the form. It will be 0 otherwise.
+;
+;   FONTINFO -- Set this keyword is you wish to have font information
+;   appear on the form. The default is to not include font information.
+;
+;   FONTTYPE -- Set this keyword to a named variable that will indicate
+;   the user's preference for font type. Values will be -1 (Hershey fonts),
+;   0 (hardware fonts), and 1 (true-type fonts). This keyword will always
+;   return -1 unless the FONTINFO keyword has also been set.
+;
+;   GROUP_LEADER -- Set this keyword to a widget identifier of the widget
+;   you wish to be a group leader for this program.
+;
+; EXAMPLE:
+;
+;   A simple sequence of using the object would look something like this:
+;
+;     psObject = Obj_New("FSC_PSCONFIG")
+;     psObject->GUI
+;     psKeywords = psObject->GetKeywords()
+;     thisDevice = !D.Name
+;     Set_Plot, 'PS'
+;     Device, _Extra=psKeywords
+;     TVImage, image
+;     Device, /Close_File
+;     Set_Plot, thisDevice
+;     Obj_Destroy, psObject
+;
+;  Note that the object can also be called from the PS_CONFIG interface:
+;
+;     psKeywords = PSConfig()
+;
+; OTHER PROGRAMS NEEDED:
+;
+;   The following programs are required to run this one:
+;
+;     fsc_droplist.pro
+;     fsc_fileselect.pro
+;     fsc_field.pro
+;     fsc_plotwindow
+;
+; MODIFICATIONS:
+;
+;   Written by David W. Fanning, 31 January 2000.
+;   Added capability to call GUI methods when the current graphics device
+;      doesn't support windows. Device is restored when the GUI exits. 11 May 2000. DWF.
+;   Changed the default value for the Color keyword to 1. 16 May 2000. DWF.
+;   Fixed a bug where filename changed when switching Setups. 8 AUG 2000. DWF.
+;   Fixed a bug when saving setup in Landscape mode. 8 AUG 2000. DWF.
+;   Added the ability to Get and Set the object's name via the SetProperty
+;      and a very abbreviated GetProperty method. Also added a GetName method. 26 SEP 2000. DWF.
+;   Fixed a problem in which the proper configuration was not restored if in Landscape mode. 20 Nov 2000. DWF.
+;   Made a number of modifications at the request of Martin Schultz. 4 Dec 2000. DWF.
+;   Fixed a bug when setting file  and directory names with the SetProperty method. 18 Dec 2000. DWF.
+;   Fixed a small problem in initializing the page size properly. 3 Jan 2001. DWF.
+;   Corrected a problem that resulted from a change to FSC_DROPLIST. 6 Jan 2001. DWF.
+;   Added the ability to restore the font type instead of always reverting to !P.Font. 7 Jan 2001. DWF.
+;   Increased the length of the file/directory name fields. 7 Jan 2001. DWF.
+;   Fixed another problem with Landscape mode interacting with A4 paper size. 7 Jan 2001. DWF.
+;   Seems I only half fixed the previous problem. :-( 26 April 2001. DWF.
+;   Forgot to update program to reflect change in FSC_FIELD. Fixed 26 April 2001. DWF.
+;   Changed BOOKMAN keyword to BKMAN to avoid conflict with BOOKSTYLE keyword. 26 April 2001. DWF.
+;   Modified the System Defaults to say "None" if none is used. Improved documentation. 10 September 2001. DWF.
+;   Added the ability to specify a filename at the same time as a Default Setup. 10 September 2001. DWF.
+;   Fixed a small problem in not setting new page sizes appropriately. 22 May 2002. DWF.
+;   Fixed a problem that occurred when the Accept button was not named "Accept". 6 May 2003.DWF.
+;   Whoops! I was a bit overly agressive on that last fix. :-( 17 July 2003. DWF.
+;   Fixed a problem with setting page types when using the DEFAULTSETUP keyword. 31 July 2003. DWF.
+;   Fixed a problem with turning encapsulation on in the GUI. Renamed ENCAPSULATE keyword ENCAPSULATED
+;      to avoid obvious errors. 31 July 2003. DWF.
+;   Removed obsolete STR_SEP and replaced with STRSPLIT. 27 Oct 2004. DWF.
+;   Now honoring EUROPEAN keyword when setting system default setups in the INIT method. 12 Nov 2004. DWF.
+;   Added CMYK output option 24 August 2007. Assumes LANGUAGE_LEVEL=2 printer. L. Anderson.
+;   Fixed a problem with the filename on WINDOWS computers coming back with forward slashes instead of
+;       backward slashes. 20 May 2008. DWF.
+;-
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright (c) 2000-2008 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+;
+
+
+FUNCTION FSC_PSCONFIG_RStrPos, Expr, SubStr, Pos
+
+; This function finds the last occurance of a substring
+; in a string. It was made obsolete in IDL 5.3. It is
+; provided here for backwards compatibility. It normally
+; resides in the IDL obsolete directory.
+
+; PURPOSE:
+;  This function finds the last occurrence of a substring within
+;  an object string. If the substring is found in the expression,
+;  RSTRPOS returns the character position of the match, otherwise
+;  it returns -1.
+;
+; CATEGORY:
+;  String processing.
+;
+; CALLING SEQUENCE:
+;        Result = RSTRPOS(Expr, SubStr [, Pos])
+;
+; INPUTS:
+;       Expr:  The expression string in which to search for the substring.
+;  SubStr: The substring to search for.
+;
+; OPTIONAL INPUTS:
+;  Pos:  The character position before which the search is begun.
+;           If Pos is omitted, the search begins at the last character
+;           of Expr.
+;
+; OUTPUTS:
+;        Returns the position of the substring, or -1 if the
+;   substring was not found within Expr.
+;
+
+  ON_ERROR, 2
+  N = N_PARAMS()
+  if (n lt 2) then message, 'Incorrect number of arguments.'
+
+  ; Is expr an array or a scalar? In either case, make a result
+  ; that matches.
+  if (size(expr, /n_dimensions) eq 0) then result = 0 $
+  else result = make_array(dimension=size(expr,/dimensions), /INT)
+
+  RSubStr = STRING(REVERSE(BYTE(SubStr))) ; Reverse the substring
+
+  for i = 0, n_elements(expr) - 1 do begin
+    Len = STRLEN(Expr[i])
+    IF (N_ELEMENTS(Pos) EQ 0) THEN Start=0 ELSE Start = Len - Pos
+
+    RString = STRING(REVERSE(BYTE(Expr[i]))) ; Reverse the string
+
+    SubPos = STRPOS(RString, RSubStr, Start)
+    IF SubPos NE -1 THEN SubPos = Len - SubPos - STRLEN(SubStr)
+    result[i] = SubPos
+  endfor
+
+  RETURN, result
+END ;-------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG_CenterTLB, tlb
+
+; This procedure centers the given top-level base on the display.
+
+   ; Get the screen size and find its center.
+
+screenSize = Get_Screen_Size()
+IF screenSize[0] GT 2000 THEN screenSize[0] = screenSize[0]/2 ; Dual monitors.
+xCenter = screenSize(0) / 2
+yCenter = screenSize(1) / 2
+
+   ; Get the size of the widget program and calculate a half-size.
+
+geom = Widget_Info(tlb, /Geometry)
+xHalfSize = geom.Scr_XSize / 2
+yHalfSize = geom.Scr_YSize / 2
+
+   ; Position the widget program on the display.
+
+Widget_Control, tlb, XOffset = xCenter-xHalfSize, $
+   YOffset = yCenter-yHalfSize
+
+END ;-------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PSCONFIG_Error_Message, theMessage, Traceback=traceback, $
+   NoName=noName
+
+; Handles program errors.
+
+On_Error, 2
+
+   ; Check for presence and type of message.
+
+IF N_Elements(theMessage) EQ 0 THEN theMessage = !Error_State.Msg
+s = Size(theMessage)
+messageType = s[s[0]+1]
+IF messageType NE 7 THEN BEGIN
+   Message, "The message parameter must be a string."
+ENDIF
+
+   ; Get the call stack and the calling routine's name.
+
+Help, Calls=callStack
+callingRoutine = (StrSplit(StrCompress(callStack[1])," ", /Extract))[0]
+
+   ; Are widgets supported? Doesn't matter in IDL 5.3 and higher.
+
+widgetsSupported = ((!D.Flags AND 65536L) NE 0) OR Float(!Version.Release) GE 5.3
+IF widgetsSupported THEN BEGIN
+   IF Keyword_Set(noName) THEN answer = Dialog_Message(theMessage) ELSE BEGIN
+      IF StrUpCase(callingRoutine) EQ "$MAIN$" THEN answer = Dialog_Message(theMessage) ELSE $
+         answer = Dialog_Message(StrUpCase(callingRoutine) + ": " + theMessage)
+   ENDELSE
+ENDIF ELSE BEGIN
+      Message, theMessage, /Continue, /NoPrint, /NoName, /NoPrefix
+      Print, '%' + callingRoutine + ': ' + theMessage
+      answer = 'OK'
+ENDELSE
+
+   ; Provide traceback information if requested.
+
+IF Keyword_Set(traceback) THEN BEGIN
+   Help, /Last_Message, Output=traceback
+   FOR j=0,N_Elements(traceback)-1 DO Print, traceback[j]
+ENDIF
+
+RETURN, answer
+END ;---------------------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG_Events, event
+
+; This is the main event hander for the program. Its purpose
+; is to dispatch events to the appropriate event handler
+; methods by parsing the user value of the widget causing
+; the event.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Get the instructions from the widget causing the event and
+   ; act on them.
+
+thisEvent = Tag_Names(event, /Structure_Name)
+CASE thisEvent OF
+
+   'FSC_DROPLIST_EVENT' : BEGIN
+         Widget_Control, event.id, Get_UValue=instructions
+      ENDCASE
+
+   'FSC_FIELD_EVENT': BEGIN
+         Widget_Control, event.id, Get_UValue=instructions
+      ENDCASE
+
+   'WIDGET_BUTTON': BEGIN
+         Widget_Control, event.id, Get_UValue=instructions
+      ENDCASE
+
+   'WIDGET_DRAW': BEGIN
+         Widget_Control, event.id, Get_UValue=instructions
+      ENDCASE
+
+   ELSE: BEGIN ; FSC_PLOTWINDOW events.
+         Widget_Control, event.id, Get_UValue=object
+         instructions = object->GetUValue()
+      ENDCASE
+
+ENDCASE
+
+   ; Turn the status light to OFF, if necessary.
+
+IF instructions.method NE 'HELP' AND instructions.method NE 'REVERT' $
+   AND instructions.method NE 'ACCEPT' THEN instructions.object->StatusLight, 0
+IF instructions.method NE 'NULL' THEN $
+   Call_Method, instructions.method, instructions.object, event
+
+END ;--------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PSCONFIG_Normalize, range, Position=position
+
+; The program creates a scaling and translating factor for
+; positioning objects in the view coordinate system.
+
+On_Error, 1
+IF N_Params() EQ 0 THEN Message, 'Please pass range vector as argument.'
+
+IF (N_Elements(position) EQ 0) THEN position = [0.0, 1.0] ELSE $
+    position=Float(position)
+range = Float(range)
+
+scale = [((position[0]*range[1])-(position[1]*range[0])) / $
+    (range[1]-range[0]), (position[1]-position[0])/(range[1]-range[0])]
+
+RETURN, scale
+END ;-------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG_Help_Event, event
+
+; Destroy the HELP widget window.
+
+Widget_Control, event.top, /Destroy
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG_Restore_Device, id
+Widget_Control, id, Get_UValue=thisDevice
+Set_Plot, thisDevice
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::Accept, event
+
+; This method handles the event from the ACCEPT or APPLY buttons.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Get all the values from the form and load the appropriate
+   ; self fields.
+
+self.cancel = 0
+self.pageTypeSet = self.pageTypeID->GetSelection()
+self.landscapeSet = self.orientationID->GetIndex()
+self.inchesSet = self.unitsID->GetIndex()
+self.cmykSet = self.cmykID->GetIndex()
+self.colorSet = self.colorID->GetIndex()
+self.encapsulationSet = self.encapsulationID->GetIndex()
+self.previewSet = self.previewID->GetIndex()
+IF self.encapsulationSet EQ 0 THEN self.previewSet = 0
+self.bitsSet = self.bitsID->GetSelection()
+
+IF N_Elements(self.xsizeID->Get_Value()) EQ 0 THEN BEGIN
+   IF self.inchesSet THEN xsize = 1.0 ELSE xsize = 2.54
+   self.xsizeID->Set_Value, xsize
+ENDIF ELSE xsize = self.xsizeID->Get_Value()
+self.xsizeSet = xsize
+
+IF N_Elements(self.ysizeID->Get_Value()) EQ 0 THEN BEGIN
+   IF self.inchesSet THEN ysize = 1.0 ELSE ysize = 2.54
+   self.ysizeID->Set_Value, ysize
+ENDIF ELSE ysize = self.ysizeID->Get_Value()
+self.ysizeSet = ysize
+
+IF N_Elements(self.xoffsetID->Get_Value()) EQ 0 THEN BEGIN
+   xoffset = 0.0
+   self.xoffsetID->Set_Value, xoffset
+ENDIF ELSE xoffset = self.xoffsetID->Get_Value()
+self.xoffsetSet = xoffset
+
+IF N_Elements(self.yoffsetID->Get_Value()) EQ 0 THEN BEGIN
+   yoffset = 0.0
+   self.yoffsetID->Set_Value, yoffset
+ENDIF ELSE yoffset = self.yoffsetID->Get_Value()
+self.yoffsetSet = yoffset
+
+self.plotID->SetWindowLocation, xsize, ysize, xoffset, yoffset
+
+   ; Get the font information if it is on the form.
+
+IF self.fontInfo THEN BEGIN
+   ;fonttype = self.fontTypeID->GetIndex()
+   ;self.fonttypeSet = fonttype - 1
+   self.fontsizeSet = self.fontsizeID->GetSelection()
+
+   values = self.fontnameID->GetValues()
+   selection = self.fontnameID->GetSelection()
+   index = Where(StrUpCase(values) EQ StrUpCase(selection))
+   FOR j=1,7 DO BEGIN
+      cmd = "self." + values[j] + " = 0"
+      ok = Execute(cmd)
+      IF NOT ok THEN ok = Dialog_Message("Problem executing statment: " + cmd)
+   ENDFOR
+   IF index[0] NE 0 THEN ok = Execute("self." + values[index[0]] + " = 1")
+   self.fontnameSet = values[index[0]]
+
+   self.isolatinSet = self.isolatinID->GetIndex()
+   IF Obj_Valid(self.set_fontID) THEN self.set_fontSet = self.Set_FontID->Get_Value()
+   self.truetypeSet = self.truetypeID->GetIndex()
+   self.fontTypeSet = self.fontTypeID->GetIndex() - 1
+ENDIF
+
+   ; Get the filename information.
+
+self.filenameID->GetProperty, File=filename, Directory=directory
+self.filenameSet = filename
+self.directorySet = directory
+self.fullFilenameSet=self.filenameID->GetFileName()
+
+   ; If this is WINDOWS, then forward slashes need to be converted to backward slashes.
+   
+IF StrUpCase(!Version.OS_FAMILY) EQ 'WINDOWS' THEN BEGIN
+   self.directorySet = StrJoin( StrSplit(self.directorySet, '/', /Regex, /Extract, /Preserve_Null), '\')
+   self.fullFilenameSet = StrJoin( StrSplit(self.fullFilenameSet, '/', /Regex, /Extract, /Preserve_Null), '\')
+ENDIF
+
+   ; Set the status light if this is the APPLY button
+
+Widget_Control, event.id, Get_UValue=buttonInfo
+IF N_Elements(buttonInfo) NE 0 THEN $
+   IF buttonInfo.method EQ 'APPLY' THEN self->StatusLight, 1
+
+   ; Save this configuration.
+
+self->SaveConfiguration
+
+   ; Destroy the widget if this is a modal widget.
+
+IF N_Elements(buttonInfo) NE 0 THEN $
+   IF buttonInfo.method EQ 'ACCEPT' AND Widget_Info(self.tlb, /Valid_ID) THEN BEGIN
+   Widget_Control, self.tlb, /Destroy
+   self.noblock = 0
+ENDIF
+
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::Cancel, event
+
+; If the cancel button was clicked, set the cancel flag to 1 and
+; destroy the widget.
+
+self.cancel = 1
+self.noblock = 0
+Widget_Control, event.top, /Destroy
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::ClearStyles, event
+
+; This event handler method responds to the Clear button by setting
+; turning all the font style buttons off..
+
+self->UpDateFontStyle, /Clear
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::Color, event
+
+; This event handler method responds to changes in the Color droplist.
+
+
+self.plotID->SetColor, event.index
+
+; Set sensitivity of cmyk button
+
+self.cmykID->Sensitive, event.index
+END ;--------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PSCONFIG::Construct_Full_Filename
+
+; This method returns the fully-qualified filename. Checks to be
+; sure the last character in the directory name is not a directory
+; specifier.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN, ""
+ENDIF
+
+   ; Get the correct directory separator.
+
+CASE StrUpCase(!Version.OS_Family) OF
+   'WINDOWS' : sep = '\'    ; PCs
+   'MACOS'   : sep = ':'    ; Macintoshes
+   'VMS'     : sep = ']'    ; VMS machines
+   ELSE      : sep = '/'    ; Unix machines
+ENDCASE
+
+IF StrUpCase(!Version.OS_Family) NE "VMS" THEN BEGIN
+   length = StrLen(self.directorySet)
+   WHILE StrMid(self.directorySet, length-1, 1) EQ sep DO BEGIN
+      self.directorySet = StrMid(self.directorySet, 0, length-1)
+      length = StrLen(self.directorySet)
+   ENDWHILE
+ENDIF
+
+RETURN, Filepath(Root_Dir=self.directorySet, self.filenameSet)
+END ;-------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PSCONFIG::DefaultList
+
+; This method defines the default settings values in the Defaults droplist.
+; To add your own defaults, start by adding the new default name here. Then
+; add your default setup to the SetDefault method below.
+
+defaultlist = [ 'None', $
+                'System (Portrait)', $
+                'System (Landscape)', $
+                'Centered (Portrait)', $
+                'Centered (Landscape)', $
+                'Square (Portrait)', $
+                'Square (Landscape)', $
+                'Figure (Small)', $
+                'Figure (Large)', $
+                'Color (Portrait)', $
+                'Color (Landscape)' ]
+
+RETURN, defaultList
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::Defaults, event
+
+; This event handler method responds to changes in the Defaults droplist.
+
+self->SetDefault, *event.selection
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::Encapsulate, event
+
+; This method responds to a change in the Encapsulation droplist widget.
+
+IF event.index THEN self.previewID->Sensitive, 1 ELSE self.previewID->Sensitive, 0
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::FontType, event
+
+; This event handler method responds to changes in the Font Type droplist.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Font styles, etc. can only be on if hardware or
+   ; true-type fonts are selected.
+
+CASE event.index OF
+
+   0: BEGIN
+   Widget_Control, self.fontnameID->GetID(), Sensitive=0
+   Widget_Control, self.stylebaseID, Sensitive=0
+   Widget_Control, self.clearbuttonID, Sensitive=0
+   Widget_Control, self.fontSizeID->GetID(), Sensitive=0
+   Widget_Control, self.truetypeID->GetID(), Sensitive=0
+   Widget_Control, self.isolatinID->GetID(), Sensitive=0
+   IF Obj_Valid(self.set_fontID) THEN Widget_Control, self.set_fontID->GetID(), Sensitive=0
+   ENDCASE
+
+   ELSE: BEGIN
+   Widget_Control, self.fontnameID->GetID(), Sensitive=1
+   Widget_Control, self.stylebaseID, Sensitive=1
+   Widget_Control, self.clearbuttonID, Sensitive=1
+   Widget_Control, self.fontSizeID->GetID(), Sensitive=1
+   Widget_Control, self.truetypeID->GetID(), Sensitive=1
+   Widget_Control, self.isolatinID->GetID(), Sensitive=1
+   IF Obj_Valid(self.set_fontID) THEN Widget_Control, self.set_fontID->GetID(), Sensitive=1
+   ENDCASE
+
+ENDCASE
+
+fontname = *event.selection
+CASE StrUpCase(fontname) OF
+   "TRUE-TYPE": BEGIN
+      self.truetypeID->SetIndex, 1
+      self.trueTypeSet = 1
+      self.fontTypeSet = 1
+   ENDCASE
+   "HARDWARE" : BEGIN
+      self.trueTypeSet = 0
+      self.fontTypeSet = 0
+      ENDCASE
+   ELSE: BEGIN
+      self.trueTypeSet = 0
+      self.fontTypeSet = -1
+      self.truetypeID->SetIndex, 0
+   ENDCASE
+ENDCASE
+
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::EuroStyle, event
+
+; This event handler sets and unset the "European Style" button.
+
+IF event.select EQ 1 THEN BEGIN
+
+   Widget_Control, event.top, Update=0
+   self.european = 1
+   IF self.inchesSet EQ 1 THEN BEGIN
+      sizes = self->GetSizes()
+      self.xsizeSet = sizes[0] * 2.54
+      self.ysizeSet = sizes[1] * 2.54
+      self.xoffsetSet = sizes[2] * 2.54
+      self.yoffsetSet = sizes[3] * 2.54
+   ENDIF
+   self.inchesSet = 0
+   self.pageTypeSet = 'A4'
+   self.plotID->SetUnits, 'Centimeters'
+   Widget_Control, event.top, Update=1
+
+ENDIF ELSE BEGIN
+
+   Widget_Control, event.top, Update=0
+   self.european = 0
+   IF self.inchesSet EQ 0 THEN BEGIN
+      sizes = self->GetSizes()
+      self.xsizeSet = sizes[0] / 2.54
+      self.ysizeSet = sizes[1] / 2.54
+      self.xoffsetSet = sizes[2] / 2.54
+      self.yoffsetSet = sizes[3] / 2.54
+   self.inchesSet = 1
+   self.pageTypeSet = 'LETTER'
+   self.plotID->SetUnits, 'Inches'
+   Widget_Control, event.top, Update=1
+
+   ENDIF
+
+ENDELSE
+self->UpdateDisplay
+self.plotID->CenterPlot
+END ;--------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PSCONFIG::GetKeywords, FontType=fonttype
+
+; This method creates and returns a structure with the PostScript Device
+; keywords as fields in the structure.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN, {Cancel:1}
+ENDIF
+
+  ; I am shielding the user from the strangeness of PostScript
+  ; Landscape mode, in which the X and Y offsets are rotated
+  ; 180 degrees. Thus, in the form, the offsets are calculated from
+  ; the lower-left corner in both Landscape and Portrait mode.
+  ; This means I have to monkey around to get the proper offsets
+  ; if the form is in Landscape mode.
+
+IF self.landscapeSet EQ 1 THEN BEGIN
+    pageDims = self->PageDimensions()
+       ; Switch x and y offsets
+    yoffset = pageDims[1] - self.xoffsetSet
+    xoffset = self.yoffsetSet
+ENDIF ELSE BEGIN
+    xoffset = self.xoffsetSet
+    yoffset = self.yoffsetSet
+ENDELSE
+
+   ; Create the basic structure.
+
+struct = { $
+   bits_per_pixel: Fix(self.bitsSet), $
+   cmyk: self.cmykSet, $
+   color: self.colorSet, $
+   encapsulated: self.encapsulationSet, $
+   filename: self.fullfilenameSet, $
+   font_size: Fix(self.fontSizeSet), $
+   inches: self.inchesSet, $
+   isolatin1: self.isolatinSet, $
+   preview: self.previewSet, $
+   tt_font: self.truetypeSet, $
+   xoffset: xoffset, $
+   xsize: self.xsizeSet, $
+   yoffset: yoffset, $
+   ysize: self.ysizeSet }
+
+   ; Addition of CMYK keyword implies LANGUAGE_LEVEL keyword set to 2.
+
+IF self.cmykSet THEN struct = Create_Struct(struct, 'language_level', 2) $
+   ELSE struct = Create_Struct(struct, 'language_level', 1)
+
+   ; Return the font type information to the user.
+
+fonttype = self.fonttypeSet
+
+   ; Depending upon which widgets are set, we have to add
+   ; additional fields to the structure.
+
+IF self.landscapeSet THEN BEGIN
+   struct = Create_Struct(struct, 'landscape', 1)
+   struct = Create_Struct(struct, 'portrait', 0)
+ENDIF ELSE BEGIN
+   struct = Create_Struct(struct, 'portrait', 1)
+   struct = Create_Struct(struct, 'landscape', 0)
+ENDELSE
+IF self.set_fontSet NE "" THEN struct = Create_Struct(struct, 'set_font', self.set_font)
+
+   ; What about font keywords?
+
+IF self.avantgarde THEN struct = Create_Struct(struct, 'avantgarde', 1)
+IF self.bookman THEN struct = Create_Struct(struct, 'bkman', 1)
+IF self.courier THEN struct = Create_Struct(struct, 'courier', 1)
+IF self.helvetica THEN struct = Create_Struct(struct, 'helvetica', 1)
+IF self.palatino THEN struct = Create_Struct(struct, 'palatino', 1)
+IF self.schoolbook THEN struct = Create_Struct(struct, 'schoolbook', 1)
+IF self.symbol THEN struct = Create_Struct(struct, 'symbol', 1)
+IF self.times THEN struct = Create_Struct(struct, 'times', 1)
+IF self.zapfdingbats THEN struct = Create_Struct(struct, 'zapfdingbats', 1)
+IF self.zapfchancery THEN struct = Create_Struct(struct, 'zapfchancery', 1)
+
+   ; What about style keywords?
+
+IF self.fontStyleSet[0] THEN struct = Create_Struct(struct, 'bold', 1) ELSE struct = Create_Struct(struct, 'bold', 0)
+IF self.fontStyleSet[1] THEN struct = Create_Struct(struct, 'book', 1) ELSE struct = Create_Struct(struct, 'book', 0)
+IF self.fontStyleSet[2] THEN struct = Create_Struct(struct, 'demi', 1) ELSE struct = Create_Struct(struct, 'demi', 0)
+IF self.fontStyleSet[3] THEN struct = Create_Struct(struct, 'italic', 1) ELSE struct = Create_Struct(struct, 'italic', 0)
+IF self.fontStyleSet[4] THEN struct = Create_Struct(struct, 'light', 1) ELSE struct = Create_Struct(struct, 'light', 0)
+IF self.fontStyleSet[5] THEN struct = Create_Struct(struct, 'medium', 1) ELSE struct = Create_Struct(struct, 'medium', 0)
+IF self.fontStyleSet[6] THEN struct = Create_Struct(struct, 'narrow', 1) ELSE struct = Create_Struct(struct, 'narrow', 0)
+IF self.fontStyleSet[7] THEN struct = Create_Struct(struct, 'oblique', 1) ELSE struct = Create_Struct(struct, 'oblique', 0)
+
+   ; Return the keyword stucture.
+
+RETURN, struct
+END ;--------------------------------------------------------------------------------
+
+
+
+
+FUNCTION FSC_PSConfig::GetName
+
+; This method returns the "name" of the object.
+
+RETURN, self.name
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSConfig::GetProperty, Name=name, _Extra=extra
+
+; This GetProperty method is set up only to be able to obtain
+; the name of the object. This makes the object compatible with
+; Martin Shultz's container object. All other keywords are swallowed
+; silently. Note that the GetName method can also be used.
+
+name = self.name
+END ;--------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PSCONFIG::GetSizes
+
+RETURN, [self.xsizeID->Get_Value(), self.ysizeID->Get_Value(), $
+   self.xoffsetID->Get_Value(), self.yoffsetID->Get_Value()]
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::GUI, Group_Leader=leader, NoBlock=noblock, Cancel=cancel, $
+   FontInfo=fontinfo, Accept_Button_Name=acceptButtonName, FontType=fonttype
+
+; This method displays the graphical user interface without font information.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Can't run this program in a device that doesn't support windows.
+
+self.thisDevice = !D.Name
+IF (!D.Flags AND 256) EQ 0 THEN BEGIN
+   thisOS = StrUpCase(!Version.OS_Family)
+   CASE thisOS OF
+      'MACOS': Set_Plot, 'Mac'
+      'WINDOWS': Set_Plot, 'Win'
+      ELSE: Set_Plot, 'X'
+   ENDCASE
+ENDIF
+
+   ; If the user wants font information, then call the GUIFont method.
+
+IF Keyword_Set(fontinfo) THEN BEGIN
+   self->GUIFont, Group_Leader=leader, NoBlock=noblock, Cancel=cancel, $
+      Accept_Button_Name=acceptButtonName, FontType=fonttype
+   RETURN
+ENDIF
+
+IF N_Elements(acceptButtonName) EQ 0 THEN BEGIN
+   IF Keyword_Set(noblock) THEN BEGIN
+      acceptButtonName = 'Apply'
+   ENDIF ELSE BEGIN
+      acceptButtonName = 'Accept'
+   ENDELSE
+ENDIF
+
+   ; Only one GUI at a time with the same name.
+
+IF XRegistered('fsc_psconfig_' + self.name) GT 0 THEN RETURN
+
+   ;Set default values.
+
+self.fontInfo = 0
+CW_FIELD_SIZE = 5
+IF Keyword_Set(noblock) THEN BEGIN
+   cancelButVal = 'Dismiss'
+ENDIF ELSE BEGIN
+   cancelButVal = 'Cancel'
+ENDELSE
+
+self.fontTypeSet = !P.Font
+IF Keyword_Set(noblock) THEN self.cancel = 0 ELSE self.cancel = 1
+
+   ; Modal TLB if possible.
+
+IF self.name NE "" THEN tlbTitle = self.name + ": Configure PostScript Device" ELSE $
+   tlbTitle = "Configure PostScript Device"
+
+IF N_Elements(leader) EQ 0 OR Keyword_Set(noblock) THEN BEGIN
+   tlb = Widget_Base(Title=tlbTitle, Column=1, Base_Align_Center=1)
+ENDIF ELSE BEGIN
+   tlb = Widget_Base(Title=tlbTitle, Column=1, $
+      Base_Align_Center=1, Group_Leader=leader, /Modal)
+ENDELSE
+
+self.tlb = tlb
+
+   ; Widget sub-bases.
+
+   topBase = Widget_Base(tlb, Row=1, UValue=self.thisDevice, Kill_Notify='FSC_PSConfig_Restore_Device')
+      leftTopBase = Widget_Base(topBase, Column=1)
+         controlBase = Widget_Base(leftTopBase, Column=1, /Frame)
+         euroBase = Widget_Base(leftTopBase, row=1, /NonExclusive)
+      rightTopBase = Widget_Base(topBase, Column=1, Base_Align_Center=1, Frame=1)
+         sizebase = Widget_Base(rightTopBase, Column=2)
+      middleTopBase = Widget_Base(topBase, Column=1, Base_Align_Center=1)
+   actionBase = Widget_Base(tlb, Row=1, Base_Align_Center=1)
+
+   ; Create droplist widgets.
+
+values = ['Letter', 'A4', 'Legal', 'Ledger']
+self.pageTypeID = FSC_Droplist(controlBase, Value=values, Title='Page Size:', $
+   UValue={Method:'PageSize', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.pageTypeID->SetSelection, self.pageTypeSet
+self.pagetype = self.pageTypeSet
+
+values = ['Portrait', 'Landscape']
+self.orientationID = FSC_Droplist(controlBase, Value=values, Title='Orientation:', $
+   UValue={Method:'Orientation', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.orientationID->SetIndex, self.landscapeSet
+
+values = ['Centimeters', 'Inches']
+self.unitsID = FSC_Droplist(controlBase, Value=values, Title='Units:', $
+   UValue={Method:'Units', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.unitsID->SetIndex, self.inchesSet
+
+values = ['Off', 'On']
+self.encapsulationID = FSC_Droplist(controlBase, Value=values, Title='Encapsulation:', $
+   UValue={Method:'ENCAPSULATE', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.encapsulationID->SetIndex, self.encapsulationSet
+
+values = ['None', 'EPSI', 'EPSF']
+self.previewID = FSC_Droplist(controlBase, Value=values, Title='Preview Mode:', $
+   UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.previewID->SetIndex, self.previewSet
+
+values = ['Off', 'On']
+self.colorID = FSC_Droplist(controlBase, Value=values, Title='Color Output:', $
+   UValue={Method:'COLOR', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.colorID->SetIndex, self.colorSet
+
+values = ['Off', 'On']
+self.cmykID = FSC_Droplist(controlBase, Value=values, Title = 'CMYK Output', $
+    UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.cmykID->SetIndex, self.cmykSet
+IF ~self.colorset THEN self.cmykID->Sensitive, 0
+
+values = ['8', '4', '2']
+self.bitsID = FSC_Droplist(controlBase, Value=values, Title='Bits Per Image Pixel:', $
+   UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.bitsID->SetSelection, self.bitsSet
+
+values = self->DefaultList()
+self.defaultsID = FSC_Droplist(controlBase, Value=values, Title='Setups:', $
+   UValue={Method:'DEFAULTS', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.defaultsID->SetSelection, self.defaultsSet
+
+euroSetUPID = Widget_Button(euroBase, Value='European Style', UValue={Method:'EUROSTYLE', Object:self})
+IF self.european THEN Widget_Control, euroSetUpID, /Set_Button
+IF self.inchesSet THEN unit = 'INCHES' ELSE unit = 'CENTIMETERS'
+
+windowDims = self->PageDimensions()
+shortside = Min(windowDims, Max=longside)
+IF self.landscapeSet THEN BEGIN
+   windowsize = [self.xoffsetSet/longside, self.yoffsetSet/shortside, $
+      self.xsizeSet/longside + self.xoffsetSet/longside, self.ysizeSet/shortside + self.yoffsetSet/shortside]
+ENDIF ELSE BEGIN
+   windowsize = [self.xoffsetSet/shortside, self.yoffsetSet/longside, $
+      self.xsizeSet/shortside + self.xoffsetSet/shortside, self.ysizeSet/longside + self.yoffsetSet/longside]
+ENDELSE
+
+   ; Create the plot window.
+
+self.plotID = FSC_PlotWindow(middleTopBase, Units=unit, PageSize=self.pagetypeSet, $
+   Landscape=self.landscapeSet, WindowSize=windowsize, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'PLOTWINDOW', Object:self})
+
+   ; Create size and offset windows.
+
+xsizeID = FSC_Field(sizebase, Title=' X Size: ', Value=self.xsizeSet, Object=xsizeObj, $
+   /Float, XSize=CW_FIELD_SIZE, Decimal=2, /CR_Only, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'WINDOWSIZE', Object:self}, /Positive, /Label_Left)
+self.xsizeID = xsizeObj
+ysizeID = FSC_Field(sizebase, Title=' Y Size: ', Value=self.ysizeSet, Object=ysizeObj, $
+   /Float, XSize=CW_FIELD_SIZE, Decimal=2, /CR_Only, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'WINDOWSIZE', Object:self}, /Positive, /Label_Left)
+self.ysizeID = ysizeObj
+
+xoffsetID = FSC_Field(sizebase, Title=' X Offset: ', Value=self.xoffsetSet, Object=xoffsetObj, $
+   /Float, XSize=CW_FIELD_SIZE, Decimal=2, /CR_Only, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'WINDOWSIZE', Object:self}, /Positive, /Label_Left)
+self.xoffsetID = xoffsetObj
+
+yoffsetID = FSC_Field(sizebase, Title=' Y Offset: ', Value=self.yoffsetSet, Object=yoffsetObj, $
+   /Float, XSize=CW_FIELD_SIZE, Decimal=2, /CR_Only, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'WINDOWSIZE', Object:self}, /Positive, /Label_Left)
+self.yoffsetID = yoffsetObj
+
+   ; Set up TABing between fields.
+
+self.xsizeID->SetTabNext, self.ysizeID->GetTextID()
+self.ysizeID->SetTabNext, self.xoffsetID->GetTextID()
+self.xoffsetID->SetTabNext, self.yoffsetID->GetTextID()
+self.yoffsetID->SetTabNext, self.xsizeID->GetTextID()
+
+   ; Create directions widgets.
+
+labelBase = Widget_Base(rightTopBase, Column=1, Base_Align_Center=1)
+label = Widget_Label(labelBase, Value='Directions')
+label = Widget_Label(labelBase, Value='Move or resize the PostScript "plot" on the', /Align_Left)
+label = Widget_Label(labelBase, Value='page with left or right buttons. Click the middle', /Align_Left)
+label = Widget_Label(labelBase, Value='button in the window to center plot on the page.', /Align_Left)
+
+   ; Create filename widgets.
+
+dummy = FSC_FileSelect(rightTopBase, Filename=self.filenameSet, $
+   Directory=self.directorySet, XSIZE=40, ObjectRef=filenameID)
+self.filenameID = filenameID
+
+   ; Create bottom button widgets.
+
+cancel = Widget_Button(actionBase, Value=cancelButVal, UValue={Method:'CANCEL', Object:self})
+self.revertID = Widget_Button(actionBase, Value='Revert', UValue={Method:'REVERT', Object:self}, Sensitive=0)
+helper = Widget_Button(actionBase, Value='Help', UValue={Method:'HELP', Object:self})
+self.acceptID = Widget_Button(actionBase, Value=acceptButtonName, UValue={Method:'ACCEPT', Object:self})
+
+   ; Size the widgets.
+
+t = Widget_Info(leftTopBase, /Geometry)
+targetSize = t.scr_xsize
+self.pageTypeID->Resize, ParentSize=targetsize
+self.orientationID->Resize, targetsize
+self.unitsID->Resize, targetsize
+self.encapsulationID->Resize, targetsize
+self.previewID->Resize, targetsize
+self.cmykID->Resize, targetsize
+self.colorID->Resize, targetsize
+self.bitsID->Resize, targetsize
+self.defaultsID->Resize, targetsize
+
+IF self.encapsulationID->GetIndex() THEN self.previewID->Sensitive, 1 ELSE self.previewID->Sensitive, 0
+self.plotID->SetColor, self.colorSet
+
+   ; Center and realize TLB.
+
+FSC_PSConfig_CenterTLB, tlb
+Widget_Control, tlb, /Realize
+
+self.noblock = Keyword_Set(noblock)
+
+   ; Save the current configuration.
+
+self->SaveConfiguration
+
+XManager, 'fsc_psconfig_' + self.name, tlb, Event_Handler='FSC_PSCONFIG_EVENTS', $
+  No_Block=Keyword_Set(noblock)
+IF Keyword_Set(noblock) THEN cancel = 0 ELSE cancel = self.cancel
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::GUIFont, Cancel=cancel, Group_Leader=leader, NoBlock=noblock, $
+   NoFont=nofont, Accept_Button_Name=acceptButtonName, FontType=fonttype
+
+; This method displays the graphical user interface with font information
+; in place.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Can't run this program in a device that doesn't support windows.
+
+self.thisDevice = !D.Name
+IF (!D.Flags AND 256) EQ 0 THEN BEGIN
+   thisOS = StrUpCase(!Version.OS_Family)
+   CASE thisOS OF
+      'MACOS': Set_Plot, 'Mac'
+      'WINDOWS': Set_Plot, 'Win'
+      ELSE: Set_Plot, 'X'
+   ENDCASE
+ENDIF
+
+   ; If the NoFont keyword is set, call the non-font GUI method.
+
+IF Keyword_Set(nofont) THEN BEGIN
+   self->Gui, Cancel=cancel, Group_Leader=leader, NoBlock=Keyword_Set(noblock), $
+      Accept_Button_Name=acceptButtonName, FontType=fonttype
+   RETURN
+ENDIF
+
+IF N_Elements(acceptButtonName) EQ 0 THEN BEGIN
+   IF Keyword_Set(noblock) THEN BEGIN
+      acceptButtonName = 'Apply'
+   ENDIF ELSE BEGIN
+      acceptButtonName = 'Accept'
+   ENDELSE
+ENDIF
+
+   ; Only one GUI at a time with the same name.
+
+IF XRegistered('fsc_psconfig_' + self.name) GT 0 THEN RETURN
+
+   ;Set default values.
+
+self.fontInfo = 1
+CW_FIELD_SIZE = 5
+IF Keyword_Set(noblock) THEN BEGIN
+   cancelButVal = 'Dismiss'
+ENDIF ELSE BEGIN
+   cancelButVal = 'Cancel'
+ENDELSE
+
+IF N_Elements(fonttype) EQ 0 THEN fonttype = self.fontTypeSet
+self.fontTypeSet = fonttype
+
+IF self.fontTypeSet EQ 1 THEN self.trueTypeSet = 1
+IF Keyword_Set(noblock) THEN self.cancel = 0 ELSE self.cancel = 1
+
+IF self.name NE "" THEN tlbTitle = self.name + ": Configure PostScript Device" ELSE $
+   tlbTitle = "Configure PostScript Device"
+
+   ; Modal TLB if possible.
+
+IF N_Elements(leader) EQ 0 OR Keyword_Set(noblock) THEN BEGIN
+   tlb = Widget_Base(Title=tlbTitle, Column=1, Base_Align_Center=1)
+ENDIF ELSE BEGIN
+   tlb = Widget_Base(Title=tlbTitle, Column=1, $
+      Base_Align_Center=1, Group_Leader=leader, /Modal)
+ENDELSE
+
+self.tlb = tlb
+
+   ; Sub-base hierarchy.
+
+   topBase = Widget_Base(tlb, Row=1, UValue=self.thisDevice, Kill_Notify='FSC_PSConfig_Restore_Device')
+      leftTopBase = Widget_Base(topBase, Column=1)
+         controlBase = Widget_Base(leftTopBase, Column=1, /Frame)
+         euroBase = Widget_Base(leftTopBase, row=1, /NonExclusive)
+      rightTopBase = Widget_Base(topBase, Column=1)
+         sizebase = Widget_Base(rightTopBase, Row=1, /Frame)
+         fontbase = Widget_Base(rightTopBase, Column=1, Base_Align_Left=1, Frame=1)
+            firstRow = Widget_Base(fontbase, Row=1)
+            secondRow = Widget_Base(fontbase, Row=1)
+            thirdRow = Widget_Base(fontbase, Row=1)
+            fourthRow = Widget_Base(fontbase, Row=1)
+      middleTopBase = Widget_Base(topBase, Column=1, Base_Align_Center=1)
+   actionBase = Widget_Base(tlb, Row=1, Base_Align_Center=1)
+
+   ; Create droplist widgets.
+
+values = ['Letter', 'A4', 'Legal', 'Ledger']
+self.pageTypeID = FSC_Droplist(controlBase, Value=values, Title='Page Size:', $
+   UValue={Method:'PageSize', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.pageTypeID->SetSelection, self.pageTypeSet
+self.pagetype = self.pageTypeSet
+
+values = ['Portrait', 'Landscape']
+self.orientationID = FSC_Droplist(controlBase, Value=values, Title='Orientation:', $
+   UValue={Method:'Orientation', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.orientationID->SetIndex, self.landscapeSet
+
+values = ['Centimeters', 'Inches']
+self.unitsID = FSC_Droplist(controlBase, Value=values, Title='Units:', $
+   UValue={Method:'Units', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.unitsID->SetIndex, self.inchesSet
+
+values = ['Off', 'On']
+self.encapsulationID = FSC_Droplist(controlBase, Value=values, Title='Encapsulation:', $
+   UValue={Method:'ENCAPSULATE', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.encapsulationID->SetIndex, self.encapsulationSet
+
+values = ['None', 'EPSI', 'EPSF']
+self.previewID = FSC_Droplist(controlBase, Value=values, Title='Preview Mode:', $
+   UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.previewID->SetIndex, self.previewSet
+
+values = ['Off', 'On']
+self.colorID = FSC_Droplist(controlBase, Value=values, Title='Color Output:', $
+   UValue={Method:'COLOR', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.colorID->SetIndex, self.colorSet
+
+values = ['Off', 'On']
+self.cmykID = FSC_Droplist(controlBase, Value=values, Title = 'CMYK Output', $
+    UValue={Method:'CMYK', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.cmykID->SetIndex, self.cmykSet
+
+values = ['8', '4', '2']
+self.bitsID = FSC_Droplist(controlBase, Value=values, Title='Bits Per Image Pixel:', $
+   UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.bitsID->SetSelection, self.bitsSet
+
+values = self->DefaultList()
+self.defaultsID = FSC_Droplist(controlBase, Value=values, Title='Setups:', $
+   UValue={Method:'DEFAULTS', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+self.defaultsID->SetSelection, self.defaultsSet
+
+euroSetUpID = Widget_Button(euroBase, Value='European Style', UValue={Method:'EUROSTYLE', Object:self})
+IF self.european THEN Widget_Control, euroSetUpID, /Set_Button
+IF self.inchesSet THEN unit = 'INCHES' ELSE unit = 'CENTIMETERS'
+
+windowDims = self->PageDimensions()
+shortside = Min(windowDims, Max=longside)
+IF self.landscapeSet THEN BEGIN
+   windowsize = [self.xoffsetSet/longside, self.yoffsetSet/shortside, $
+      self.xsizeSet/longside + self.xoffsetSet/longside, self.ysizeSet/shortside + self.yoffsetSet/shortside]
+ENDIF ELSE BEGIN
+   windowsize = [self.xoffsetSet/shortside, self.yoffsetSet/longside, $
+      self.xsizeSet/shortside + self.xoffsetSet/shortside, self.ysizeSet/longside + self.yoffsetSet/longside]
+ENDELSE
+
+   ; Create the plot window.
+
+self.plotID = FSC_PlotWindow(middleTopBase, Units=unit, PageSize=self.pagetypeSet, $
+   Landscape=self.landscapeSet, WindowSize=windowsize, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'PLOTWINDOW', Object:self})
+
+   ; Create size and offset windows.
+
+xsizeID = FSC_Field(sizebase, Title=' X Size: ', Value=self.xsizeSet, Object=xsizeObj, $
+   /Float, XSize=CW_FIELD_SIZE, Decimal=2, /CR_Only, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'WINDOWSIZE', Object:self}, /Positive, /Label_Left)
+self.xsizeID = xsizeObj
+ysizeID = FSC_Field(sizebase, Title=' Y Size: ', Value=self.ysizeSet, Object=ysizeObj, $
+   /Float, XSize=CW_FIELD_SIZE, Decimal=2, /CR_Only, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'WINDOWSIZE', Object:self}, /Positive, /Label_Left)
+self.ysizeID = ysizeObj
+
+xoffsetID = FSC_Field(sizebase, Title=' X Offset: ', Value=self.xoffsetSet, Object=xoffsetObj, $
+   /Float, XSize=CW_FIELD_SIZE, Decimal=2, /CR_Only, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'WINDOWSIZE', Object:self}, /Positive, /Label_Left)
+self.xoffsetID = xoffsetObj
+
+yoffsetID = FSC_Field(sizebase, Title=' Y Offset: ', Value=self.yoffsetSet, Object=yoffsetObj, $
+   /Float, XSize=CW_FIELD_SIZE, Decimal=2, /CR_Only, Event_Pro='FSC_PSCONFIG_Events', $
+   UValue={Method:'WINDOWSIZE', Object:self}, /Positive, /Label_Left)
+self.yoffsetID = yoffsetObj
+
+   ; Set up TABing between fields.
+
+self.xsizeID->SetTabNext, self.ysizeID->GetTextID()
+self.ysizeID->SetTabNext, self.xoffsetID->GetTextID()
+self.xoffsetID->SetTabNext, self.yoffsetID->GetTextID()
+self.yoffsetID->SetTabNext, self.xsizeID->GetTextID()
+
+   ; Create the font widgets.
+
+values = ['Vector (Hershey)', 'Hardware', 'True-Type']
+self.fontTypeID = FSC_Droplist(firstRow, Value=values, Title='Font Type: ', $
+   UValue={Method:'FONTTYPE', Object:self}, Event_Pro='FSC_PSCONFIG_Events') ;, UName='Font Type')
+self.fontTypeID->SetIndex, (0 > (self.fonttypeSet + 1) < 2)
+
+self.fontnameID = FSC_Droplist(firstrow, Value=*self.fontnames, Title='Font: ', $
+   UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events') ;, UName='Font Name')
+self.fontnameID->SetSelection, self.fontNameSet
+
+values = ['Bold','Book', 'Demi', 'Italic', 'Light', 'Medium', 'Narrow', 'Oblique']
+self.styleBaseID = Widget_Base(secondRow, Column=4, /Nonexclusive, /Frame)
+FOR j=0,7 DO BEGIN
+      self.fontStyleButtonID[j] = Widget_Button(self.styleBaseID, Value=values[j], $
+         UValue={Method:'STYLEBUTTONS', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+      Widget_Control, self.fontStylebuttonID[j], Set_Button=self.fontStyleSet[j]
+ENDFOR
+FOR j=0,7 DO IF self.fontStyleSet[j] THEN Widget_Control, self.fontStyleButtonID[j], Set_Button=1
+
+clearBaseID = Widget_Base(secondRow)
+self.clearButtonID = Widget_Button(clearBaseID, Value='Clear Font Styles', YOffset=15, XOffset=6, $
+         UValue={Method:'CLEARSTYLES', Object:self}, Event_Pro='FSC_PSCONFIG_Events')
+
+   ; More droplist widgets.
+
+values = Indgen(31) + 6
+self.fontSizeID = FSC_Droplist(thirdrow, Value=StrTrim(values,2), Title='Font Size: ', $
+   UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events') ;, UName='Font Size')
+self.fontSizeID->SetSelection, StrTrim(self.fontsizeSet,2)
+
+self.truetypeID = FSC_Droplist(thirdrow, Value=['No', 'Yes'], Title='True-Type: ', $
+   UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events') ;, UName='True-Type Fonts')
+self.truetypeID->SetIndex, self.truetypeSet
+
+self.isolatinID = FSC_Droplist(thirdrow, Value=['Off', 'On'], Title='ISOlatin1: ', $
+   UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events') ;, UName='Isolatin Encoding')
+self.isolatinID->SetIndex, self.isolatinSet
+
+;self.set_fontID = FSC_InputField(fourthRow, Value=self.set_fontSet, $
+;   UValue={Method:'NULL', Object:self}, Event_Pro='FSC_PSCONFIG_Events', $
+;   Title='Set_Font Name: ', XSize=35, /StringValue)
+
+   ; The directions widgets.
+
+labelBase = Widget_Base(middleTopBase, Column=1, Base_Align_Center=1)
+label = Widget_Label(labelBase, Value='Directions')
+label = Widget_Label(labelBase, Value='Move or resize the PostScript "plot" on the', /Align_Left)
+label = Widget_Label(labelBase, Value='page with left or right buttons. Click the middle', /Align_Left)
+label = Widget_Label(labelBase, Value='button in the window to center plot on the page.', /Align_Left)
+
+   ; The file name widgets.
+
+dummy = FSC_FileSelect(rightTopBase, Filename=self.filenameSet, $
+   Directory=self.directorySet, XSIZE=40, ObjectRef=filenameID)
+self.filenameID = filenameID
+
+   ; The bottom button widgets.
+
+cancel = Widget_Button(actionBase, Value=cancelButVal, UValue={Method:'CANCEL', Object:self})
+self.revertID = Widget_Button(actionBase, Value='Revert', UValue={Method:'REVERT', Object:self}, Sensitive=0)
+helper = Widget_Button(actionBase, Value='Help', UValue={Method:'HELP', Object:self})
+self.acceptID = Widget_Button(actionBase, Value=acceptButtonName, UValue={Method:'ACCEPT', Object:self})
+
+   ; Size the widgets for layout.
+
+t = Widget_Info(leftTopBase, /Geometry)
+targetSize = t.scr_xsize
+self.pageTypeID->Resize, ParentSize=targetsize
+self.orientationID->Resize, targetsize
+self.unitsID->Resize, targetsize
+self.encapsulationID->Resize, targetsize
+self.previewID->Resize, targetsize
+self.cmykID->Resize, targetsize
+self.colorID->Resize, targetsize
+self.bitsID->Resize, targetsize
+self.defaultsID->Resize, targetsize
+
+t = Widget_Info(fontbase, /Geometry)
+targetsize = t.scr_xsize / 2
+self.fontTypeID->Resize, targetsize
+self.fontnameID[0]->Resize, targetsize
+
+targetsize = t.scr_xsize / 3
+self.truetypeID->Resize, targetsize
+self.isoLatinID->Resize, targetsize
+self.fontSizeID->Resize, targetsize
+
+targetsize = t.scr_xsize
+IF Obj_Valid(self.set_fontID) THEN self.set_fontID->Resize, targetsize
+
+   ; Some widgets need to be turned off.
+
+IF self.encapsulationID->GetIndex() THEN self.previewID->Sensitive, 1 ELSE self.previewID->Sensitive, 0
+self.plotID->SetColor, self.colorSet
+IF self.fontTypeSet EQ -1 THEN BEGIN
+   Widget_Control, self.fontnameID->GetID(), Sensitive=0
+   Widget_Control, self.stylebaseID, Sensitive=0
+   Widget_Control, self.clearbuttonID, Sensitive=0
+   Widget_Control, self.fontSizeID->GetID(), Sensitive=0
+   Widget_Control, self.truetypeID->GetID(), Sensitive=0
+   Widget_Control, self.isolatinID->GetID(), Sensitive=0
+   IF Obj_Valid(self.set_fontID) THEN Widget_Control, self.set_fontID->GetID(), Sensitive=0
+ENDIF
+
+   ; Center and realize the top-level base.
+
+FSC_PSConfig_CenterTLB, tlb
+Widget_Control, tlb, /Realize
+
+self.noblock = Keyword_Set(noblock)
+
+   ; Save the current configuration.
+
+self->SaveConfiguration
+
+XManager, 'fsc_psconfig_' + self.name, tlb, Event_Handler='FSC_PSCONFIG_EVENTS', $
+  No_Block=Keyword_Set(noblock)
+IF Keyword_Set(noblock) THEN cancel = 0 ELSE cancel = self.cancel
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::Help, event
+
+; This is the text that pops up in the HELP WINDOW when the
+; Help button is selected. Feel free to change it to whatever
+; you like. The "textsize" variable below the help text should
+; be set to the number of lines of textual information.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+helptext = [ $
+"                                                              ", $
+"  The FSC_PSConfig object is a Open Source program written    ", $
+"  by David Fanning of Fanning Software Consulting. Complete   ", $
+"  program documenation is available on the FSC web page:      ", $
+"                                                              ", $
+"     http://www.dfanning.com/programs/docs/fsc_psconfig.html  ", $
+"                                                              ", $
+"  Other IDL programs, as well as many IDL programming tips    ", $
+"  and techniques can be found on the Coyote's Guide to IDL    ", $
+"  Programming web page. Please take a moment to look around.  ", $
+"                                                              ", $
+"     Fanning Software Consulting                              ", $
+"     1645 Sheely Drive                                        ", $
+"     Fort Collins, CO 80526                                   ", $
+"     Phone: 970-221-0438   Fax: 970-221-4762                  ", $
+"     E-Mail: david@dfanning.com                               ", $
+"     IDL Book Orders: 1-888-461-0155                          ", $
+"     Coyote's Guide: http://www.dfanning.com/                 ", $
+"                                                              " ]
+textsize = 19
+
+   ; Only one help display at a time, please.
+
+IF XRegistered('fsc_psconfig_help') GT 0 THEN RETURN
+
+   ; Creat the widgets for the HELP WINDOW.
+
+base = Widget_Base(Column=1, Group_Leader=self.acceptID)
+textID = Widget_Text(base, Value=helptext, Scr_XSize=500, YSize=textsize)
+IF NOT Widget_Info(self.tlb, /Modal) THEN button = Widget_Button(base, Value='Dismiss')
+FSC_PSConfig_CenterTLB, base
+Widget_Control, base, /Realize
+XManager, 'fsc_psconfig_help', base, /Just_Reg
+END ;--------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PSCONFIG::PageDimensions
+
+; This method sets up the page size. If you add a new page size,
+; you must add its dimensions (in inches) to the CASE statement below.
+
+; Letter 8.5 x 11.
+; Ledger 11 x 17.
+; Legal 8.5 x 14.
+; A4 8.27 x 11.7.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN, [0,0]
+ENDIF
+
+CASE StrUpCase(self.pagetype) OF
+   'LETTER': BEGIN
+         shortside = 8.5
+         longside = 11.0
+      ENDCASE
+   'LEDGER': BEGIN
+         shortside = 11.0
+         longside = 17.0
+      ENDCASE
+   'LEGAL': BEGIN
+         shortside = 8.5
+         longside = 14.0
+      ENDCASE
+   'A4': BEGIN
+         shortside = 8.27
+         longside = 11.70
+      ENDCASE
+;   ELSE: BEGIN
+;         shortside = 8.5
+;         longside = 11.0
+;      ENDCASE
+ENDCASE
+
+IF self.inchesSet EQ 0 THEN BEGIN
+   shortside = shortside * 2.54
+   longside = longside * 2.54
+ENDIF
+
+RETURN, [shortside, longside]
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::Orientation, event
+
+; This event handler method responds to changes in the Orientation droplist.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+pagetype = self.pageTypeID->GetSelection()
+Widget_Control, event.top, Update=0
+self.plotID->SetPageSize, pagetype, Landscape=event.index, TLB=self.tlb
+self.plotID->GetWindowLocation, xsize, ysize, xoffset, yoffset
+self->UpdateSizes, xsize, ysize, xoffset, yoffset
+self.landscapeSet = event.index
+Widget_Control, event.top, Update=1
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::PageSize, event
+
+; This event handler method responds to changes in the Page Size droplist.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Landscape is the default orientation for LEDGER output.
+
+IF StrUpCase(*event.selection) EQ "LEDGER" THEN BEGIN
+   landscapeValue = 1
+   self.orientationID->SetIndex, 1
+ENDIF ELSE landscapeValue = self.orientationID->GetIndex()
+
+   ; Change the page size. Get the window location and update the display.
+
+Widget_Control, event.top, Update=0
+self.plotID->SetPageSize, *event.selection, Landscape=landscapeValue, TLB=self.tlb
+self.plotID->GetWindowLocation, xsize, ysize, xoffset, yoffset
+self->UpdateSizes, xsize, ysize, xoffset, yoffset
+self.pagetype = *event.selection
+Widget_Control, event.top, Update=1
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::PlotWindow, event
+
+; The plot window moved or changed size. Update the size and offset widgets.
+
+self->UpdateSizes, event.xsize, event.ysize, event.xoffset, event.yoffset
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::Revert, event
+
+; This method allows the user to revert to the previously
+; saved configuration. All buttons, droplists, etc. are set
+; to their previously saved values.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Reset the widget setting variables.
+
+self.bitsSet = self.bitsRevert
+self.defaultsSet = self.defaultsRevert
+self.directorySet = self.directoryRevert
+self.encapsulationSet = self.encapsulationRevert
+self.filenameSet = self.filenameRevert
+self.fontsizeSet = self.fontsizeRevert
+self.fontstyleSet = self.fontstyleRevert
+self.fonttypeSet = self.fonttypeRevert
+self.fontnameSet = self.fontnameRevert
+self.inchesSet = self.inchesRevert
+self.isolatinSet = self.isolatinRevert
+self.landscapeSet = self.landscapeRevert
+self.pagetypeSet = self.pagetypeRevert
+self.previewSet = self.previewRevert
+self.set_fontSet = self.set_fontRevert
+self.truetypeSet = self.truetypeRevert
+self.cmykSet = self.cmykRevert
+self.colorSet = self.colorRevert
+self.xoffsetSet = self.xoffsetRevert
+self.xsizeSet = self.xsizeRevert
+self.yoffsetSet = self.yoffsetRevert
+self.ysizeSet = self.ysizeRevert
+
+IF Obj_Valid(self.plotID) THEN BEGIN
+   IF self.inchesSet THEN plotUnits = 'INCHES' ELSE plotUnits = 'CENTIMETERS'
+   self.plotID->SetUnits, plotUnits
+ENDIF
+
+   ; Turn off updating while you update the plot window.
+
+Widget_Control, event.top, Update=0
+self.plotID->SetPageSize, self.pagetypeSet, Landscape=self.landscapeSet, TLB=self.tlb
+self.plotID->SetWindowLocation, self.xsizeSet, self.ysizeSet, self.xoffsetSet, self.yoffsetSet
+self.plotID->SetColor, self.colorSet
+
+   ; Make sure the Preview droplist is set correctly.
+
+IF self.encapsulationSet THEN self.previewID->Sensitive, 1 ELSE self.previewID->Sensitive, 0
+
+   ; The statuslight should be set to SAFE.
+
+self->StatusLight, 1
+
+   ; Update the display.
+
+self->UpdateDisplay
+Widget_Control, event.top, Update=1
+self.plotID->Refresh
+
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::SaveConfiguration
+
+; This method saves the current configuration. Reversion
+; variables are set so the REVERT button can be used to
+; return to the previously saved configuration.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+self.bitsRevert = self.bitsSet
+self.cmykRevert = self.cmykSet
+self.colorRevert = self.colorSet
+self.defaultsRevert = self.defaultsSet
+self.directoryRevert = self.directorySet
+self.encapsulationRevert = self.encapsulationSet
+self.filenameRevert = self.filenameSet
+self.fontnameRevert = self.fontnameSet
+self.fontsizeRevert = self.fontsizeSet
+self.fontstyleRevert = self.fontstyleSet
+self.fonttypeRevert = self.fonttypeSet
+self.inchesRevert = self.inchesSet
+self.isolatinRevert = self.isolatinSet
+self.landscapeRevert = self.landscapeSet
+self.pagetypeRevert = self.pagetypeSet
+self.previewRevert = self.previewSet
+self.truetypeRevert = self.truetypeSet
+self.set_fontRevert = self.set_fontSet
+self.xoffsetRevert = self.xoffSetSet
+self.yoffsetRevert = self.yoffSetSet
+self.xsizeRevert = self.xsizeSet
+self.ysizeRevert = self.ysizeSet
+
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::SetDefault, defaultname
+
+; This method implements the default setups. To add your own default
+; setups, add the new default name to the list in the DefaultList method
+; above. Then add the default settings in the CASE statement below.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Set the page type and page units here, based on EUROPEAN setting.
+
+IF self.european THEN BEGIN
+   pagetype = 'A4'
+   units = 0
+ENDIF ELSE BEGIN
+   pagetype = 'LETTER'
+   units = 1
+ENDELSE
+
+   ; Get the directory name.
+
+IF Obj_Valid(self.filenameID) THEN BEGIN
+   self.filenameID->GetProperty, Directory=directoryName
+ENDIF ELSE BEGIN
+   CD, Current=directoryName
+ENDELSE
+
+   ; Get the file name.
+
+IF Obj_Valid(self.filenameID) THEN BEGIN
+   self.filenameID->GetProperty, Filename=defaultFileName
+   index = FSC_PSConfig_RStrPos( defaultFileName, "." )
+   IF index GE 0 THEN defaultFileName = StrMid(defaultFileName, 0, index)
+ENDIF ELSE BEGIN
+   IF self.filenameSet NE "" THEN defaultFilename = self.filenameSet ELSE defaultFileName = "idl"
+ENDELSE
+
+   ; Get the names of the defaults on the default list.
+
+defaultlist = self->DefaultList()
+
+   ; If the defaultname variable is undefined, choose the first one
+   ; in the list.
+
+IF N_Elements(defaultname) EQ 0 THEN defaultname = defaultlist[0]
+defaultname = String(defaultname)
+
+   ; Define synonyms.
+
+IF StrUpCase(defaultname) EQ 'SYSTEM' THEN defaultname = 'System (Portrait)'
+IF StrUpCase(defaultname) EQ 'PORTRAIT' THEN defaultname = 'Centered (Portrait)'
+IF StrUpCase(defaultname) EQ 'LANDSCAPE' THEN defaultname = 'Centered (Landscape)'
+IF StrUpCase(defaultname) EQ 'CENTER' THEN defaultname = 'Centered (Portrait)'
+IF StrUpCase(defaultname) EQ 'CENTERED' THEN defaultname = 'Centered (Portrait)'
+IF StrUpCase(defaultname) EQ 'FIGURE' THEN defaultname = 'Figure (Large)'
+IF StrUpCase(defaultname) EQ 'ENCAPSULATED' THEN defaultname = 'Figure (Small)'
+IF StrUpCase(defaultname) EQ 'ENCAPSULATE' THEN defaultname = 'Figure (Small)'
+IF StrUpCase(defaultname) EQ 'COLOR' THEN defaultname = 'Color (Portrait)'
+IF StrUpCase(defaultname) EQ 'NONE' THEN defaultname = 'None'
+
+
+index = Where(StrUpCase(defaultlist) EQ StrUpCase(defaultname), count)
+IF count EQ 0 THEN BEGIN
+   ok = Dialog_Message(['Default set-up "' + defaultname + '" is', $
+      'unknown. Using system defaults.'])
+   defaultname = 'System (Portrait)'
+ENDIF
+
+thisDefault = defaultlist[index[0]]
+
+   ; The default setups. Add your setups to this CASE statement if you are
+   ; adding a new default setup.
+
+CASE thisDefault OF
+
+   'System (Portrait)': BEGIN
+         self.bitsSet = '8'                          ; Sets the Bits-per-Pixels keyword.
+         self.colorSet = 0                           ; Sets the Color keyword.
+         self.directorySet = directoryName           ; Sets the directory name of the PostScript file.
+         self.encapsulationSet = 0                   ; Sets the Encapsulation keyword.
+         self.filenameSet = defaultFilename + ".ps"  ; Sets the filename of the PostScript file.
+         self.fonttypeSet = !P.Font                  ; Sets the Font keyword.
+         self.fontsizeSet = 12                       ; Sets the Font_Size keyword.
+         self.fontStyleSet = Replicate(0, 8)         ; Sets the font style keywords in this order: Bold, Book, Demi, Italic, Light, Medium, Narrow, and Oblique.
+         self.fontnameSet = "Helvetica"              ; Sets the PostScript font name. All PostScript font names acceptable.
+         self.inchesSet = units                      ; Sets the Inches keyword.
+         self.landscapeSet = 0                       ; Sets the Landscape keyword.
+         self.isolatinSet = 0                        ; Sets the Isolatin1 keyword.
+         self.pagetypeSet = pagetype                 ; Sets the page type. Possible values include "Letter", "A4", etc.
+         self.pagetype = pagetype                    ; Sets the page type. Possible values include "Letter", "A4", etc.
+         self.previewSet = 0                         ; Sets the Preview keyword.
+         self.truetypeSet = 0                        ; Sets the TT_Font keyword.
+         IF self.european THEN self.xoffsetSet = 1.61 ELSE self.xoffsetSet = 0.75 ; Sets the XOffset keyword.
+         IF self.european THEN self.yoffsetSet = 14.65 ELSE self.yoffsetSet = 5.0 ; Sets the YOffset keyword.
+         IF self.european THEN self.xsizeSet = 17.80 ELSE self.xsizeSet = 7.0     ; Sets the XSize keyword.
+         IF self.european THEN self.ysizeSet = 12.70 ELSE self.ysizeSet = 5.0     ; Sets the YSize keyword.
+         self.defaultsSet = 'System (Portrait)'
+      ENDCASE
+
+   'System (Landscape)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 0
+         self.directorySet = directoryName
+         self.encapsulationSet = 0
+         self.filenameSet = defaultFilename + ".ps"
+         self.fonttypeSet = !P.Font
+         self.fontsizeSet = 12
+         self.fontstyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 1
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.pagetype = pagetype
+         self.previewSet = 0
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 1.76 ELSE self.xoffsetSet = 0.75
+         IF self.european THEN self.yoffsetSet = 1.69 ELSE self.yoffsetSet = 0.75
+         IF self.european THEN self.xsizeSet = 26.25 ELSE self.xsizeSet = 9.5
+         IF self.european THEN self.ysizeSet = 17.63 ELSE self.ysizeSet = 7.0
+         self.defaultsSet = 'System (Landscape)'
+     ENDCASE
+
+   'Centered (Portrait)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 1
+         self.directorySet = directoryName
+         self.encapsulationSet = 0
+         self.filenameSet = defaultFilename + ".ps"
+         self.fonttypeSet = !P.Font
+         self.fontsizeSet = 12
+         self.fontstyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 0
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.pagetype = pagetype
+         self.previewSet = 0
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 3.51 ELSE self.xoffsetSet = 1.5
+         IF self.european THEN self.yoffsetSet = 3.68 ELSE self.yoffsetSet = 1.5
+         IF self.european THEN self.xsizeSet = 14.00 ELSE self.xsizeSet = 5.5
+         IF self.european THEN self.ysizeSet = 22.40 ELSE self.ysizeSet = 8.0
+         self.defaultsSet = 'Centered (Portrait)'
+      ENDCASE
+
+   'Centered (Landscape)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 1
+         self.directorySet = directoryName
+         self.encapsulationSet = 0
+         self.filenameSet = defaultFilename + ".ps"
+         self.fonttypeSet = !P.Font
+         self.fontsizeSet = 12
+         self.fontstyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 1
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.pagetype = pagetype
+         self.previewSet = 0
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 3.66 ELSE self.xoffsetSet = 1.5
+         IF self.european THEN self.yoffsetSet = 3.52 ELSE self.yoffsetSet = 1.5
+         IF self.european THEN self.xsizeSet = 22.43 ELSE self.xsizeSet = 8.0
+         IF self.european THEN self.ysizeSet = 13.97 ELSE self.ysizeSet = 5.5
+         self.defaultsSet = 'Centered (Landscape)'
+      ENDCASE
+
+   'Square (Portrait)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 1
+         self.directorySet = directoryName
+         self.encapsulationSet = 0
+         self.filenameSet = defaultFilename + ".ps"
+         self.fonttypeSet = !P.Font
+         self.fontsizeSet = 12
+         self.fontstyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 0
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.pagetype = pagetype
+         self.previewSet = 0
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 2.26 ELSE self.xoffsetSet = 1.0
+         IF self.european THEN self.yoffsetSet = 6.63 ELSE self.yoffsetSet = 2.25
+         IF self.european THEN self.xsizeSet = 16.50 ELSE self.xsizeSet = 6.5
+         IF self.european THEN self.ysizeSet = 16.50 ELSE self.ysizeSet = 6.5
+         self.defaultsSet = 'Square (Portrait)'
+      ENDCASE
+
+   'Square (Landscape)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 1
+         self.directorySet = directoryName
+         self.encapsulationSet = 0
+         self.filenameSet = defaultFilename + ".ps"
+         self.fonttypeSet = !P.Font
+         self.fontsizeSet = 12
+         self.fontstyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 1
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.pagetype = pagetype
+         self.previewSet = 0
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 6.63 ELSE self.xoffsetSet = 2.25
+         IF self.european THEN self.yoffsetSet = 2.26 ELSE self.yoffsetSet = 1.0
+         IF self.european THEN self.xsizeSet = 16.50 ELSE self.xsizeSet = 6.5
+         IF self.european THEN self.ysizeSet = 16.50 ELSE self.ysizeSet = 6.5
+         self.defaultsSet = 'Square (Landscape)'
+      ENDCASE
+
+   'Figure (Small)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 1
+         self.directorySet = directoryName
+         self.encapsulationSet = 1
+         self.filenameSet = defaultFilename + ".eps"
+         self.fonttypeSet = !P.Font
+         self.fontsizeSet = 12
+         self.fontstyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 0
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.pagetype = pagetype
+         self.previewSet = 2
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 6.06 ELSE self.xoffsetSet = 2.5
+         IF self.european THEN self.yoffsetSet = 11.71 ELSE self.yoffsetSet = 4.25
+         IF self.european THEN self.xsizeSet = 8.89 ELSE self.xsizeSet = 3.5
+         IF self.european THEN self.ysizeSet = 6.35 ELSE self.ysizeSet = 2.5
+         self.defaultsSet = 'Figure (Small)'
+      ENDCASE
+
+   'Figure (Large)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 1
+         self.directorySet = directoryName
+         self.encapsulationSet = 1
+         self.filenameSet = defaultFilename + ".eps"
+         self.fonttypeSet = 0
+         self.fontsizeSet = 12
+         self.fontstyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 0
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.pagetype = pagetype
+         self.previewSet = 2
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 4.16 ELSE self.xoffsetSet = 1.75
+         IF self.european THEN self.yoffsetSet = 9.8 ELSE self.yoffsetSet = 3.5
+         IF self.european THEN self.xsizeSet = 12.70 ELSE self.xsizeSet = 5.0
+         IF self.european THEN self.ysizeSet = 10.16 ELSE self.ysizeSet = 4.0
+         self.defaultsSet = 'Figure (Large)'
+      ENDCASE
+
+   'Color (Portrait)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 1
+         self.directorySet = directoryName
+         self.encapsulationSet = 0
+         self.filenameSet = defaultFilename + ".ps"
+         self.fonttypeSet = !P.Font
+         self.fontsizeSet = 12
+         self.fontstyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 0
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.pagetype = pagetype
+         self.previewSet = 0
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 3.51 ELSE self.xoffsetSet = 1.5
+         IF self.european THEN self.yoffsetSet = 3.68 ELSE self.yoffsetSet = 1.5
+         IF self.european THEN self.xsizeSet = 14.00 ELSE self.xsizeSet = 5.5
+         IF self.european THEN self.ysizeSet = 22.40 ELSE self.ysizeSet = 8.0
+         self.defaultsSet = 'Color (Portrait)'
+      ENDCASE
+
+   'Color (Landscape)': BEGIN
+         self.bitsSet = '8'
+         self.colorSet = 1
+         self.directorySet = directoryName
+         self.encapsulationSet = 0
+         self.filenameSet = defaultFilename + ".ps"
+         self.fonttypeSet = !P.Font
+         self.fontsizeSet = 12
+         self.fontstyleSet = Replicate(0, 8)
+         self.fontnameSet = "Helvetica"
+         self.inchesSet = units
+         self.landscapeSet = 1
+         self.isolatinSet = 0
+         self.pagetypeSet = pagetype
+         self.pagetype = pagetype
+         self.previewSet = 0
+         self.truetypeSet = 0
+         IF self.european THEN self.xoffsetSet = 3.66 ELSE self.xoffsetSet = 1.5
+         IF self.european THEN self.yoffsetSet = 3.52 ELSE self.yoffsetSet = 1.5
+         IF self.european THEN self.xsizeSet = 22.43 ELSE self.xsizeSet = 8.0
+         IF self.european THEN self.ysizeSet = 13.97 ELSE self.ysizeSet = 5.5
+         self.defaultsSet = 'Color (Landscape)'
+      ENDCASE
+
+   ELSE: self.defaultsSet = 'None'
+ENDCASE
+
+
+IF Obj_Valid(self.plotID) THEN BEGIN
+   IF self.inchesSet THEN plotUnits = 'INCHES' ELSE plotUnits = 'CENTIMETERS'
+   self.plotID->SetUnits, plotUnits
+ENDIF
+
+   ; If the font information is on the display, update it.
+
+IF self.fontInfo THEN BEGIN
+
+   IF self.fontTypeSet EQ -1 THEN BEGIN
+      Widget_Control, self.fontnameID->GetID(), Sensitive=0
+      Widget_Control, self.stylebaseID, Sensitive=0
+      Widget_Control, self.clearbuttonID, Sensitive=0
+      Widget_Control, self.fontSizeID->GetID(), Sensitive=0
+      Widget_Control, self.truetypeID->GetID(), Sensitive=0
+      Widget_Control, self.isolatinID->GetID(), Sensitive=0
+      IF Obj_Valid(self.set_fontID) THEN Widget_Control, self.set_fontID->GetID(), Sensitive=0
+   ENDIF ELSE BEGIN
+      Widget_Control, self.fontnameID->GetID(), Sensitive=1
+      Widget_Control, self.stylebaseID, Sensitive=1
+      Widget_Control, self.clearbuttonID, Sensitive=1
+      Widget_Control, self.fontSizeID->GetID(), Sensitive=1
+      Widget_Control, self.truetypeID->GetID(), Sensitive=1
+      Widget_Control, self.isolatinID->GetID(), Sensitive=1
+      IF Obj_Valid(self.set_fontID) THEN Widget_Control, self.set_fontID->GetID(), Sensitive=1
+
+ENDELSE
+
+ENDIF
+
+   ; Update the display.
+
+self->UpDateDisplay
+
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::StatusLight, safe
+
+; This method sets the status light (the background color of the
+; page window). Safe equal 1 means the current configuration is saved.
+; Safe equal 0 means the current configuration is not saved. The
+; REVERT button is turned on or off to reflect the current SAFE state.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+safe = Keyword_Set(safe)
+
+   ; Different colors based on depth of visual class.
+
+Device, Get_Visual_Depth=theDepth
+IF safe THEN BEGIN
+   IF theDepth GT 8 THEN windowColor = [60, 140, 140] ELSE windowColor = [80, 80, 80]
+   Widget_Control, self.revertID, Sensitive=0
+ENDIF ELSE BEGIN
+   IF theDepth GT 8 THEN windowColor = [200, 133, 133] ELSE windowColor = [140, 140, 140]
+      Widget_Control, self.revertID, Sensitive=1
+ENDELSE
+
+   ; Update the background window color. Done only in NOBLOCK conditions.
+
+IF self.noblock THEN self.plotID->SetWindowColor, windowColor
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::StyleButtons, event
+
+; This event handler method responds to changes in the font style buttons.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+index = Where(self.fontStyleButtonID EQ event.id)
+index = index[0]
+self.fontStyleSet[index] = event.select
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::Units, event
+
+; This event handler method responds to changes in the Units droplist.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+units = self.unitsID->GetSelection()
+self.plotID->SetUnits, units
+self.plotID->GetWindowLocation, xsize, ysize, xoffset, yoffset
+self->UpdateSizes, xsize, ysize, xoffset, yoffset
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::UpdateDisplay
+
+; This method updates the GUI display with the current object settings.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Can only update if widget is valid and realized.
+
+IF Widget_Info(self.tlb, /Valid_ID) EQ 0 THEN RETURN
+IF Widget_Info(self.tlb, /Realized) EQ 0 THEN RETURN
+
+   ; Set the normal GUI widgets.
+
+self.bitsID->SetSelection, self.bitsSet
+self.cmykID->SetIndex, self.cmykSet
+self.colorID->SetIndex, self.colorSet
+self.filenameID->SetProperty, Directory=self.directorySet, Filename=self.filenameSet
+self.encapsulationID->SetIndex, self.encapsulationSet
+self.unitsID->SetIndex, self.inchesSet
+self.orientationID->SetIndex, self.landscapeSet
+self.pagetypeID->SetSelection, self.pagetypeSet
+self.previewID->SetIndex, self.previewSet
+self.xsizeID->Set_Value, self.xsizeSet
+self.ysizeID->Set_Value, self.ysizeSet
+self.xoffsetID->Set_Value, self.xoffsetSet
+self.yoffsetID->Set_Value, self.yoffsetSet
+self.defaultsID->SetSelection, self.defaultsSet
+
+   ; If font information is on the display, set that too.
+
+IF self.fontInfo THEN BEGIN
+   self.fontTypeID->SetIndex, (0 > (self.fonttypeSet + 1) < 2)
+   self.fontsizeID->SetSelection, StrTrim(self.fontsizeSet,2)
+   self.isolatinID->SetIndex, self.isolatinSet
+   self->UpDateFontStyle
+   self.fontnameID->SetSelection, self.fontnameSet
+   IF Obj_Valid(self.set_fontID) THEN self.set_fontID->Set_Value, self.set_fontSet
+   self.truetypeID->SetIndex, self.truetypeSet
+ENDIF
+
+   ; Update the plot window and set the size and offset widgets.
+
+self.plotID->SetPageSize, self.pagetypeSet, Landscape=self.landscapeSet, TLB=self.tlb
+self.plotID->SetWindowLocation, self.xsizeSet, self.ysizeSet, self.xoffsetSet, self.yoffsetSet
+self.plotID->GetWindowLocation, xsize, ysize, xoffset, yoffset
+self.xsizeID->Set_Value, xsize
+self.ysizeID->Set_Value, ysize
+self.xoffsetID->Set_Value, xoffset
+self.yoffsetID->Set_Value, yoffset
+self.plotID->SetColor, self.colorSet
+
+IF self.encapsulationSet THEN self.previewID->Sensitive, 1 ELSE self.previewID->Sensitive, 0
+
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::UpdateFontStyle, Clear = Clear
+
+; This method updates the font style box. If the CLEAR keyword
+; is set, all the widgets are turned OFF.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+IF Keyword_Set(clear) THEN BEGIN
+   FOR j=0,7 DO BEGIN
+      Widget_Control, self.fontstyleButtonID[j], Set_Button=0
+      self.fontStyleSet[j] = 0
+   ENDFOR
+ENDIF ELSE BEGIN
+   FOR j=0,7 DO Widget_Control, self.fontstyleButtonID[j], Set_Button=self.fontStyleSet[j]
+ENDELSE
+
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::UpdateSizes, xsize, ysize, xoffset, yoffset
+
+; This method updates the size and offset widgets.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+self.xsizeID->Set_Value, xsize
+self.ysizeID->Set_Value, ysize
+self.xoffsetID->Set_Value, xoffset
+self.yoffsetID->Set_Value, yoffset
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::WindowSize, event
+
+; This is the event handler method that responds to events
+; in the XSize, YSize, XOffset, and YOffset text widgets.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=self.debug)
+   RETURN
+ENDIF
+
+   ; Get the values in the appropriate widgets.
+
+IF N_Elements(self.xsizeID->Get_Value()) EQ 0 THEN BEGIN
+   IF self.inchesSet THEN xsize = 1.0 ELSE xsize = 2.54
+ENDIF ELSE xsize = self.xsizeID->Get_Value()
+IF N_Elements(self.ysizeID->Get_Value()) EQ 0 THEN BEGIN
+   IF self.inchesSet THEN ysize = 1.0 ELSE ysize = 2.54
+ENDIF ELSE ysize = self.ysizeID->Get_Value()
+IF N_Elements(self.xoffsetID->Get_Value()) EQ 0 THEN xoffset = 0.0 $
+   ELSE xoffset = self.xoffsetID->Get_Value()
+IF N_Elements(self.yoffsetID->Get_Value()) EQ 0 THEN yoffset = 0.0 $
+   ELSE yoffset = self.yoffsetID->Get_Value()
+
+   ; Change the plot window to these sizes and offsets.
+
+self.plotID->SetWindowLocation, xsize, ysize, xoffset, yoffset
+
+   ; The input values may be bogus. Get the "real" values from the
+   ; plot object and update the size and offset widgets.
+
+self.plotID->GetWindowLocation, xsize, ysize, xoffset, yoffset
+self.xsizeID->Set_Value, xsize
+self.ysizeID->Set_Value, ysize
+self.xoffsetID->Set_Value, xoffset
+self.yoffsetID->Set_Value, yoffset
+END ;--------------------------------------------------------------------------------
+
+
+
+
+PRO FSC_PSCONFIG::SetProperty,        $ ; The SetProperty method of the object.
+   AvantGarde=avantgarde,             $ ; Set this keyword to select the AvantGarde font.
+   Bits_per_Pixel=bits_per_pixel,     $ ; The number of image bits saved for each image pixel: 2, 4, or 8.
+   Bold=bold,                         $ ; Set this keyword to select the Bold font style.
+   BookStyle=book,                    $ ; Set this keyword to select the Book font style.
+   Bkman=bookman,                     $ ; Set this keyword to select the Bookman font.
+   CMYK=cmyk,                         $ ; Set this keywprd to use CMYK colors instead of RGB.
+   Color=color,                       $ ; Set this keyword to select Color PostScript output.
+   Courier=courier,                   $ ; Set this keyword to select the Courier font.
+   DefaultSetup=defaultsetup,         $ ; Set this keyword to the "name" of a default style.
+   Demi=demi,                         $ ; Set this keyword to select the Demi font style.
+   Directory=directory,               $ ; Set thie keyword to the name of the starting directory. Current directory by default.
+   Encapsulated=encapsulated,         $ ; Set this keyword to select Encapsulated PostScript output.
+   European=european,                 $ ; Set this keyword to indicate "european" mode (i.e., A4 page and centimeter units).
+   Filename=filename,                 $ ; Set this keyword to the name of the file. Default: 'idl.ps'
+   FontSize=fontsize,                 $ ; Set this keyword to the font size. Between 6 and 36. Default is 12.
+   FontType=fonttype,                 $ ; Set this keyword to select the font type: -1 is Hershey, 0 is hardward, 1 is true-type.
+   Helvetica=helvetica,               $ ; Set this keyword to select the Helvetica font.
+   Inches=inches,                     $ ; Set this keyword to indicate sizes and offsets are in inches as opposed to centimeters.
+   Italic=italic,                     $ ; Set this keyword to select the Italic font style.
+   Isolatin=isolatin,                 $ ; Set this keyword to select ISOlatin1 encoding.
+   Landscape=landscape,               $ ; Set this keyword to select Landscape output.
+   Light=light,                       $ ; Set this keyword to select the Light font style.
+   Medium=medium,                     $ ; Set this keyword to select the Medium font style.
+   Name=name,                         $ ; This is the "name" of the object.
+   Narrow=narrow,                     $ ; Set this keyword to select the Narrow font style.
+   Oblique=oblique, $                 $ ; Set this keyword to select the Oblique font style.
+   PageType=pagetype,                 $ ; Set this keyword to the "type" of page: 'Letter', 'Legal', 'Ledger', or 'A4'.
+   Palatino=palatino,                 $ ; Set this keyword to select the Palatino font.
+   Preview=preview,                   $ ; Set this keyword to select Preview mode: 0, 1, or 2.
+   Schoolbook=schoolbook,             $ ; Set this keyword to select the Schoolbook font.
+   Set_Font=set_font,                 $ ; Set this keyword to the name of a font passed to PostScript with Set_Plot keyword.
+   Symbol=symbol,                     $ ; Set this keyword to select the Symbol font.
+   Times=times,                       $ ; Set this keyword to select the Times font.
+   TrueType=truetype,                 $ ; Set this keyword to select True-Type fonts.
+   UpDate=update, $                   $ ; Set this keyword to update the GUI if it is on the display.
+   XOffset=xoffset,                   $ ; Set this keyword to the XOffset. (Note: offset calculated from lower-left corner of page.)
+   XSize=xsize,                       $ ; Set this keyword to the X size of the PostScript "window".
+   YOffset=yoffset,                   $ ; Set this keyword to the YOffset. (Note: offset calculated from lower-left corner of page.)
+   YSize=ysize,                       $ ; Set this keyword to the Y size of the PostScript "window".
+   ZapfChancery=zapfchancery,         $ ; Set this keyword to select the ZapfChancery font.
+   ZapfDingbats=zapfdingbats            ; Set this keyword to select the ZapfDingbats font.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=Keyword_Set(self.debug))
+   RETURN
+ENDIF
+
+   ; Check for undefined variables.
+
+IF N_Elements(bits_per_pixel) NE 0 THEN BEGIN
+   IF bits_per_pixel EQ 2 OR bits_per_pixel EQ 4 OR bits_per_pixel EQ 8 THEN $
+      self.bitsSet = StrTrim(bits_per_pixel,2) ELSE self.bitsSet = '8'
+ENDIF
+IF N_Elements(color) NE 0 THEN self.colorSet = color
+IF N_Elements(directory) NE 0 THEN self.directorySet = directory
+IF N_Elements(filename) NE 0 THEN self.filenameSet = filename
+self.fullfilenameSet = self->Construct_Full_Filename()
+IF N_Elements(fontsize) NE 0 THEN self.fontsizeSet = fontsize
+IF N_Elements(fonttype) NE 0 THEN self.fonttypeSet = fonttype
+IF N_Elements(encapsulated) NE 0 THEN self.encapsulationSet = encapsulated
+IF Keyword_Set(inches) NE 0 THEN self.inchesSet = inches
+IF N_Elements(landscape) NE 0 THEN self.landscape = landscape
+IF Keyword_Set(name) NE 0 THEN self.name = name
+IF N_Elements(pagetype) NE 0 THEN BEGIN
+   self.pagetypeSet = pagetype
+   self.pagetype = pagetype
+ENDIF
+IF N_Elements(preview) NE 0 THEN self.previewSet = 0 > preview < 2
+
+IF N_Elements(set_font) NE 0 THEN self.set_fontSet = set_font
+IF N_Elements(xsize) NE 0 THEN self.xsizeSet = xsize
+IF N_Elements(ysize) NE 0 THEN self.ysizeSet = ysize
+
+   ; Offsets are weird.
+
+dims = self->PageDimensions()
+IF N_Elements(xoffset) NE 0 THEN IF self.landscape THEN self.xoffsetSet = dims[1] - yoffset ELSE self.xoffsetSet = xoffset
+IF N_Elements(yoffset) NE 0 THEN IF self.landscape THEN self.yoffsetSet = xoffset ELSE self.yoffsetSet = yoffset
+
+
+avantgarde = Keyword_Set(avantgarde)
+bold = Keyword_Set(bold)
+book = Keyword_Set(book)
+bookman = Keyword_Set(bookman)
+cmyk = Keyword_Set(cmyk)
+courier = Keyword_Set(courier)
+demi = Keyword_Set(demi)
+encapsulated = Keyword_Set(encapsulated)
+european = Keyword_Set(european)
+helvetica = Keyword_Set(helvetica)
+isolatin = Keyword_Set(isolatin)
+italic = Keyword_Set(italic)
+landscape = Keyword_Set(landscape)
+light = Keyword_Set(light)
+medium = Keyword_Set(medium)
+narrow = Keyword_Set(narrow)
+oblique = Keyword_Set(oblique)
+palatino = Keyword_Set(palatino)
+schoolbook = Keyword_Set(schoolbook)
+symbol = Keyword_Set(symbol)
+times = Keyword_Set(times)
+truetype = Keyword_Set(truetype)
+zapfchancery = Keyword_Set(zapfchancery)
+zapfdingbats = Keyword_Set(zapfdingbats)
+
+fontset = [avantgarde, bookman, courier, helvetica, palatino, schoolbook, symbol, times, zapfchancery, zapfdingbats]
+index = Where(fontset EQ 1, count)
+IF count EQ 0 THEN self.fontnameSet = 'Helvetica' ELSE self.fontnameSet = (*self.fontnames)[index[0]]
+IF self.fontnameSet EQ 'AvantGarde' THEN self.avantgarde = 1 ELSE self.avantgarde = 0
+IF self.fontnameSet EQ 'Bookman' THEN self.bookman = 1 ELSE self.bookman = 0
+IF self.fontnameSet EQ 'Courier' THEN self.courier = 1 ELSE self.courier = 0
+IF self.fontnameSet EQ 'Helvetica' THEN self.helvetica = 1 ELSE self.helvetica = 0
+IF self.fontnameSet EQ 'Palatino' THEN self.palatino = 1 ELSE self.palatino = 0
+IF self.fontnameSet EQ 'Schoolbook' THEN self.schoolbook = 1 ELSE self.schoolbook = 0
+IF self.fontnameSet EQ 'Symbol' THEN self.symbol = 1 ELSE self.symbol = 0
+IF self.fontnameSet EQ 'Times' THEN self.times = 1 ELSE self.times = 0
+IF self.fontnameSet EQ 'ZapfChancery' THEN self.zapfchancery = 1 ELSE self.zapfchancery = 0
+IF self.fontnameSet EQ 'ZapfDingbats' THEN self.zapfdingbats = 1 ELSE self.zapfdingbats = 0
+self.fontstyleSet = [bold, book, demi, italic, light, medium, narrow, oblique]
+
+   ; Populate the self object by saving the configuration.
+
+self->SaveConfiguration
+
+   ; Update the display if required.
+
+IF Keyword_Set(update) THEN self->UpdateDisplay
+
+END ;--------------------------------------------------------------------------------
+
+
+
+PRO FSC_PSCONFIG::CLEANUP
+Ptr_Free, self.fontnames
+END ;--------------------------------------------------------------------------------
+
+
+
+FUNCTION FSC_PSCONFIG::INIT,          $ ; The INIT method of the FSC_PSCONFIG object.
+   AvantGarde=avantgarde,             $ ; Set this keyword to select the AvantGarde font.
+   Bits_per_Pixel=bits_per_pixel,     $ ; The number of image bits saved for each image pixel: 2, 4, or 8.
+   Bold=bold,                         $ ; Set this keyword to select the Bold font style.
+   BookStyle=book,                    $ ; Set this keyword to select the Book font style.
+   Bkman=bookman,                     $ ; Set this keyword to select the Bookman font.
+   CMYK=cmyk,                         $ ; Set this keywprd to use CMYK colors instead of RGB.
+   Color=color,                       $ ; Set this keyword to select Color PostScript output.
+   Courier=courier,                   $ ; Set this keyword to select the Courier font.
+   Debug=debug,                       $ ; Set this keyword to get traceback information when errors are encountered.
+   DefaultSetup=defaultsetup,         $ ; Set this keyword to the "name" of a default style.
+   Demi=demi,                         $ ; Set this keyword to select the Demi font style.
+   Directory=directory,               $ ; Set thie keyword to the name of the starting directory. Current directory by default.
+   Encapsulated=encapsulated,         $ ; Set this keyword to select Encapsulated PostScript output.
+   European=european,                 $ ; Set this keyword to indicate "european" mode (i.e., A4 page and centimeter units).
+   Filename=filename,                 $ ; Set this keyword to the name of the file. Default: 'idl.ps'
+   FontSize=fontsize,                 $ ; Set this keyword to the font size. Between 6 and 36. Default is 12.
+   FontType=fonttype,                 $ ; Set this keyword to select the font type: -1 is Hershey, 0 is hardward, 1 is true-type.
+   Helvetica=helvetica,               $ ; Set this keyword to select the Helvetica font.
+   Inches=inches,                     $ ; Set this keyword to indicate sizes and offsets are in inches as opposed to centimeters.
+   Italic=italic,                     $ ; Set this keyword to select the Italic font style.
+   Isolatin=isolatin,                 $ ; Set this keyword to select ISOlatin1 encoding.
+   Landscape=landscape,               $ ; Set this keyword to select Landscape output.
+   Light=light,                       $ ; Set this keyword to select the Light font style.
+   Medium=medium,                     $ ; Set this keyword to select the Medium font style.
+   Name=name,                         $ ; The "name" of the object. Objects with different names can have their
+                                        ; graphical user interfaces appear simultaneously on the display.
+   Narrow=narrow,                     $ ; Set this keyword to select the Narrow font style.
+   Oblique=oblique, $                 $ ; Set this keyword to select the Oblique font style.
+   PageType=pagetype,                 $ ; Set this keyword to the "type" of page: 'Letter', 'Legal', 'Ledger', or 'A4'.
+   Palatino=palatino,                 $ ; Set this keyword to select the Palatino font.
+   Preview=preview,                   $ ; Set this keyword to select Preview mode: 0, 1, or 2.
+   Schoolbook=schoolbook,             $ ; Set this keyword to select the Schoolbook font.
+   Set_Font=set_font,                 $ ; Set this keyword to the name of a font passed to PostScript with Set_Plot keyword.
+   Symbol=symbol,                     $ ; Set this keyword to select the Symbol font.
+   Times=times,                       $ ; Set this keyword to select the Times font.
+   TrueType=truetype,                 $ ; Set this keyword to select True-Type fonts.
+   XOffset=xoffset,                   $ ; Set this keyword to the XOffset. (Note: offset calculated from lower-left corner of page.)
+   XSize=xsize,                       $ ; Set this keyword to the X size of the PostScript "window".
+   YOffset=yoffset,                   $ ; Set this keyword to the YOffset. (Note: offset calculated from lower-left corner of page.)
+   YSize=ysize,                       $ ; Set this keyword to the Y size of the PostScript "window".
+   ZapfChancery=zapfchancery,         $ ; Set this keyword to select the ZapfChancery font.
+   ZapfDingbats=zapfdingbats            ; Set this keyword to select the ZapfDingbats font.
+
+   ; Error handling.
+
+Catch, theError
+IF theError NE 0 THEN BEGIN
+   Catch, /Cancel
+   ok = FSC_PSConfig_Error_Message(Traceback=Keyword_Set(debug))
+   RETURN, 1
+ENDIF
+
+self.debug = Keyword_Set(debug)
+
+
+   ; Set the available PostScript fonts.
+
+availableFonts = [                      $
+        'AvantGarde',                   $
+        'Bookman',                      $
+        'Courier',                      $
+        'Helvetica',                    $
+        'Palatino',                     $
+        'Schoolbook',                   $
+        'Symbol',                       $
+        'Times',                        $
+        'ZapfChancery',                 $
+        'ZapfDingbats']
+
+self.fontnames = Ptr_New(availableFonts)
+
+   ; Default font and font type.
+
+fontname = "Helvetica"
+IF N_Elements(fonttype) EQ 0 THEN fonttype = !P.Font
+IF N_Elements(filename) NE 0 THEN self.filenameSet = filename
+
+   ; European style
+self.european = Keyword_Set(european)
+
+   ; Set default values if a default setup was not asked for.
+
+IF N_Elements(defaultsetup) EQ 0 THEN BEGIN
+
+   self.defaultsSet = 'None'
+   IF N_Elements(bits_per_pixel) EQ 0 THEN bits_per_pixel = 8
+   IF N_Elements(bits_per_pixel) NE 0 THEN BEGIN
+   IF bits_per_pixel EQ 2 OR bits_per_pixel EQ 4 OR bits_per_pixel EQ 8 THEN $
+      self.bitsSet = StrTrim(bits_per_pixel,2) ELSE self.bitsSet = '8'
+ENDIF
+   IF N_Elements(color) EQ 0 THEN color = 1 ELSE color = 0 > color < color
+   IF N_Elements(directory) EQ 0 THEN CD, Current=directory
+   IF N_Elements(filename) EQ 0 THEN filename = "idl.ps"
+   IF N_Elements(fontsize) EQ 0 THEN fontsize = 12
+   IF Keyword_Set(inches) EQ 0 THEN IF Keyword_Set(european) THEN inches = 0 ELSE inches = 1
+   IF N_Elements(name) EQ 0 THEN name = ""
+   IF N_Elements(pagetype) EQ 0 THEN IF Keyword_Set(european) THEN pagetype = "A4" ELSE pagetype = "LETTER"
+   IF N_Elements(preview) EQ 0 THEN preview = 0
+   IF N_Elements(set_font) EQ 0 THEN set_font = ""
+   IF N_Elements(xoffset) EQ 0 THEN IF inches THEN xoffset = 1.75 ELSE xoffset = 1.75 * 2.54
+   IF N_Elements(xsize) EQ 0 THEN IF inches THEN xsize = 5 ELSE xsize = 5.0 * 2.54
+   IF N_Elements(yoffset) EQ 0 THEN IF inches THEN yoffset = 3.5 ELSE yoffset = 3.5 * 2.54
+   IF N_Elements(ysize) EQ 0 THEN IF inches THEN ysize = 4 ELSE ysize = 4.0 * 2.54
+
+   avantgarde = Keyword_Set(avantgarde)
+   bold = Keyword_Set(bold)
+   book = Keyword_Set(book)
+   bookman = Keyword_Set(bookman)
+   cmyk = Keyword_Set(cmyk)
+   courier = Keyword_Set(courier)
+   demi = Keyword_Set(demi)
+   encapsulated = Keyword_Set(encapsulated)
+   european = Keyword_Set(european)
+   helvetica = Keyword_Set(helvetica)
+   isolatin = Keyword_Set(isolatin)
+   italic = Keyword_Set(italic)
+   landscape = Keyword_Set(landscape)
+   light = Keyword_Set(light)
+   medium = Keyword_Set(medium)
+   narrow = Keyword_Set(narrow)
+   oblique = Keyword_Set(oblique)
+   palatino = Keyword_Set(palatino)
+   schoolbook = Keyword_Set(schoolbook)
+   symbol = Keyword_Set(symbol)
+   times = Keyword_Set(times)
+   truetype = Keyword_Set(truetype)
+   zapfchancery = Keyword_Set(zapfchancery)
+   zapfdingbats = Keyword_Set(zapfdingbats)
+
+   fontset = [avantgarde, bookman, courier, helvetica, palatino, schoolbook, symbol, times, zapfchancery, zapfdingbats]
+   index = Where(fontset EQ 1, count)
+   IF count EQ 0 THEN self.fontnameSet = 'Helvetica' ELSE self.fontnameSet = (*self.fontnames)[index[0]]
+   IF self.fontnameSet EQ 'AvantGarde' THEN self.avantgarde = 1 ELSE self.avantgarde = 0
+   IF self.fontnameSet EQ 'Bookman' THEN self.bookman = 1 ELSE self.bookman = 0
+   IF self.fontnameSet EQ 'Courier' THEN self.courier = 1 ELSE self.courier = 0
+   IF self.fontnameSet EQ 'Helvetica' THEN self.helvetica = 1 ELSE self.helvetica = 0
+   IF self.fontnameSet EQ 'Palatino' THEN self.palatino = 1 ELSE self.palatino = 0
+   IF self.fontnameSet EQ 'Schoolbook' THEN self.schoolbook = 1 ELSE self.schoolbook = 0
+   IF self.fontnameSet EQ 'Symbol' THEN self.symbol = 1 ELSE self.symbol = 0
+   IF self.fontnameSet EQ 'Times' THEN self.times = 1 ELSE self.times = 0
+   IF self.fontnameSet EQ 'ZapfChancery' THEN self.zapfchancery = 1 ELSE self.zapfchancery = 0
+   IF self.fontnameSet EQ 'ZapfDingbats' THEN self.zapfdingbats = 1 ELSE self.zapfdingbats = 0
+
+   self.bitsSet = StrTrim(bits_per_pixel, 2)
+   self.cmykSet = cmyk
+   self.colorSet = color
+   self.directorySet = directory
+   self.european = european
+   self.encapsulationSet = encapsulated
+   self.filenameSet = filename
+   self.fonttypeSet = -1 > fonttype < 1
+   self.fontsizeSet = Strtrim( 6 > Fix(fontsize) < 36, 2)
+   self.fontstyleSet = [bold, book, demi, italic, light, medium, narrow, oblique]
+   self.inchesSet = inches
+   self.isolatinSet = isolatin
+   self.landscapeSet = landscape
+   self.name = name
+   self.pagetype = pagetype
+   self.pagetypeSet = pagetype
+   self.previewSet = preview
+   self.truetypeSet = truetype
+   self.set_fontSet = set_font
+
+   ; Offsets are harder to set because I am trying to shield the
+   ; user from PostScript weirdness.
+
+   IF landscape THEN BEGIN
+      dims = self->PageDimensions()
+      self.xoffsetSet = dims[1] - yoffset
+      self.xsizeSet = xsize
+      self.yoffsetSet = xoffset
+      self.ysizeSet = ysize
+   ENDIF ELSE BEGIN
+      self.xoffsetSet = xoffset
+      self.xsizeSet = xsize
+      self.yoffsetSet = yoffset
+      self.ysizeSet = ysize
+   ENDELSE
+
+   ; Get the correct directory separator.
+
+CASE StrUpCase(!Version.OS_Family) OF
+   'WINDOWS' : sep = '\'    ; PCs
+   'MACOS'   : sep = ':'    ; Macintoshes
+   'VMS'     : sep = ']'    ; VMS machines
+   ELSE      : sep = '/'    ; Unix machines
+ENDCASE
+
+index = FSC_PSCONFIG_RStrPos(directory, sep)
+IF index EQ - 1 THEN BEGIN
+   self.fullFilenameSet = directory + sep + filename
+ENDIF ELSE BEGIN
+   IF index EQ (StrLen(directory) - 1) THEN self.fullFilenameSet = directory + filename ELSE $
+       self.fullFilenameSet = directory + sep + filename
+ENDELSE
+
+ENDIF ELSE self->SetDefault, defaultsetup
+
+   ; Save this configuration.
+
+self->SaveConfiguration
+
+RETURN, 1
+END ;--------------------------------------------------------------------------------
+
+
+PRO FSC_PSCONFIG__DEFINE
+
+   struct = { FSC_PSCONFIG,            $
+
+                  ; Font specifiers.
+
+              avantgarde: 0,           $
+              bkman: 0,                $
+              bookman: 0,              $
+              courier: 0,              $
+              helvetica: 0,            $
+              palatino: 0,             $
+              portrait: 0,             $
+              schoolbook: 0,           $
+              symbol: 0,               $
+              times: 0,                $
+              zapfchancery: 0,         $
+              zapfdingbats: 0,         $
+
+                  ; Widget identifiers.
+
+              clearbuttonID: 0L,            $ ; Clear Font Style settings button.
+              tlb: 0L,                      $ ; The top-level base of the GUI.
+              acceptID: 0L,                 $ ; The Accept or Apply button ID.
+              revertID: 0L,                 $ ; The Revert button ID.
+              pagetypeID: Obj_New(),        $ ; The pagetype droplist ID.
+              orientationID: Obj_New(),     $ ; The orientation droplist ID.
+              unitsID: Obj_New(),           $ ; The units droplist ID.
+              encapsulationID: Obj_New(),   $ ; The encapsulation droplist ID.
+              previewID: Obj_New(),         $ ; The preview droplist ID.
+              colorID: Obj_New(),           $ ; The color droplist ID.
+              cmykID: Obj_New(),            $ ; The cmyk droplist ID.
+              bitsID: Obj_New(),            $ ; The bits droplist ID.
+              defaultsID: Obj_New(),        $ ; The defaults droplist ID.
+              plotID: Obj_New(),            $ ; The plot window ID.
+              filenameID: Obj_New(),        $ ; The filename widget ID.
+              fontnameID: Obj_New(),        $ ; The font name droplist ID.
+              fontsizeID: Obj_New(),        $ ; The font size droplist ID.
+              fontstyleID: Obj_New(),       $ ; The font style droplist ID.
+              fontstyleButtonID: LonArr(8), $ ; The pagetype droplist ID.
+              fonttypeID: Obj_New(),        $ ; The font style button IDs.
+              isolatinID: Obj_New(),        $ ; The isolatin1 droplist ID.
+              set_fontID: Obj_New(),        $ ; The set font text widget ID.
+              stylebaseID: 0L,              $ ; The style base widget ID.
+              truetypeID: Obj_New(),        $ ; The true-type droplist ID.
+              xsizeID: Obj_New(),           $ ; The xsize field ID.
+              ysizeID: Obj_New(),           $ ; The ysize field  ID.
+              xoffsetID: Obj_New(),         $ ; The xoffset field  ID.
+              yoffsetID: Obj_New(),         $ ; The yoffset field ID.
+
+                  ; Data values and flags.
+
+               debug: 0,             $ ; Set if debugging in turned on.
+               fontInfo: 0,          $ ; Set if the user wants font information on GUI.
+               fontnames: Ptr_New(), $ ; The allowed font names.
+               european: 0,          $ ; Set if European units and page size are in effect.
+               pagetype: "",         $ ; The current page size or type.
+               name: "",             $ ; The "name" of the object.
+               noblock: 0,           $ ; A flag that tells whether the GUI is in NOBLOCK state.
+               cancel: 0,            $ ; A flag that tells the status of the Cancel button.
+               thisDevice: "",       $ ; The entry graphics device. Will be restored.
+
+                  ; GUI property identifiers.
+
+               bitsSet: "",             $ ; Sets the bits_per_pixel value.
+               cmykSet:0,               $ ; Sets the CMYK on/off value.
+               colorSet: 0,             $ ; Sets the color on/off value.
+               defaultsSet: "",         $ ; Sets the default setup value.
+               directorySet: "",        $ ; Sets the directory name value.
+               inchesSet: 0,            $ ; Sets the units value.
+               isolatinSet: 0,          $ ; Sets the isolatin1 value.
+               encapsulationSet: 0,     $ ; Sets the encapsulation value.
+               filenameSet: "",         $ ; Sets the file name value.
+               fullFilenameSet: "",     $ ; Sets the fully-qualified filename.
+               fontsizeSet: "",         $ ; Sets the font size value.
+               fontstyleSet: IntArr(8), $ ; Sets the font style values.
+               fontnameSet: "",         $ ; Sets the font name value.
+               fonttypeSet: 0,          $ ; Sets the font type value.
+               landscapeSet: 0,         $ ; Sets the orientation value.
+               pagetypeSet: "",         $ ; Sets the page type or size value.
+               previewSet: 0,           $ ; Sets the preview value.
+               set_fontSet: "",         $ ; Sets the Set_Font font name value.
+               truetypeSet: 0,          $ ; Sets the true-type font value.
+               xoffsetSet: 0.0,         $ ; Sets the xoffset value.
+               xsizeSet: 0.0,           $ ; Sets the xsize value.
+               yoffsetSet: 0.0,         $ ; Sets the yoffset value.
+               ysizeSet: 0.0,           $ ; Sets the ysize value.
+
+                  ; GUI revert property identifiers. Mirrors of GUI property identifiers above.
+
+               bitsRevert: "", $
+               cmykRevert:0, $
+               colorRevert: 0, $
+               defaultsRevert: "", $
+               directoryRevert: "", $
+               inchesRevert: 0, $
+               isolatinRevert: 0, $
+               encapsulationRevert: 0, $
+               filenameRevert: "", $
+               fontsizeRevert: "", $
+               fontstyleRevert: IntArr(8), $
+               fontnameRevert: "", $
+               fonttypeRevert: 0, $
+               landscapeRevert: 0, $
+               pagetypeRevert: "", $
+               previewRevert: 0, $
+               set_fontRevert: "", $
+               truetypeRevert: 0, $
+               xoffsetRevert: 0.0, $
+               xsizeRevert: 0.0, $
+               yoffsetRevert: 0.0, $
+               ysizeRevert: 0.0 $
+
+}
+
+END
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/ps_plotter.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/ps_plotter.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/ps_plotter.pro	(revision 1185)
@@ -0,0 +1,60 @@
+PRO PS_Plotter, image, $
+   European=european, $   ; Set this keyword if you want European measurements.
+   Font=font, $           ; Set this keyword if you want font information.
+   Object=object          ; Output variable to return FSC_PSConfig object.
+
+   ; Get an image if one is not passed in.
+
+IF N_Elements(image) EQ 0 THEN BEGIN
+   image = BytArr(360, 360)
+   file = Filepath(SubDirectory=['examples', 'data'], 'worldelv.dat')
+   OpenR, lun, file, /Get_Lun
+   ReadU, lun, image
+   Free_Lun, lun
+ENDIF
+
+   ; Create the PostScript configuration object.
+
+object = Obj_New('FSC_PSConfig', European=Keyword_Set(european))
+
+   ; We want hardware fonts.
+
+thisFontType = !P.Font
+!P.Font = 1
+
+   ; Get user input to PostScript configuration.
+
+IF Keyword_Set(font) THEN object->GUI, /Font ELSE object->GUI
+
+   ; Configure the PostScript Device.
+
+thisDevice = !D.Name
+Set_Plot, 'PS'
+keywords = object->GetKeywords(FontType=fonttype)
+Device, _Extra=keywords
+
+   ; Draw the example plots.
+
+!P.Multi = [ 0, 1, 2]
+TVImage, image
+Plot, Histogram(image), Title='Example Histogram Plot', XTitle='Pixel Value', $
+   YTitle='Number of Pixels', XStyle=1, Max_Value=5000
+!P.Multi = 0
+
+   ; Clean up.
+
+Device, /Close_File
+Set_Plot, thisDevice
+!P.Font = thisfontType
+
+   ; Return the PS_Configuration object or destroy it.
+
+IF Arg_Present(object) EQ 0 THEN Obj_Destroy, object
+END ;--------------------------------------------------------------------------------
+
+
+
+
+
+
+
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/ps_start.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/ps_start.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/ps_start.pro	(revision 1185)
@@ -0,0 +1,265 @@
+;+
+; NAME:
+;   PS_START/PS_END
+;
+; PURPOSE:
+;
+;    The purpose of PS_START and PS_END is to make it easy to set-up
+;    for and close a PostScript file. The programs work in close conjunction
+;    with PSCONFIG, another program from the Coyote Library.
+;
+;    If ImageMagick  (http://www.imagemagick.org/script/index.php) is installed 
+;    on your computer, you can easily convert PostScript output to JPEG, PNG, and TIFF
+;    image output. (See the keywords to PS_END.)
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;       Graphics, File Output, PostScript
+;
+; CALLING SEQUENCE:
+;
+;       PS_START
+;       Various graphics commands here...
+;       PS_END
+;
+; KEYWORD PARAMETERS FOR PS_START:
+;
+;       GUI:          The default behavior is to use PSCONFIG to configure the
+;                     PostScript device silently. If you wish to allow the user
+;                     to interatively configure the PostScript device, set this
+;                     keyword.
+;
+;       SCALE_FACTOR: Set this to the PostScript scale factor. By default: 1.
+;
+;       Any keyword supported by PSCONFIG can be used to configure the PostScript device.
+;       Common keywords would include FILENAME, XSIZE, YSIZE, XOFFSET, YOFFSET, etc. See
+;       the PSCONFIG documentation for details.
+;
+; KEYWORD PARAMETERS FOR PS_END:
+;
+;      All keywords for PS_END require that ImageMagick is installed on your computer
+;      and is configured correctly. Image conversion is done by spawning a "convert" 
+;      command to ImageMagick.
+;
+;       JPEG:         Set this keyword to convert the PostScript output file to a JPEG image.
+;       PNG:          Set this keyword to convert the PostScript output file to a PNG image.
+;       TIFF:         Set this keyword to convert the PostScript output file to a TIFF image.
+;
+; COMMON BLOCKS:
+;
+;       _$FSC_PS_START_   Contains the PS_STRUCT structure for communication between
+;                         PS_START and PS_END.
+;
+; SIDE EFFECTS:
+;
+;       When PS_START is called, the current graphics device is set to "PS" (the PostScript 
+;       device). When PS_END is called the current graphics device is returned to the device
+;       in effect when PS_START was called.
+;
+; RESTRICTIONS:
+;
+;       Requires numerous programs from the Coyote Library. To convert PostScript files
+;       to PNG, JPEG, and TIFF files requires ImageMagick be installed on your
+;       computer and configured correctly. You can download Coyote Library programs here:
+;
+;             http://www.dfanning.com/programs/coyoteprograms.zip
+;
+;       ImageMagick can be found here:
+;
+;              http://www.imagemagick.org/script/index.php
+;
+; EXAMPLE:
+;
+;       To create a line plot in a PostScript file named lineplot.ps and
+;       also create a PNG file named lineplot.png for display in a browser,
+;       type these commands.
+;
+;       PS_Start, FILENAME='lineplot.ps'
+;       Plot, Findgen(11), COLOR=FSC_Color('navy'), /NODATA, XTITLE='Time', YTITLE='Signal'
+;       OPlot, Findgen(11), COLOR=FSC_Color('indian red')
+;       OPlot, Findgen(11), COLOR=FSC_Color('olive'), PSYM=2
+;       PS_End, /PNG
+;
+; NOTES:
+;
+;       You can easily configure any modifications you like for your PostScript output
+;       by setting fields in the plot and axis system variables (!P, !X, !Y, and !Z).
+;       The modifications currently made by default in this program are these:
+;
+;          !P.Charsize = 1.5
+;          !P.Thick = 2
+;          !X.Thick = 2
+;          !Y.Thick = 2
+;          !Z.Thick = 2
+;          !P.Symsize = 1.25
+;          !P.Font = 1
+;
+; MODIFICATION HISTORY:
+;
+;       Written by: David W. Fanning, 20 May 2008.
+;-
+;
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright 2008 Fanning Software Consulting.
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+PRO FSC_PS_SETUP__DEFINE
+
+    struct = { FSC_PS_SETUP, $
+               currentDevice: "", $
+               setup: 0, $
+               convert: "", $
+               filename: "", $
+               p: !P, $
+               x: !X, $
+               y: !Y, $
+               z: !Z $
+              }
+            
+END ;---------------------------------------------------------------
+
+
+
+PRO PS_END, JPEG=jpeg, PNG=png, TIFF=tiff
+
+   COMMON _$FSC_PS_START_, ps_struct
+   
+   ON_ERROR, 2 ; Return to caller.
+   
+   ; Close the PostScript file, if this is PostScript device.
+   IF !D.Name EQ 'PS' THEN Device, /CLOSE_FILE
+   
+   ; Need to convert with ImageMagick?
+   IF Keyword_Set(png) THEN ps_struct.convert = 'PNG'
+   IF Keyword_Set(jpeg) THEN ps_struct.convert = 'JPEG'
+   IF Keyword_Set(tiff) THEN ps_struct.convert = 'TIFF'
+   IF ps_struct.convert NE "" THEN BEGIN
+
+        basename = FSC_Base_Filename(ps_struct.filename, DIRECTORY=theDir, EXTENSION=theExtension)
+        CASE 1 OF
+            ps_struct.convert EQ 'PNG':  outfilename = Filepath(ROOT_DIR=theDir, basename + '.png')
+            ps_struct.convert EQ 'JPEG': outfilename = Filepath(ROOT_DIR=theDir, basename + '.jpg')
+            ps_struct.convert EQ 'TIFF': outfilename = Filepath(ROOT_DIR=theDir, basename + '.tif')
+        ENDCASE
+        IF N_Elements(outfilename) NE "" THEN BEGIN
+;;; resize fait baisser la taille, density bcp moins
+;            cmd = 'convert +antialias -density 300 ' + ps_struct.filename + ' -resize 25% ' + outfilename
+;            cmd = 'convert -density 600 ' + ps_struct.filename + ' -resize 12% ' + outfilename
+cmd = 'ps2epsi '+ps_struct.filename+' 2> /dev/null ; gs -sDEVICE=png16m -dTextAlphaBits=4 -sOutputFile='+outfilename+' -dNOPAUSE -dBATCH -dEPSCrop -r500x500 '+basename+'.epsi > /dev/null 2> /dev/null'
+            SPAWN, cmd
+        ENDIF
+        
+   ENDIF
+   
+   ; Clean up.
+   Set_Plot, ps_struct.currentDevice
+   !P = ps_struct.p
+   !X = ps_struct.x
+   !Y = ps_struct.y
+   !Z = ps_struct.z
+   ps_struct.setup = 0
+   ps_struct.currentDevice = ""
+   ps_struct.filename = ""
+   ps_struct.convert = ""
+
+END ;---------------------------------------------------------------
+
+
+
+PRO PS_START, SCALE_FACTOR=scale_factor, GUI=gui, _EXTRA=extra
+
+   COMMON _$FSC_PS_START_, ps_struct
+   
+   ; Define the PS structure.
+   IF N_Elements(ps_struct) EQ 0 THEN ps_struct = {FSC_PS_SETUP}
+   
+   ; If the setup flag is on, then we have to close the previous
+   ; start command before we can continue.
+   IF ps_struct.setup EQ 1 THEN PS_END
+   
+   ; Save current setup information in the PS_STRUCT structure.
+   ps_struct.setup = 1
+   ps_struct.currentDevice = !D.Name
+   ps_struct.p = !P
+   ps_struct.x = !X
+   ps_struct.y = !Y
+   ps_struct.z = !Z
+   
+   ; Change any parameters you feel like changing.
+;;;;;;; AYMERIC
+;   !P.Charsize = 1.75
+;   !P.Thick = 2
+;   !X.Thick = 2
+;   !Y.Thick = 2
+   !Z.Thick = 2
+   !P.Symsize = 1.25
+   !P.Font = 1
+
+;;;;;;; AYMERIC
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+
+
+   Device, Set_Font='Helvetica', /TT_FONT
+
+   ; Configure the PostScript Device
+   cancelled = 0
+   sizes = PSWindow(_Extra=extra)
+   keywords = PSConfig(_Extra=extra, INCHES=sizes.inches, XSIZE=sizes.xsize, YSIZE=sizes.ysize, $
+      XOFFSET=sizes.xoffset, YOFFSET=sizes.yoffset, Cancel=cancelled, NOGUI=(1-Keyword_Set(gui)))
+   IF cancelled THEN BEGIN
+        PS_END
+        RETURN
+   ENDIF
+   Set_Plot, 'PS'
+   Device, _EXTRA=keywords
+   
+   ; What about scale factor?
+   IF N_Elements(scale_factor) NE 0 THEN $
+        DEVICE, SCALE_FACTOR=scale_factor ELSE $
+        DEVICE, SCALE_FACTOR=1
+   
+   ; Store filename.
+   ps_struct.filename = keywords.filename
+   
+END
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/psconfig.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/psconfig.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/psconfig.pro	(revision 1185)
@@ -0,0 +1,303 @@
+;+
+; NAME:
+;   PSCONFIG
+;
+; PURPOSE:
+;
+;   This program is simply a function wrapper for the FSC_PSCONFIG
+;   object program (fsc_psconfig__define.pro). It was written so
+;   that it could serve as a drop-in replacement for the PS_FORM
+;   program it replaces. It calls the object program's graphical
+;   user interface as a modal widget and returns the DEVICE keywords
+;   collected from the form in a form that is appropriate for
+;   configuring the PostScript device.
+;
+;   It is now possible to call the program without a graphical user
+;   interface, thus getting the default keywords directly. This is
+;   appropriate for many applications. Use the NOGUI keyword when
+;   you call the program. For example, like this:
+;
+;       Set_Plot, 'PS'
+;       Device, _Extra=PSConfig(/NoGUI, Filename='myfilename.eps')
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CALLING SEQUENCE:
+;
+;   psKeywords = PSConfig()
+;
+; CATEGORY:
+;
+;   Configuring PostScript output.
+;
+; DOCUMENTATION:
+;
+;   Complete documentation for the FSC_PSCONFIG object, including
+;   keyword and method descriptions, and example programs using the object
+;   can be found on the Coyote's Guide to IDL Programming web page:
+;
+;     http://www.dfanning.com/programs/docs/fsc_psconfig.html
+;
+; INPUT:
+;
+;    psConfigObject -- An optional FSC_PSCONFIG object reference can be
+;       passed as an argument to the function. The object is not destroyed
+;       if passed in as an argument.
+;
+;       psConfigObject = Obj_New("FSC_PSCONFIG")
+;       keywords = PSConfig(psConfigObject)
+;
+;    Having the object means that you have an on-going and current record
+;    of exactly how your PostScript device is configured. Be sure to destroy
+;    the object when you are finished with it.
+;
+; KEYWORDS:
+;
+;   NOGUI:   Setting this keyword returns the default keyword settings directly,
+;            without allowing user interaction.
+;
+;   Any keyword accepted by the FSC_PSCONFIG object can be used with
+;   this program. Here are a few of the most popular keywords.
+;
+;   Bits_per_Pixel - The number of image bits saved for each image pixel: 2, 4, or 8. The default is 8.
+;   Color - Set this keyword to select Color PostScript output. Turned on by default.
+;   DefaultSetup - Set this keyword to the "name" of a default style. Current styles (you can easily
+;     create and add your own to the source code) are the following:
+;
+;       "System (Portrait)" - The normal "default" system set-up. Also, "System".
+;       "System (Landcape)" - The normal "default" landscape system set-up.
+;       "Centered (Portrait)" - The window centered on the page. Also, "Center" or "Centered".
+;       "Centered (Landscape)" - The window centered on the landscape page. Also, "Landscape".
+;       "Square (Portrait)" - A square plot, centered on the page.
+;       "Square (Landscape)" - A square plot, centered on the landscape page.
+;       "Figure (Small)" - A small encapsulated figure size, centered on page. Also, "Encapsulated" or "Encapsulate".
+;       "Figure (Large)" - A larger encapsulated figure size, centered on page. Also, "Figure".
+;       "Color (Portrait)" - A "centered" plot, with color turned on. Also, "Color".
+;       "Color (Landscape)" - A "centered" landscape plot, with color turned on.
+;
+;   Directory - Set this keyword to the name of the starting directory. The current directory is used by default.
+;   Encapsulate - Set this keyword to select Encapsulated PostScript output. Turned off by default.
+;   European - Set this keyword to indicate "european" mode (i.e., A4 page and centimeter units). Turned off by default.
+;   Filename - Set thie keyword to the name of the PostScript file. The default is "idl.ps".
+;   Inches - Set this keyword to indicate sizes and offsets are in inches as opposed to centimeters. Set by European keyword by default.
+;   Landscape - Set this keyword to select Landscape page output. Portrait page output is the default.
+;   PageType - Set this keyword to the "type" of page. Possible values are:
+;       "Letter" - 8.5 by 11 inches. (Default, unless the European keyword is set.)
+;       "Legal" - 8.5 by 14 inches.
+;       "Ledger" - 11 by 17 inches.
+;       "A4" - 21.0 by 29.7 centimeters. (Default, if the European keyword is set.)
+;   XOffset - Set this keyword to the X Offset. Uses "System (Portrait)" defaults. (Note: offset calculated from lower-left corner of page.)
+;   XSize - Set this keyword to the X size of the PostScript "window". Uses "System (Portrait)" defaults.
+;   YOffset - Set this keyword to the Y Offset. Uses "System (Portrait)" defaults. (Note: offset calculated from lower-left corner of page.)
+;   YSize - Set this keyword to the Y size of the PostScript "window". Uses "System (Portrait)" defaults.
+;
+;   In addition, the following keywords can be used:
+;
+;   CANCEL -- An output keyword that will be set to 1 if the user
+;   chooses the Cancel button on the form. It will be 0 otherwise.
+;
+;   FONTINFO -- Set this keyword is you wish to have font information
+;   appear on the form. The default is to not include font information.
+;
+;   FONTTYPE -- Set this keyword to a named variable that will indicate
+;   the user's preference for font type. Values will be -1 (Hershey fonts),
+;   0 (hardware fonts), and 1 (true-type fonts). This keyword will always
+;   return -1 unless the FONTINFO keyword has also been set.
+;
+;   GROUP_LEADER -- Set this keyword to a widget identifier of the widget
+;   you wish to be a group leader for this program.
+;
+; EXAMPLE:
+;
+;   To have the user specify PostScript configuration parameters, use
+;   the program like this:
+;
+;     keywords = PSConfig(Cancel=cancelled)
+;     IF cancelled THEN RETURN
+;     thisDevice = !D.Name
+;     Set_Plot, 'PS'
+;     Device, _Extra=keywords
+;     Plot, findgen(11) ; Or whatever graphics commands you use.
+;     Device, /Close_File
+;     Set_Plot, thisDevice
+;
+; OTHER PROGRAMS NEEDED:
+;
+;   The following programs are required to run this one:
+;
+;     fsc_droplist.pro
+;     fsc_fileselect.pro
+;     fsc_inputfield.pro
+;     fsc_plotwindow
+;     fsc_psconfig__define.pro
+;
+; MODIFICATIONS:
+;
+;   Written by David W. Fanning, 31 January 2000.
+;   Added NOGUI keyword to allow default keywords to be obtained without
+;     user interaction. 11 Oct 2004. DWF.
+;   Added CMYK option 24 August 2007. Requires LANGUAGE_LEVEL=2 printer. L. Anderson
+;-
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright (c) 2000-2007 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+
+
+FUNCTION PSConfig,                    $
+   psObject,                          $ ; A FSC_PSCONFIG object. If psObject is present, all input keywords
+                                        ; except Group_Leader and FontInfo are ignored.
+   AvantGarde=avantgarde,             $ ; Set this keyword to select the AvantGarde font.
+   Bits_per_Pixel=bits_per_pixel,     $ ; The number of image bits saved for each image pixel: 2, 4, or 8.
+   Bold=bold,                         $ ; Set this keyword to select the Bold font style.
+   BookStyle=book,                    $ ; Set this keyword to select the Book font style.
+   Bkman=bookman,                     $ ; Set this keyword to select the Bookman font.
+   Cancel=cancelled,                  $ ; This output keyword will be set to 1 if the user CANCELs. Set to 0 otherwise.
+   Color=color,                       $ ; Set this keyword to select Color PostScript output.
+   Courier=courier,                   $ ; Set this keyword to select the Courier font.
+   CMYK=cmyk,                         $ ; Set this keyword to use CMYK colors instead of RGB. (Requires LANGUAGE_LEVEL=2 printer.)
+   Debug=debug,                       $ ; Set this keyword to get traceback information when errors are encountered.
+   DefaultSetup=defaultsetup,         $ ; Set this keyword to the "name" of a default style.
+   Demi=demi,                         $ ; Set this keyword to select the Demi font style.
+   Directory=directory,               $ ; Set thie keyword to the name of the starting directory. Current directory by default.
+   Encapsulate=encapsulate,           $ ; Set this keyword to select Encapsulated PostScript output.
+   European=european,                 $ ; Set this keyword to indicate "european" mode (i.e., A4 page and centimeter units).
+   Filename=filename,                 $ ; Set this keyword to the name of the file. Default: 'idl.ps'
+   FontInfo=fontinfo,                 $ ; Set this keyword if you want font information in the FSC_PSCONFIG GUI.
+   FontSize=fontsize,                 $ ; Set this keyword to the font size. Between 6 and 36. Default is 12.
+   FontType=fonttype,                 $ ; An input/output keyword that will have the FontType. Will be !P.Font unless FontInfo is selected.
+   Group_Leader=group_leader,         $ ; The group leader of the PSConfig modal widget.
+   Helvetica=helvetica,               $ ; Set this keyword to select the Helvetica font.
+   Inches=inches,                     $ ; Set this keyword to indicate sizes and offsets are in inches as opposed to centimeters.
+   Italic=italic,                     $ ; Set this keyword to select the Italic font style.
+   Isolatin=isolatin,                 $ ; Set this keyword to select ISOlatin1 encoding.
+   Landscape=landscape,               $ ; Set this keyword to select Landscape output.
+   Light=light,                       $ ; Set this keyword to select the Light font style.
+   Medium=medium,                     $ ; Set this keyword to select the Medium font style.
+   Name=name,                         $ ; The "name" of the object.
+   Narrow=narrow,                     $ ; Set this keyword to select the Narrow font style.
+   NOGUI=nogui, $                     $ ; Return the default keywords directly, without user interaction.
+   Oblique=oblique, $                 $ ; Set this keyword to select the Oblique font style.
+   PageType=pagetype,                 $ ; Set this keyword to the "type" of page: 'Letter', 'Legal', 'Ledger', or 'A4'.
+   Palatino=palatino,                 $ ; Set this keyword to select the Palatino font.
+   Preview=preview,                   $ ; Set this keyword to select Preview mode: 0, 1, or 2.
+   Schoolbook=schoolbook,             $ ; Set this keyword to select the Schoolbook font.
+   Set_Font=set_font,                 $ ; Set this keyword to the name of a font passed to PostScript with Set_Plot keyword.
+   Symbol=symbol,                     $ ; Set this keyword to select the Symbol font.
+   Times=times,                       $ ; Set this keyword to select the Times font.
+   TrueType=truetype,                 $ ; Set this keyword to select True-Type fonts.
+   XOffset=xoffset,                   $ ; Set this keyword to the XOffset. (Note: offset calculated from lower-left corner of page.)
+   XSize=xsize,                       $ ; Set this keyword to the X size of the PostScript "window".
+   YOffset=yoffset,                   $ ; Set this keyword to the YOffset. (Note: offset calculated from lower-left corner of page.)
+   YSize=ysize,                       $ ; Set this keyword to the Y size of the PostScript "window".
+   ZapfChancery=zapfchancery,         $ ; Set this keyword to select the ZapfChancery font.
+   ZapfDingbats=zapfdingbats            ; Set this keyword to select the ZapfDingbats font.
+
+On_Error, 2
+
+IF N_Elements(psObject) EQ 0 THEN BEGIN
+   psObject = Obj_New('FSC_PSCONFIG', $
+      AvantGarde=avantgarde,             $
+      Bits_per_Pixel=bits_per_pixel,     $
+      Bold=bold,                         $
+      BookStyle=book,                    $
+      Bkman=bookman,                     $
+      CMYK=cmyk,                         $
+      Color=color,                       $
+      Courier=courier,                   $
+      Debug=debug,                       $
+      DefaultSetup=defaultsetup,         $
+      Demi=demi,                         $
+      Directory=directory,               $
+      Encapsulate=encapsulate,           $
+      European=european,                 $
+      Filename=filename,                 $
+      FontSize=fontsize,                 $
+      FontType=fonttype,                 $
+      Helvetica=helvetica,               $
+      Inches=inches,                     $
+      Italic=italic,                     $
+      Isolatin=isolatin,                 $
+      Landscape=landscape,               $
+      Light=light,                       $
+      Medium=medium,                     $
+      Name=name,                         $
+      Narrow=narrow,                     $
+      Oblique=oblique,                   $
+      PageType=pagetype,                 $
+      Palatino=palatino,                 $
+      Preview=preview,                   $
+      Schoolbook=schoolbook,             $
+      Set_Font=set_font,                 $
+      Symbol=symbol,                     $
+      Times=times,                       $
+      TrueType=truetype,                 $
+      XOffset=xoffset,                   $
+      XSize=xsize,                       $
+      YOffset=yoffset,                   $
+      YSize=ysize,                       $
+      ZapfChancery=zapfchancery,         $
+      ZapfDingbats=zapfdingbats )
+      create = 1
+ENDIF ELSE BEGIN
+   type = Size(psObject, /Type)
+   IF type NE 11 THEN BEGIN
+      Message, 'Object Reference required as an argument'
+   ENDIF
+   create = 0
+ENDELSE
+
+   ; Call the GUI of the FSC_PSCONFIG object.
+
+IF Keyword_Set(nogui) EQ 0 THEN $
+   psObject->GUI, Group_Leader=group_leader, Cancel=cancelled, FontInfo=Keyword_Set(fontinfo)
+
+   ; Get the PostScript device keywords, along with the font type information.
+
+keywords = psObject->GetKeywords(FontType=fonttype)
+
+   ; If this program created the psObject, destroy it. Otherwise leave it.
+
+IF create THEN Obj_Destroy, psObject
+
+   ; Return the PostScript device keywords.
+
+RETURN, keywords
+END ;----------------------------------------------------------------------
+
+
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/pswindow.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/pswindow.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/pswindow.pro	(revision 1185)
@@ -0,0 +1,337 @@
+;+
+; NAME:
+;    PSWINDOW
+;
+; PURPOSE:
+;
+;    This function is used to calculate the size of a PostScript
+;    window that has the same aspect ratio (ratio of height to
+;    width) as the current display graphics window. It creates
+;    the largest possible PostScript output window with the
+;    desired aspect ratio. This assures that graphics output
+;    looks similar, if not identical, to PostScript output.
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;    Graphics.
+;
+; CALLING SEQUENCE:
+;
+;    pageInfo = PSWINDOW()
+;
+; INPUTS:
+;
+;    None.
+;
+; KEYWORD PARAMETERS:
+;
+;    CM: Normally the structure value that is returned from this
+;    function reports its values in inches. Setting this keyword
+;    causes the return values to be in units of centimeters.
+;
+;    FUDGE: A quick way to set symetrical XFUDGE and YFUDGE factors.
+;    If this keyword is set to a value, XFUDGE and YFUDGE keywords are
+;    set to the same value.
+;
+;    LANDSCAPE: Normally this function assumes a PostScript window
+;    in Portrait mode. Setting this keyword assumes you want
+;    the graphic in Landscape mode.
+;
+;    MARGIN:  The margin around the edges of the plot. The value must be
+;    a floating point value between 0.0 and 0.5. It is expressed in
+;    normalized coordinate units. The default margin is 0.05.
+;
+;    PAGESIZE: Set this keyword to a string indicating the type
+;    of PostScript page size you want. Current values are "LETTER",
+;    "LEGAL", and "A4". Default is "LETTER".
+;
+;    PRINTER: Set this keyword if the output will be used to
+;    configure the PRINTER device, rather than the PS device.
+;    (In the PRINTER device, offsets are always calculated from
+;    the lower-left corner of the page and do not rotate in
+;    Landscape mode, as they do with the PS device.) Note that
+;    the PRINTER device is only able to accept these keywords
+;    in IDL 5.1 and higher.
+;
+;    XFUDGE: Printers calculate the offset point from the printable
+;    edge of the paper (sometimes), rather from the corner of the paper.
+;    For example, on my Lexmark printer, both X and Y offsets are
+;    calculated from a point 0.25 inches in from the edge. This keyword
+;    allows you to set a "fudge" factor that will be subtracted from
+;    the XOFFSET that is returned to the user. This allows you to create
+;    output that is centered on the page. The fudge factor should be in
+;    the same units as the returned size and offset values.
+;
+;    YFUDGE: Printers calculate the offset point from the printable
+;    edge of the paper (sometimes), rather from the corner of the paper.
+;    For example, on my Lexmark printer, both X and Y offsets are
+;    calculated from a point 0.25 inches in from the edge. This keyword
+;    allows you to set a "fudge" factor that will be subtracted from
+;    the YOFFSET that is returned to the user. This allows you to create
+;    output that is centered on the page. The fudge factor should be in
+;    the same units as the returned size and offset values.
+;
+; OUTPUTS:
+;
+;    pageInfo: The output value is a named structure defined like
+;    this:
+;
+;      pageInfo = {PSWINDOW_STRUCT, XSIZE:0.0, YSIZE:0.0, $
+;         XOFSET:0.0, YOFFSET:0.0, INCHES:0, PORTRAIT:0, LANDSCAPE:0}
+;
+;    The units of the four size fields are inches unless the CM
+;    keyword is set.
+;
+;    The output can be used to immediately configure the PostScript
+;    or Printer device, like this:
+;
+;       Set_Plot, 'PS' ; or 'PRINTER'
+;       Device, _Extra=pageInfo
+;
+; RESTRICTIONS:
+;
+;    The aspect ratio of the current graphics window is calculated
+;    like this:
+;
+;       aspectRatio = FLOAT(!D.Y_VSIZE) / !D.X_VSIZE
+;
+; EXAMPLE:
+;
+;    To create a PostScript output window with the same aspect
+;    ratio as the curently active display window, type:
+;
+;     pageInfo = PSWINDOW()
+;     SET_PLOT, 'PS'
+;     DEVICE, _Extra=pageInfo
+;
+;     To configure the PRINTER device:
+;
+;     pageInfo = PSWINDOW(/Printer, Fudge=0.25)
+;     SET_PLOT, 'PRINTER'
+;     DEVICE, _Extra=pageInfo
+;
+; MODIFICATION HISTORY:
+;
+;    Written by: David W. Fanning, November 1996.
+;       Fixed a bug in which the YOFFSET was calculated incorrectly
+;          in Landscape mode. 12 Feb 97.
+;       Took out a line of code that wasn't being used. 14 Mar 97.
+;       Added correct units keyword to return structure. 29 JUN 98. DWF
+;       Fixed a bug in how landscape offsets were calculated. 19 JUL 99. DWF.
+;       Fixed a bug in the way margins were used to conform to my
+;          original conception of the program. 19 JUL 99. DWF.
+;       Added Landscape and Portrait fields to the return structure. 19 JUL 99. DWF.
+;       Added PageSize keyword, changed MARGIN keyword, and completely
+;          rewrote most of the intenal code. 9 FEB 2000. DWF.
+;       Fixed a bug in how I calculated the aspect ratio. 1 MAR 2000. DWF.
+;       Added PRINTER keyword to return proper offset values for the
+;          PRINTER device, where the offset location is not rotated. 1 MAR 2000. DWF.
+;       Added PRINTER fudge factors to take into account that printer offsets are
+;          calculated from the printable area of the paper, rather than the corner
+;          of the paper. 8 AUG 2000. DWF.
+;       Changed the default margin to 0.05 from 0.15. 29 Nov 2004, DWF.
+;-
+;
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright © 2000-2004 Fanning Software Consulting
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+
+
+
+FUNCTION PSWINDOW_ASPECT, aspectRatio, MARGIN=margin, WindowAspect=wAspectRatio
+
+ON_ERROR, 1
+
+   ; Check for aspect ratio parameter and possibilities.
+
+IF N_PARAMS() EQ 0 THEN aspectRatio = 1.0
+
+IF aspectRatio EQ 0 THEN BEGIN
+   MESSAGE, 'Aspect Ratio of 0. Changing to 1...', /Informational
+   aspectRatio = 1.0
+ENDIF
+
+s = SIZE(aspectRatio)
+IF s(s(0)+1) NE 4 THEN $
+   MESSAGE, 'Aspect Ratio is not a FLOAT. Take care...', /Informational
+
+   ; Check for margins.
+
+IF N_ELEMENTS(margin) EQ 0 THEN margin = 0.15
+
+   ; Error checking.
+
+IF margin LT 0 OR margin GE 0.5 THEN $
+   MESSAGE, 'The MARGIN keyword value must be between 0.0 and 0.5.'
+
+   ; Calculate the aspect ratio of the current window.
+
+IF N_Elements(wAspectRatio) EQ 0 THEN wAspectRatio = FLOAT(!D.Y_VSIZE) / !D.X_VSIZE
+
+   ; Calculate normalized positions in window.
+
+IF (aspectRatio LE wAspectRatio) THEN BEGIN
+   xstart = margin
+   ystart = 0.5 - (0.5 - margin) * (aspectRatio / wAspectRatio)
+   xend = 1.0 - margin
+   yend = 0.5 + (0.5 - margin) * (aspectRatio / wAspectRatio)
+ENDIF ELSE BEGIN
+   xstart = 0.5 - (0.5 - margin) * (wAspectRatio / aspectRatio)
+   ystart = margin
+   xend = 0.5 + (0.5 - margin) * (wAspectRatio / aspectRatio)
+   yend = 1.0 - margin
+ENDELSE
+
+position = [xstart, ystart, xend, yend]
+
+RETURN, position
+END ; ----------------------------------------------------------------------------------
+
+
+
+FUNCTION PSWINDOW, LANDSCAPE=landscape, CM=cm, MARGIN=margin, $
+   PageSize=pagesize, Printer=printer, Fudge=fudge, XFudge=xfudge, YFudge=yfudge
+
+   ; Set up default values.
+
+landscape = Keyword_Set(landscape)
+cm = Keyword_Set(cm)
+printer = Keyword_Set(printer)
+inches = 1
+
+   ; Set up printer fudge factors, if necessary.
+
+IF N_Elements(fudge) NE 0 THEN BEGIN
+   xfudge = fudge
+   yfudge = fudge
+ENDIF
+IF N_Elements(xfudge) EQ 0 THEN xfudge = 0.0
+IF N_Elements(yfudge) EQ 0 THEN yfudge = 0.0
+
+   ; Get the page size.
+
+IF N_Elements(pagesize) EQ 0 THEN pagesize = 'LETTER' $
+   ELSE pagesize = StrUpCase(pagesize)
+CASE pagesize OF
+   'LETTER': BEGIN
+      shortside = 8.5
+      longside = 11.0
+      ENDCASE
+   'LEGAL': BEGIN
+      shortside = 8.5
+      longside = 14.0
+      ENDCASE
+    'A4': BEGIN
+      shortside = 8.27
+      longside = 11.7
+      ENDCASE
+    ELSE: BEGIN
+      Message, 'Unknown page size. Using LETTER...', /Informational
+      shortside = 8.5
+      longside = 11.0
+      ENDCASE
+ENDCASE
+
+   ; Need measurements in centimeters?
+
+IF KEYWORD_SET(cm) THEN BEGIN
+      shortside = shortside * 2.54
+      longside = longside * 2.54
+      inches = 0
+ENDIF
+
+   ; Determine the margin of the window on the page.
+
+IF N_ELEMENTS(margin) EQ 0 THEN margin=0.05
+
+   ; Get the aspect ratio of the current display window. Aspect ratio
+   ; is ratio of xsize/ysize.
+
+aspectRatio = FLOAT(!D.Y_VSIZE) / !D.X_VSIZE
+
+   ; Get the aspect ratio of the page.
+
+IF Keyword_Set(landscape) THEN pAspectRatio = shortside / longside $
+   ELSE pAspectRatio = longside / shortside
+
+   ; Get the position on the page for this window.
+
+pos = PSWindow_Aspect(aspectRatio, Margin=margin, WindowAspect=pAspectRatio)
+
+   ; Convert normalized position coordinates to size units.
+
+IF KEYWORD_SET(landscape) THEN BEGIN
+   IF printer THEN BEGIN
+      xsize = (pos[2] - pos[0]) * longside
+      ysize = (pos[3] - pos[1]) * shortside
+      yoffset = pos[1] * shortside - yfudge
+      xoffset = pos[0] * longside - xfudge
+      landscape = 1
+      portrait = 0
+   ENDIF ELSE BEGIN
+      xsize = (pos[2] - pos[0]) * longside
+      ysize = (pos[3] - pos[1]) * shortside
+      xoffset = pos[1] * shortside
+      yoffset = longside - (pos[0] * longside)
+      landscape = 1
+      portrait = 0
+   ENDELSE
+ENDIF ELSE BEGIN
+   xsize = (pos[2] - pos[0]) * shortside
+   ysize = (pos[3] - pos[1]) * longside
+   IF printer THEN BEGIN
+      xoffset = pos[0] * shortside - xfudge
+      yoffset = pos[1] * longside - yfudge
+   ENDIF ELSE BEGIN
+      xoffset = pos[0] * shortside
+      yoffset = pos[1] * longside
+   ENDELSE
+   landscape = 0
+   portrait = 1
+ENDELSE
+
+   ; Return the proper DEVICE data structure.
+
+RETURN, {PSWINDOW_STRUCT, XSIZE:xsize, YSIZE:ysize, $
+   XOFFSET:xoffset, YOFFSET:yoffset, INCHES:inches, $
+   PORTRAIT:portrait, LANDSCAPE:landscape}
+
+END
Index: trunk/UTIL/IDLplot/MINIMAL/fsc/tvimage.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc/tvimage.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc/tvimage.pro	(revision 1185)
@@ -0,0 +1,1020 @@
+;+
+; NAME:
+;     TVIMAGE
+;
+; PURPOSE:
+;     This purpose of TVIMAGE is to enable the TV command in IDL
+;     to be a completely device-independent and color-decomposition-
+;     state independent command. On 24-bit displays color decomposition
+;     is always turned off for 8-bit images and on for 24-bit images.
+;     The color decomposition state is restored for those versions of
+;     IDL that support it (> 5.2). Moreover, TVIMAGE adds features
+;     that TV lacks. For example, images can be positioned in windows
+;     using the POSITION keyword like other IDL graphics commands.
+;     TVIMAGE also supports the !P.MULTI system variable, unlike the
+;     TV command. TVIMAGE was written to work especially well in
+;     resizeable graphics windows. Note that if you wish to preserve
+;     the aspect ratio of images in resizeable windows, you should set
+;     the KEEP_ASPECT_RATIO keyword, described below. TVIMAGE works
+;     equally well on the display, in the PostScript device, and in
+;     the Printer and Z-Graphics Buffer devices. The TRUE keyword is
+;     set automatically to the correct value for 24-bit images, so you
+;     don't need to specify it when using TVIMAGE.
+;
+; AUTHOR:
+;       FANNING SOFTWARE CONSULTING:
+;       David Fanning, Ph.D.
+;       1645 Sheely Drive
+;       Fort Collins, CO 80526 USA
+;       Phone: 970-221-0438
+;       E-mail: davidf@dfanning.com
+;       Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;     Graphics display.
+;
+; CALLING SEQUENCE:
+;
+;     TVIMAGE, image
+;
+; INPUTS:
+;     image:    A 2D or 3D image array. It should be byte data.
+;
+;       x  :    The X position of the lower-left corner of the image.
+;               This parameter is only recognized if the TV keyword is set.
+;               If the Y position is not used, X is taken to be the image
+;               "position" in the window. See the TV command documenation
+;               for details.
+;
+;       y  :    The Y position of the lower-left corner of the image.
+;               This parameter is only recognized if the TV keyword is set.
+;
+; KEYWORD PARAMETERS:
+;
+;     ACOLOR:   Set this keyword to the axis color. If a byte or integer value,
+;               it will assume you are using INDEXED color mode. If a long integer
+;               is will assume you are using DECOMPOSED color mode. If a string,
+;               is will pass the string color name along to FSC_COLOR for processing.
+;
+;     AXES:     Set this keyword to draw a set of axes around the image.
+;
+;     AXKEYWORDS:   An IDL structure variable of PLOT keywords as structure fields
+;               and keyword values as the values of the fields. Pass directly to the
+;               PLOT command that draws the axes for the image. Ignored unless the
+;               AXES keyword is set. For example,
+;
+;               TVImage, image, /AXES, AXKEYWORDS={CHARSIZE:1.5, XTITLE:'Distance (mm)', $
+;                    YTITLE:'Signal', TICKLEN:-0.025}, ACOLOR='NAVY'
+;
+;     BACKGROUND:   This keyword specifies the background color. Note that
+;               the keyword ONLY has effect if the ERASE keyword is also
+;               set or !P.MULTI is set to multiple plots and TVIMAGE is
+;               used to place the *first* plot. Can be a string (e.g., 'ivory'), or
+;               a 24-bit value that can be decomposed into a color, or an 8-bit
+;               index number into the current color table. ERASE and BACKGROUND
+;               should only be used on 24-bit devices that support windows!
+;
+;     BREWER:   If set, applies only to BACKGROUND AND ACOLOR keywords. Selects
+;               brewer colors, rather than standard FSC_COLOR colors as strings.
+;
+;     ERASE:    If this keyword is set an ERASE command is issued
+;               before the image is displayed. ERASE and BACKGROUND 
+;               should only be used on 24-bit devices that support windows! 
+;               The keyword is ignored on 8-bit devices or devices that do
+;               not support windows.
+;
+;     _EXTRA:   This keyword picks up any TV keywords you wish to use.
+;
+;     HALF_HALF: If set, will tell CONGRID to extrapolate a *half* row
+;               and column on either side, rather than the default of
+;               one full row/column at the ends of the array.  If you
+;               are interpolating images with few rows, then the
+;               output will be more consistent with this technique.
+;               This keyword is intended as a replacement for
+;               MINUS_ONE, and both keywords probably should not be
+;               used in the same call to CONGRID.
+;
+;     KEEP_ASPECT_RATIO: Normally, the image will be resized to fit the
+;               specified position in the window. If you prefer, you can
+;               force the image to maintain its aspect ratio in the window
+;               (although not its natural size) by setting this keyword.
+;               The image width is fitted first. If, after setting the
+;               image width, the image height is too big for the window,
+;               then the image height is fitted into the window. The
+;               appropriate values of the POSITION keyword are honored
+;               during this fitting process. Once a fit is made, the
+;               POSITION coordiates are re-calculated to center the image
+;               in the window. You can recover these new position coordinates
+;               as the output from the POSITION keyword.
+;
+;     MARGIN:   A single value, expressed as a normalized coordinate, that
+;               can easily be used to calculate a position in the window.
+;               The margin is used to calculate a POSITION that gives
+;               the image an equal margin around the edge of the window.
+;               The margin must be a number in the range 0.0 to 0.333. This
+;               keyword is ignored if the POSITION or OVERPLOT keywords are
+;               used. It is also ignored when TVImage is executed in a
+;               multi-plot window, EXCEPT if it's value is zero. In this
+;               special case, the image will be drawn into its position in
+;               the multi-plot window with no margins whatsoever. (The
+;               default is to have a slight margin about the image to separate
+;               it from other images or graphics.
+;
+;     MINUS_ONE: The value of this keyword is passed along to the CONGRID
+;               command. It prevents CONGRID from adding an extra row and
+;               column to the resulting array, which can be a problem with
+;               small image arrays.
+;
+;     NOINTERPOLATION: Setting this keyword disables the default bilinear
+;               interpolation done to the image when it is resized. Nearest
+;               neighbor interpolation is done instead. This is preferred
+;               when you do not wish to change the pixel values of the image.
+;               This keyword must be set, for example, when you are displaying
+;               GIF files that come with their own non-IDL color table vectors.
+;
+;     NORMAL:   Setting this keyword means image position coordinates x and y
+;               are interpreted as being in normalized coordinates. This keyword
+;               is only valid if the TV keyword is set.
+;
+;     OVERPLOT: Setting this keyword causes the POSITION keyword to be ignored
+;               and the image is positioned in the location established by the
+;               last graphics command. For example:
+;
+;                    Plot, Findgen(11), Position=[0.1, 0.3, 0.8, 0.95]
+;                    TVImage, image, /Overplot
+;
+;     POSITION: The location of the image in the output window. This is
+;               a four-element floating array of normalized coordinates of
+;               the type given by !P.POSITION or the POSITION keyword to
+;               other IDL graphics commands. The form is [x0, y0, x1, y1].
+;               The default is [0.0, 0.0, 1.0, 1.0]. Note that this keyword is ALSO
+;               an output keyword. That is to say, upon return from TVIMAGE
+;               this keyword (if passed by reference) contains the actual
+;               position in the window where the image was displayed. This
+;               may be different from the input values if the KEEP_ASPECT_RATIO
+;               keyword is set, or if you are using TVIMAGE with the POSITION
+;               keyword when !P.MULTI is set to something other than a single
+;               plot. One use for the output values might be to position other
+;               graphics (e.g., a colorbar) in relation to the image.
+;
+;               Note that the POSITION keyword should not, normally, be used
+;               when displaying multiple images with !P.MULTI. If it *is* used,
+;               its meaning differs slightly from its normal meaning. !P.MULTI
+;               is responsible for calculating the position of graphics in the
+;               display window. Normally, it would be a mistake to use a POSITION
+;               graphics keyword on a graphics command that was being drawn with
+;               !P.MULTI. But in this special case, TVIMAGE will use the POSITION
+;               coordinates to calculate an image position in the actual position
+;               calculated for the image by !P.MULTI. The main purpose of this
+;               functionality is to allow the user to display images along with
+;               colorbars when using !P.MULTI. See the example below.
+;
+;    QUIET:      There are situations when you would prefer that TVIMAGE does not
+;                advertise itself by filling out the FSC_$TVIMAGE common block. For
+;                example, if you are using TVIMAGE to draw a color bar, it would
+;                not be necessary. Setting this keyword means that TVIMAGE just
+;                goes quietly about it's business without bothering anyone else.
+;
+;    SCALE:     Set this keyword to byte scale the image before display.
+;
+;     TV:       Setting this keyword makes the TVIMAGE command work much
+;               like the TV command, although better. That is to say, it
+;               will still set the correct DECOMPOSED state depending upon
+;               the kind of image to be displayed (8-bit or 24-bit). It will
+;               also allow the image to be "positioned" in the window by
+;               specifying the coordinates of the lower-left corner of the
+;               image. The NORMAL keyword is activated when the TV keyword
+;               is set, which will indicate that the position coordinates
+;               are given in normalized coordinates rather than device
+;               coordinates.
+;
+;               Setting this keyword will ensure that the keywords
+;               KEEP_ASPECT_RATIO, MARGIN, MINUS_ONE, MULTI, and POSITION
+;               are ignored.
+;
+;      XRANGE:  If the AXES keyword is set, this keyword is a two-element vector
+;               giving the X axis range. By default, [0, size of image in X].
+;
+;      YRANGE:  If the AXES keyword is set, this keyword is a two-element vector
+;               giving the Y axis range. By default, [0, size of image in Y].
+;
+; OUTPUTS:
+;     None.
+;
+; SIDE EFFECTS:
+;     Unless the KEEP_ASPECT_RATIO keyword is set, the displayed image
+;     may not have the same aspect ratio as the input data set.
+;
+; RESTRICTIONS:
+;     If the POSITION keyword and the KEEP_ASPECT_RATIO keyword are
+;     used together, there is an excellent chance the POSITION
+;     parameters will change. If the POSITION is passed in as a
+;     variable, the new positions will be returned in the same variable
+;     as an output parameter.
+;
+;     If a 24-bit image is displayed on an 8-bit display, the
+;     24-bit image must be converted to an 8-bit image and the
+;     appropriate color table vectors. This is done with the COLOR_QUAN
+;     function. The TVIMAGE command will load the color table vectors
+;     and set the NOINTERPOLATION keyword if this is done. Note that the
+;     resulting color table vectors are normally incompatible with other
+;     IDL-supplied color tables. Hence, other graphics windows open at
+;     the time the image is display are likely to look strange.
+;
+;     Other programs from Coyote Library (e.g., FSC_COLOR) may also be
+;     required.
+;
+; EXAMPLE:
+;     To display an image with a contour plot on top of it, type:
+;
+;        filename = FILEPATH(SUBDIR=['examples','data'], 'worldelv.dat')
+;        image = BYTARR(360,360)
+;        OPENR, lun, filename, /GET_LUN
+;        READU, lun, image
+;        FREE_LUN, lun
+;
+;        TVIMAGE, image, POSITION=thisPosition, /KEEP_ASPECT_RATIO
+;        CONTOUR, image, POSITION=thisPosition, /NOERASE, XSTYLE=1, $
+;            YSTYLE=1, XRANGE=[0,360], YRANGE=[0,360], NLEVELS=10
+;
+;     To display four images in a window without spacing between them:
+;
+;     !P.Multi=[0,2,2]
+;     TVImage, image, Margin=0
+;     TVImage, image, Margin=0
+;     TVImage, image, Margin=0
+;     TVImage, image, Margin=0
+;     !P.Multi = 0
+;
+;     To display four image in a window with associated color bars:
+;
+;     !P.Multi=[0,2,2]
+;     p = [0.02, 0.3, 0.98, 0.98]
+;     LoadCT, 0
+;     TVImage, image, Position=p
+;     Colorbar, Position=[p[0], p[1]-0.1, p[2], p[1]-0.05]
+;     p = [0.02, 0.3, 0.98, 0.98]
+;     LoadCT, 2
+;     TVImage, image, Position=p
+;     Colorbar, Position=[p[0], p[1]-0.1, p[2], p[1]-0.05]
+;     p = [0.02, 0.3, 0.98, 0.98]
+;     LoadCT, 3
+;     TVImage, image, Position=p
+;     Colorbar, Position=[p[0], p[1]-0.1, p[2], p[1]-0.05]
+;     p = [0.02, 0.3, 0.98, 0.98]
+;     LoadCT, 5
+;     TVImage, image, Position=p
+;     Colorbar, Position=[p[0], p[1]-0.1, p[2], p[1]-0.05]
+;     !P.Multi =0
+;
+; MODIFICATION HISTORY:
+;      Written by:     David Fanning, 20 NOV 1996.
+;      Fixed a small bug with the resizing of the image. 17 Feb 1997. DWF.
+;      Removed BOTTOM and NCOLORS keywords. This reflects my growing belief
+;         that this program should act more like TV and less like a "color
+;         aware" application. I leave "color awareness" to the program
+;         using TVIMAGE. Added 24-bit image capability. 15 April 1997. DWF.
+;      Fixed a small bug that prevented this program from working in the
+;          Z-buffer. 17 April 1997. DWF.
+;      Fixed a subtle bug that caused me to think I was going crazy!
+;          Lession learned: Be sure you know the *current* graphics
+;          window! 17 April 1997. DWF.
+;      Added support for the PRINTER device. 25 June 1997. DWF.
+;      Extensive modifications. 27 Oct 1997. DWF
+;          1) Removed PRINTER support, which didn't work as expected.
+;          2) Modified Keep_Aspect_Ratio code to work with POSITION keyword.
+;          3) Added check for window-able devices (!D.Flags AND 256).
+;          4) Modified PostScript color handling.
+;      Craig Markwart points out that Congrid adds an extra row and column
+;          onto an array. When viewing small images (e.g., 20x20) this can be
+;          a problem. Added a Minus_One keyword whose value can be passed
+;          along to the Congrid keyword of the same name. 28 Oct 1997. DWF
+;      Changed default POSITION to fill entire window. 30 July 1998. DWF.
+;      Made sure color decomposition is OFF for 2D images. 6 Aug 1998. DWF.
+;      Added limited PRINTER portrait mode support. The correct aspect ratio
+;          of the image is always maintained when outputting to the
+;          PRINTER device and POSITION coordinates are ignored. 6 Aug 1998. DWF
+;      Removed 6 August 98 fixes (Device, Decomposed=0) after realizing that
+;          they interfere with operation in the Z-graphics buffer. 9 Oct 1998. DWF
+;      Added a MARGIN keyword. 18 Oct 1998. DWF.
+;      Re-established Device, Decomposed=0 keyword for devices that
+;         support it. 18 Oct 1998. DWF.
+;      Added support for the !P.Multi system variable. 3 March 99. DWF
+;      Added DEVICE, DECOMPOSED=1 command for all 24-bit images. 2 April 99. DWF.
+;      Added ability to preserve DECOMPOSED state for IDL 5.2 and higher. 4 April 99. DWF.
+;      Added TV keyword to allow TVIMAGE to work like the TV command. 11 May 99. DWF.
+;      Added the OVERPLOT keyword to allow plotting on POSITION coordinates
+;         estabished by the preceding graphics command. 11 Oct 99. DWF.
+;      Added automatic recognition of !P.Multi. Setting MULTI keyword is no
+;         longer required. 18 Nov 99. DWF.
+;      Added NOINTERPOLATION keyword so that nearest neighbor interpolation
+;         is performed rather than bilinear. 3 Dec 99. DWF
+;      Changed ON_ERROR condition from 1 to 2. 19 Dec 99. DWF.
+;      Added Craig Markwardt's CMCongrid program and removed RSI's. 24 Feb 2000. DWF.
+;      Added HALF_HALF keyword to support CMCONGRID. 24 Feb 2000. DWF.
+;      Fixed a small problem with image start position by adding ROUND function. 19 March 2000. DWF.
+;      Updated the PRINTER device code to take advantage of available keywords. 2 April 2000. DWF.
+;      Reorganized the code to handle 24-bit images on 8-bit displays better. 2 April 2000. DWF.
+;      Added BACKGROUND keyword. 20 April 2000. DWF.
+;      Fixed a small problem in where the ERASE was occuring. 6 May 2000. DWF.
+;      Rearranged the PLOT part of code to occur before decomposition state
+;         is changed to fix Background color bug in multiple plots. 23 Sept 2000. DWF.
+;      Removed MULTI keyword, which is no longer needed. 23 Sept 2000. DWF.
+;      Fixed a small problem with handling images that are slices from 3D image cubes. 5 Oct 2000. DWF.
+;      Added fix for brain-dead Macs from Ben Tupper that restores Macs ability to
+;         display images. 8 June 2001. DWF.
+;      Fixed small problem with multiple plots and map projections. 29 June 2003. DWF.
+;      Converted all array subscripts to square brackets. 29 June 2003. DWF.
+;      Removed obsolete STR_SEP and replaced with STRSPLIT. 27 Oct 2004. DWF.
+;      Small modification at suggestion of Karsten Rodenacker to increase size of
+;         images in !P.MULTI mode. 8 December 2004. DWF.
+;      Minor modifications on Karsten Rodenacker's own account concerning margination
+;         and TV behaviour. 8 December 2004. KaRo
+;      There was a small inconsistency in how the image was resized for PostScript as
+;         opposed to the display, which could occasionally result in a small black line
+;         to the right of the image. This is now handled consistently. 3 January 2007. DWF.
+;      Made a small change to CMCONGRID to permit nearest-neighbor interpolation for 3D arrays.
+;         Previously, any 24-bit image was interpolated, no matter the setting of the NOINTERP
+;         keyword. 22 April 2007. DWF.
+;      Updated the program for the 24-bit Z-buffer in IDL 6.4. 11 June 2007. DWF.
+;      Added new POSITION keyword functionality for !P.MULTI display. 9 Sept 2007. DWF.
+;      Bit one too many times. Added _STRICT_EXTRA keywords for all _EXTRA keywords. 1 Feb 2008. DWF.
+;      Added FSC_$TVIMAGE common block for interactive interaction with TVINFO. 16 March 2008. DWF.
+;      Added SCALE keyword. 18 March 2008. DWF.
+;      Added keywords to allow axes to be drawn around the image. 18 March 2008. DWF.
+;      Added QUIET keyword to allow by-passing of FSC_$TVIMAGE common block updating. 21 March 2008. DWF.
+;      Made BACKGROUND and ERASE valid keywords only on 24-bit devices. Ignored on others. 28 May 2008. DWF.
+;      Cannot make color work in device independent way for axes, unless I handle axis color directly. To this
+;          end, I have added an ACOLOR keyword. 16 June 2008. DWF.
+;      Added BREWER keyword so I can specify Brewer colors with BACKGROUND and ACOLOR keywords. 16 June 2008. DWF.
+;-
+;
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright 2000-2008 Fanning Software Consulting.
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+;
+;
+; NAME:
+;  TVIMAGE_CONGRID
+;
+; PURPOSE:
+;       Shrink or expand the size of an array by an arbitrary amount.
+;       This IDL procedure simulates the action of the VAX/VMS
+;       CONGRID/CONGRIDI function.
+;
+;  This function is similar to "REBIN" in that it can resize a
+;       one, two, or three dimensional array.   "REBIN", however,
+;       requires that the new array size must be an integer multiple
+;       of the original size.   CONGRID will resize an array to any
+;       arbitrary size (REBIN is somewhat faster, however).
+;       REBIN averages multiple points when shrinking an array,
+;       while CONGRID just resamples the array.
+;
+; CATEGORY:
+;       Array Manipulation.
+;
+; CALLING SEQUENCE:
+;  array = TVIMAGE_CONGRID(array, x, y, z)
+;
+; INPUTS:
+;       array:  A 1, 2, or 3 dimensional array to resize.
+;               Data Type : Any type except string or structure.
+;
+;       x:      The new X dimension of the resized array.
+;               Data Type : Int or Long (greater than or equal to 2).
+;
+; OPTIONAL INPUTS:
+;       y:      The new Y dimension of the resized array.   If the original
+;               array has only 1 dimension then y is ignored.   If the
+;               original array has 2 or 3 dimensions then y MUST be present.
+;
+;       z:      The new Z dimension of the resized array.   If the original
+;               array has only 1 or 2 dimensions then z is ignored.   If the
+;               original array has 3 dimensions then z MUST be present.
+;
+; KEYWORD PARAMETERS:
+;       INTERP: If set, causes linear interpolation to be used.
+;               Otherwise, the nearest-neighbor method is used.
+;
+;       CUBIC:  If set, uses "Cubic convolution" interpolation.  A more
+;               accurate, but more time-consuming, form of interpolation.
+;               CUBIC has no effect when used with 3 dimensional arrays.
+;
+;       MINUS_ONE:
+;               If set, will prevent CONGRID from extrapolating one row or
+;               column beyond the bounds of the input array.   For example,
+;               If the input array has the dimensions (i, j) and the
+;               output array has the dimensions (x, y), then by
+;               default the array is resampled by a factor of (i/x)
+;               in the X direction and (j/y) in the Y direction.
+;               If MINUS_ONE is present (AND IS NON-ZERO) then the array
+;               will be resampled by the factors (i-1)/(x-1) and
+;               (j-1)/(y-1).
+;
+;       HALF_HALF:
+;               If set, will tell CONGRID to extrapolate a *half* row
+;               and column on either side, rather than the default of
+;               one full row/column at the ends of the array.  If you
+;               are interpolating images with few rows, then the
+;               output will be more consistent with this technique.
+;               This keyword is intended as a replacement for
+;               MINUS_ONE, and both keywords probably should not be
+;               used in the same call to CONGRID.
+;
+; OUTPUTS:
+;  The returned array has the same number of dimensions as the original
+;       array and is of the same data type.   The returned array will have
+;       the dimensions (x), (x, y), or (x, y, z) depending on how many
+;       dimensions the input array had.
+;
+; PROCEDURE:
+;       IF the input array has three dimensions, or if INTERP is set,
+;       then the IDL interpolate function is used to interpolate the
+;       data values.
+;       If the input array has two dimensions, and INTERP is NOT set,
+;       then the IDL POLY_2D function is used for nearest neighbor sampling.
+;       If the input array has one dimension, and INTERP is NOT set,
+;       then nearest neighbor sampling is used.
+;
+; EXAMPLE:
+;       ; vol is a 3-D array with the dimensions (80, 100, 57)
+;       ; Resize vol to be a (90, 90, 80) array
+;       vol = TVIMAGE_CONGRID(vol, 90, 90, 80)
+;
+; MODIFICATION HISTORY:
+;       DMS, Sept. 1988.
+;       DMS, Added the MINUS_ONE keyword, Sept. 1992.
+;  Daniel Carr. Re-wrote to handle one and three dimensional arrays
+;                    using INTERPOLATE function.
+;  DMS, RSI, Nov, 1993.  Added CUBIC keyword.
+;       Craig Markwardt, Dec, 1997.  Added halfhalf keyword to
+;                        more evenly distribute "dead" pixel row
+;       Use uniformly spaced grid points for half_half W. Landsman   Feb. 2000
+;              (and slightly modified by C. Markwardt 14 Feb 2000)
+;  DWF, FSC, 22 Apr 2007. Modified the program so that 3D arrays use nearest-neighbor
+;       interpolation unless the INTERP keyword is set.
+;  DWF, FSC, 22 Apr 2007. Function renamed from CMCONGRID to TVIMAGE_CONGRID on
+;       recommendation of Craig Markwardt as he wants no part of this. :-)
+
+
+FUNCTION TVIMAGE_CONGRID, arr, x, y, z, Interp=int, Minus_One=m1, Cubic = cubic, $
+                    Half_Half=hh
+
+    ON_ERROR, 2    ;Return to caller if error
+    s = Size(arr)
+    
+    IF ((s[0] EQ 0) OR (s[0] GT 3)) THEN $
+       Message, 'Array must have 1, 2, or 3 dimensions.'
+    
+    ;  Supply defaults = no interpolate, and no minus_one.
+    if n_elements(int) le 0 then int = 0 else int = keyword_set(int)
+    if n_elements(m1) le 0 then m1 = 0 else m1 = keyword_set(m1)
+    
+    ; Compute offsets pixel offsets for half_half
+    halfx = 0.0 & halfy = 0.0 & halfz = 0.0
+    if keyword_set(hh) then begin
+        if s[0] GE 1 then halfx = -0.5 + (float(s[1])/x)
+        if s[0] GE 2 then halfy = -0.5 + (float(s[2])/y)
+        if s[0] GE 3 then halfz = -0.5 + (float(s[3])/z)
+    endif
+    cub = KEYWORD_SET(cubic)
+    if cub THEN int = 1  ;Cubic implies interpolate
+    
+    
+    CASE s[0] OF
+       1: BEGIN          ; *** ONE DIMENSIONAL ARRAY
+       srx = float(s[1] - m1)/(x-m1) * findgen(x) + halfx
+          IF int THEN $
+             RETURN, INTERPOLATE(arr, srx, CUBIC = cub) ELSE $
+             RETURN, arr(ROUND(srx))
+       ENDCASE
+       2: BEGIN ; *** TWO DIMENSIONAL ARRAY
+       IF int THEN BEGIN
+         srx = float(s[1] - m1) / (x-m1) * findgen(x) + halfx
+         sry = float(s[2] - m1) / (y-m1) * findgen(y) + halfy
+              RETURN, INTERPOLATE(arr, srx, sry, /GRID, CUBIC=cub)
+       ENDIF ELSE $
+         RETURN, POLY_2D(arr, $
+          [[0,0],[(s[1]-m1)/float(x-m1),0]], $ ;Use poly_2d
+          [[0,(s[2]-m1)/float(y-m1)],[0,0]],int,x,y)
+    
+       ENDCASE
+       3: BEGIN ; *** THREE DIMENSIONAL ARRAY
+       srx = float(s[1] - m1) / (x-m1) * findgen(x) + halfx
+       sry = float(s[2] - m1) / (y-m1) * findgen(y) + halfy
+       srz = float(s[3] - m1) / (z-m1) * findgen(z) + halfz
+       IF int THEN BEGIN
+          RETURN, interpolate(arr, srx, sry, srz, /grid)
+       ENDIF ELSE BEGIN
+          RETURN, interpolate(arr, round(srx), round(sry), round(srz), /grid)
+       ENDELSE
+       ENDCASE
+    ENDCASE
+    
+    RETURN, arr_r
+END
+;--------------------------------------------------------------------------
+
+
+
+FUNCTION TVIMAGE_ERROR, theMessage, Traceback=traceback, NoName=noName, _Extra=extra
+
+    On_Error, 2
+    
+    ; Check for presence and type of message.
+    IF N_Elements(theMessage) EQ 0 THEN theMessage = !Error_State.Msg
+    s = Size(theMessage)
+    messageType = s[s[0]+1]
+    IF messageType NE 7 THEN BEGIN
+       Message, "The message parameter must be a string.", _Extra=extra
+    ENDIF
+    
+    ; Get the call stack and the calling routine's name.
+    Help, Calls=callStack
+    callingRoutine = (StrSplit(StrCompress(callStack[1])," ", /Extract))[0]
+    
+    ; Are widgets supported? Doesn't matter in IDL 5.3 and higher.
+    widgetsSupported = ((!D.Flags AND 65536L) NE 0) OR Float(!Version.Release) GE 5.3
+    IF widgetsSupported THEN BEGIN
+       IF Keyword_Set(noName) THEN answer = Dialog_Message(theMessage, _Extra=extra) ELSE BEGIN
+          IF StrUpCase(callingRoutine) EQ "$MAIN$" THEN answer = Dialog_Message(theMessage, _Extra=extra) ELSE $
+             answer = Dialog_Message(StrUpCase(callingRoutine) + ": " + theMessage, _Extra=extra)
+       ENDELSE
+    ENDIF ELSE BEGIN
+          Message, theMessage, /Continue, /NoPrint, /NoName, /NoPrefix, _Extra=extra
+          Print, '%' + callingRoutine + ': ' + theMessage
+          answer = 'OK'
+    ENDELSE
+    
+    ; Provide traceback information if requested.
+    IF Keyword_Set(traceback) THEN BEGIN
+       Help, /Last_Message, Output=traceback
+       Print,''
+       Print, 'Traceback Report from ' + StrUpCase(callingRoutine) + ':'
+       Print, ''
+       FOR j=0,N_Elements(traceback)-1 DO Print, "     " + traceback[j]
+       Print, ''
+    ENDIF
+    
+    RETURN, answer
+END
+
+
+
+PRO TVIMAGE, image, x, y, $
+   ACOLOR=acolor, $
+   AXIS=axis, $
+   AXES=axes, $
+   AXKEYWORDS=axkeywords, $
+   BACKGROUND=background, $
+   BREWER=brewer, $
+   ERASE=eraseit, $
+   HALF_HALF=half_half, $
+   KEEP_ASPECT_RATIO=keep, $
+   MARGIN=margin, $
+   MINUS_ONE=minusOne, $
+   NOINTERPOLATION=nointerp, $
+   NORMAL=normal, $
+   POSITION=position, $
+   OVERPLOT=overplot, $
+   QUIET=quiet, $
+   SCALE=scale, $
+   TV=tv, $
+   XRANGE=plotxrange, $
+   YRANGE=plotyrange, $
+   _EXTRA=extra
+
+    ; Error handling.
+    Catch, theError
+    IF theError NE 0 THEN BEGIN
+       Catch, /Cancel
+       ok = TVIMAGE_ERROR(Traceback=1, /Error)
+       IF Ptr_Valid(ptr) THEN BEGIN
+            image = Temporary(*ptr)
+            Ptr_Free, ptr
+       ENDIF
+       RETURN
+    ENDIF
+    
+    ; Set up a common block as input to TVINFO.
+    COMMON FSC_$TVIMAGE, _tvimage_xsize, _tvimage_ysize, $
+                         _tvimage_winxsize, _tvimage_winysize, $
+                         _tvimage_position, _tvimage_winID, $
+                         _tvimage_current
+    
+    ; Check for image parameter and keywords.
+    IF N_Elements(image) EQ 0 THEN MESSAGE, 'You must pass a valid image argument.', /NoName
+    
+    ; Did the user want me to scale the image.
+    IF Keyword_Set(scale) THEN BEGIN
+        ptr = Ptr_New(image, /NO_COPY)
+        image = BytScl(*ptr)
+    ENDIF
+    IF N_Elements(acolor) EQ 0 THEN acolor = !P.Color
+    IF Keyword_Set(axis) THEN axes = 1
+    axes = Keyword_Set(axes)
+    brewer = Keyword_Set(brewer)
+    interp = 1.0 - Keyword_Set(nointerp)
+    half_half = Keyword_Set(half_half)
+    minusOne = Keyword_Set(minusOne)
+    IF N_Elements(background) EQ 0 THEN background = !P.Background
+    IF Keyword_Set(eraseit) THEN BEGIN
+         IF (!D.Flags AND 256) NE 0 THEN BEGIN
+            Device, Get_Visual_Depth=theDepth
+            IF theDepth GE 24 THEN BEGIN
+               varType = Size(background, /TNAME)
+               CASE 1 OF
+                  varType EQ 'BYTE' OR varType EQ 'INT': BEGIN
+                     TVLCT, r, g, b, /GET
+                     Erase, Color=background
+                     TVLCT, r, g, b
+                     END
+                  varType EQ 'LONG': BEGIN
+                     Device, Decomposed=1, Get_Decomposed=theState
+                     Erase, Color=background
+                     Device, Decomposed=theState
+                     END
+                  varType EQ 'STRING': BEGIN
+                     Device, Decomposed=1, Get_Decomposed=theState
+                     Erase, Color=FSC_Color(background, BREWER=brewer)
+                     Device, Decomposed=theState
+                     END
+                  ELSE: BEGIN
+                     TVLCT, r, g, b, /GET
+                     Erase, Color=background
+                     TVLCT, r, g, b
+                     END
+               ENDCASE
+            ENDIF
+         ENDIF
+    ENDIF
+    IF (N_Elements(margin) GT 0) AND (Keyword_Set(margin) EQ 0) THEN vmargin=[0.,0.] ELSE vmargin=[1.,1.]
+    
+    ; Check image size.
+    s = Size(image)
+    IF s[0] LT 2 OR s[0] GT 3 THEN $
+       MESSAGE, 'Argument does not appear to be an image. Returning...', /NoName
+    
+    ; Allow 24-bit images and 2D images that are sent in as 3D
+    ; arrays where one dimension is a 1.
+    IF s[0] EQ 3 THEN BEGIN
+       IF (s[1] NE 3L) AND (s[2] NE 3L) AND (s[3] NE 3L) THEN BEGIN
+          IF (s[1] NE 1L) AND (s[2] NE 1L) AND (s[3] NE 1L) THEN BEGIN
+             MESSAGE, 'Argument does not appear to be a 24-bit image. Returning...', /NoName
+          ENDIF ELSE BEGIN
+             IF s[1] EQ 1 THEN single = 1
+             IF s[2] EQ 1 THEN single = 2
+             IF s[3] EQ 1 THEN single = 3
+             CASE single OF
+                1: image = Reform(image, s[2], s[3])
+                2: image = Reform(image, s[1], s[3])
+                3: image = Reform(image, s[1], s[2])
+             ENDCASE
+             s = Size(image)
+          ENDELSE
+       ENDIF
+    ENDIF ELSE s = Size(image)
+    
+    ; If a window is not open, open one, otherwise in X devices you get incorrect
+    ; window size information the first time you call TVIMAGE.
+    IF (!D.FLAGS AND 256) NE 0 THEN IF !D.Window EQ -1 THEN Window
+    
+    ; Which release of IDL is this?
+    thisRelease = Float(!Version.Release)
+    
+    ; Doing multiple plots?
+    IF Total(!P.Multi) GT 0 THEN multi = 1 ELSE multi = 0
+    
+    ; Check for position and overplot keywords.
+    IF N_Elements(position) EQ 0 THEN BEGIN
+       IF Keyword_Set(multi) AND (Keyword_Set(overplot) NE 1) THEN BEGIN
+          Plot, Findgen(11), XStyle=4, YStyle=4, /NoData, Background=background, XMargin=vmargin, YMargin=vmargin
+          position = [!X.Window[0], !Y.Window[0], !X.Window[1], !Y.Window[1]]
+       ENDIF ELSE BEGIN
+          IF Keyword_Set(overplot) THEN BEGIN
+             position = [!X.Window[0], !Y.Window[0], !X.Window[1], !Y.Window[1]]
+          ENDIF ELSE position = [0.0, 0.0, 1.0, 1.0]
+       ENDELSE
+    ENDIF ELSE BEGIN
+       IF Keyword_Set(multi) AND (Keyword_Set(overplot) NE 1)THEN BEGIN
+    
+          ; Draw the invisible plot to get plot position.
+          Plot, Findgen(11), XStyle=4, YStyle=4, /NoData, Background=background, XMargin=vmargin, YMargin=vmargin
+    
+          ; Use position coordinates to indicate position in this set of coordinates.
+          xrange = !X.Window[1] - !X.Window[0]
+          xstart = !X.Window[0] + position[0]*xrange
+          xend = xrange * (position[2] - position[0]) + xstart
+    
+          yrange = !Y.Window[1] - !Y.Window[0]
+          ystart = !Y.Window[0] + position[1]*yrange
+          yend = yrange * (position[3] - position[1]) + ystart
+    
+          ; New position based on !P.MULTI position.
+          position = [xstart, ystart, xend, yend]
+    
+       ENDIF ELSE BEGIN
+          IF Keyword_Set(overplot) THEN BEGIN
+             position = [!X.Window[0], !Y.Window[0], !X.Window[1], !Y.Window[1]]
+          ENDIF ELSE position = Float(position)
+       ENDELSE
+    ENDELSE
+    
+    ; Check for margin keyword.
+    IF (Keyword_Set(multi) EQ 0) AND (Keyword_Set(overplot) EQ 0) THEN BEGIN
+       IF N_Elements(margin) NE 0 THEN BEGIN
+               margin = 0.0 > margin < 0.33
+               position = [position[0] + margin, position[1] + margin, $
+                           position[2] - margin, position[3] - margin]
+       ENDIF
+    ENDIF
+    
+    ; 2D image.
+    IF s[0] EQ 2 THEN BEGIN
+    
+       imgXsize = FLOAT(s[1])
+       imgYsize = FLOAT(s[2])
+       true = 0
+    
+       ; Decomposed color off if device supports it.
+       CASE  StrUpCase(!D.NAME) OF
+            'X': BEGIN
+                Device, Get_Visual_Depth=thisDepth
+                IF thisRelease GE 5.2 THEN Device, Get_Decomposed=thisDecomposed
+                Device, Decomposed=0
+                ENDCASE
+            'WIN': BEGIN
+    
+                Device, Get_Visual_Depth=thisDepth
+                IF thisRelease GE 5.2 THEN Device, Get_Decomposed=thisDecomposed
+                Device, Decomposed=0
+                ENDCASE
+            'MAC': BEGIN
+                Device, Get_Visual_Depth=thisDepth
+                IF thisRelease GE 5.2 THEN Device, Get_Decomposed=thisDecomposed
+                Device, Decomposed=0
+                ENDCASE
+            'Z': BEGIN
+                ; Fix for 24-bit Z-buffer.
+                IF (Float(!Version.Release) GE 6.4) THEN BEGIN
+                   Device, Get_Decomposed=thisDecomposed, Get_Pixel_Depth=thisDepth
+                   Device, Decomposed=0
+                ENDIF ELSE thisDepth = 8
+                ENDCASE
+            ELSE: thisDepth = 8
+       ENDCASE
+    
+    ENDIF
+    
+    ; 3D image.
+    IF s[0] EQ 3 THEN BEGIN
+    
+       IF s[1] EQ 3 THEN true = 1 ; Pixel interleaved
+       IF s[2] EQ 3 THEN true = 2 ; Row interleaved
+       IF s[3] EQ 3 THEN true = 3 ; Band interleaved
+    
+       ; Decomposed color on if device supports it.
+       CASE StrUpCase(!D.NAME) OF
+          'X': BEGIN
+             Device, Get_Visual_Depth=thisDepth
+             IF thisRelease GE 5.2 THEN Device, Get_Decomposed=thisDecomposed
+             IF thisDepth GT 8 THEN Device, Decomposed=1
+             ENDCASE
+          'WIN': BEGIN
+             Device, Get_Visual_Depth=thisDepth
+             IF thisRelease GE 5.2 THEN Device, Get_Decomposed=thisDecomposed
+             IF thisDepth GT 8 THEN Device, Decomposed=1
+             ENDCASE
+          'MAC': BEGIN
+             Device, Get_Visual_Depth=thisDepth
+             IF thisRelease GE 5.2 THEN Device, Get_Decomposed=thisDecomposed
+             IF thisDepth GT 8 THEN Device, Decomposed=1
+             ENDCASE
+          'Z': BEGIN
+             ; Fix for 24-bit Z-buffer.
+             IF (Float(!Version.Release) GE 6.4) THEN BEGIN
+                Device, Get_Pixel_Depth=thisDepth
+                IF thisDepth GT 8 THEN Device, Decomposed=1
+             ENDIF
+             ENDCASE
+          ELSE: thisDepth = 8
+       ENDCASE
+    
+       CASE true OF
+          1: BEGIN
+             imgXsize = FLOAT(s[2])
+             imgYsize = FLOAT(s[3])
+             ENDCASE
+          2: BEGIN
+             imgXsize = FLOAT(s[1])
+             imgYsize = FLOAT(s[3])
+             ENDCASE
+          3: BEGIN
+             imgXsize = FLOAT(s[1])
+             imgYsize = FLOAT(s[2])
+             ENDCASE
+       ENDCASE
+    
+    ENDIF
+    
+    ; Check for TV keyword. If present, then act like a TV command.
+    IF Keyword_Set(tv) THEN BEGIN
+    
+       IF N_Params() GE 3 OR N_Params() EQ 1 THEN BEGIN
+         IF N_Elements(x) EQ 0 THEN x = 0
+         IF N_Elements(y) EQ 0 THEN y = 0
+         IF Keyword_Set(normal) THEN TV, image, x, y, True=true, _STRICT_EXTRA=extra, /Normal ELSE $
+                                     TV, image, x, y, True=true, _STRICT_EXTRA=extra, /Device
+       ENDIF ELSE BEGIN
+         IF N_Params() EQ 2 THEN BEGIN
+             IF Keyword_Set(normal) THEN TV, image, x, True=true, _STRICT_EXTRA=extra, /Normal ELSE $
+                                         TV, image, x, True=true, _STRICT_EXTRA=extra, /Device
+         ENDIF
+       ENDELSE
+       GoTo, restoreDecomposed
+    
+    ENDIF
+    
+    ; Maintain aspect ratio (ratio of height to width)?
+    IF KEYWORD_SET(keep) THEN BEGIN
+    
+       ; Find aspect ratio of image.
+       ratio = FLOAT(imgYsize) / imgXSize
+    
+       ; Find the proposed size of the image in pixels without aspect
+       ; considerations.
+       xpixSize = (position(2) - position(0)) * !D.X_VSize
+       ypixSize = (position(3) - position(1)) * !D.Y_VSize
+    
+       ; Try to fit the image width. If you can't maintain
+       ; the aspect ratio, fit the image height.
+       trialX = xpixSize
+       trialY = trialX * ratio
+       IF trialY GT ypixSize THEN BEGIN
+          trialY = ypixSize
+          trialX = trialY / ratio
+       ENDIF
+    
+       ; Recalculate the position of the image in the window.
+       position[0] = (((xpixSize - trialX) / 2.0) / !D.X_VSize) + position[0]
+       position[2] = position[0] + (trialX/FLOAT(!D.X_VSize))
+       position[1] = (((ypixSize - trialY) / 2.0) / !D.Y_VSize)  + position[1]
+       position[3] = position[1] + (trialY/FLOAT(!D.Y_VSize))
+    
+    ENDIF
+    
+    ; Calculate the image size and start locations.
+    xsize = Ceil((position[2] - position[0]) * !D.X_VSIZE)
+    ysize = Ceil((position[3] - position[1]) * !D.Y_VSIZE)
+    xstart = Round(position[0] * !D.X_VSIZE)
+    ystart = Round(position[1] * !D.Y_VSIZE)
+    
+    ; Display the image. Sizing different for scalable pixels devices.
+    IF (!D.Flags AND 1) NE 0 THEN BEGIN
+    
+       ; Need a gray-scale color table if this is a true
+       ; color image.
+       IF true GT 0 THEN LOADCT, 0, /Silent
+       TV, image, xstart, ystart, XSIZE=xsize, $
+          YSIZE=ysize, _STRICT_EXTRA=extra, True=true
+    
+    ENDIF ELSE BEGIN ; All other devices.
+    
+       CASE true OF
+          0: TV, TVIMAGE_CONGRID(image, xsize, ysize, INTERP=interp, $
+                MINUS_ONE=minusOne, HALF_HALF=half_half), xstart, $
+                ystart, _STRICT_EXTRA=extra
+          1: IF thisDepth GT 8 THEN BEGIN
+                TV, TVIMAGE_CONGRID(image, 3, xsize, ysize, INTERP=interp, $
+                   MINUS_ONE=minusOne, HALF_HALF=half_half), xstart, $
+                   ystart, _STRICT_EXTRA=extra, True=1
+             ENDIF ELSE BEGIN
+                image2d = Color_Quan(image, 1, r, g, b)
+                TVLCT, r, g, b
+                TV, TVIMAGE_CONGRID(image2d, xsize, ysize, INTERP=0, $
+                   MINUS_ONE=minusOne, HALF_HALF=half_half), xstart, $
+                   ystart, _STRICT_EXTRA=extra, True=0
+             ENDELSE
+          2: IF thisDepth GT 8 THEN BEGIN
+                TV, TVIMAGE_CONGRID(image, xsize, 3, ysize, INTERP=interp, $
+                   MINUS_ONE=minusOne, HALF_HALF=half_half), xstart, $
+                   ystart, _STRICT_EXTRA=extra, True=2
+             ENDIF ELSE BEGIN
+                image2d = Color_Quan(image, 2, r, g, b, _STRICT_EXTRA=extra)
+                TVLCT, r, g, b
+                TV, TVIMAGE_CONGRID(image2d, xsize, ysize, INTERP=0, $
+                   MINUS_ONE=minusOne, HALF_HALF=half_half), xstart, $
+                   ystart, _STRICT_EXTRA=extra, True=0
+             ENDELSE
+          3: IF thisDepth GT 8 THEN BEGIN
+                TV, TVIMAGE_CONGRID(image, xsize, ysize, 3, INTERP=interp, $
+                   MINUS_ONE=minusOne, HALF_HALF=half_half), xstart, $
+                   ystart, _STRICT_EXTRA=extra, True=3
+             ENDIF ELSE BEGIN
+                image2d = Color_Quan(image, 3, r, g, b, _STRICT_EXTRA=extra)
+                TVLCT, r, g, b
+                TV, TVIMAGE_CONGRID(image2d, xsize, ysize, INTERP=0, $
+                   MINUS_ONE=minusOne, HALF_HALF=half_half), xstart, $
+                   ystart, _STRICT_EXTRA=extra, True=0
+             ENDELSE
+      ENDCASE
+    ENDELSE
+        
+    ; Restore Decomposed state if necessary.
+    RestoreDecomposed:
+    
+    CASE StrUpCase(!D.NAME) OF
+       'X': BEGIN
+          IF thisRelease GE 5.2 THEN Device, Decomposed=thisDecomposed
+          ENDCASE
+       'WIN': BEGIN
+          IF thisRelease GE 5.2 THEN Device, Decomposed=thisDecomposed
+          ENDCASE
+       'MAC': BEGIN
+          IF thisRelease GE 5.2 THEN BEGIN
+             Device, Decomposed=thisDecomposed
+    
+             ; Here is a hack that fixes a longstanding Mac problem with
+             ; color tables after changing the decomposed state.
+             TV, [0]
+          ENDIF
+          ENDCASE
+       'Z': BEGIN
+          IF thisRelease GE 6.4 THEN Device, Decomposed=thisDecomposed
+          ENDCASE
+       ELSE:
+    ENDCASE
+
+    ; Set up common block parameters, but only if device supports windows.
+    ; And only if the QUIET flag is not turned on.
+    IF ~Keyword_Set(quiet) THEN BEGIN
+        IF (!D.FLAGS AND 256) NE 0 THEN BEGIN
+            _tvimage_xsize = imgXsize
+            _tvimage_ysize = imgYsize
+            _tvimage_winID = !D.Window
+            _tvimage_winxsize = !D.X_Size
+            _tvimage_winysize = !D.Y_Size
+            _tvimage_position = position
+            _tvimage_current = 1
+        ENDIF 
+    ENDIF
+    
+    ; If the user wanted axes, draw them now.
+    IF axes THEN BEGIN
+    
+         ; Save plot system variables and current color table.
+        bangp = !P
+        bangx = !X
+        bangy = !Y
+        TVLCT, r, g, b, /GET
+    
+        ; If axes color is string, convert it.
+        IF Size(acolor, /TNAME) EQ 'STRING' THEN acolor = FSC_COLOR(acolor, BREWER=brewer)    
+    
+        ; Need a data range?
+        IF N_Elements(plotxrange) EQ 0 THEN plotxrange = [0, imgXsize]
+        IF N_Elements(plotyrange) EQ 0 THEN plotyrange = [0, imgYsize]
+        PLOT, [0], /NODATA, /NOERASE, XRANGE=plotxrange, YRANGE=plotyrange, $
+            XSTYLE=1, YSTYLE=1, POSITION=position, COLOR=acolor, _STRICT_EXTRA=axkeywords
+            
+        ; Clean up after yourself.
+        TVLCT, r, g, b
+        !P = bangp
+        !X = bangx
+        !Y = bangy
+    ENDIF
+
+    ; If you scaled the data, but the image back.
+    IF Ptr_Valid(ptr) THEN BEGIN
+        image = Temporary(*ptr)
+        Ptr_Free, ptr
+    ENDIF
+END
Index: trunk/UTIL/IDLplot/MINIMAL/fsc_base_filename.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc_base_filename.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc_base_filename.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/fsc_base_filename.pro
Index: trunk/UTIL/IDLplot/MINIMAL/fsc_droplist.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc_droplist.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc_droplist.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/fsc_droplist.pro
Index: trunk/UTIL/IDLplot/MINIMAL/fsc_field.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc_field.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc_field.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/fsc_field.pro
Index: trunk/UTIL/IDLplot/MINIMAL/fsc_fileselect.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc_fileselect.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc_fileselect.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/fsc_fileselect.pro
Index: trunk/UTIL/IDLplot/MINIMAL/fsc_plotwindow.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc_plotwindow.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc_plotwindow.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/fsc_plotwindow.pro
Index: trunk/UTIL/IDLplot/MINIMAL/fsc_psconfig.html
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc_psconfig.html	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc_psconfig.html	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/fsc_psconfig.html
Index: trunk/UTIL/IDLplot/MINIMAL/fsc_psconfig__define.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/fsc_psconfig__define.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/fsc_psconfig__define.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/fsc_psconfig__define.pro
Index: trunk/UTIL/IDLplot/MINIMAL/getcdf.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/getcdf.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/getcdf.pro	(revision 1185)
@@ -0,0 +1,16 @@
+pro getcdf, $
+	file=file, $
+	charvar=charvar, $
+	invar=invar	
+
+T = SYSTIME(1)
+
+cdfid = ncdf_open(file)
+varid=ncdf_varid(cdfid,charvar)
+ncdf_varget, cdfid, varid, invar
+
+print, 'got '+charvar+' in '+file+' within ', SYSTIME(1) - T, ' seconds'
+print, '         size is', size(invar, /Dimensions) 
+
+
+end
Index: trunk/UTIL/IDLplot/MINIMAL/map_latlon.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/map_latlon.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/map_latlon.pro	(revision 1185)
@@ -0,0 +1,593 @@
+pro map_latlon, $
+	what_I_plot, $				; 2D field
+	lon, $					; 1D latitude OR 2D
+	lat, $					; 1D longitude OR 2D
+	minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+	maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+	overcontour=overcontour, $		; another 2D field to overplot with contour lines (=0: no)
+	overvector_x=overvector_x, $		; wind vector - x component (=0: no)
+	overvector_y=overvector_y, $		; wind vector - y component (=0: no)
+	ct=pal, $				; color table (33-rainbow is default)
+	colors=colors, $			; number of colors/levels (32 is default)
+	title=title_user, $			; title of the plot ('' is default)
+	format=format				; format of colorbar annotations ('(F6.2)' is default)
+
+;--------------------------------------------
+;
+; A general routine to plot lat/lon maps
+;
+; USE:	- map_latlon, what_I_plot 	
+;	- map_latlon, what_I_plot, lon, lat
+;	- ... and see options above
+;
+;--------------------------------------------
+; A. Spiga, August 2007
+;--------------------------------------------
+
+
+
+
+;---------------------------
+; a few permanent settings
+;---------------------------
+;
+missing_value=1.e30
+flag_cb='true'
+;-- optional:
+;-- user defined parameters
+; do not forget to type '.compile map_latlon' to update changes
+SPAWN, 'touch param_plot.idl'
+@param_plot.idl
+;
+;------------------
+
+
+;------------------
+; user settings
+;------------------
+if (n_elements(lon) eq 0) then begin
+	lon=findgen(n_elements(what_I_plot(*,0)))
+endif
+if (n_elements(lat) eq 0) then lat=findgen(n_elements(what_I_plot(0,*)))
+if (n_elements(minfield_init) eq 0) then minfield_init=0.
+if (n_elements(maxfield_init) eq 0) then maxfield_init=0.
+if (n_elements(overcontour) eq 0) then overcontour=0.
+if ((n_elements(overvector_x) eq 0) or (n_elements(overvector_y) eq 0)) then begin
+	overvector_x=0.
+	overvector_y=0.
+endif
+if (n_elements(colors) eq 0) then colors=32
+if (n_elements(title_user) eq 0) then title_user=''
+if (n_elements(subtitle_user) eq 0) then subtitle_user=''
+if (n_elements(pal) eq 0) then pal=33
+if (n_elements(format) eq 0) then format='(F6.2)'
+if (format eq '') then format='(F6.2)'
+;if (n_elements(xtitleset) eq 0) then xtitleset='longitude'
+;if (n_elements(ytitleset) eq 0) then ytitleset='latitude'
+if (n_elements(title_axis) ne 2) then begin
+        xtitleset='longitude'
+        ytitleset='latitude'
+endif else begin
+        xtitleset=title_axis(0)
+        ytitleset=title_axis(1)
+endelse
+if (n_elements(isotropic) eq 0) then isotropic='true'
+if (n_elements(coord2d) eq 0) then coord2d='false'
+
+;------------------
+; limits
+;------------------
+;if (minfield_init*maxfield_init eq 0) then begin   
+if (minfield_init eq maxfield_init) then begin
+	;---different min/max for each layer
+	w=where(abs(what_I_plot) lt missing_value)
+	if (w(0) ne -1) then begin
+		minfield=min(what_I_plot[w])
+		maxfield=max(what_I_plot[w])
+;goodscale, $
+;     what_I_plot, $
+;     minfield, $
+;     maxfield
+	endif else begin
+		what_I_plot=0.
+		print, 'no valid values in this field' 
+	endelse
+endif else begin
+	;---user-defined limits	
+	minfield=minfield_init 
+	maxfield=maxfield_init
+	;;w=where(what_I_plot lt minfield) & if (w(0) ne -1) then what_I_plot[w]=minfield
+	;;w=where(what_I_plot gt maxfield) & if (w(0) ne -1) then what_I_plot[w]=maxfield
+endelse
+
+if ((minfield+maxfield eq 0) and (abs(minfield) ne abs(maxfield))) then begin
+	print, 'nothing to plot ... skipping this plot ...'
+endif else begin
+
+
+;-----------------------------------------
+; fix the possible longitude ugliness :)
+; ...get rid of the -180/180 limit
+;-----------------------------------------
+
+;;;;; PB WITH 2D COORDINATES
+;w=where(lon eq min(lon))
+;if (w(0) ne 0) then begin
+;	lon[0:w(0)-1]=lon[0:w(0)-1]-360
+;endif
+
+
+;---------------
+; adapt ticks
+;---------------
+if (n_elements(windowx) eq 0) then windowx=[min(lon),max(lon)]
+if (n_elements(windowy) eq 0) then windowy=[min(lat),max(lat)]
+if (n_elements(intervalx) eq 0) then intervalx=round((windowx(1)-windowx(0))/8.)
+if (n_elements(intervaly) eq 0) then intervaly=round((windowy(1)-windowy(0))/5.)
+
+
+;------------------
+; plot window
+;------------------
+
+	;lons=lon & lats=lat
+	;;--------------------------------------------
+	;;
+	;; ANOMALY
+	;;
+	;w=where( (lon ge windowx(0)) and (lon le windowx(1)) ) & w2=where( (lat ge windowy(0)) and (lat le windowy(1)) )
+	;yeah=fltarr(n_elements(w),n_elements(w2)) & for i=0,n_elements(w)-1 do for j=0,n_elements(w2)-1 do yeah(i,j)=what_I_plot(w(i),w2(j))
+	;what_I_plot = yeah - mean(yeah)
+	;lon=lon[w] & lat=lat[w2]
+	;;--------------------------------------------
+
+
+	; to ensure the right limits
+	dumb_what_I_plot=what_I_plot
+	dumb_what_I_plot(*,*)=minfield & print, minfield
+	dumb_what_I_plot(0,0)=maxfield & print, maxfield
+
+;;
+;;
+;subtitle_hunhun = subtitle_user
+;subtitle_user = ''
+;;
+;;
+
+
+pospos = [0.10, 0.12, 0.90, 0.92] ;; iso
+;pospos = [0.15, 0.35, 0.95, 0.95] ;; non-iso
+
+if (isotropic eq 'true') then begin
+        loadct, 0, /silent
+        if ( coord2d ne 'polar' ) then begin
+                ;;trace non polaire
+                contour, /nodata, $
+                         /isotropic, $
+                         position=pospos, $
+                         dumb_what_I_plot,      lon,                            lat, $
+                         title=title_user,      xtitle=xtitleset,               ytitle=ytitleset, $
+                         xrange=windowx,                yrange=windowy, $
+                         xtickinterval=intervalx,       ytickinterval=intervaly, $
+                         subtitle=subtitle_user, color=0
+        endif else begin
+                ;;trace avec MAP_SET -- MAP_SET -- MAP_SET 
+                print,'------------------- Polar plot'
+                contour, /nodata, $
+                         /isotropic, $
+                         /overplot, $
+                         dumb_what_I_plot,      lon,                            lat, $
+                         title=title_user,      xtitle=xtitleset,               ytitle=ytitleset, $
+                         xrange=windowx,                yrange=windowy, $
+                         xtickinterval=intervalx,       ytickinterval=intervaly, $
+                         subtitle=subtitle_user, color=0
+        endelse
+        subtitle_user = ''
+endif else begin
+        pospos = [0.15, 0.35, 0.95, 0.95] ;; non-iso
+	loadct, 0, /silent
+        if ( coord2d ne 'polar' ) then begin
+                ;;trace non polaire
+                contour, /nodata, $
+                         position=pospos, $
+                         dumb_what_I_plot,      lon,                            lat, $
+                         title=title_user,      xtitle=xtitleset,               ytitle=ytitleset, $
+                         xrange=windowx,                yrange=windowy, $
+                         xtickinterval=intervalx,       ytickinterval=intervaly, $
+                         color=0,subtitle=subtitle_user
+        endif else begin
+                ;;trace avec MAP_SET -- MAP_SET -- MAP_SET 
+                print,'------------------- Polar plot'
+                contour, /nodata, $
+                         /overplot, $
+                         dumb_what_I_plot,      lon,                            lat, $
+                         title=title_user,      xtitle=xtitleset,               ytitle=ytitleset, $
+                         xrange=windowx,                yrange=windowy, $
+                         xtickinterval=intervalx,       ytickinterval=intervaly, $
+                         color=0,subtitle=subtitle_user
+        endelse
+endelse	
+
+;------------------
+; plot field
+;------------------
+
+; to avoid spurious blank zones
+nlevels=colors
+levp=minfield+(findgen(nlevels)/float(nlevels-1))*(maxfield-minfield)
+
+loadct,pal,/silent
+;reverse_ct
+if (pal eq 0) then reverse_ct
+if (pal eq 21) then reverse_ct
+contour, what_I_plot, $
+	lon,lat, $
+;	nlevels=colors, $
+	levels=levp, $
+	/cell_fill, $
+	max_value=maxfield, $
+	min_value=minfield, $
+	/overplot
+
+
+;nlat=128.
+;oplot, lat*0.+nlat*100./1000., linestyle=1
+
+;;; ANOMALY
+;lon=lons
+;lat=lats
+
+;------------------
+; colorbar
+;------------------
+
+;if (flag_cb eq 'true') then begin
+;        format_colorbar=format
+;        colorbar, $
+;                position=[0.15, 0.85, 0.95, 0.90], $
+;                divisions=8, $
+;                range=[float(minfield),float(maxfield)], $
+;                format=format_colorbar
+;endif
+;goto, skip_new
+
+if (flag_cb eq 'true') then begin
+format_colorbar=format
+
+;;; ndiv peut etre regle
+if (n_elements(ndiv) eq 0) then ndiv=10
+
+;if (n_elements(poscb) eq 0) then poscb=0.95
+;if (n_elements(poscb) eq 0) then poscb=0.80
+if (n_elements(poscb) eq 0) then poscb=0.70
+
+     if (isotropic eq 'true') then begin
+       ;poscb=0.85 & 
+       pos=[poscb, 0.12, poscb+0.03, 0.92]
+       ;poscb=0.95 & pos=[poscb, 0.12, poscb+0.03, 0.92]
+;       poscb=0.96 & pos=[poscb, 0.12, poscb+0.03, 0.92]
+;       poscb=0.05 & pos=[poscb, 0.12, poscb+0.03, 0.92]
+               ;colorbar = Obj_New("COLORBAR",$
+               ; Range=[float(minfield),float(maxfield)],$
+               ; /vertical, $
+               ; Ncolors=255,$
+               ; charsize=0.85,$
+               ; format=format_colorbar,$
+               ; major=ndiv,$
+               ; ticklen=-0.15,$
+               ; position=pos)
+               ;colorbar->Draw
+               ;Obj_Destroy, colorbar
+        colorbar, $
+                /vertical, $
+                position=pos, $
+                range=[float(minfield),float(maxfield)], $
+                divisions=ndiv, $
+                ncolors=255,$
+;               charsize=0.85,$
+                ticklen=-0.15,$
+                format=format_colorbar
+
+xyouts, pos(2), 0.01, subtitle_user, charsize=0.8, alignment=1., /NORMAL
+
+	if (n_elements(nam2) ne 0) then begin
+		thedate=STRSPLIT(nam2, /EXTRACT)
+		thedate=STRSPLIT(thedate(2),"'",/EXTRACT)
+		thedate=STRSPLIT(thedate(0),"_",/EXTRACT) 
+		thedate=STRSPLIT(thedate(0),"-",/EXTRACT) 
+		xyouts, pos(2), 0.01, 'LMD Martian Mesoscale Model - d'+thedate(2)+'/m'+thedate(1), charsize=0.7, alignment=1., /NORMAL 
+	endif else begin
+		thedate=''
+	endelse
+;;
+;;
+;;
+;xyouts, pos(2), 0.01, 'LMD Mars Mesoscale Model / '+subtitle_hunhun, charsize=0.95, alignment=1., /NORMAL
+;;
+;;
+;;
+
+     endif else begin
+
+	pos=[0.15, 0.17, 0.95, 0.20]
+	if (subtitle_user eq '') then pos=[0.15, 0.20, 0.95, 0.23]
+
+               ;colorbar = Obj_New("COLORBAR",$
+               ; Range=[float(minfield),float(maxfield)],$
+               ; Ncolors=255,$
+               ; charsize=0.85,$
+               ; format=format_colorbar,$
+               ; major=ndiv,$
+               ; ticklen=-0.15,$
+               ; position=pos)
+               ;colorbar->Draw
+               ;Obj_Destroy, colorbar
+        colorbar, $
+                position=pos, $
+                range=[float(minfield),float(maxfield)], $
+                divisions=ndiv, $
+                ncolors=255,$
+;               charsize=0.85,$
+                ticklen=-0.15,$
+                format=format_colorbar
+
+	if (n_elements(nam2) ne 0) then begin
+		thedate=STRSPLIT(nam2, /EXTRACT) 
+		thedate=STRSPLIT(thedate(2),"'",/EXTRACT) 
+		thedate=STRSPLIT(thedate(0),"_",/EXTRACT) 
+		thedate=STRSPLIT(thedate(0),"-",/EXTRACT) 
+		xyouts, 0.95, pos(1)-0.08, 'LMD Martian Mesoscale Model - d'+thedate(2)+'/m'+thedate(1), charsize=0.7, alignment=1., /NORMAL 
+	endif else begin
+		thedate=''
+	endelse
+
+      endelse	
+endif
+
+skip_new:
+
+;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;
+;;; ajouter un point
+;loadct, 0
+;xyouts, 353.87-360, -1.88, '+', ALIGNMENT=0.5, CHARSIZE=2, CHARTHICK=2
+;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;
+
+;goto, nocontour 
+;print, 'contour' 
+;--------------------
+; overplot contour
+;--------------------
+if (n_elements(overcontour) ne 1) then begin
+
+	w=where(abs(overcontour) lt missing_value)
+	if (w(0) ne -1) then begin
+		min_contour=min(overcontour[w])
+		max_contour=max(overcontour[w])
+	endif
+
+
+; to avoid spurious blank zones
+nlevels=colors/2
+if (n_elements(lev) eq 0) then lev=min_contour+(findgen(nlevels)/float(nlevels-1))*(max_contour-min_contour)
+
+;lev=round(lev)
+;yeah=UNIQ(lev) & lev=lev[yeah]
+
+colcont = 150 ;75
+if (pal eq 16) then colcont=0 ;noir
+if (pal eq 4) then colcont=255 ;blanc
+
+if (isotropic eq 'true') then begin
+loadct,0,/silent
+;reverse_ct
+contour, overcontour, $
+	lon,lat, $
+/overplot, $ 
+;	nlevels=colors/2, $
+	levels=lev, $
+	C_LINESTYLE = (lev LT 0.0), $   ;; dotted lines if negative
+	max_value=max_contour, $
+	min_value=min_contour, $	
+	c_labels=findgen(n_elements(lev))*0., $
+;        c_charsize=!P.charsize/2, $
+	color=colcont;75;0;50;75;100tropclair;150;0;, $
+;	/noerase, $
+;	xtitle=xtitleset, $
+;	xrange=windowx, $
+;	ytitle=ytitleset, $
+;	yrange=windowy, $
+;       position=pospos, $
+;	/isotropic, $
+;	xtickinterval=intervalx, $
+;	ytickinterval=intervaly 
+endif else begin
+loadct,0,/silent
+contour, overcontour, $
+        lon,lat, $
+/overplot, $
+;        nlevels=colors/2, $ 
+        levels=lev, $
+        C_LINESTYLE = (lev LT 0.0), $   ;; dotted lines if negative
+        max_value=max_contour, $
+        min_value=min_contour, $
+        c_labels=findgen(n_elements(lev))*0., $
+        color=colcont;, $
+;        /noerase, $
+;        xtitle=xtitleset, $ 
+;        xrange=windowx, $
+;        ytitle=ytitleset, $
+;        yrange=windowy, $
+;;       position=[0.15, 0.15, 0.95, 0.75], $
+;        xtickinterval=intervalx, $
+;        ytickinterval=intervaly 
+endelse	
+
+
+endif
+nocontour:
+
+;--------------------
+; overplot wind
+;--------------------
+if (n_elements(overvector_x)*n_elements(overvector_y) ne 1) then begin
+
+	w=where(abs(overvector_x) ge missing_value)  ; u and v have the same missing values ...
+	if (w(0) ne -1) then begin
+		overvector_x[w]=0.
+		overvector_y[w]=0.
+	endif
+		
+
+len=2.0
+if (n_elements(windex) eq 0) then windex=20. 
+ref_mag=round(windex)
+mytext=STRTRIM(STRING(ref_mag),2)+'ms!E-1!N'
+
+if (n_elements(stride) eq 0) then begin
+;stride=3 		; STRIDE: Pick every nth vector for plotting. (1)
+;stride=2
+stride=5
+endif else begin
+stride=round(stride)
+endelse
+	
+ref_pos=[0.10, 0.90] 	
+ref_pos=[0.15, 0.10]
+ref_pos=[0.20, 0.05]
+;ref_pos=[0.20, 0.02]
+
+s=size(lon)
+if (s[0] eq 1) then begin
+ zeu=overvector_x
+ zev=overvector_y
+ longs=lon
+ lats=lat
+endif else begin
+ minlat=min(lat) & maxlat=max(lat) & minlon=min(lon) & maxlon=max(lon)
+ npoints=2*n_elements(lon(*,0))  ;; trop de points, mais au moins on ne perd rien (2 et 3 donnent results similaires)
+ TRIANGULATE, lon, lat, tr
+ zeu = GRIDDATA( lon, lat, overvector_x, /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+ zev = GRIDDATA( lon, lat, overvector_y, /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+ longs =  minlon + (maxlon - minlon)*findgen(npoints)/float(npoints-1)
+ lats =  minlat + (maxlat - minlat)*findgen(npoints)/float(npoints-1)
+endelse
+
+wlon=where( (longs gt windowx(0)) and (longs lt windowx(1)) )
+wlat=where( (lats gt windowy(0)) and (lats lt windowy(1)) )
+
+if ((wlon(0) eq -1) or (wlat(0) eq -1)) then begin
+	print, 'wrong window settings'
+        print, windowx(0), windowx(1)
+	print, longs
+	print, windowy(0), windowy(1)
+	print, lats
+	stop 
+endif
+
+myu=dblarr(n_elements(longs),n_elements(lats))
+myv=dblarr(n_elements(longs),n_elements(lats))
+
+myu(*,*)=!Values.F_NAN
+myv(*,*)=!Values.F_NAN
+
+for i=0,n_elements(wlon)-1 do begin
+for j=0,n_elements(wlat)-1 do begin	
+	myu(wlon(i),wlat(j))=zeu(wlon(i),wlat(j))
+        myv(wlon(i),wlat(j))=zev(wlon(i),wlat(j))
+endfor	
+endfor	
+
+	;; eliminate vector for colorbar clarity ?
+	;nxs=1
+	;nxe=n_elements(longs(*))-2
+	;nys=1
+	;nye=n_elements(lats(*))-2
+	;myu=overvector_x(nxs:nxe,nys:nye)
+	;myv=overvector_y(nxs:nxe,nys:nye)
+	;longs=lon(nxs:nxe)
+	;lats=lat(nys:nye)
+
+loadct,0,/silent
+VECTOR, myu, myv, longs, lats, LENGTH=len, REF_MAG=ref_mag,$
+        STRIDE=stride, TYPE=2, HEAD_LEN=0.3, ANGLE=30, $
+        REF_POS=ref_pos, REF_TEXT=mytext,$
+        ALIGN=0.5, COLOR=1, /OVERPLOT;, /NOERASE
+
+yeah:
+endif
+
+
+endelse
+
+
+
+goto, why_contour_end
+;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;
+
+if (n_elements(overcontour) ne 1) then begin
+
+        w=where(abs(overcontour) lt missing_value)
+        if (w(0) ne -1) then begin
+                min_contour=min(overcontour[w])
+                max_contour=max(overcontour[w])
+        endif
+
+
+; to avoid spurious blank zones
+nlevels=colors/2
+if (n_elements(lev) eq 0) then lev=min_contour+(findgen(nlevels)/float(nlevels-1))*(max_contour-min_contour)
+;lev=round(lev)
+;yeah=UNIQ(lev) & lev=lev[yeah]
+
+
+if (isotropic eq 'true') then begin
+loadct,0,/silent
+contour, overcontour, $
+        lon,lat, $
+;       nlevels=colors/2, $
+        levels=lev, $
+        C_LINESTYLE = (lev LT 0.0), $   ;; dotted lines if negative
+        max_value=max_contour, $
+        min_value=min_contour, $
+        c_labels=findgen(nlevels), $ ;*0., $
+        color=0, $
+        /noerase, $
+        xtitle=xtitleset, $
+        xrange=windowx, $
+        ytitle=ytitleset, $
+        yrange=windowy, $
+;        position=[0.15, 0.15, 0.95, 0.75], $
+        /isotropic, $
+        xtickinterval=intervalx, $
+        ytickinterval=intervaly
+endif else begin
+loadct,0,/silent
+contour, overcontour, $
+        lon,lat, $
+;       nlevels=colors/2, $ 
+        levels=lev, $
+        C_LINESTYLE = (lev LT 0.0), $   ;; dotted lines if negative
+        max_value=max_contour, $
+        min_value=min_contour, $
+        c_labels=findgen(nlevels), $
+        color=0, $
+        /noerase, $
+        xtitle=xtitleset, $
+        xrange=windowx, $
+        ytitle=ytitleset, $
+        yrange=windowy, $
+        position=[0.15, 0.15, 0.95, 0.75], $
+        xtickinterval=intervalx, $
+        ytickinterval=intervaly
+endelse
+
+
+endif
+
+why_contour_end:
+
+end
Index: trunk/UTIL/IDLplot/MINIMAL/param_plot.idl.minimal
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/param_plot.idl.minimal	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/param_plot.idl.minimal	(revision 1185)
@@ -0,0 +1,22 @@
+;subtitle_user='-- LMD Martian Mesoscale Model --'            ;; grepALL
+title_user='Friction velocity (!Nm!N.s!U-1!N) at local time 16h'     ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+;flag_cb='false'                ;; grepALL
+;format='(I0)'                  ;; grepALL
+;colors=64                       ;; grepALL
+pal=22                          ;; grepALL
+minfield_init=0.3      ;; grepALL
+maxfield_init=1.3	;; grepALL
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+windex=15. ;25. ;20.	;; grepALL
+stride=3. ;2.	;; grepALL
+;overcontour=overcontour-mean(overcontour)	;; grepALL
+;lev=220. + 2.*findgen(30) ;; grepALL
+lev=-10. + 1.*findgen(30) ;; grepALL
+;isotropic='false'       ;; grepALL
+intervalx=2.            ;; grepALL
+intervaly=2.             ;; grepALL
+windowx=[-130.,-112.]        ;; grepMAP
+windowy=[-18.,-2.]     ;; grepMAP
Index: trunk/UTIL/IDLplot/MINIMAL/plot_vector.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/plot_vector.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/plot_vector.pro	(revision 1185)
@@ -0,0 +1,129 @@
+PRO plot_vector, u, v, x, y, type=type, angle=angle, head_len=head_len,$
+                 maxmag=maxmag, align=align, length=length,$
+		 ref_text=ref_text, color=color, cstyle=cstyle
+;Procedure to calculate and plot a vector
+ 
+mylen=300.0 ; length of default arrow in pixels
+rev=1.0    
+x0=0.0
+y0=0.0
+x1=u/maxmag*mylen*length
+y1=v/maxmag*mylen*length
+dx=x1-x0
+IF (dx LT 0.0) THEN rev=-1.0
+dy=y1-y0
+r=SQRT(dx^2+dy^2)
+theta=ATAN(dy/dx)     
+phi=angle*!dtor
+rfrac=head_len 
+x2=x1-r*rfrac*rev*COS(theta-phi)
+y2=y1-r*rfrac*rev*SIN(theta-phi)
+x3=x1-r*rfrac*rev*COS(theta+phi)
+y3=y1-r*rfrac*rev*SIN(theta+phi)
+x4=x1-rfrac/2*r*rev*COS(theta)
+y4=y1-rfrac/2*r*rev*SIN(theta)
+;Calculate intersection of vector shaft and head points either
+;side of the shaft - see
+;http://astronomy.swin.edu.au/~pbourke/geometry/lineline2d
+;for more details
+ua=((x3-x2)*(y0-y2)-(y3-y2)*(x0-x2))/$
+   ((y3-y2)*(x1-x0)-(x3-x2)*(y1-y0))
+x5=x0+ua*(x1-x0)
+y5=y0+ua*(y1-y0) 
+               
+;Plot vectors in data space - cstyle=0
+;Position in device coordinates and then convert to data coordinates
+IF (cstyle EQ 0) THEN BEGIN
+ pt1=CONVERT_COORD(x,y, /DATA, /TO_DEVICE)
+ xpts=[x0,x1,x2,x3,x4,x5]+pt1[0]-align*dx
+ ypts=[y0,y1,y2,y3,y4,y5]+pt1[1]-align*dy
+ pts=CONVERT_COORD(xpts,ypts, /DEVICE, /TO_DATA)
+ xpts=pts[0,*]
+ ypts=pts[1,*]
+ x0=xpts[0]
+ x1=xpts[1]
+ x2=xpts[2]
+ x3=xpts[3]
+ x4=xpts[4]
+ x5=xpts[5]
+ y0=ypts[0]
+ y1=ypts[1]
+ y2=ypts[2]
+ y3=ypts[3]
+ y4=ypts[4]
+ y5=ypts[5]   
+   
+	       
+; Plot the vectors omiting any vectors with NaNs
+ z=[xpts, ypts] 	 
+ IF (TOTAL(FINITE(z)) EQ 12) THEN BEGIN
+  IF (N_ELEMENTS(TYPE) EQ 0) THEN TYPE=0
+  IF (TYPE EQ 0) THEN BEGIN	 
+    PLOTS, [x0,x1,x2,x1,x3], [y0,y1,y2,y1,y3], COLOR=color
+  ENDIF
+  IF (TYPE EQ 1) THEN BEGIN	 
+    PLOTS, [x0,x5,x3,x1,x2,x5], [y0,y5,y3,y1,y2,y5], COLOR=color
+  ENDIF  
+  IF (TYPE EQ 2) THEN BEGIN	 
+    PLOTS, [x0,x4,x2,x1,x3,x4], [y0,y4,y2,y1,y3,y4], COLOR=color
+  ENDIF
+  IF (TYPE EQ 3) THEN BEGIN	 
+    PLOTS, [x0,x1], [y0,y1], COLOR=color
+    POLYFILL, [x1,x2,x3,x1], [y1,y2,y3,y1], COLOR=color
+  ENDIF
+  IF (TYPE EQ 4) THEN BEGIN	 
+    PLOTS, [x0,x4], [y0,y4], COLOR=color
+   POLYFILL, [x1,x2,x4,x3,x1], [y1,y2,y4,y3,y1], COLOR=color
+  ENDIF
+ ENDIF
+ENDIF	
+
+
+;Plot reference vector - cstyle=1
+;Position in device coordinates and then convert to data coordinates
+IF (cstyle EQ 1) THEN BEGIN
+ pt1=CONVERT_COORD(x,y, /NORMAL, /TO_DEVICE)
+ xpts=[x0,x1,x2,x3,x4,x5]+pt1[0]
+ ypts=[y0,y1,y2,y3,y4,y5]+pt1[1]
+ x0=xpts[0]
+ x1=xpts[1]
+ x2=xpts[2]
+ x3=xpts[3]
+ x4=xpts[4]
+ x5=xpts[5]
+ y0=ypts[0]
+ y1=ypts[1]
+ y2=ypts[2]
+ y3=ypts[3]
+ y4=ypts[4]
+ y5=ypts[5]     
+	       
+; Plot the vectors omiting any vectors with NaNs
+ z=[xpts, ypts] 	 
+ IF (TOTAL(FINITE(z)) EQ 12) THEN BEGIN
+  IF (N_ELEMENTS(TYPE) EQ 0) THEN TYPE=0
+  IF (TYPE EQ 0) THEN BEGIN	 
+    PLOTS, [x0,x1,x2,x1,x3], [y0,y1,y2,y1,y3], COLOR=color, /DEVICE
+  ENDIF
+  IF (TYPE EQ 1) THEN BEGIN	 
+    PLOTS, [x0,x5,x3,x1,x2,x5], [y0,y5,y3,y1,y2,y5], COLOR=color, /DEVICE
+  ENDIF  
+  IF (TYPE EQ 2) THEN BEGIN	 
+    PLOTS, [x0,x4,x2,x1,x3,x4], [y0,y4,y2,y1,y3,y4], COLOR=color, /DEVICE
+  ENDIF
+  IF (TYPE EQ 3) THEN BEGIN	 
+    PLOTS, [x0,x1], [y0,y1], COLOR=color, /DEVICE
+    POLYFILL, [x1,x2,x3,x1], [y1,y2,y3,y1], COLOR=color, /DEVICE
+  ENDIF
+  IF (TYPE EQ 4) THEN BEGIN	 
+    PLOTS, [x0,x4], [y0,y4], COLOR=color, /DEVICE
+   POLYFILL, [x1,x2,x4,x3,x1], [y1,y2,y4,y3,y1], COLOR=color, /DEVICE
+  ENDIF
+ ENDIF
+ 
+ ;Add the reference vector text
+ IF (N_ELEMENTS(REF_TEXT) EQ 0) THEN ref_text=' '
+ XYOUTS, x0-100, y0-100, ref_text, ALIGNMENT=1.0, /DEVICE
+ENDIF
+	
+END		
Index: trunk/UTIL/IDLplot/MINIMAL/profile.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/profile.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/profile.pro	(revision 1185)
@@ -0,0 +1,171 @@
+pro profile, $
+	what_I_plot, $				; 1D vertical profile
+	column, $				; altitudes	
+	alt=alt, $				; altitude range [altmin, altmax]
+	minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+	maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+	inprofile=overplot, $			; another vertical profile to overplot
+	incolumn=overplot_column, $		; altitudes of the other vertical profile (in case /= column)
+	discrete=discrete, $			; show the profile points (= type of points in !psym)
+	title_plot=title_user, $		; title of the plot ('Profile' is default)
+	title_axis=title_axis, $		; title of the [x,y] axis (['Field','Altitude'] is default)
+	mention=mention				; add text precision within the plot window (default is nothing or '')
+
+;--------------------------------------------
+;
+; A general routine to plot 1D profiles
+;
+; USE: see comments above
+;
+; EXAMPLE:
+;	profile, findgen(30)^2, findgen(30)
+;	profile, findgen(30)^2, findgen(30), overplot=findgen(30)^2.2, discrete=4, title_plot='An example of profile'
+;	profile, findgen(30)^2, findgen(30), title_axis=['Dumb profile', 'Dumb Altitude']
+;
+;--------------------------------------------
+; A. Spiga, September 2007
+;--------------------------------------------
+
+
+
+;---------------------------
+; a few permanent settings
+;---------------------------
+;
+missing_value=1.e30
+SPAWN, 'touch param_plot.idl'
+@param_plot.idl
+;
+;------------------
+
+
+;-----------------------------
+; user and default settings
+;-----------------------------
+if (n_elements(title_user) eq 0) then title='Profile'
+if (n_elements(title_axis) ne 2) then begin
+	xtitle='Field'
+	ytitle='Altitude'
+endif else begin
+	xtitle=title_axis(0)
+	ytitle=title_axis(1)
+endelse	
+if (n_elements(maxfield_init) eq 0) then maxfield_init=0
+if (n_elements(minfield_init) eq 0) then minfield_init=0
+
+if (n_elements(column) eq 0) then column=findgen(n_elements(what_I_plot))
+if (n_elements(mention) eq 0) then mention='' 
+if (mention ne '') then mention='('+mention+')'
+
+;------------------
+; missing values
+;------------------
+w=where(abs(what_I_plot) gt missing_value)
+if (w(0) ne -1) then what_I_plot[w]=!Values.F_NAN
+
+
+;------------------
+; limits
+;------------------
+if (minfield_init*maxfield_init eq 0) then begin 
+	xrange=[min(what_I_plot),max(what_I_plot)]
+        print, xrange
+endif else begin
+	xrange=[minfield_init,maxfield_init]
+        print, xrange
+endelse
+
+if (xrange(0)*xrange(1) eq 0) then begin
+	print, 'nothing to plot ... skipping this plot ...'
+	stop
+endif
+
+  
+;---------------
+; adapt ticks
+;---------------
+;intervalx=round((xrange(1)-xrange(0))/5.)
+;intervaly=round(abs(max(column)-min(column))/5.)
+;intervalx=5.
+;intervaly=5.
+
+;if (n_elements(intervalx) eq 0) then intervalx=round((xrange(1)-xrange(0))/8.)
+;;if (n_elements(intervaly) eq 0) then intervaly=round((abs(max(column)-min(column))/5.))
+
+
+;; ----------------------------
+;; manage the altitude range
+;; ----------------------------
+;if (n_elements(alt) eq 2) then begin
+;	altmin=alt(0)
+;	altmax=alt(1)
+;	w=where((column ge altmin) and (column le altmax))
+;	if (n_elements(intervaly) eq 0) then intervaly=(altmax-altmin)/5
+;	if (w(0) ne -1) then begin
+;		column=column[w]
+;		what_I_plot=what_I_plot[w]
+;		minfield=min(what_I_plot)
+;		maxfield=max(what_I_plot)	
+;	endif
+;endif
+
+
+
+;-------------
+; plot
+;-------------
+plot, $
+	what_I_plot,column, $
+	xrange=xrange, $
+;	yrange=[min(column),max(column)], $
+yrange=alt, $
+	xtickinterval=intervalx, $
+	ytickinterval=intervaly, $	
+	xtitle=xtitle, $
+	ytitle=ytitle,$
+	title=title_user,$
+;/ylog, $
+	subtitle=mention 
+
+;-------------
+; overplot
+;-------------
+if (n_elements(discrete) ne 0) then begin
+if (discrete ne 0) then begin
+	!psym=discrete
+	oplot, $
+		what_I_plot,column
+	!psym=0
+endif
+endif	
+
+if (n_elements(overplot) gt 1) then begin
+	column_overplot=column
+	w=where(abs(overplot) gt missing_value)
+	if (w(0) ne -1) then overplot[w]=!Values.F_NAN
+	if (n_elements(overplot_column) gt 1) then column_overplot=overplot_column
+oplot, $
+	overplot, column_overplot, $
+	linestyle=2
+	if (n_elements(discrete) ne 0) then begin
+		!psym=discrete
+		oplot, $
+			overplot,column_overplot
+		!psym=0
+	endif	
+endif	
+
+
+
+;;--------------
+;; text inside
+;;--------------
+;if (n_elements(mention) ne 0) then begin
+;	alignx=(max(what_I_plot)+min(what_I_plot))/2
+;	aligny=max(column)-intervaly/2
+;	xyouts, alignx, $
+;		aligny, $
+;		mention
+;endif
+
+end
Index: trunk/UTIL/IDLplot/MINIMAL/ps_plotter.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/ps_plotter.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/ps_plotter.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/ps_plotter.pro
Index: trunk/UTIL/IDLplot/MINIMAL/ps_start.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/ps_start.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/ps_start.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/ps_start.pro
Index: trunk/UTIL/IDLplot/MINIMAL/psconfig.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/psconfig.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/psconfig.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/psconfig.pro
Index: trunk/UTIL/IDLplot/MINIMAL/pswindow.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/pswindow.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/pswindow.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/pswindow.pro
Index: trunk/UTIL/IDLplot/MINIMAL/reverse_ct.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/reverse_ct.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/reverse_ct.pro	(revision 1185)
@@ -0,0 +1,7 @@
+PRO Reverse_CT
+
+; This program reverses the colors in the current color table.
+
+TVLCT, r, g, b, /Get
+TVLCT, Reverse(r), Reverse(g), Reverse(b)
+END
Index: trunk/UTIL/IDLplot/MINIMAL/section.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/section.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/section.pro	(revision 1185)
@@ -0,0 +1,452 @@
+pro section, $
+	what_I_plot, $				; 2D field
+	space, $				; horizontal coordinate
+	altitude, $				; altitude coordinate
+	minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+	maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+	minspace=minspace, $			; minimum value of space window (=0: calculate)
+	maxspace=maxspace, $			; maximum value of space window (=0: calculate)
+	overcontour=overcontour, $		; another 2D field to overplot with contour lines (=0: no)
+	overvector_x=overvector_x, $		; wind vector - x component (=0: no)
+	overvector_y=overvector_y, $		; wind vector - y component (=0: no)
+	colors=colors, $			; number of colors/levels (32 is default)
+	title_plot=title_user, $		; title of the plot ('Profile' is default)
+	title_axis=title_axis, $		; title of the [x,y] axis (['Field','Altitude'] is default)
+	ct=pal, $				; color table (33-rainbow is default)
+topo=topography, $
+	format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+
+	
+;--------------------------------------------
+;
+; A general routine to plot H/V section maps
+;
+; USE:	- section, what_I_plot 	
+;	- section, what_I_plot, space, altitude
+;	- ... and see options above
+;
+;--------------------------------------------
+; A. Spiga, September 2007
+;--------------------------------------------
+
+
+;---------------------------
+; a few permanent settings
+;---------------------------
+;
+missing_value=1.e30
+flag_cb='true'
+SPAWN, 'touch param_plot.idl'
+space_save=space
+@param_plot.idl
+;
+;------------------
+
+
+
+;------------------
+; user settings
+;------------------
+if (n_elements(title_user) eq 0) then title='Section' else title=title_user
+if (n_elements(subtitle_user) eq 0) then subtitle_user=''
+if (n_elements(title_axis) ne 2) then begin
+	xtitle='Horizontal coordinate'
+	ytitle='Altitude'
+endif else begin
+	xtitle=title_axis(0)
+	ytitle=title_axis(1)
+endelse	
+
+if (n_elements(space) eq 0) then begin
+	space=findgen(n_elements(what_I_plot(*,0)))
+endif
+if (n_elements(altitude) eq 0) then begin
+	altitude=findgen(n_elements(what_I_plot(0,*)))
+endif
+
+if (n_elements(minfield_init) eq 0) then minfield_init=0.
+if (n_elements(maxfield_init) eq 0) then maxfield_init=0.
+if (n_elements(minspace) eq 0) then minspace=0.
+if (n_elements(maxspace) eq 0) then maxspace=0.
+if (n_elements(minalt) eq 0) then minalt=min(altitude)
+if (n_elements(maxalt) eq 0) then maxalt=max(altitude)
+if (n_elements(colors) eq 0) then colors=32
+if (n_elements(title) eq 0) then title=''
+if (n_elements(pal) eq 0) then pal=33
+if (n_elements(format) eq 0) then format='(F6.2)'
+if (format eq '') then format='(F6.2)'
+
+if ((n_elements(overvector_x) eq 0) or (n_elements(overvector_y) eq 0)) then begin
+	overvector_x=0.
+	overvector_y=0.
+endif
+if (n_elements(overcontour) eq 0) then overcontour=0.
+
+
+;
+; dilatation factor (for winds mainly)
+;
+;if (n_elements(overvector_x)*n_elements(overvector_y) ne 1) then begin
+
+if (n_elements(spacekm) eq 0) then spacekm='false'
+
+if (n_elements(factor) ne 0.) then begin
+	if (factor eq 0.) then stop
+	space=space/factor
+	if (spacekm ne 'false') then xtitle=xtitle+' (km)'
+	xtitle=xtitle+' - divided by '+string(factor,'(I0)')
+endif else begin
+	factor=1.
+endelse	
+;endif
+	
+;------------------
+; limits
+;------------------
+;if (minfield_init*maxfield_init eq 0) then begin   
+if (minfield_init eq maxfield_init) then begin
+	;---different min/max for each layer
+	w=where(abs(what_I_plot) lt missing_value)
+	if (w(0) ne -1) then begin
+		minfield=min(what_I_plot[w])
+		maxfield=max(what_I_plot[w])
+	endif else begin
+		what_I_plot=0.
+		print, 'no valid values in this field' 
+		stop
+	endelse
+endif else begin
+	;---user-defined limits	
+	minfield=minfield_init 
+	maxfield=maxfield_init
+	;;w=where(what_I_plot lt minfield) & if (w(0) ne -1) then what_I_plot[w]=minfield
+	;;w=where(what_I_plot gt maxfield) & if (w(0) ne -1) then what_I_plot[w]=maxfield
+endelse
+
+if ((minfield+maxfield eq 0) and (abs(minfield) ne abs(maxfield))) then begin
+	print, 'nothing to plot ... skipping this plot ...'
+endif else begin
+
+
+
+;-----------------------------------------
+; fix the possible longitude ugliness :)
+; ...get rid of the -180/180 limit
+;-----------------------------------------
+
+if (spacekm ne 'true') then begin
+	w=where(space eq min(space))
+	if (w(0) ne 0) then begin
+		space[0:w(0)-1]=space[0:w(0)-1]-360
+	endif
+endif	
+
+
+;---------------
+; adapt ticks
+;---------------
+if ((minspace eq 0) and (maxspace eq 0)) then begin 
+	minspace=min(space)
+	maxspace=max(space)
+endif
+if (n_elements(intervalx) eq 0) then intervalx=round((maxspace-minspace)/8.)
+if (n_elements(intervaly) eq 0) then intervaly=round((maxalt-minalt)/5.)
+
+
+;------------------
+; plot window
+;------------------
+
+	; to ensure the right limits
+	dumb_what_I_plot=what_I_plot
+	dumb_what_I_plot(*,*)=minfield & print, minfield
+	dumb_what_I_plot(0,0)=maxfield & print, maxfield
+
+
+;xticks=sindgen(21)
+;xticks(*)=' '
+;;xticks(0)='-120'
+;;xticks(2)='-119'
+;;xticks(4)='-118'
+;;xticks(6)='-117'
+;;xticks(8)='-116'
+;;xticks(10)='-115'
+;;xticks(12)='-114'
+;;xticks(14)='-113'
+;;xticks(16)='-112'
+;;xticks(18)='-111'
+;;xticks(20)='-110'
+;xticks(0)='-110'
+;xticks(2)='-109'
+;xticks(4)='-108'
+;xticks(6)='-107'
+;xticks(8)='-106'
+;xticks(10)='-105'
+;xticks(12)='-104'
+;xticks(14)='-103'
+;xticks(16)='-102'
+;xticks(18)='-101'
+;xticks(20)='-100'
+;print, xticks
+
+loadct,0,/silent  
+contour, $
+	/nodata, $ 
+	dumb_what_I_plot, $
+	space, $
+	altitude, $
+	title=title, $
+	xtitle=xtitle, $
+	xrange=[minspace,maxspace], $
+	ytitle=ytitle, $
+	yrange=[minalt,maxalt], $
+	xtickinterval=intervalx, $
+	ytickinterval=intervaly, $
+;	position=[0.15, 0.15, 0.95, 0.75], $ ;;OLD OLD
+	position=[0.15, 0.35, 0.95, 0.95], $
+	subtitle=subtitle_user, $
+;/isotropic, $
+xtickname=xticks, $
+	color=0
+
+;if (n_elements(topography) gt 1) then begin
+;oplot, space, topography/1000.
+;print, max(topography)
+;endif
+
+;------------------
+; plot field
+;------------------
+
+; to avoid spurious blank zones
+nlevels=colors
+levp=minfield+(findgen(nlevels)/float(nlevels-1))*(maxfield-minfield)
+
+loadct,pal,/silent
+;reverse_ct
+contour, what_I_plot, $
+	space, $
+	altitude, $
+;	nlevels=colors, $
+	levels=levp, $
+	/cell_fill, $
+	max_value=maxfield, $
+	min_value=minfield, $	
+	/overplot
+
+
+;------------------
+; colorbar
+;------------------
+
+;if (flag_cb eq 'true') then begin
+;        format_colorbar=format
+;        colorbar, $
+;                position=[0.15, 0.85, 0.95, 0.90], $
+;                divisions=8, $
+;                range=[float(minfield),float(maxfield)], $
+;                format=format_colorbar
+;endif
+;goto, skip_new
+
+
+if (flag_cb eq 'true') then begin
+
+format_colorbar=format
+ndiv=10
+;ndiv=8
+pos=[0.15, 0.17, 0.95, 0.20]
+if (subtitle_user eq '') then pos=[0.15, 0.20, 0.95, 0.23]
+
+;colorbar = Obj_New("COLORBAR",$
+;        Range=[minfield,maxfield],$
+;        Ncolors=255,$
+;        charsize=0.85,$
+;        format=format_colorbar,$
+;        major=ndiv,$
+;        ticklen=-0.15,$
+;	position=pos)
+;colorbar->Draw
+;Obj_Destroy, colorbar
+
+        colorbar, $
+;                /vertical, $
+                position=pos, $
+                range=[float(minfield),float(maxfield)], $
+                divisions=ndiv, $
+                ncolors=255,$
+;               charsize=0.85,$
+                ticklen=-0.15,$
+                format=format_colorbar
+
+endif
+
+if (n_elements(nam2) ne 0) then thedate=STRSPLIT(nam2, /EXTRACT) & thedate=STRSPLIT(thedate(2),"'",/EXTRACT) & thedate=STRSPLIT(thedate(0),"_",/EXTRACT) & thedate=STRSPLIT(thedate(0),"-",/EXTRACT) & xyouts, 0.95, pos(1)-0.08, 'LMD Martian Mesoscale Model - d'+thedate(2)+'/m'+thedate(1), charsize=0.7, alignment=1., /NORMAL
+
+skip_new:
+
+;--------------------
+; overplot contour
+;--------------------
+if (n_elements(overcontour) ne 1) then begin
+
+	w=where(abs(overcontour) lt missing_value)
+	if (w(0) ne -1) then begin
+		min_contour=min(overcontour[w])
+		max_contour=max(overcontour[w])
+	endif
+
+
+; to avoid spurious blank zones
+nlevels=colors/2
+if (n_elements(lev) eq 0) then lev=min_contour+(findgen(nlevels)/float(nlevels-1))*(max_contour-min_contour)
+nlevels=n_elements(lev)
+
+;lev=round(lev)
+;yeah=UNIQ(lev) & lev=lev[yeah] 
+
+
+loadct,0,/silent
+contour, $
+	overcontour, $
+	space,altitude, $
+;	nlevels=colors/2, $
+	levels=lev, $
+	C_LINESTYLE = (lev LT 0.0), $	;; dotted lines if negative
+	max_value=max_contour, $
+	min_value=min_contour, $	
+	c_labels=findgen(nlevels), $
+	color=0, $ ;255, $ ;0, $
+	/noerase, $
+	/overplot
+;        xtickinterval=intervalx, $
+;        ytickinterval=intervaly, $
+;;/isotropic, $
+;;xtickname=xticks, $
+;	xtitle=xtitle, $
+;	xrange=[minspace,maxspace], $
+;	ytitle=ytitle, $
+;	yrange=[minalt,maxalt], $
+;position=[0.15, 0.15, 0.95, 0.75]
+
+
+
+endif
+
+;--------------------
+; overplot wind
+;--------------------
+if (n_elements(overvector_x)*n_elements(overvector_y) ne 1) then begin
+
+	w=where(abs(overvector_x) ge missing_value)  ; u and v have the same missing values ...
+	if (w(0) ne -1) then begin
+		overvector_x[w]=0.
+		overvector_y[w]=0.
+	endif
+		
+
+len=2.0
+if (n_elements(windex) eq 0) then begin
+	ref_mag=round(max(sqrt(overvector_x^2+overvector_y^2))/2)
+	;ref_mag=round(median(sqrt(overvector_x^2+overvector_y^2)))
+ref_mag=15.	;;ce qui est ci dessus deconne !!!
+endif else begin
+        ref_mag=round(windex)
+endelse	
+mytext=STRTRIM(STRING(ref_mag),2)+'ms!E-1!N'
+
+mytext=''
+
+if (n_elements(stride) eq 0) then begin
+stride=3                ; STRIDE: Pick every nth vector for plotting. (1)
+stride=2
+stride=5
+endif else begin
+stride=round(stride)
+endelse
+
+
+ref_pos=[0.10, 0.90] 	
+ref_pos=[0.20, 0.05]
+
+myu=overvector_x
+myv=overvector_y
+
+longs=space
+lats=altitude
+
+wlon=where( (space gt minspace) and (space lt maxspace) )
+wlat=where( (altitude gt minalt) and (altitude lt maxalt) )
+
+if ((wlon(0) eq -1) or (wlat(0) eq -1)) then begin
+        print, 'wrong window settings'
+ 	print, space
+	print, 'lim ',minspace,maxspace
+        print, altitude
+        print, 'lim ',minalt,maxalt
+ 	stop
+endif
+
+myu=dblarr(n_elements(space),n_elements(altitude))
+myv=dblarr(n_elements(space),n_elements(altitude))
+
+myu(*,*)=!Values.F_NAN
+myv(*,*)=!Values.F_NAN
+
+for i=0,n_elements(wlon)-1 do begin
+for j=0,n_elements(wlat)-1 do begin
+        myu(wlon(i),wlat(j))=overvector_x(wlon(i),wlat(j))
+        myv(wlon(i),wlat(j))=overvector_y(wlon(i),wlat(j))
+endfor
+endfor
+
+
+	;; eliminate vector for colorbar clarity ?
+	;nxs=1
+	;nxe=n_elements(longs(*))-2
+	;nys=1
+	;nye=n_elements(lats(*))-2
+	;myu=overvector_x(nxs:nxe,nys:nye)
+	;myv=overvector_y(nxs:nxe,nys:nye)
+	;longs=space(nxs:nxe)
+	;lats=altitude(nys:nye)
+
+
+;;---------------------------
+;;
+;factor=float(mean(overvector_x^2))/float(mean(overvector_y^2))
+;factor=sqrt(factor)
+;factor=factor/2
+;
+;factor=6.
+;factor=12.
+;factor=15.
+;
+;print, 'X/Z correction factor', factor
+;
+;;rapport ordre de grandeur entre mouvements verticaux et horizontaux
+;;
+;;---------------------------
+
+
+myv=myv*factor
+
+
+loadct,0,/silent
+VECTOR, myu, myv, longs, lats, LENGTH=len, REF_MAG=ref_mag,$
+        STRIDE=stride, TYPE=2, HEAD_LEN=0.3, ANGLE=30, $
+;	REF_POS=ref_pos, $
+;	REF_TEXT=mytext,$
+        ALIGN=0.5, COLOR=1, /OVERPLOT;, /NOERASE
+
+endif
+
+
+endelse
+
+space=space_save	;; careful with sequential call to section.pro
+			;; combined with modified space (e.g. with factor)
+			;; -- this save fix the issue
+
+
+end
Index: trunk/UTIL/IDLplot/MINIMAL/tvimage.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/tvimage.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/tvimage.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link fsc/tvimage.pro
Index: trunk/UTIL/IDLplot/MINIMAL/vector.pro
===================================================================
--- trunk/UTIL/IDLplot/MINIMAL/vector.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/MINIMAL/vector.pro	(revision 1185)
@@ -0,0 +1,119 @@
+; vector.pro
+; vector plotting routine 
+; see http://cgam.nerc.ac.uk/graphics/idl.php for more details
+
+; Calling procedure:
+; VECTOR, U, V, X, Y
+; U and V are the vector components as two dimensional arrays.
+; X and Y are the vectors locations as one dimensional arrays.
+;
+; Optional parameters:
+; LENGTH: Length of the vector, default=1 which is 300 pixels.
+; OVERPLOT: Set this to overplot the current graphics plot.
+; STRIDE: Pick every nth vector for plotting.
+; TYPE:   Type of arrow head. 0-4, default=0
+; ANGLE:  Angle of vector head in degrees, default=22.5.
+; HEAD_LEN: Length of the arrow head relative to shaft, default=0.3
+; ALIGN:  Alignment of arrow.  Default is 0.5, range=0.0 to 1.0.
+; REF_MAG: Arrow magnitude.
+; REF_POS: Position for reference vector in normalised coordinates [x,y].
+; REF_TEXT: Text to place to the left of the reference vector.
+; COLOR: Color index of vectors
+		
+PRO VECTOR, u,v,x,y, LENGTH = length,$
+        Color=color, STRIDE=stride, ALIGN=align, $
+	REF_MAG=ref_mag, TYPE=type, ANGLE=angle, HEAD_LEN=head_len,$
+	REF_POS=ref_pos, REF_TEXT=ref_text, OVERPLOT=overplot, _EXTRA=extra
+
+;Check mapping is cylindrical or not set - reject if otherwise.
+IF ((!MAP.PROJECTION NE 0) AND (!MAP.PROJECTION NE 8)) THEN BEGIN
+  PRINT, 'Mapping must be cylindrical or unset to use the vector routine'
+  RETURN
+ENDIF
+
+;Basic checks of the input data
+a=SIZE(u)
+b=SIZE(v)
+c=SIZE(x)
+d=SIZE(y)
+IF ((a[0] NE 2) OR (b[0] NE 2)) THEN BEGIN
+  PRINT, 'u and v must be two dimensional'
+  RETURN
+ENDIF
+IF (TOTAL(ABS(b[0:2]-a[0:2])) NE 0) THEN BEGIN
+  PRINT, 'u and v must have the same size'
+  RETURN
+ENDIF
+IF ((c[0] NE 1) AND (d[0] NE 1)) THEN BEGIN
+  PRINT, 'x and y must be one dimensional'
+  RETURN
+ENDIF
+IF ((c[1]-a[1]) NE 0) THEN BEGIN
+  PRINT, 'u and x have mismatched sizes'
+  RETURN
+ENDIF
+IF ((d[1]-b[2]) NE 0) THEN BEGIN
+  PRINT, 'v and y have mismatched sizes'
+  RETURN
+ENDIF
+
+;Initialise parameters if undefined
+IF (N_ELEMENTS(STRIDE) EQ 0) THEN stride=0
+IF N_ELEMENTS(LENGTH) EQ 0 THEN length=1.0
+IF N_ELEMENTS(COLOR) EQ 0 THEN color = !P.COLOR
+IF (N_ELEMENTS(ANGLE) EQ 0) THEN angle=22.5
+IF (N_ELEMENTS(HEAD_LEN) EQ 0) THEN head_len=0.3
+IF (N_ELEMENTS(TYPE) EQ 0) THEN TYPE=0
+IF (N_ELEMENTS(ALIGN) EQ 0) THEN align=0.5	
+IF (N_ELEMENTS(REF_TEXT) EQ 0) THEN ref_text=' '
+IF (N_ELEMENTS(REF_MAG) EQ 0) THEN BEGIN
+  maxmag=MAX(ABS(SQRT(u^2.+v^2.)))
+ENDIF ELSE BEGIN
+  maxmag=ref_mag
+ENDELSE
+
+;Setup the plot area if undefined
+IF (NOT KEYWORD_SET(overplot)) THEN BEGIN
+  xs=x[0]-(x(1)-x(0))
+  xf=x[N_ELEMENTS(x)-1]+(x(1)-x(0))
+  ys=y[0]-(y(1)-y(0))
+  yf=y[N_ELEMENTS(y)-1]+(y(1)-y(0))  
+  PLOT,[xs,xf],[ys,yf], XSTYLE=1, YSTYLE=1, /NODATA,$
+       COLOR=color, _EXTRA = extra
+ENDIF
+
+;Do stride data reduction if needed	
+IF (stride GT 1) THEN BEGIN
+  mypts=FLTARR(a[1], a[2])
+  mypts[*,*]=0.0	   
+  FOR iy=0,a[2]-1,stride DO BEGIN
+  FOR ix=0,a[1]-1,stride DO BEGIN
+    IF ( ((ix/stride) EQ FIX(ix/stride)) AND $
+         ((iy/stride) EQ FIX(iy/stride)) ) THEN mypts[ix,iy]=1.0
+  ENDFOR
+  ENDFOR
+  pts=WHERE(mypts LT 1.0)
+  u[pts]=0.0
+  v[pts]=0.0
+ENDIF 
+
+;Main vector plotting loop
+FOR ix=0, N_ELEMENTS(x)-1 DO BEGIN
+FOR iy=0, N_ELEMENTS(y)-1 DO BEGIN
+  PLOT_VECTOR, u(ix,iy), v(ix,iy), x(ix), y(iy), type=type, $
+               angle=angle, head_len=head_len,$
+               maxmag=maxmag, align=align, length=length,$
+	       color=color, cstyle=0
+ENDFOR
+ENDFOR
+
+;Plot a reference vector if requested
+IF (N_ELEMENTS(REF_POS) NE 0) THEN BEGIN
+  PLOT_VECTOR, maxmag, 0.0, ref_pos[0], ref_pos[1], type=type, $
+               angle=angle, ref_text=ref_text, head_len=head_len,$
+               maxmag=maxmag, align=align, length=length,$
+	       color=color, cstyle=1
+ENDIF
+
+END
+
Index: trunk/UTIL/IDLplot/RESERVE/atlas/atlas.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas/atlas.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas/atlas.pro	(revision 1185)
@@ -0,0 +1,31 @@
+;;
+;; ATLAS EXOMARS STUDY
+;;
+
+;;;zelevel='1'
+;;;firstextract = 'true'
+;;;zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_W_HGT.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+if (firstextract eq 'true') then SPAWN, "echo 'dumb=999' >> gw.def" else SPAWN, "echo 'dumb=0' >> gw.def"  ;;  juste pour le premier
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;SPAWN, "echo 'dumb=0' >> gw.def ; echo 'intervalx=1.0 ;; grepALL' >> gw.def ; echo 'intervaly=1.0 ;; grepALL' >> gw.def ; echo 'windowx=[-12.,00.] ;; grepMAP' >> gw.def ; echo 'windowy=[-08.,04.] ;; grepMAP' >> gw.def ; echo 'stride=3. ;; grepALL' >> gw.def ; sed s:'atlasMERIDIANI':'atlasMERIDIANI_closer':g gw.def | sed s:'false':'true':g > ye.def ; mv -f ye.def gw.def"  ;; attention dernier pas tres robuste, pour useidlfile
+;@gwc
+;gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;SPAWN, "echo 'intervalx=0.5 ;; grepALL' >> gw.def ; echo 'intervaly=0.5 ;; grepALL' >> gw.def ; echo 'windowx=[-08.,-04.] ;; grepMAP' >> gw.def ; echo 'windowy=[-04.,00.] ;; grepMAP' >> gw.def ; echo 'stride=1. ;; grepALL' >> gw.def ; sed s:'atlasMERIDIANI_closer':'atlasMERIDIANI_ellipse':g gw.def > ye.def ; mv -f ye.def gw.def"
+;@gwc
+;gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+
+
+;;;;
+;;;SPAWN, 'mkdir zefolder/idl_save_'+zelevel+' ; mv zefolder/*.idl zefolder/idl_save_'+zelevel+'/'
+
Index: trunk/UTIL/IDLplot/RESERVE/atlas/atlas.pro_2
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas/atlas.pro_2	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas/atlas.pro_2	(revision 1185)
@@ -0,0 +1,202 @@
+;;
+;; ATLAS EXOMARS STUDY
+;;
+
+;zelevel='1'
+;firstextract = 'true'
+;zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_W_HGT.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+if (firstextract eq 'true') then SPAWN, "echo 'dumb=999' >> gw.def"  ;;  juste pour le premier
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "echo 'dumb=0' >> gw.def ; echo 'intervalx=1.0 ;; grepALL' >> gw.def ; echo 'intervaly=1.0 ;; grepALL' >> gw.def ; echo 'windowx=[-12.,00.] ;; grepMAP' >> gw.def ; echo 'windowy=[-08.,04.] ;; grepMAP' >> gw.def ; echo 'stride=3. ;; grepALL' >> gw.def ; sed s:'atlasMERIDIANI':'atlasMERIDIANI_closer':g gw.def | sed s:'false':'true':g > ye.def ; mv -f ye.def gw.def"  ;; attention dernier pas tres robuste, pour useidlfile
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "echo 'intervalx=0.5 ;; grepALL' >> gw.def ; echo 'intervaly=0.5 ;; grepALL' >> gw.def ; echo 'windowx=[-08.,-04.] ;; grepMAP' >> gw.def ; echo 'windowy=[-04.,00.] ;; grepMAP' >> gw.def ; echo 'stride=1. ;; grepALL' >> gw.def ; sed s:'atlasMERIDIANI_closer':'atlasMERIDIANI_ellipse':g gw.def > ye.def ; mv -f ye.def gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+SPAWN, 'mkdir zefolder/idl_save_'+zelevel+' ; mv zefolder/*.idl zefolder/idl_save_'+zelevel+'/'
+
+
+
+
+stop
+
+
+
+zelevel='2'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_W_HGT.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='2'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='2'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_2 ; mv zefolder/*.idl zefolder/idl_save_2/'
+;
+
+zelevel='4'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_W_HGT.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='4'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='4'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_4 ; mv zefolder/*.idl zefolder/idl_save_4/'
+;
+
+zelevel='6'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_W_HGT.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='6'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='6'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_6 ; mv zefolder/*.idl zefolder/idl_save_6/'
+;
+
+zelevel='7'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_W_HGT.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='7'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='7'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_7 ; mv zefolder/*.idl zefolder/idl_save_7/'
+;
+
+zelevel='8'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_W_HGT.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='8'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='8'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_8 ; mv zefolder/*.idl zefolder/idl_save_8/'
+;
+
+zelevel='18'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_W_HGT.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='18'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='18'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_W_HGT.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_18 ; mv zefolder/*.idl zefolder/idl_save_18/'
+;
+
+exit
Index: trunk/UTIL/IDLplot/RESERVE/atlas/atlas.sh
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas/atlas.sh	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas/atlas.sh	(revision 1185)
@@ -0,0 +1,45 @@
+#! /bin/bash
+
+\rm atlas.log
+echo "print, '****************************yy'
+zelevel='1'
+firstextract = 'true'
+zeatlas='/tmp7/aslmd/atlas-web_map_model_level_U_HGT_UV.def' 
+@atlas.pro
+print, '****************************yy'
+zelevel='2'
+firstextract = 'true'
+zeatlas='/tmp7/aslmd/atlas-web_map_model_level_U_HGT_UV.def' 
+@atlas.pro
+print, '****************************yy'
+zelevel='3'
+firstextract = 'true'
+zeatlas='/tmp7/aslmd/atlas-web_map_model_level_U_HGT_UV.def' 
+@atlas.pro
+print, '****************************yy'
+zelevel='4'
+firstextract = 'true'
+zeatlas='/tmp7/aslmd/atlas-web_map_model_level_U_HGT_UV.def' 
+@atlas.pro
+print, '****************************yy'
+zelevel='5'
+firstextract = 'true'
+zeatlas='/tmp7/aslmd/atlas-web_map_model_level_U_HGT_UV.def' 
+@atlas.pro
+print, '****************************yy'
+zelevel='6'
+firstextract = 'true'
+zeatlas='/tmp7/aslmd/atlas-web_map_model_level_U_HGT_UV.def' 
+@atlas.pro
+exit" | /opt/idl-6.4/idl/bin/idl >> atlas.log 2>& 1 
+
+
+#############################
+#
+# have you modified atlas.pro ?
+# sed s/'U_HGT_UV'/'W_HGT'/g atlas.pro > ye.pro
+#
+#echo atlas.pro should have been modified
+#echo you should have had generated input files
+#
+
Index: trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-closer_web_map_model_level_U_HGT_UV.def
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-closer_web_map_model_level_U_HGT_UV.def	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-closer_web_map_model_level_U_HGT_UV.def	(revision 1185)
@@ -0,0 +1,267 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------------;
+; DATA LOCATION and PLOT DESTINATION  ;
+; default is ./                       ;
+;-------------------------------------;
+datafolder='/home/aslmd/MERIDIANI_EXOMARS'
+plotfolder=datafolder
+;; for web anim and tex report (default is 'plot')
+textitle='MERIDIANI_closer_MLzeremplace'
+texcomments='sol3'
+
+;;; load/save ARWpost-generated text files ? default is no
+;backup_data='yes'
+;already_data='yes'
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'U,V,HGT' "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE FIELDS TO BE EXTRACTED 
+;; ex: tk,HGT,PSFC,U,V,W,T,tk,ICETOT,RAVE,QH2O_ICE,QH2O,PTOT,TSURF
+
+nam2=" start_date = '2024-03-21_00:00:00' " 
+nam3=" end_date   = '2024-03-22_00:00:00' "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE START/END DATE
+
+nam4=" interval_seconds = 3700 "		
+
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
+;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s, 12h: 44400s	
+
+;nam5=" interp_method = 1 "	
+nam5=" interp_method = 0 "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 		
+;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+tabnam=[0.,50.,1.]
+;tabnam=[8., 9., 0.1]
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+;nest='d03'  
+;; ^ ^ ^ ^
+;; SET NEST
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=24		   	;; how many plots ?
+
+
+field1='U'		;; FILLED
+;field2='HGT'		;; CONTOURED
+winds=['U','V']		;; VECTORS
+topo=1
+
+
+;;; VORTICITY
+;field1='HGT' & winds=['U','V'] & topo=1
+
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+;; first is 1
+plot='map' & level=zeremplace	
+;plot='meridional' & nlon=89
+;plot='zonal' & nlat=66
+
+
+;---------;
+; special ;
+;---------;
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & plot='map' & level=7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1 & plot='map' & level=9
+
+useidlfile='true' ;; if you are just changing what is below...
+extract='no' ;; SPECIFIC FOR ATLAS
+
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+;;;
+;;; PLOT TITLES
+;;;
+;subtitle_user='-- LMD Martian Mesoscale Model --'            ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N)'     ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+
+;;;
+;;; COLOR TABLES
+;;;
+;flag_cb='false'                ;; grepALL
+;format='(F4.1)'                  ;; grepALL
+;colors=128                      ;; grepALL
+;pal=39                          ;; grepALL
+;; GOOD COLOR TABLES: 4, 18, 22, 16, 37, 33, 39
+
+;;;
+;;; FILL LIMITS
+;;;
+minfield_init= 00.      ;; grepALL
+maxfield_init= 25.  	;; grepALL
+
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+
+;;;
+;;; WINDS
+;;;
+windex=20.      ;; grepALL
+stride=3.       ;; grepALL
+
+;;;
+;;; CONTOUR
+;;;
+;overcontour=overcontour-mean(overcontour)      ;; grepALL
+lev=-10. + 0.5*findgen(50) ;; grepALL
+
+;;;
+;;; AXIS
+;;;
+;isotropic='false'       ;; grepALL
+intervalx=1.0            ;; grepALL
+intervaly=1.0            ;; grepALL
+
+;;;
+;;; MAP LIMITS 
+;;;
+windowx=[-12.,00.]       ;; grepMAP
+windowy=[-08.,04.]       ;; grepMAP
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-4.		;; grepSEC
+;maxalt=16.		;; grepSEC
+;minspace=-30.   	;; grepSEC
+;maxspace=0.   		;; grepSEC
+
+;;
+;; METRIC UNITS FOR VERTICAL SECTION
+;;
+;factor=20.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; POUBELLE
+
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+;extract='yes'   ;;   EXECUTE ARWPOST.EXE
+                ;;   WITH THE FOLLOWING PARAMETERS :
+
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='U' & winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='tk' & topo=1
+;field1='tk' & winds=['U','V'] & topo=1
+;field1='T' & field2='T'
+;field1='T' & winds=['U','V'] 
+;field1='HGT' & winds=['HGT','HGT'] 
+
Index: trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-closer_web_map_model_level_W_HGT.def
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-closer_web_map_model_level_W_HGT.def	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-closer_web_map_model_level_W_HGT.def	(revision 1185)
@@ -0,0 +1,267 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------------;
+; DATA LOCATION and PLOT DESTINATION  ;
+; default is ./                       ;
+;-------------------------------------;
+datafolder='/home/aslmd/MERIDIANI_EXOMARS'
+plotfolder=datafolder
+;; for web anim and tex report (default is 'plot')
+textitle='MERIDIANI_closer_MLzeremplace'
+texcomments='sol3'
+
+;;; load/save ARWpost-generated text files ? default is no
+;backup_data='yes'
+;already_data='yes'
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'W,HGT' "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE FIELDS TO BE EXTRACTED 
+;; ex: tk,HGT,PSFC,U,V,W,T,tk,ICETOT,RAVE,QH2O_ICE,QH2O,PTOT,TSURF
+
+nam2=" start_date = '2024-03-21_00:00:00' " 
+nam3=" end_date   = '2024-03-22_00:00:00' "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE START/END DATE
+
+nam4=" interval_seconds = 3700 "		
+
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
+;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s, 12h: 44400s	
+
+;nam5=" interp_method = 1 "	
+nam5=" interp_method = 0 "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 		
+;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+tabnam=[0.,50.,1.]
+;tabnam=[8., 9., 0.1]
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+;nest='d03'  
+;; ^ ^ ^ ^
+;; SET NEST
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=24		   	;; how many plots ?
+
+
+field1='W'		;; FILLED
+;field2='HGT'		;; CONTOURED
+;winds=['U','V']	;; VECTORS
+topo=1
+
+
+;;; VORTICITY
+;field1='HGT' & winds=['U','V'] & topo=1
+
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+;; first is 1
+plot='map' & level=zeremplace	
+;plot='meridional' & nlon=89
+;plot='zonal' & nlat=66
+
+
+;---------;
+; special ;
+;---------;
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & plot='map' & level=7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1 & plot='map' & level=9
+
+useidlfile='true' ;; if you are just changing what is below...
+extract='no' ;; SPECIFIC FOR ATLAS
+
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+;;;
+;;; PLOT TITLES
+;;;
+;subtitle_user='-- LMD Martian Mesoscale Model --'            ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N)'     ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+
+;;;
+;;; COLOR TABLES
+;;;
+;flag_cb='false'                ;; grepALL
+;format='(F4.1)'                  ;; grepALL
+;colors=128                      ;; grepALL
+;pal=39                          ;; grepALL
+;; GOOD COLOR TABLES: 4, 18, 22, 16, 37, 33, 39
+
+;;;
+;;; FILL LIMITS
+;;;
+minfield_init= -05.      ;; grepALL
+maxfield_init= 05.  	;; grepALL
+
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+
+;;;
+;;; WINDS
+;;;
+windex=20.      ;; grepALL
+stride=3.       ;; grepALL
+
+;;;
+;;; CONTOUR
+;;;
+;overcontour=overcontour-mean(overcontour)      ;; grepALL
+lev=-10. + 0.5*findgen(50) ;; grepALL
+
+;;;
+;;; AXIS
+;;;
+;isotropic='false'       ;; grepALL
+intervalx=1.0            ;; grepALL
+intervaly=1.0            ;; grepALL
+
+;;;
+;;; MAP LIMITS 
+;;;
+windowx=[-12.,00.]       ;; grepMAP
+windowy=[-08.,04.]       ;; grepMAP
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-4.		;; grepSEC
+;maxalt=16.		;; grepSEC
+;minspace=-30.   	;; grepSEC
+;maxspace=0.   		;; grepSEC
+
+;;
+;; METRIC UNITS FOR VERTICAL SECTION
+;;
+;factor=20.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; POUBELLE
+
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+;extract='yes'   ;;   EXECUTE ARWPOST.EXE
+                ;;   WITH THE FOLLOWING PARAMETERS :
+
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='U' & winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='tk' & topo=1
+;field1='tk' & winds=['U','V'] & topo=1
+;field1='T' & field2='T'
+;field1='T' & winds=['U','V'] 
+;field1='HGT' & winds=['HGT','HGT'] 
+
Index: trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-ellipse_web_map_model_level_U_HGT_UV.def
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-ellipse_web_map_model_level_U_HGT_UV.def	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-ellipse_web_map_model_level_U_HGT_UV.def	(revision 1185)
@@ -0,0 +1,267 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------------;
+; DATA LOCATION and PLOT DESTINATION  ;
+; default is ./                       ;
+;-------------------------------------;
+datafolder='/home/aslmd/MERIDIANI_EXOMARS'
+plotfolder=datafolder
+;; for web anim and tex report (default is 'plot')
+textitle='MERIDIANI_ellipse_MLzeremplace'
+texcomments='sol3'
+
+;;; load/save ARWpost-generated text files ? default is no
+;backup_data='yes'
+;already_data='yes'
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'U,V,HGT' "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE FIELDS TO BE EXTRACTED 
+;; ex: tk,HGT,PSFC,U,V,W,T,tk,ICETOT,RAVE,QH2O_ICE,QH2O,PTOT,TSURF
+
+nam2=" start_date = '2024-03-21_00:00:00' " 
+nam3=" end_date   = '2024-03-22_00:00:00' "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE START/END DATE
+
+nam4=" interval_seconds = 3700 "		
+
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
+;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s, 12h: 44400s	
+
+;nam5=" interp_method = 1 "	
+nam5=" interp_method = 0 "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 		
+;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+tabnam=[0.,50.,1.]
+;tabnam=[8., 9., 0.1]
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+;nest='d03'  
+;; ^ ^ ^ ^
+;; SET NEST
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=24		   	;; how many plots ?
+
+
+field1='U'		;; FILLED
+;field2='HGT'		;; CONTOURED
+winds=['U','V']		;; VECTORS
+topo=1
+
+
+;;; VORTICITY
+;field1='HGT' & winds=['U','V'] & topo=1
+
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+;; first is 1
+plot='map' & level=zeremplace	
+;plot='meridional' & nlon=89
+;plot='zonal' & nlat=66
+
+
+;---------;
+; special ;
+;---------;
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & plot='map' & level=7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1 & plot='map' & level=9
+
+useidlfile='true' ;; if you are just changing what is below...
+extract='no' ;; SPECIFIC FOR ATLAS
+
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+;;;
+;;; PLOT TITLES
+;;;
+;subtitle_user='-- LMD Martian Mesoscale Model --'            ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N)'     ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+
+;;;
+;;; COLOR TABLES
+;;;
+;flag_cb='false'                ;; grepALL
+;format='(F4.1)'                  ;; grepALL
+;colors=128                      ;; grepALL
+;pal=39                          ;; grepALL
+;; GOOD COLOR TABLES: 4, 18, 22, 16, 37, 33, 39
+
+;;;
+;;; FILL LIMITS
+;;;
+minfield_init= 00.      ;; grepALL
+maxfield_init= 25.  	;; grepALL
+
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+
+;;;
+;;; WINDS
+;;;
+windex=20.      ;; grepALL
+stride=1.       ;; grepALL
+
+;;;
+;;; CONTOUR
+;;;
+;overcontour=overcontour-mean(overcontour)      ;; grepALL
+lev=-10. + 0.5*findgen(50) ;; grepALL
+
+;;;
+;;; AXIS
+;;;
+;isotropic='false'       ;; grepALL
+intervalx=0.5            ;; grepALL
+intervaly=0.5            ;; grepALL
+
+;;;
+;;; MAP LIMITS 
+;;;
+windowx=[-08.,-04.]       ;; grepMAP
+windowy=[-04.,00.]       ;; grepMAP
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-4.		;; grepSEC
+;maxalt=16.		;; grepSEC
+;minspace=-30.   	;; grepSEC
+;maxspace=0.   		;; grepSEC
+
+;;
+;; METRIC UNITS FOR VERTICAL SECTION
+;;
+;factor=20.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; POUBELLE
+
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+;extract='yes'   ;;   EXECUTE ARWPOST.EXE
+                ;;   WITH THE FOLLOWING PARAMETERS :
+
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='U' & winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='tk' & topo=1
+;field1='tk' & winds=['U','V'] & topo=1
+;field1='T' & field2='T'
+;field1='T' & winds=['U','V'] 
+;field1='HGT' & winds=['HGT','HGT'] 
+
Index: trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-ellipse_web_map_model_level_W_HGT.def
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-ellipse_web_map_model_level_W_HGT.def	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-ellipse_web_map_model_level_W_HGT.def	(revision 1185)
@@ -0,0 +1,267 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------------;
+; DATA LOCATION and PLOT DESTINATION  ;
+; default is ./                       ;
+;-------------------------------------;
+datafolder='/home/aslmd/MERIDIANI_EXOMARS'
+plotfolder=datafolder
+;; for web anim and tex report (default is 'plot')
+textitle='MERIDIANI_ellipse_MLzeremplace'
+texcomments='sol3'
+
+;;; load/save ARWpost-generated text files ? default is no
+;backup_data='yes'
+;already_data='yes'
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'W,HGT' "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE FIELDS TO BE EXTRACTED 
+;; ex: tk,HGT,PSFC,U,V,W,T,tk,ICETOT,RAVE,QH2O_ICE,QH2O,PTOT,TSURF
+
+nam2=" start_date = '2024-03-21_00:00:00' " 
+nam3=" end_date   = '2024-03-22_00:00:00' "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE START/END DATE
+
+nam4=" interval_seconds = 3700 "		
+
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
+;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s, 12h: 44400s	
+
+;nam5=" interp_method = 1 "	
+nam5=" interp_method = 0 "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 		
+;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+tabnam=[0.,50.,1.]
+;tabnam=[8., 9., 0.1]
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+;nest='d03'  
+;; ^ ^ ^ ^
+;; SET NEST
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=24		   	;; how many plots ?
+
+
+field1='W'		;; FILLED
+;field2='HGT'		;; CONTOURED
+;winds=['U','V']	;; VECTORS
+topo=1
+
+
+;;; VORTICITY
+;field1='HGT' & winds=['U','V'] & topo=1
+
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+;; first is 1
+plot='map' & level=zeremplace	
+;plot='meridional' & nlon=89
+;plot='zonal' & nlat=66
+
+
+;---------;
+; special ;
+;---------;
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & plot='map' & level=7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1 & plot='map' & level=9
+
+useidlfile='true' ;; if you are just changing what is below...
+extract='no' ;; SPECIFIC FOR ATLAS
+
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+;;;
+;;; PLOT TITLES
+;;;
+;subtitle_user='-- LMD Martian Mesoscale Model --'            ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N)'     ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+
+;;;
+;;; COLOR TABLES
+;;;
+;flag_cb='false'                ;; grepALL
+;format='(F4.1)'                  ;; grepALL
+;colors=128                      ;; grepALL
+;pal=39                          ;; grepALL
+;; GOOD COLOR TABLES: 4, 18, 22, 16, 37, 33, 39
+
+;;;
+;;; FILL LIMITS
+;;;
+minfield_init= -05.      ;; grepALL
+maxfield_init= 05.  	;; grepALL
+
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+
+;;;
+;;; WINDS
+;;;
+windex=20.      ;; grepALL
+stride=1.       ;; grepALL
+
+;;;
+;;; CONTOUR
+;;;
+;overcontour=overcontour-mean(overcontour)      ;; grepALL
+lev=-10. + 0.5*findgen(50) ;; grepALL
+
+;;;
+;;; AXIS
+;;;
+;isotropic='false'       ;; grepALL
+intervalx=0.5            ;; grepALL
+intervaly=0.5            ;; grepALL
+
+;;;
+;;; MAP LIMITS 
+;;;
+windowx=[-08.,-04.]       ;; grepMAP
+windowy=[-04.,00.]       ;; grepMAP
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-4.		;; grepSEC
+;maxalt=16.		;; grepSEC
+;minspace=-30.   	;; grepSEC
+;maxspace=0.   		;; grepSEC
+
+;;
+;; METRIC UNITS FOR VERTICAL SECTION
+;;
+;factor=20.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; POUBELLE
+
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+;extract='yes'   ;;   EXECUTE ARWPOST.EXE
+                ;;   WITH THE FOLLOWING PARAMETERS :
+
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='U' & winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='tk' & topo=1
+;field1='tk' & winds=['U','V'] & topo=1
+;field1='T' & field2='T'
+;field1='T' & winds=['U','V'] 
+;field1='HGT' & winds=['HGT','HGT'] 
+
Index: trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-web_map_model_level_U_HGT_UV.def
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-web_map_model_level_U_HGT_UV.def	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-web_map_model_level_U_HGT_UV.def	(revision 1185)
@@ -0,0 +1,267 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------------;
+; DATA LOCATION and PLOT DESTINATION  ;
+; default is ./                       ;
+;-------------------------------------;
+datafolder='/home/aslmd/MERIDIANI_EXOMARS'
+plotfolder=datafolder
+;; for web anim and tex report (default is 'plot')
+textitle='MERIDIANI_MLzeremplace'
+texcomments='sol3'
+
+;;; load/save ARWpost-generated text files ? default is no
+;backup_data='yes'
+;already_data='yes'
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'U,V,HGT' "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE FIELDS TO BE EXTRACTED 
+;; ex: tk,HGT,PSFC,U,V,W,T,tk,ICETOT,RAVE,QH2O_ICE,QH2O,PTOT,TSURF
+
+nam2=" start_date = '2024-03-21_00:00:00' " 
+nam3=" end_date   = '2024-03-22_00:00:00' "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE START/END DATE
+
+nam4=" interval_seconds = 3700 "		
+
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
+;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s, 12h: 44400s	
+
+;nam5=" interp_method = 1 "	
+nam5=" interp_method = 0 "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 		
+;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+tabnam=[0.,50.,1.]
+;tabnam=[8., 9., 0.1]
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+;nest='d03'  
+;; ^ ^ ^ ^
+;; SET NEST
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=24		   	;; how many plots ?
+
+
+field1='U'		;; FILLED
+;field2='HGT'		;; CONTOURED
+winds=['U','V']		;; VECTORS
+topo=1
+
+
+;;; VORTICITY
+;field1='HGT' & winds=['U','V'] & topo=1
+
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+;; first is 1
+plot='map' & level=zeremplace	
+;plot='meridional' & nlon=89
+;plot='zonal' & nlat=66
+
+
+;---------;
+; special ;
+;---------;
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & plot='map' & level=7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1 & plot='map' & level=9
+
+useidlfile='false' ;; if you are just changing what is below...
+extract='no' ;; SPECIFIC FOR ATLAS
+
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+;;;
+;;; PLOT TITLES
+;;;
+;subtitle_user='-- LMD Martian Mesoscale Model --'            ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N)'     ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+
+;;;
+;;; COLOR TABLES
+;;;
+;flag_cb='false'                ;; grepALL
+;format='(F4.1)'                  ;; grepALL
+;colors=128                      ;; grepALL
+;pal=39                          ;; grepALL
+;; GOOD COLOR TABLES: 4, 18, 22, 16, 37, 33, 39
+
+;;;
+;;; FILL LIMITS
+;;;
+minfield_init= 00.      ;; grepALL
+maxfield_init= 25.  	;; grepALL
+
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+
+;;;
+;;; WINDS
+;;;
+windex=20.	;; grepALL
+stride=5.	;; grepALL
+
+;;;
+;;; CONTOUR
+;;;
+;overcontour=overcontour-mean(overcontour)	;; grepALL
+lev=-10. + 0.5*findgen(50) ;; grepALL
+
+;;;
+;;; AXIS
+;;;
+;isotropic='false'       ;; grepALL
+intervalx=2.0            ;; grepALL
+intervaly=2.0             ;; grepALL
+
+;;;
+;;; MAP LIMITS 
+;;;
+windowx=[-20.,08.]       ;; grepMAP
+windowy=[-16.,12.]       ;; grepMAP
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-4.		;; grepSEC
+;maxalt=16.		;; grepSEC
+;minspace=-30.   	;; grepSEC
+;maxspace=0.   		;; grepSEC
+
+;;
+;; METRIC UNITS FOR VERTICAL SECTION
+;;
+;factor=20.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; POUBELLE
+
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+;extract='yes'   ;;   EXECUTE ARWPOST.EXE
+                ;;   WITH THE FOLLOWING PARAMETERS :
+
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='U' & winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='tk' & topo=1
+;field1='tk' & winds=['U','V'] & topo=1
+;field1='T' & field2='T'
+;field1='T' & winds=['U','V'] 
+;field1='HGT' & winds=['HGT','HGT'] 
+
Index: trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-web_map_model_level_W_HGT.def
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-web_map_model_level_W_HGT.def	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas2/atlas-web_map_model_level_W_HGT.def	(revision 1185)
@@ -0,0 +1,267 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------------;
+; DATA LOCATION and PLOT DESTINATION  ;
+; default is ./                       ;
+;-------------------------------------;
+datafolder='/home/aslmd/MERIDIANI_EXOMARS'
+plotfolder=datafolder
+;; for web anim and tex report (default is 'plot')
+textitle='atlasMERIDIANI_MLzeremplace'
+texcomments='sol3'
+
+;;; load/save ARWpost-generated text files ? default is no
+;backup_data='yes'
+;already_data='yes'
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'W,HGT' "		
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE FIELDS TO BE EXTRACTED 
+;; ex: tk,HGT,PSFC,U,V,W,T,tk,ICETOT,RAVE,QH2O_ICE,QH2O,PTOT,TSURF
+
+nam2=" start_date = '2024-03-21_00:00:00' " 
+nam3=" end_date   = '2024-03-21_00:00:00' "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; CHANGE HERE START/END DATE
+
+nam4=" interval_seconds = 3700 "		
+
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
+;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s, 12h: 44400s	
+
+;nam5=" interp_method = 1 "	
+nam5=" interp_method = 0 "
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 		
+;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+tabnam=[0.,50.,1.]
+;tabnam=[8., 9., 0.1]
+;; ^ ^ ^ ^ ^ ^ ^ ^ ^
+;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+;nest='d03'  
+;; ^ ^ ^ ^
+;; SET NEST
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=24		   	;; how many plots ?
+
+
+field1='W'		;; FILLED
+;field2='HGT'		;; CONTOURED
+;winds=['U','V']		;; VECTORS
+topo=1
+
+
+;;; VORTICITY
+;field1='HGT' & winds=['U','V'] & topo=1
+
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+;; first is 1
+plot='map' & level=zeremplace	
+;plot='meridional' & nlon=89
+;plot='zonal' & nlat=66
+
+
+;---------;
+; special ;
+;---------;
+;;; SEA-LEVEL PRESSURE
+;field1='PSFC' & winds=['tk','HGT'] & topo=1 & plot='map' & level=7
+;;; HORIZONTAL WIND VELOCITY
+;field1='U' & winds=['U','V'] & topo=1 & plot='map' & level=9
+
+useidlfile='false' ;; if you are just changing what is below...
+;extract='no' ;; SPECIFIC FOR ATLAS
+;extract='yes'
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+;;;
+;;; PLOT TITLES
+;;;
+;subtitle_user='-- LMD Martian Mesoscale Model --'            ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N)'     ;; grepALL
+;title_axis=['x coord (km)','y coord (km)']     ;; grepALL
+
+;;;
+;;; COLOR TABLES
+;;;
+;flag_cb='false'                ;; grepALL
+;format='(F4.1)'                  ;; grepALL
+;colors=128                      ;; grepALL
+;pal=39                          ;; grepALL
+;; GOOD COLOR TABLES: 4, 18, 22, 16, 37, 33, 39
+
+;;;
+;;; FILL LIMITS
+;;;
+minfield_init= -05.      ;; grepALL
+maxfield_init=  05.  	;; grepALL
+
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max ;; grepALL
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min ;; grepALL
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value ;; grepALL
+
+;;;
+;;; WINDS
+;;;
+windex=20.	;; grepALL
+stride=5.	;; grepALL
+
+;;;
+;;; CONTOUR
+;;;
+;overcontour=overcontour-mean(overcontour)	;; grepALL
+lev=-10. + 0.5*findgen(50) ;; grepALL
+
+;;;
+;;; AXIS
+;;;
+;isotropic='false'       ;; grepALL
+intervalx=2.0            ;; grepALL
+intervaly=2.0             ;; grepALL
+
+;;;
+;;; MAP LIMITS 
+;;;
+windowx=[-20.,08.]       ;; grepMAP
+windowy=[-16.,12.]       ;; grepMAP
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-4.		;; grepSEC
+;maxalt=16.		;; grepSEC
+;minspace=-30.   	;; grepSEC
+;maxspace=0.   		;; grepSEC
+
+;;
+;; METRIC UNITS FOR VERTICAL SECTION
+;;
+;factor=20.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;; POUBELLE
+
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+;extract='yes'   ;;   EXECUTE ARWPOST.EXE
+                ;;   WITH THE FOLLOWING PARAMETERS :
+
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='U' & winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='tk' & topo=1
+;field1='tk' & winds=['U','V'] & topo=1
+;field1='T' & field2='T'
+;field1='T' & winds=['U','V'] 
+;field1='HGT' & winds=['HGT','HGT'] 
+
Index: trunk/UTIL/IDLplot/RESERVE/atlas2/atlas_U_HGT_UV.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/atlas2/atlas_U_HGT_UV.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/atlas2/atlas_U_HGT_UV.pro	(revision 1185)
@@ -0,0 +1,173 @@
+;;
+;; ATLAS EXOMARS STUDY
+;;
+
+zelevel='2'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_U_HGT_UV.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='2'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='2'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_2 ; mv zefolder/*.idl zefolder/idl_save_2/'
+;
+
+zelevel='4'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_U_HGT_UV.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='4'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='4'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_4 ; mv zefolder/*.idl zefolder/idl_save_4/'
+;
+
+zelevel='6'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_U_HGT_UV.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='6'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='6'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_6 ; mv zefolder/*.idl zefolder/idl_save_6/'
+;
+
+zelevel='7'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_U_HGT_UV.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='7'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='7'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_7 ; mv zefolder/*.idl zefolder/idl_save_7/'
+;
+
+zelevel='8'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_U_HGT_UV.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='8'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='8'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_8 ; mv zefolder/*.idl zefolder/idl_save_8/'
+;
+
+zelevel='18'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-web_map_model_level_U_HGT_UV.def'   ;; event. modifier si on ne veut pas recalculer les .idl
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='18'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-closer_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+zelevel='18'
+zeatlas='/home/aslmd/MERIDIANI_EXOMARS/atlas-ellipse_web_map_model_level_U_HGT_UV.def'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+SPAWN, "ln -sf "+zeatlas+" atlas.def ; \rm gw.def ; sed s:'zeremplace':'"+zelevel+"':g atlas.def > gw.def"
+@gwc
+gw, 'w'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+SPAWN, 'mkdir zefolder/idl_save_18 ; mv zefolder/*.idl zefolder/idl_save_18/'
+;
+
+exit
Index: trunk/UTIL/IDLplot/RESERVE/base
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/base	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/base	(revision 1185)
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+echo 'type the title'
+read title
+echo 'type the caption'
+read caption
+
+quality=100
+
+
+rm -rf basefig
+mkdir basefig
+cd basefig
+cp ../base.eps fig1.eps
+cp ../base.eps fig2.eps
+cp ../base.eps fig3.eps
+cp ../base.eps fig4.eps
+cp ../base.eps fig5.eps
+cp ../base.eps fig6.eps
+cd ..
+
+convert -density ${quality}x${quality} -crop 0x0 $1 basefig/fig1.eps
+echo 'converted 1'
+
+convert -density ${quality}x${quality} -crop 0x0 $2 basefig/fig2.eps
+echo 'converted 2'
+
+convert -density ${quality}x${quality} -crop 0x0 $3 basefig/fig3.eps
+echo 'converted 3'
+
+convert -density ${quality}x${quality} -crop 0x0 $4 basefig/fig4.eps
+echo 'converted 4'
+
+convert -density ${quality}x${quality} -crop 0x0 $5 basefig/fig5.eps
+echo 'converted 5'
+
+convert -density ${quality}x${quality} -crop 0x0 $6 basefig/fig6.eps
+echo 'converted 6'
+
+echo $7
+
+sed s/thetitle/${title}/g basefig.tex | sed s/thecaption/${caption}/g > basefig_temp.tex 
+sed s/basefig/basefig_temp/g base.tex > base_temp.tex
+latex base_temp.tex > base_temp.tmp 
+
+mv -f base_temp.dvi base.dvi
+
+\rm base_temp*
+\rm basefig_temp.tex
+
+dvips -o base.ps base.dvi 
+
+xdvi base.dvi 
+\rm base.dvi
Index: trunk/UTIL/IDLplot/RESERVE/base.tex
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/base.tex	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/base.tex	(revision 1185)
@@ -0,0 +1,55 @@
+\documentclass[10pt,twoside,a4paper]{report}
+                                                                            
+% Packages
+\usepackage[french]{babel}   % pour dire que le texte est en français
+\usepackage{a4}              % pour la taille
+\usepackage[T1]{fontenc}     % pour les font postscript
+\usepackage{epsfig}          % pour gérer les images
+\usepackage{psfig}
+\usepackage{graphicx}
+\usepackage{amsmath, amsthm} % très bon mode mathématique
+\usepackage{amsfonts,amssymb}% permet la definition des ensembles
+\usepackage{float}           % pour le placement des figure
+% \usepackage{pslatex}       % évite un affichage laid à l'écran
+% Style bibliographique
+\bibliographystyle{plain}
+% Definitions de nouvelles commandes
+%\newcommand{\N}{\mathbb{N}} % les entiers naturels
+                                                                                                         
+% Titre
+\title{Titre}
+                                                                                
+\author{Aymeric Spiga\footnote{Contact : aymeric.spiga@m4x.org}\\
+\\
+\\
+Resultats\\
+   \\
+    \\
+\\
+Sous la direction de François Forget\\
+\\
+Laboratoire de M\'et\'eorologie Dynamique du CNRS\\
+\\
+\\}
+                                                                                
+                                                                                
+%============================= Corps =================================
+
+\begin{document}
+                                                                                
+%\maketitle            % écrit le titre
+%\thispagestyle{empty}
+                                                                                
+                                                                                
+%\tableofcontents      % écrit la table des matières
+%\thispagestyle{empty}
+
+\input{basefig.tex}
+
+% Bibliographie
+%\section*{Annexe 2}
+%\input{biba.tex}
+
+
+\end{document}
+
Index: trunk/UTIL/IDLplot/RESERVE/basefig.tex
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/basefig.tex	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/basefig.tex	(revision 1185)
@@ -0,0 +1,28 @@
+\section*{
+thetitle
+}
+                                                         
+\begin{figure}[!h]
+\centerline{
+\epsfig {file=basefig/fig1.eps,width=9cm}
+\hfill
+\epsfig {file=basefig/fig2.eps,width=9cm}
+}
+\centerline{ 
+\epsfig {file=basefig/fig3.eps,width=9cm}   
+\hfill
+\epsfig {file=basefig/fig4.eps,width=9cm}
+}
+\centerline{
+\epsfig {file=basefig/fig5.eps,width=9cm}
+\hfill
+\epsfig {file=basefig/fig6.eps,width=9cm}
+}
+\caption{
+thecaption
+}
+\end{figure}
+                                                                                
+                                                         
+                                                         
+
Index: trunk/UTIL/IDLplot/RESERVE/bigconvert100
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/bigconvert100	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/bigconvert100	(revision 1185)
@@ -0,0 +1,9 @@
+#!/bin/csh
+# f. forget
+foreach i ( $* )
+    echo $1
+    set name = `echo $1 | sed -e 's/\./ /' `
+    echo $name[1].png
+   convert -antialias -density 100x100 -crop 0x0 $1 $name[1].png
+   shift
+end
Index: trunk/UTIL/IDLplot/RESERVE/bigconvert200
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/bigconvert200	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/bigconvert200	(revision 1185)
@@ -0,0 +1,10 @@
+#!/bin/csh
+# f. forget
+foreach i ( $* )
+    echo $1
+    set name = `echo $1 | sed -e 's/\./ /' `
+    echo $name[1].png
+#   convert -antialias -density 200x200 -crop 0x0 $1 $name[1].png
+gs -sDEVICE=png16m -dTextAlphaBits=4 -sOutputFile=$name[1].png -dNOPAUSE -dBATCH -dEPSCrop -r300x300 $1
+   shift
+end
Index: trunk/UTIL/IDLplot/RESERVE/body.html
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/body.html	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/body.html	(revision 1185)
@@ -0,0 +1,365 @@
+//**************************************************************************
+ 
+//=== THE CODE STARTS HERE - no need to change anything below ===
+ 
+//=== global variables ====
+theImages = new Array();      //holds the images
+imageNum = new Array();       //keeps track of which images to omit from loop
+normal_delay = 1000;
+delay = normal_delay;         //delay between frames in 1/100 seconds
+delay_step = 50;
+delay_max = 6000;
+delay_min = 50;
+dwell_multipler = 3;
+dwell_step = 1;
+end_dwell_multipler   = dwell_multipler;
+start_dwell_multipler = dwell_multipler;
+current_image = first_image;     //number of the current image
+timeID = null;
+status = 0;                      // 0-stopped, 1-playing
+play_mode = 0;                   // 0-normal, 1-loop, 2-sweep
+size_valid = 0;
+ 
+//===> Make sure the first image number is not bigger than the last image number
+if (first_image > last_image)
+{
+   var help = last_image;
+   last_image = first_image;
+   first_image = help;
+}
+ 
+//===> Preload the first image (while page is downloading)
+   theImages[0] = new Image();
+   theImages[0].src = modImages[0];
+   imageNum[0] = true;
+ 
+//==============================================================
+//== All previous statements are performed as the page loads. ==
+//== The following functions are also defined at this time.   ==
+//==============================================================
+ 
+//===> Stop the animation
+function stop()
+{
+   //== cancel animation (timeID holds the expression which calls the fwd or bkwd function) ==
+   if (status == 1)
+      clearTimeout (timeID);
+   status = 0;
+}
+ 
+ 
+//===> Display animation in fwd direction in either loop or sweep mode
+function animate_fwd()
+{
+   current_image++;                      //increment image number
+ 
+   //== check if current image has exceeded loop bound ==
+   if (current_image > last_image) {
+      if (play_mode == 1) {              //fwd loop mode - skip to first image
+         current_image = first_image;
+      }
+      if (play_mode == 2) {              //sweep mode - change directions (go bkwd)
+         current_image = last_image;
+         animate_rev();
+         return;
+      }
+   }
+ 
+   //== check to ensure that current image has not been deselected from the loop ==
+   //== if it has, then find the next image that hasn't been ==
+   while (imageNum[current_image-first_image] == false) {
+         current_image++;
+         if (current_image > last_image) {
+            if (play_mode == 1)
+               current_image = first_image;
+            if (play_mode == 2) {
+               current_image = last_image;
+               animate_rev();
+               return;
+            }
+         }
+   }
+ 
+   document.animation.src = theImages[current_image-first_image].src;   //display image onto screen
+   document.control_form.frame_nr.value = current_image;                //display image number
+
+   delay_time = delay;
+   if ( current_image == first_image) delay_time = start_dwell_multipler*delay;
+   if (current_image == last_image)   delay_time = end_dwell_multipler*delay;
+ 
+   //== call "animate_fwd()" again after a set time (delay_time) has elapsed ==
+   timeID = setTimeout("animate_fwd()", delay_time);
+}
+ 
+ 
+//===> Display animation in reverse direction
+function animate_rev()
+{
+   current_image--;                      //decrement image number
+ 
+   //== check if image number is before lower loop bound ==
+   if (current_image < first_image) {
+     if (play_mode == 1) {               //rev loop mode - skip to last image
+        current_image = last_image;
+     }
+     if (play_mode == 2) {
+        current_image = first_image;     //sweep mode - change directions (go fwd)
+        animate_fwd();
+        return;
+     }
+   }
+ 
+   //== check to ensure that current image has not been deselected from the loop ==
+   //== if it has, then find the next image that hasn't been ==
+   while (imageNum[current_image-first_image] == false) {
+         current_image--;
+         if (current_image < first_image) {
+            if (play_mode == 1)
+               current_image = last_image;
+            if (play_mode == 2) {
+               current_image = first_image;
+               animate_fwd();
+               return;
+            }
+         }
+   }
+ 
+   document.animation.src = theImages[current_image-first_image].src;   //display image onto screen
+   document.control_form.frame_nr.value = current_image;                //display image number
+
+   delay_time = delay;
+   if ( current_image == first_image) delay_time = start_dwell_multipler*delay;
+   if (current_image == last_image)   delay_time = end_dwell_multipler*delay;
+ 
+   //== call "animate_rev()" again after a set amount of time (delay_time) has elapsed ==
+   timeID = setTimeout("animate_rev()", delay_time);
+}
+ 
+ 
+//===> Changes playing speed by adding to or substracting from the delay between frames
+function change_speed(dv)
+{
+   delay+=dv;
+   //== check to ensure max and min delay constraints have not been crossed ==
+   if(delay > delay_max) delay = delay_max;
+   if(delay < delay_min) delay = delay_min;
+}
+ 
+//===> functions that changed the dwell rates.
+function change_end_dwell(dv) {
+   end_dwell_multipler+=dv;
+   if ( end_dwell_multipler < 1 ) end_dwell_multipler = 0;
+   }
+ 
+function change_start_dwell(dv) {
+   start_dwell_multipler+=dv;
+   if ( start_dwell_multipler < 1 ) start_dwell_multipler = 0;
+   }
+ 
+//===> Increment to next image
+function incrementImage(number)
+{
+   stop();
+ 
+   //== if image is last in loop, increment to first image ==
+   if (number > last_image) number = first_image;
+ 
+   //== check to ensure that image has not been deselected from loop ==
+   while (imageNum[number-first_image] == false) {
+         number++;
+         if (number > last_image) number = first_image;
+   }
+ 
+   current_image = number;
+   document.animation.src = theImages[current_image-first_image].src;   //display image
+   document.control_form.frame_nr.value = current_image;                //display image number
+}
+ 
+//===> Decrement to next image
+function decrementImage(number)
+{
+   stop();
+ 
+   //== if image is first in loop, decrement to last image ==
+   if (number < first_image) number = last_image;
+ 
+   //== check to ensure that image has not been deselected from loop ==
+   while (imageNum[number-first_image] == false) {
+         number--;
+         if (number < first_image) number = last_image;
+   }
+ 
+   current_image = number;
+   document.animation.src = theImages[current_image-first_image].src;   //display image
+   document.control_form.frame_nr.value = current_image;                //display image number
+}
+ 
+//===> "Play forward"
+function fwd()
+{
+   stop();
+   status = 1;
+   play_mode = 1;
+   animate_fwd();
+}
+ 
+//===> "Play reverse"
+function rev()
+{
+   stop();
+   status = 1;
+   play_mode = 1;
+   animate_rev();
+}
+
+//===> "play sweep"
+function sweep() {
+   stop();
+   status = 1;
+   play_mode = 2;
+   animate_fwd();
+   }
+ 
+//===> Change play mode (normal, loop, swing)
+function change_mode(mode)
+{
+   play_mode = mode;
+}
+ 
+//===> Load and initialize everything once page is downloaded (called from 'onLoad' in <BODY>)
+function launch()
+{
+   for (var i = first_image + 1; i <= last_image; i++)
+   {
+      theImages[i-first_image] = new Image();
+      theImages[i-first_image].src = modImages[i-first_image];
+      imageNum[i-first_image] = true;
+      document.animation.src = theImages[i-first_image].src;
+      document.control_form.frame_nr.value = i;
+   }
+ 
+   // this needs to be done to set the right mode when the page is manually reloaded
+   change_mode (1);
+   fwd();
+}
+ 
+//===> Check selection status of image in animation loop
+function checkImage(status,i)
+{
+   if (status == true)
+      imageNum[i] = false;
+   else imageNum[i] = true;
+}
+ 
+//==> Empty function - used to deal with image buttons rather than HTML buttons
+function func()
+{
+}
+ 
+//===> Sets up interface - this is the one function called from the HTML body
+function animation()
+{
+  count = first_image;
+}
+ 
+// -->
+
+function MM_jumpMenu(targ,selObj,restore){ //v3.0
+  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
+  if (restore) selObj.selectedIndex=0;
+}
+//-->
+</SCRIPT>
+
+<link href="animate_styles.css" rel="stylesheet" type="text/css">
+</head>
+
+<body bgcolor="#FFFFFF" onLoad="launch()">
+
+
+
+<table border=1 align=center cellpadding=3 cellspacing=0 id="frame">
+
+<tr>
+
+<td valign="top" id="leftnav">
+    
+<!--
+
+	<h1>Frame Controls</h1>
+     <p>Choose another forecast:</p>
+                   
+		<form name="form1" method="post" action="">
+     <p>
+        <select name="menu1" onChange="MM_jumpMenu('parent',this,1)">
+
+<option value="none.html" selected>  </option>
+<option value="none.html">  </option>
+
+</select>                                           
+</p>
+</form>
+
+--!>
+
+
+<p>Play Mode:<br><br>
+    <a href="JavaScript: func()" onClick="change_mode(1);rev()">
+    <img border=0 hspace=0 vspace=0 width=29 height=24 src="images/button_rev.png" alt="+1"></a>
+    <a href="JavaScript: func()" onClick="stop()">
+    <img border=0 hspace=0 vspace=0 width=29 height=24 src="images/button_stop.png" alt="+1"></a>
+
+    <a href="JavaScript: func()" onClick="change_mode(1);fwd()">
+    <img border=0 hspace=0 vspace=0 width=29 height=24 src="images/button_fwd.png" alt="+1"></a>
+		</p>
+				     					
+		<p>Adjust Speed:<br><br>
+    <a href="JavaScript: func()" onClick="change_speed(delay_step)">
+    <img border=0 hspace=0 vspace=0 width=29 height=24 src="images/button_slow.png" alt="+1"></a>
+	  <a href="JavaScript: func()" onClick="change_speed(-delay_step)">
+		<img border=0 hspace=0 vspace=0 width=29 height=24 src="images/button_fast.png" alt="+1"></a>
+
+    </p>
+
+
+		<p>Advance One Frame:<br><br>
+		<a href="JavaScript: func()" onClick="decrementImage(--current_image)">
+		<img border=0 hspace=0 vspace=0 width=29 height=24 src="images/button_rev1.png" alt="+1"></a>
+		<a href="JavaScript: func()" onClick="incrementImage(++current_image)">
+		<img border=0 hspace=0 vspace=0 width=29 height=24 src="images/button_fwd1.png" alt="+1"></a>
+		</p>
+
+
+		<form method="post" name="control_form">
+
+    <p>Frame No:</p>
+    <p>
+       <input type="text" name="frame_nr" value="9" size="2" onFocus="this.select()" onChange="go2image(this.value)"></input>
+       <br /> &#160; <br />
+    </p>
+
+    </form>   				     
+   <p><A HREF="http://www.lmd.jussieu.fr/~aslmd">Back</A><br /><br />
+      <A HREF="http://dl.dropbox.com/u/11078310/my_papers/spiga_jgr_SF09.pdf">About the LMD Mesoscale Model</A></a><br /><br />
+<!--      <A HREF="http://www-mars.lmd.jussieu.fr/mars/publi/jgr99_gcm.pdf">About the LMD physics parameterizations</A></a><br /><br />	
+      <A HREF="http://www.mmm.ucar.edu/people/skamarock/jcp_2007.pdf">About the WRF dynamical core</A></a><br /><br />--!>
+      <A HREF="http://www-mars.lmd.jussieu.fr">Mars Climate Database</A></a><br /><br />
+   </p>
+</td>
+
+						<td valign="top" id="content">
+<!--
+						<h1>LMD Martian Mesoscale Model</h1>
+--!>
+
+
+             <!--<p><img WIDTH="525" name="animation" border="0" src="images/loading.gif" ALT="model image">--!>
+             <p><img WIDTH="725" name="animation" border="0" src="images/loading.gif" ALT="model image">
+</p>
+</tr>
+</table>
+
+
+</body>
+</html>
+
Index: trunk/UTIL/IDLplot/RESERVE/colorbar__define.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/colorbar__define.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/colorbar__define.pro	(revision 1185)
@@ -0,0 +1,666 @@
+;+
+; NAME:
+;       COLORBAR__DEFINE
+;
+; PURPOSE:
+;       The purpose of this routine is to implement a COLORBAR object
+;       class. The ColorBar is rendered in the direct graphics system.
+;
+; AUTHOR:
+;       FANNING SOFTWARE CONSULTING
+;       David Fanning, Ph.D.
+;       1645 Sheely Drive
+;       Fort Collins, CO 80526 USA
+;       Phone: 970-221-0438
+;       E-mail: davidf@dfanning.com
+;       Coyote's Guide to IDL Programming: http://www.dfanning.com
+;
+; CATEGORY:
+;       Graphics.
+;
+; CALLING SEQUENCE:
+;       colorbar = Obj_New("COLORBAR")
+;
+; INPUTS:
+;       All inputs to the program are via keyword parameters.
+;
+; KEYWORD PARAMETERS:
+;
+;   Background: Background color. This is the color with which the colorbar is
+;               erased. The default color is !P.Background.
+;   Bottom: Bottom color index of colors allocated to colorbar.
+;   Charsize: Character size of annotation. Default is 1.0.
+;   Color: Color of annotation and outline. Default is !P.Color.
+;   Font: Font to use for annotation. Default is -1, Hershey fonts.
+;   Format: Format of annotation. Default is "(F8.2)".
+;   Major: The number of major tick intervals. Default is 5.
+;   Minor: The number of minor tick intervals. Default is 2.
+;   MinusOne: Set this keyword to choose MinusOne keyword on the Congrid command
+;               that resizes the colorbar into the window.
+;   NColors: The number of colors allocated to colorbar. Default is (256 <
+;            !D.N_Colors).
+;   Neighbor: Set to indicate Nearest Neighbor sampling for Congrid. Default is
+;             0 (Bilinear).
+;   Position: The position of colorbar in normalized coordinates. Default for a
+;             horizontal colorbar is [0.15, 0.88, 0.85, 0.95]. Default for a
+;             vertical colorbar is [0.88, 0.15, 0.95, 0.85]. These defaults are
+;             designed for a 400 by 400 window.
+;   Range: The data range on colorbar. Default is [0, 255].
+;   TickLen: The length of tick marks. Default is -0.1
+;   TickV:   Locations for the tick marks in data units. This is the same as
+;            the [XY]TickV keyword. Default is to do what IDL would do
+;            normally.
+;   Vertical: Set this keyword if you want a vertical colorbar. Default is
+;             horizontal.
+;   XEraseBox: A five-element vector of X points (normalized) for erasing the
+;              colorbar plot. Normally this keyword will not have to be used.
+;              The program uses the plot REGION for erasing. But larger
+;              character sizes can result in annotation going outside the
+;              region enclosed by the plot. If that is the case, then use this
+;              keyword along with YEraseBox to specify a larger-than-normal
+;              erasure area. The points are sent to the POLYFILL command for
+;              erasing.
+;
+;                 POLYFILL, xEraseBox, yEraseBox, /Normal, Color=background
+;
+;   YEraseBox: A five-element vector of Y points (normalized) for erasing the
+;              colorbar plot.
+;
+; OBJECT METHODS:
+;
+;   Clamp: This procedure method allows the color bar range to be "clamped"
+;          to a particular data range.
+;
+;   Draw: This procedure method draws the colorbar in the display window. The
+;         ERASE keyword to this method will erase the current colorbar (by
+;         calling the ERASE method) before drawing the colorbar in the display
+;         window.
+;
+;               colorbar->Draw
+;
+;   Erase: This procedure method erases the colorbar object in the window. It
+;          accomplishes this by performing a POLYFILL in the background color.
+;          This method is primarily useful for interactive graphics display
+;          devices.
+;               colorbar->Erase
+;
+;   GetProperty: This procedure method allows one to obtain the current state
+;                of the object via the keyword parameters listed above.
+;
+;               colorbar->GetProperty, Range=currentRange, Title=currentTitle
+;               Print, currentRange, currentTitle
+;
+;   SetProperty: This procedure method allows one to set the properties of the
+;                colorbar object via the keywords described above. In addition,
+;                a DRAW and ERASE keyword are provided so that the colorbar can
+;                be immediately drawn when the new property is set.
+;
+;               colorbar->SetProperty, Range=[500, 15000], /Erase, /Draw
+;
+; COMMON BLOCKS:
+;       None.
+;
+; SIDE EFFECTS:
+;       The display window is not erased first.
+;
+; RESTRICTIONS:
+;       None.
+;
+; EXAMPLE:
+;       To create a colorbar, use it, then destroy it, type:
+;
+;       colorbar = Obj_New("COLORBAR", Title='Colorbar Values', Range=[0,1000],$
+;                  Format='(I4)')
+;       Window
+;       LoadCT, 5
+;       colorbar->Draw
+;       colorbar->SetProperty, Range=[0,500], /Erase, /Draw
+;       Obj_Destroy, colorbar
+;
+; MODIFICATION HISTORY:
+;       Written by: David Fanning, Fanning Software Consulting,
+;                   26 November 1998.
+;       Added Horizontal keyword to SetProperty method and fixed problem in
+;       going from Vertical to Horizontal color bars. 29 Nov 1998. DWF.
+;       Added LoadCT method and current color table index to object.
+;             6 December 1998.
+;       Fixed a bug dealing with nearest neighbor resampling. 30 Mar 1999. DWF.
+;       Fixed a bug with how NCOLORS and BOTTOM keywords interacted.
+;             29 Aug 1999. DWF.
+;       10 Oct 99. Modified the program so that current plot and map coordinates
+;                are saved and restored after the colorbar is drawn. DWF.
+;       26 May 2000 Added {XY}TICKV capability to the draw method. This
+;                required adding TickV to the object data structure, and to the
+;                INIT, GetProperty and SetProperty methods.
+;                Changed default tick length to -0.1. DWF (and Jack Saba)
+;       18 Nov 2001. Added Clamp method. DWF.
+;-
+
+PRO ColorBar::Clamp, datarange, Draw=draw
+
+; This method clamps the data to a particular data range.
+
+self->GetProperty, Range=currentRange
+
+thisclamp = Bytscl(datarange, Max=currentRange[1], Min=currentRange[0])
+lowval = thisclamp[0]
+highval = thisclamp[1]
+IF self.vertical THEN bar = BytScl(REPLICATE(1B,10) # BINDGEN(self.ncolors), Min=lowval, Max=highval) ELSE $
+   bar = BytScl(BIndgen(self.ncolors) # Replicate(1B, 20), Min=lowval, Max=highval)
+*self.bar = bar
+IF Keyword_Set(draw) THEN self->Draw, /Erase
+END
+;-------------------------------------------------------------------------
+
+
+PRO Colorbar::GetProperty, $
+
+; The GetProperty method of the COLORBAR object class. All properties are
+; obtained via the following keywords:
+
+   Background=background, $ ; Background color. Default is !P.Background.
+   Bottom=bottom, $         ; Bottom color index of colors allocated to
+                            ; colorbar.
+   Charsize=charsize, $     ; Character size of annotation. Default is 1.0.
+   Color=color, $           ; Color of annotation and outline. Default is
+                            ; !P.Color
+   Font=font, $             ; Font to use for annotation. Default is -1,
+                            ; Hershey fonts.
+   Format=format, $         ; Format of annotation. Default is F8.2.
+   Index=index, $           ; The color table index. Default is to use none.
+   Major=major, $           ; The number of major tick intervals. Default is 5.
+   Minor=minor, $           ; The number of minor tick intervals. Default is 2.
+   MinusOne=minusone, $     ; Set this keyword to choose MinusOne keyword on
+                            ; Congrid command.
+   NColors=ncolors, $       ; The number of colors allocated to colorbar.
+                            ; Default is (256 < !D.N_Colors).
+   Neighbor=neighbor, $     ; Set to indicate Nearest Neighbor sampling for
+                            ; Congrid. Default is 0 (Bilinear).
+   Position=position, $     ; The position of colorbar in normalized
+                            ; coordinates.
+   Range=range, $           ; The data range on colorbar. Default is [0, 255].
+   TickLen=ticklen, $       ; The length of tick marks. Default is -0.1.
+   TickV=tickv, $           ; Locations for tick marks in color index units.
+   Title=title, $           ; The title of the color bar. Default is a null
+                            ; string.
+   Vertical=vertical, $     ; Set this keyword if you want a vertical colorbar.
+                            ; Default is horizontal.
+   XEraseBox=xerasebox, $   ; A five-element vector of X points (normalized)
+                            ; for erasing the colorbar plot.
+   YEraseBox=yerasebox      ; A five-element vector of Y points (normalized)
+                            ; for erasing the colorbar plot.
+
+   ; Error handling.
+
+Catch, error
+IF error NE 0 THEN BEGIN
+   Catch, Cancel=1
+   ok = Dialog_Message('Error in GETPROPERTY method. Returning...')
+   Print, ''
+   Print, 'Colorbar::GetProperty Method: ' + !Error_State.Msg
+   RETURN
+ENDIF
+
+   ; Return value of self object.
+
+bottom = self.bottom
+charsize = self.charsize
+color = self.color
+background = self.background
+font = self.font
+format = self.format
+index = self.index
+range = self.range
+major = self.major
+minor = self.minor
+minusone = self.minusone
+ncolors = self.ncolors
+IF self.neighbor EQ 0 THEN neighbor = 1 ELSE neighbor = 0
+position = self.position
+title = self.title
+ticklen = self.ticklen
+tickv   = *(self.tickv)
+vertical = self.vertical
+xerasebox = self.xerasebox
+yerasebox = self.yerasebox
+
+END
+;-----------------------------------------------------------------
+
+
+
+PRO Colorbar::SetProperty, $
+
+; The SetProperty method of the COLORBAR object class. All properties are
+; set via the following keywords:
+
+   Background=background, $ ; Background color. Default is !P.Background.
+   Bottom=bottom, $         ; Bottom color index of colors allocated to
+                            ; colorbar.
+   Charsize=charsize, $     ; Character size of annotation. Default is 1.0.
+   Color=color, $           ; Color of annotation and outline. Default is
+                            ; !P.Color
+   Draw=draw, $             ; Set this keyword to call DRAW method after
+                            ; setting property.
+   Erase=erase, $           ; Set this keyword to set ERASE keyword on DRAW
+                            ; method call.
+   Font=font, $             ; Font to use for annotation. Default is -1,
+                            ; Hershey fonts.
+   Format=format, $         ; Format of annotation. Default is F8.2.
+   Horizontal=horizontal, $ ; Set this keyword to go from a vertical colorbar
+                            ; to horizontal.
+   Index=index, $           ; The color table index. Default is 0.
+   Major=major, $           ; The number of major tick intervals. Default is 5.
+   Minor=minor, $           ; The number of minor tick intervals. Default is 2.
+   MinusOne=minusone, $     ; Set this keyword to choose MinusOne keyword on
+                            ; Congrid command.
+   NColors=ncolors, $       ; The number of colors allocated to colorbar.
+                            ; Default is (256 < !D.N_Colors).
+   Neighbor=neighbor, $     ; Set to indicate Nearest Neighbor sampling for
+                            ; Congrid. Default is 0 (Bilinear).
+   Position=position, $     ; The position of colorbar in normalized
+                            ; coordinates.
+   Range=range, $           ; The data range on colorbar. Default is [0, 255].
+   TickLen=ticklen, $       ; The length of tick marks. Default is -0.1.
+   TickV=tickv, $           ; Locations for tick marks in color index units.
+   Title=title, $           ; The title of the color bar. Default is a null
+                            ; string.
+   Vertical=vertical, $     ; Set this keyword if you want a vertical colorbar.
+                            ; Default is horizontal.
+   XEraseBox=xerasebox, $   ; A five-element vector of X points (normalized)
+                            ; for erasing the colorbar plot.
+   YEraseBox=yerasebox      ; A five-element vector of Y points (normalized)
+                            ; for erasing the colorbar plot.
+
+   ; Error handling.
+
+Catch, error
+IF error NE 0 THEN BEGIN
+   Catch, Cancel=1
+   ok = Dialog_Message('Error in SETPROPERTY method. Returning...')
+   Print, ''
+   Print, 'Colorbar::SetProperty Method: ' + !Error_State.Msg
+   RETURN
+ENDIF
+
+   ; Set property if requested.
+
+IF N_Elements(bottom) NE 0 THEN  self.bottom = bottom
+IF N_Elements(charsize) NE 0 THEN  self.charsize = charsize
+IF N_Elements(color) NE 0 THEN  self.color = color
+IF N_Elements(background) NE 0 THEN  self.background = background
+IF N_Elements(font) NE 0 THEN  self.font = font
+IF N_Elements(format) NE 0 THEN  self.format = format
+IF N_Elements(range) NE 0 THEN  self.range = range
+IF N_Elements(major) NE 0 THEN  self.major = major
+IF N_Elements(minor) NE 0 THEN  self.minor = minor
+IF N_Elements(minusone) NE 0 THEN  self.minusone = minusone
+IF N_Elements(ncolors) NE 0 THEN  self.ncolors = ncolors
+IF N_Elements(index) NE 0 THEN  BEGIN
+   self.index = index
+   LoadCT, index, NColors=self.ncolors, Bottom=self.bottom
+ENDIF
+IF N_Elements(neighbor) NE 0 THEN  BEGIN
+   self.neighbor = neighbor
+   IF self.neighbor EQ 0 THEN self.neighbor = 1 ELSE self.neighbor = 0
+ENDIF
+IF N_Elements(position) NE 0 THEN  self.position = position
+IF N_Elements(ticklen) NE 0 THEN  self.ticklen = ticklen
+IF N_Elements(tickv) NE 0 THEN  *(self.tickv) = tickv
+IF N_Elements(title) NE 0 THEN  self.title = title
+IF N_Elements(xerasebox) NE 0 THEN  self.xerasebox = xerasebox
+IF N_Elements(yerasebox) NE 0 THEN  self.yerasebox = yerasebox
+IF Keyword_Set(vertical) THEN BEGIN
+   *self.bar = Replicate(1B, 20) # BIndgen(self.ncolors)
+   IF N_Elements(position) EQ 0 THEN self.position = [0.88, 0.15, 0.95, 0.85]
+  self.vertical = 1
+ENDIF
+IF Keyword_Set(horizontal) THEN BEGIN
+   *self.bar =  BIndgen(self.ncolors) # Replicate(1B, 20)
+   IF N_Elements(position) EQ 0 THEN self.position = [0.15, 0.88, 0.85, 0.95]
+   self.vertical = 0
+ENDIF
+
+   ; Scale the color bar.
+
+*self.bar = BytScl(*self.bar, Top=self.ncolors-1) + self.bottom
+
+   ; Draw the bar?
+
+IF Keyword_Set(draw) THEN self->Draw, Erase=Keyword_Set(erase)
+END
+;-----------------------------------------------------------------
+
+
+
+PRO Colorbar::LoadCT, index, Draw=draw, Erase=erase
+
+; The LoadCT method of the COLORBAR object class.
+
+   ; Error handling.
+
+Catch, error
+;error=0
+IF error NE 0 THEN BEGIN
+   Catch, Cancel=1
+   ok = Dialog_Message('Error in LoadCT method. Returning...')
+   Print, ''
+   Print, 'Colorbar::LoadCT Method: ' + !Error_State.Msg
+   RETURN
+ENDIF
+
+IF N_Elements(index) EQ 0 THEN index = 0
+
+LoadCT, index, NColors=self.ncolors, Bottom=self.bottom, /Silent
+self.index = index
+
+IF Keyword_Set(draw) THEN self->Draw, Erase=Keyword_Set(erase)
+END
+;-----------------------------------------------------------------
+
+
+
+
+PRO Colorbar::Erase
+
+; The Erase method of the COLORBAR object class.
+
+   ; Error handling.
+
+Catch, error
+IF error NE 0 THEN BEGIN
+   Catch, Cancel=1
+   ok = Dialog_Message('Error in ERASE method. Returning...')
+   Print, ''
+   Print, 'Colorbar::Erase Method: ' + !Error_State.Msg
+   RETURN
+ENDIF
+
+   ; Valid erase boxes?
+
+IF Total(self.xerasebox) EQ 0 OR Total(self.yerasebox) EQ 0 THEN BEGIN
+   ok = Dialog_Message('No colorbar exists to erase. Returning...')
+   RETURN
+ENDIF
+
+PolyFill, self.xerasebox, self.yerasebox, /Normal, Color=self.background
+
+END
+;-----------------------------------------------------------------
+
+
+
+
+PRO Colorbar::Draw, Erase=erase
+
+; The Draw method of the COLORBAR object class.
+
+   ; Error handling.
+
+Catch, error
+IF error NE 0 THEN BEGIN
+   Catch, Cancel=1
+   ok = Dialog_Message('Error in DRAW method. Returning...')
+   Print, ''
+   Print, 'Colorbar::Draw Method: ' + !Error_State.Msg
+   RETURN
+ENDIF
+
+   ; Save the current plot state.
+
+bang_p = !P
+bang_x = !X
+bang_Y = !Y
+bang_Z = !Z
+bang_Map = !Map
+
+   ; Must turn off decomposed color on devices that support it.
+
+CASE !D.Name OF
+   'MAC': Device, Decomposed=0
+   'WIN': Device, Decomposed=0
+   'X':   Device, Decomposed=0
+   ELSE:
+ENDCASE
+
+   ; Get starting locations.
+
+xstart = self.position(0)
+ystart = self.position(1)
+
+   ; Get the size of the bar.
+
+xsize = (self.position(2) - self.position(0))
+ysize = (self.position(3) - self.position(1))
+
+   ; Need to erase the display first?
+
+IF Keyword_Set(erase) THEN self->Erase
+
+   ; Display the color bar in the window. Sizing is different for
+   ; devices with scalable pixels.
+
+scalablePixels = (!D.Flags AND 1) NE 0
+
+IF scalablePixels THEN BEGIN
+
+   TV, *self.bar, xstart, ystart, XSIZE=xsize, YSIZE=ysize, /Normal
+
+ENDIF ELSE BEGIN
+
+   bar = CONGRID(*self.bar, Ceil(xsize*!D.X_VSize), Ceil(ysize*!D.Y_VSize), $
+       Interp=self.neighbor, Minus_One=self.minusone)
+   TV, bar, xstart, ystart, /Normal
+
+ENDELSE
+
+   ; Annotate the color bar.
+
+IF self.vertical THEN BEGIN
+
+   loadct,0
+   Plot, [self.range[0], self.range[1]], [self.range[0], self.range[1]], $
+      /NoData, XTicks=1, YTitle=self.title, Font=self.font, YMinor=self.minor, $
+      Position=self.position, YTicks=self.major, XStyle=1, YStyle=1, $
+;      Color=self.color, YCharsize=self.charsize, /NoErase, $
+      Color=0, YCharsize=self.charsize, /NoErase, $
+      YTickformat=self.format, XTickformat='(A1)', YTicklen=self.ticklen, $
+      YRange=self.range, YTickV=*(self.tickv)
+
+ENDIF ELSE BEGIN
+
+   loadct,0
+   Plot, [self.range[0], self.range[1]], [self.range[0], self.range[1]], $
+      /NoData, XTicks=self.major, Font=self.font, XMinor=self.minor, $
+      Position=self.position, YTicks=1, XStyle=1, YStyle=1, XTitle=self.title, $
+;      Color=self.color, XCharsize=self.charsize, /NoErase, YTickformat='(A1)', $
+      Color=0, XCharsize=self.charsize, /NoErase, YTickformat='(A1)', $
+      XTickformat=self.format, XTicklen=self.ticklen, XRange=self.range, $
+      XTickV=*(self.tickv)
+
+ENDELSE
+
+   ; Update the erase boxes.
+
+self.xerasebox = [ !X.Region[0], !X.Region[0], !X.Region[1], !X.Region[1], $
+                   !X.Region[0] ]
+self.yerasebox = [ !Y.Region[0], !Y.Region[1], !Y.Region[1], !Y.Region[0], $
+                   !Y.Region[0] ]
+
+   ; Restore the previous plot and map system variables.
+
+!P = bang_p
+!X = bang_x
+!Y = bang_y
+!Z = bang_z
+!Map = bang_map
+
+END
+;-----------------------------------------------------------------
+
+
+
+PRO Colorbar::CleanUp
+
+; The CleanUp method of the COLORBAR object class.
+
+Ptr_Free, self.bar
+Ptr_Free, self.tickv
+END
+;-----------------------------------------------------------------
+
+
+
+FUNCTION Colorbar::Init, $
+
+; The INIT method of the COLORBAR object class.
+
+   Background=background, $ ; Background color. Default is !P.Background.
+   Bottom=bottom, $         ; Bottom color index of colors allocated to
+                            ; colorbar.
+   Charsize=charsize, $     ; Character size of annotation. Default is 1.0.
+   Color=color, $           ; Color of annotation and outline. Default is
+                            ; !P.Color
+   Font=font, $             ; Font to use for annotation. Default is -1,
+                            ; Hershey fonts.
+   Format=format, $         ; Format of annotation. Default is F8.2.
+   Index=index, $           ; The color table index. Default is to use whatever
+                            ; is loaded.
+   Major=major, $           ; The number of major tick intervals. Default is 5.
+   Minor=minor, $           ; The number of minor tick intervals. Default is 2.
+   MinusOne=minusone, $     ; Set this keyword to choose MinusOne keyword on
+                            ; Congrid command.
+   NColors=ncolors, $       ; The number of colors allocated to colorbar.
+                            ; Default is (256 < !D.N_Colors).
+   Neighbor=neighbor, $     ; Set to indicate Nearest Neighbor sampling for
+                            ; Congrid. Default is 0 (Bilinear).
+   Position=position, $     ; The position of colorbar in normalized
+                            ; coordinates.
+   Range=range, $           ; The data range on colorbar. Default is [0, 255].
+   TickLen=ticklen, $       ; The length of tick marks. Default is -0.1.
+   TickV=tickv, $           ; Locations for tick marks in color index units.
+   Title=title, $           ; The title of the color bar. Default is a null
+                            ; string.
+   Vertical=vertical, $     ; Set this keyword if you want a vertical colorbar.
+                            ; Default is horizontal.
+   XEraseBox=xerasebox, $   ; A five-element vector of X points (normalized)
+                            ; for erasing the colorbar plot.
+   YEraseBox=yerasebox      ; A five-element vector of Y points (normalized)
+                            ; for erasing the colorbar plot.
+
+   ; Error handling.
+
+Catch, error
+IF error NE 0 THEN BEGIN
+   Catch, Cancel=1
+   ok = Dialog_Message('Error in INIT method. Returning...')
+   Print, ''
+   Print, 'Colorbar::INIT Method: ' + !Error_State.Msg
+   RETURN, 0
+ENDIF
+
+   ; Check keywords. Define default values if unsupplied.
+
+IF N_Elements(bottom) EQ 0 THEN bottom = 0
+IF N_Elements(ncolors) EQ 0 THEN ncolors = (256-bottom) < (!D.N_Colors - bottom)
+IF N_Elements(charsize) EQ 0 THEN charsize = 1.0
+IF N_Elements(font) EQ 0 THEN font = -1
+IF N_Elements(format) EQ 0 THEN format = '(F8.2)'
+IF N_Elements(color) EQ 0 THEN color = !P.Color
+IF N_Elements(index) EQ 0 THEN index = -1
+IF index GE 0 THEN LoadCT, index, NColors=ncolors, Bottom=bottom, /Silent
+IF N_Elements(background) EQ 0 THEN background = !P.Background
+IF N_Elements(range) EQ 0 THEN range = [0, 255]
+IF N_Elements(major) EQ 0 THEN major = 5
+IF N_Elements(minor) EQ 0 THEN minor = 2
+IF N_Elements(ticklen) EQ 0 THEN ticklen = -0.1
+IF N_Elements(tickv) EQ 0 THEN tickv = 0
+IF N_Elements(title) EQ 0 THEN title = ''
+IF N_Elements(xerasebox) EQ 0 THEN xerasebox = FltArr(5)
+IF N_Elements(yerasebox) EQ 0 THEN yerasebox = FltArr(5)
+vertical = Keyword_Set(vertical)
+neighbor = Keyword_Set(neighbor)
+IF neighbor EQ 0 THEN neighbor = 1 ELSE neighbor = 0
+minusone = Keyword_Set(minusone)
+
+   ; Create the colorbar image and default positions.
+
+IF vertical THEN BEGIN
+   bar = Replicate(1B, 20) # BIndgen(ncolors)
+   IF N_Elements(position) EQ 0 THEN position = [0.88, 0.15, 0.95, 0.85]
+ENDIF ELSE BEGIN
+   bar = BIndgen(ncolors) # Replicate(1B, 20)
+   IF N_Elements(position) EQ 0 THEN position = [0.15, 0.88, 0.85, 0.95]
+ENDELSE
+
+   ; Scale the color bar.
+
+bar = BytScl(bar, Top=ncolors-1) + bottom
+
+   ; Fill out this particular instance of the COLORBAR object.
+
+self.bar = Ptr_New(bar)
+self.position = Float(position)
+self.vertical = vertical
+self.bottom = bottom
+self.ncolors = ncolors
+self.font = font
+self.format = format
+self.index = index
+self.range = range
+self.title = title
+self.ticklen = ticklen
+self.tickv = Ptr_New(tickv)
+self.neighbor = neighbor
+self.major = major
+self.minor = minor
+self.minusone = minusone
+self.charsize = charsize
+self.color = color
+self.background = background
+self.xerasebox = xerasebox
+self.yerasebox = yerasebox
+
+RETURN, 1
+END
+;-----------------------------------------------------------------
+
+
+
+PRO Colorbar__Define
+
+; Structure definition of the COLORBAR object class.
+
+struct = { COLORBAR, $     ; The COLORBAR object class definition.
+   bar:Ptr_New(), $        ; The colorbar image.
+   position:FltArr(4), $   ; Position in the window (normalized coords).
+   vertical:0, $           ; Flag for vertical colorbar. Default is 0.
+   bottom:0, $             ; The bottom color index. Default is 0.
+   ncolors:0, $            ; The number of colors in the colorbar. Default is
+                           ;  (256 < !D.N_Colors).
+   major:0, $              ; The number of major tick intervals. (Same as
+                           ;  XTICKS.) Default is 5.
+   minor:0, $              ; The number of minor tick intervals. Default is 2.
+   font:0, $               ; The font to use. Default is -1, Hershey fonts.
+   format:'', $            ; The format of the annotations. Default is F8.2.
+   index:0, $              ; The current color table index.
+   range:FltArr(2), $      ; The colorbar data range. Default is [0,255].
+   title:'', $             ; The title of the colorbar. Default is null string.
+   ticklen:0.0, $          ; The length of tick marks. Default is -0.1.
+   tickv: Ptr_New(), $     ; Values for the tick marks.
+   neighbor:0, $           ; A flag to indicate nearest neighbor sampling.
+                           ;  Default is 0 (bilinear).
+   minusone:0, $           ; A flag to indicate MinusOne keyword set on
+                           ;  Congrid. Default is 0.
+   charsize:0.0, $         ; The character size of the annotation. Default is
+                           ;  1.0.
+   color:0, $              ; The color of annotation and colorbar outline.
+                           ;  Default is !P.Color.
+   background:0, $         ; The background or "erase" color. Default is
+                           ;  !P.Background.
+   xerasebox:FltArr(5), $  ; A vector of X points for erasing.
+   yerasebox:FltArr(5) $   ; A vector of Y points for erasing.
+   }
+
+END
+;--------------------------------------------------------------------------
Index: trunk/UTIL/IDLplot/RESERVE/ertel_vorticity.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/ertel_vorticity.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/ertel_vorticity.idl	(revision 1185)
@@ -0,0 +1,80 @@
+
+if ((field1 eq 'T') and (winds(0) eq 'U') and (winds(1) eq 'V')) $
+	or ((field1 eq 'tk') and (winds(0) eq 'U') and (winds(1) eq 'V')) $
+	or ((field1 eq 'HGT') and (winds(0) eq 'U') and (winds(1) eq 'V')) then begin
+
+;print, 'computing Ertel potential vorticity'
+;;---------------------------------------------------
+;;** ERTEL POTENTIAL VORTICITY
+;;---------------------------------------------------
+;; vort scalaire grad_theta / rho
+;;               and rho equal p / gH (because H ~ RT/g)
+;H=10.
+;g=3.72
+;for i=0, west_east-1 do begin
+;for j=0, south_north-1 do begin
+;     theta=220.+var[i,j,*,nt]
+;     dtheta_dz=DERIV(z*1000., theta)
+;     fac=dtheta_dz*H*g/z     ;;fac est EPV/(abs. vort)
+;     what_I_plot(i,j)=fac(theloop)
+;endfor
+;endfor
+;; alternative method : ksi * g * dtheta_dp
+;
+;
+;;--------------------------
+;; coriolis parameter 'f'
+;;--------------------------
+;omeg=7.0721E-5
+;coriolis=2*omeg*sin(lat*!pi/180)
+;ny=n_elements(coriolis)
+;nx=n_elements(what_I_plot(*,1))
+;f=fltarr(nx,ny)
+;for i=0,nx-1 do begin
+;for j=0,ny-1 do begin
+;	f(i,j)=coriolis(j)
+;endfor
+;endfor
+;print, 'coriolis'
+;print, mean(coriolis)
+;
+;;----------------------------------
+;; horizontal coordinates (meters)
+;;----------------------------------
+rad=3397000.
+deg_m=2*rad*!pi/360.
+dlon=deg_m*cos(y*!pi/180)
+dlat=deg_m
+xcal=(x-min(x))*dlon
+ycal=(y-min(y))*dlat
+
+;---------------------------------
+; wind gradients (s-1)
+;---------------------------------
+grad, dv_dx, overvector_y, xcal, ycal, 1
+grad, dv_dy, overvector_y, xcal, ycal, 2
+grad, du_dx, overvector_x, xcal, ycal, 1
+grad, du_dy, overvector_x, xcal, ycal, 2
+
+;;-----------------------------------------
+;; absolute and relative vorticity (s-1)
+;;-----------------------------------------
+;;what_I_plot=(f+dv_dx-du_dy)*what_I_plot*1.e6 
+;what_I_plot=(dv_dx-du_dy)*1.e6
+what_I_plot=(dv_dx-du_dy)*1.e4 
+			;now vort. is in PVU !!
+			;which is 1e-6 K.kg-1.m2.s-1
+;w=where(abs(what_I_plot) gt 1.e10)
+;if (w(0) ne -1) then what_I_plot[w]=1.e38
+
+;overcontour = (dv_dx-du_dy)*1.e4
+
+
+;overcontour = sqrt((overvector_x + overvector_y)^2)
+;overvector_x=0
+;overvector_y=0
+minfield_init=0.
+maxfield_init=0.
+title='Vorticity (1e-4 s!U-1!N)'
+
+endif
Index: trunk/UTIL/IDLplot/RESERVE/findxy.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/findxy.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/findxy.pro	(revision 1185)
@@ -0,0 +1,70 @@
+pro findxy, 		$
+	x=x, 		$	;;IN
+	y=y, 		$	;;IN
+	point=point,	$	;;IN
+	ind=ind, 	$	;;OUT		
+	flag=flag		;;IN OPT
+
+
+
+pointint=[0,0]
+
+;;;if (point eq 'VL1') then pointint=[-48.22,22.70]
+;;;if (point eq 'VL2') then pointint=[133.74,47.93]
+;;;if (point eq 'PAT') then pointint=[-33.5,19.1]
+
+if (n_elements(point) eq 2) then begin
+	pointint=point
+endif else begin
+;;Si lon=312.050381 et lat=22.269628, alt=-3637.1396
+;;Si lon=134.282101 et lat=47.668093, alt=-4497.0474
+;;Si lon=326.747364 et lat=19.099641, alt=-3681.9993
+if (point eq 'VL1') then pointint=[312.050381-360.,22.269628]
+if (point eq 'VL2') then pointint=[134.282101,47.668093]
+if (point eq 'PAT') then pointint=[326.747364-360.,19.099641]
+endelse
+
+
+
+if (n_elements(x) eq 0) then print, 'set x='
+if (n_elements(y) eq 0) then print, 'set y='
+if (n_elements(flag) eq 0) then flag=1
+
+
+x=reform(x)
+y=reform(y)
+
+ind=intarr(2)
+
+
+
+CASE (flag) OF
+1: begin
+
+	minim=abs(x-pointint(0))
+	w=where(minim eq min(minim))
+	print, 'distance is ', minim(w(0))
+	ind[0]=w(0)
+
+        minim=abs(y-pointint(1))
+        w=where(minim eq min(minim))
+	print, 'distance is ', minim(w(0))
+        ind[1]=w(0)
+
+end
+2: begin
+
+	distance = sqrt((x - pointint(0))^2 + (y - pointint(1))^2)
+	mx = min(distance, location)
+	print, 'distance 2D is ',mx
+	ind = array_indices(distance, location)
+	print, 'on ... ', pointint(0), pointint(1)
+	print, 'found ... ', x[ind(0),ind(1)], y[ind(0),ind(1)]
+
+end
+endcase
+
+end
+
+
+
Index: trunk/UTIL/IDLplot/RESERVE/genanim.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/genanim.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/genanim.pro	(revision 1185)
@@ -0,0 +1,20 @@
+pro genanim, num, folder, name
+
+last=num-1
+
+OPENW, 1, 'templist'
+
+FOR i=0,last do begin
+	;; on ne met plus de dossier car on nomme les images
+	;printf, 1, 'modImages['+STRTRIM(STRING(i),2)+'] = "'+folder+'/',$
+	;;	+STRTRIM(STRING(i+1000),2)+'.ps.png";'
+printf, 1, 'modImages['+STRTRIM(STRING(i),2)+'] = "',$
+       +name+STRTRIM(STRING(i+1000),2)+'.png";'
+ENDFOR
+
+printf, 1, 'first_image = '+string(0,'(I0)')+';'
+printf, 1, 'last_image = '+string(last,'(I0)')+';'
+
+CLOSE, 1
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/goodscale.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/goodscale.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/goodscale.pro	(revision 1185)
@@ -0,0 +1,54 @@
+;;Fixe l'echelle pour une tab2diable de type (x,y,z,t) ou (x,y,t) ou (z,t)
+	;;Possibilite de restreindre a une zone et des heures donnees
+
+pro goodscale, $
+    tab2d, $
+    mini, $
+    maxi, $
+    coeff=coeff_sigma
+	
+print,'Yeah !'
+
+;
+; input: the 2D array which is ready to be plotted
+;
+
+
+;if (n_elements(coeff_sigma) eq 0) then coeff_sigma=3.3 ;; vincent
+if (n_elements(coeff_sigma) eq 0) then coeff_sigma=2.5 ;; aymeric
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
+	
+;;calcul de la moyenne
+	N=n_elements(tab2d)
+	moy=(1/float(N))*total(tab2d) 	
+
+;;calcul de la tab2diance
+	moyarray = make_array(N, 1, /integer, value = 1)	
+	varia=(1/float(N-1))*total( ( tab2d - (moyarray * moy) )^2 )
+	
+;;calcul de sigma
+	sigma = sqrt( varia )
+	
+;;echelle
+	mini = moy - float(coeff_sigma) * sigma & stratmin = 'sigma'
+	maxi = moy + float(coeff_sigma) * sigma & stratmax = 'sigma'
+
+;;au cas ou 
+if (mini lt min(tab2d)) then begin
+	mini=min(tab2d)
+	stratmin = 'real min'
+endif
+if (maxi gt max(tab2d)) then begin
+	maxi=max(tab2d)
+	stratmax = 'real max'
+endif
+	
+	
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
+;;affichage a l'ecran :
+print,'min :'+STRTRIM(mini,2)+' '+stratmin	
+print,'max :'+STRTRIM(maxi,2)+' '+stratmax
+
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/grad.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/grad.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/grad.pro	(revision 1185)
@@ -0,0 +1,35 @@
+pro grad, d_param, param, x, y, flag
+
+; pour calculer le champ de gradient d'un champ 2D
+;	d_param = résultat 2D
+; 	param: tableau 2D
+; 	x: tableau 1D 
+; 	y: tableau 1D
+;	flag: 	1 pour grad_x
+;		2 pour grad_y
+
+
+missing=1.e30
+w=where(abs(param) gt missing)
+if (w(0) ne -1) then param[w]=0.
+
+
+imax = n_elements(param(*,0))
+jmax = n_elements(param(0,*))
+
+d_param=dblarr(imax,jmax) 
+case flag of
+1: begin
+for j = 0, jmax-1 do begin
+		d_param(*,j) = DERIV(x,param(*,j))
+;               d_param(*,j) = DERIV(reform(param(*,j)),x)
+endfor
+end
+2: begin
+for i = 0, imax-1 do begin
+		d_param(i,*) = DERIV(y,param(i,*))
+;               d_param(i,*) = DERIV(reform(param(i,*)),y)
+endfor
+end
+endcase
+end
Index: trunk/UTIL/IDLplot/RESERVE/graphwrf.def
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/graphwrf.def	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/graphwrf.def	(revision 1185)
@@ -0,0 +1,296 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+
+extract='yes'	;;   EXECUTE ARWPOST.EXE
+		;;   WITH THE FOLLOWING PARAMETERS :
+
+;-------------------------------
+;-------------------------------
+
+nam1=" fields = 'tk,HGT,PSFC,U,V,W' "		;; CHANGE HERE FIELDS TO BE EXTRACTED 
+nam1=" fields = 'tk,HGT' "
+;nam1=" fields = 'HGT,U,V' "
+nam1=" fields = 'V,W' "
+;nam1=" fields = 'V,W,HGT' "
+;nam1=" fields = 'tk,HGT' "
+;nam1=" fields = 'HGT,ICETOT,RAVE,QH2O_ICE,QH2O' "
+;nam1=" fields = 'U,V,W,QH2O' "
+;nam1=" fields = 'HGT,ICETOT,RAVE,tk,QH2O_ICE' "
+;nam1=" fields = 'HGT,ICETOT,RAVE' "
+;nam1=" fields = 'TSK,HGT' "
+;nam1=" fields = 'U,V,PSFC,tk' "
+nam1=" fields = 'U,V,HGT,SWDOWN' "
+nam1=" fields = 'U,V,HGT' "
+nam1=" fields = 'U,V,W' "
+nam1=" fields = 'TSURF,HGT,U,V,T' "
+nam1=" fields = 'PSFC,tk,HGT' "
+nam1=" fields = 'tk,W' "
+
+;nam2=" start_date = '2024-05-03_06:00:00' "	;; CHANGE HERE START DATE
+;nam3=" end_date   = '2024-05-04_06:00:00' "	;; CHANGE HERE END DATE
+;nam2=" start_date = '2024-06-53_06:00:00' "	;; CHANGE HERE START DATE
+;nam3=" end_date = '2024-06-53_12:00:00' "	;; CHANGE HERE END DATE
+
+nam2=" start_date = '2024-07-17_00:00:00' "	;; CHANGE HERE START DATE
+nam3=" end_date = '2024-07-18_00:00:00' "	;; CHANGE HERE END DATE
+
+
+;nam4=" interval_seconds = 14800 "		;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s	
+;nam4=" interval_seconds = 7400 "               ;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s
+;nam4=" interval_seconds = 3700 "
+;nam4=" interval_seconds = 88800 "
+nam4=" interval_seconds = 22200 "
+;nam4=" interval_seconds = 44400 "
+nam5=" interp_method = 0 "			;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+;nam5=" interp_method = 1 "
+tabnam=[0.,6.,0.1]   	;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+;tabnam=[-3.,5.,0.1]
+tabnam=[-5.,10.,0.2]
+
+nest='d03'  ;; SET NEST
+nest='d01'  ;; SET NEST
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=1		   	;; how many plots ?
+num=6                   ;; how many plots ?
+;num=2                   ;; how many plots ?
+;num=3			;; how many plots ?
+;num=12
+;num=13
+;num=4
+;num=7
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+;winds=['U','V'] & field1='SWDOWN' & topo=1
+;winds=['V','W'] & field1='V' 
+;field1='ICETOT' & topo=1
+;field1='RAVE' & topo=1
+;field1='QH2O_ICE' & topo=1
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O' & field2='W'
+;field1='QH2O' & winds=['U','W']
+;field1='QH2O_ICE' & field2='tk'
+;field1='tk' & topo=1
+;field1='V' & field2='V'
+;field1='W' & winds=['V','W']
+;field1='tk' & winds=['V','W']
+;field1='tk'
+;field1='W' & topo=1
+;field1='TSK' & topo=1
+;field1='U' & winds=['U','V'] & topo=1
+;winds=['V','W'] & field1='V'
+;winds=['V','W'] & field1='W'
+;field1='U' & winds=['U','V'] & topo=1
+;field1='HGT' & field2='HGT' 
+;field1='W' ;& winds=['U','V'] ;& topo=1
+;field1='PSFC' & winds=['U','V'] & field2='W'
+;field1='W' & winds=['U','V'] & field2='PSFC'
+;field1='TSURF' & topo=1 ;& winds=['U','V']
+;field1='T' & topo=1 & winds=['U','V']
+;field1='PSFC' & winds=['tk','HGT'] & topo=1
+;field1='W' & field2='U'
+;field2='tk' & field1='W'
+field1='tk'
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+plot='map' 	
+level=1		; first level is 1
+;level=20
+;;level=41
+;level=10
+;level=11
+;;level=1
+;level=9
+;level=8
+;level=3
+;level=49
+;level=5
+;level=15
+;level=17
+;level=5
+;level=10
+;level=7  ;;SEA LEVEL
+;level=30
+level=7
+
+;plot='meridional'  	
+;nlon=75	; first is 1
+;;;;nlon=87
+;nlon=72
+;nlon=70
+;nlon=69
+;nlon=60  
+;nlon=162
+;nlon=100
+nlon=60
+nlon=150
+nlon=250
+nlon=30
+
+;plot='zonal' 		
+;;;nlat=145	; first is 1
+;;nlat=24
+;;nlat=25
+;nlat=100.
+;nlat=165
+
+;@map_wind_stress.idl
+
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+minfield_init=200.              ;; grepALL
+maxfield_init=260.              ;; grepALL
+;minfield_init=0.              ;; grepALL
+;maxfield_init=48.               ;; grepALL
+;intervalx=5.                   ;; grepALL
+;intervaly=5.                    ;; grepALL
+;title_user='Vertical Wind (!Nm!N.s!U-1!N), LT 13, 980m ABG'	;; grepALL
+;title_axis=['x coord (km)','y coord (km)']	;; grepALL
+;subtitle_user='LT 13, 980m ABG, Contours: surface pressure anomaly each 0.5 Pa'	;; grepALL
+;colors=64			;; grepALL
+;pal=33				;; grepALL
+;pal=0				;; grepALL
+;pal=22				;; grepALL
+;format='(I0)'			;; grepALL
+;windex=30.			;; grepALL
+;stride=3			;; grepALL
+;flag_cb='false'		;; grepALL
+;what_I_plot=abs(what_I_plot)    ;; grepALL ??! minfield
+;what_I_plot=what_I_plot+220.
+;isotropic='false'		;; grepALL
+;overcontour=overcontour-mean(overcontour)	;; grepALL
+;lev=[-8.,-6.,-4.,-2.,0.,2.,4.,6.,8.]		;; grepALL
+;lev=[-5.,0.,5.,10.,15.,20.,25.] ;; grepALL
+;lev=[-1.,5.,10.,15.,20.,25.] ;; grepALL
+
+
+;minalt=-3.			;; grepSEC
+;maxalt=5.			;; grepSEC
+;;;altitude=altitude*1000.  	;; grepSEC
+;minspace=-18.0			;; grepSEC
+;maxspace=-9.0			;; grepSEC
+;minspace=-11.0                 ;; grepSEC
+;maxspace=-7.0                  ;; grepSEC
+;factor=20.  ;10.			   ;; grepSEC
+;space=space*59. & spacekm='true'   ;; grepSEC
+;minspace=minspace*59./factor       ;; grepSEC
+;maxspace=maxspace*59./factor       ;; grepSEC
+;intervalx=round(intervalx*59./factor)       ;; grepSEC
+
+
+;windowy=[10.,13.]        ;; grepMAP
+;windowx=[14.,17.]	;; grepMAP
+;windowy=[-12.,-2.]        ;; grepMAP
+;windowx=[-78.,-68.]     ;; grepMAP
+;windowy=[45.,55.]        ;; grepMAP
+;windowx=[-45.,-35.]     ;; grepMAP
+;lon=lon*59.-lon(0)*59.		;; grepMAP ;;attention plots successifs 
+;lat=lat*59.-lat(0)*59.		;; grepMAP
+;windowy=[0.,14.]	;; grepMAP
+;windowx=[0.,14.]   ;; grepMAP
+
+
+;lim_max = maxfield_init				;; 1/3 grepALL
+;w=where(what_I_plot ge lim_max) 		;; 2/3 grepALL
+;if (w[0] ne -1) then what_I_plot[w]=lim_max	;; 3/3 grepALL
+
+;lim_min = minfield_init                         ;; 1/3 grepALL
+;w=where(what_I_plot le lim_min)                 ;; 2/3 grepALL
+;if (w[0] ne -1) then what_I_plot[w]=lim_min     ;; 3/3 grepALL
+
+
+;lim_blank = 10 					;; 1/3 grepALL
+;w=where(abs(what_I_plot) le lim_blank)			;; 2/3 grepALL
+;if (w[0] ne -1) then what_I_plot[w]=missing_value	;; 3/3 grepALL
+
+;title_user='Sea-level surface pressure'+title_user	;; grepALL
+subtitle_user='LMD mesoscale model'     		;; grepALL
+
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+;------------------------------
+;------------------------------
+; some last possible settings 
+;------------------------------
+;------------------------------
+
+backup_data='no'   	;; save ARWpost-generated text files ? default is no
+already_data='no'  	;; load ARWpost-generated text files ? default is no
+;datafolder='./WHERE_RESULTS_ARE/'	;; default is ./
+;plotfolder='./WHERE_RESULTS_ARE/'       ;; default is ./
+;plotfolder='./WHERE_PLOTS_ARE/'	        ;; default is ./
+;datafolder='/d5/aslmd/WRF_Mars/EN_COURS/newTH20WC/month5/'
+;datafolder='/d5/aslmd/WRF_Mars/ARTICLE/VM/'
+datafolder='/d5/aslmd/WRF_Mars/DATA/VM/'
+plotfolder=datafolder
+
+textitle='generic'		;; one word.  default is 'plot'
+texcomments='sol'	;; one word.  default is 'plot'
+
+
+
Index: trunk/UTIL/IDLplot/RESERVE/graphwrf.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/graphwrf.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/graphwrf.pro	(revision 1185)
@@ -0,0 +1,545 @@
+pro graphwrf, typeplot
+
+
+;-----------------------------------------
+; Read files generated by ARWpost & plot
+;
+; typeplot is s for see		(.ps are not saved, .def saved)
+;	      t for trace	(.ps are saved, .def saved)
+;	      r for report	(same as t + tex report)
+;	      m for movie	(same as t + gif movie)
+;	      w for web page    (same as t + html animation)
+;
+; default is 's'
+;
+; use:
+;  1. set parameters in graphwrf.def
+;  2. @graphwrf.comp
+;  3. graphwrf, 's' (or 't' or 'r' or 'm' or 'w')
+; 
+;-----------------------------------------
+; A. Spiga, Mars 2008
+;-----------------------------------------
+
+
+nomovie='yes'
+
+if (n_elements(typeplot) eq 0) then typeplot='s'
+
+print, '---------------------'
+print, 'init. please wait ...'
+print, '---------------------'
+
+;
+; init.
+;
+field1='' & field2='' & winds=['','']
+backup_data='no' & already_data='no'
+datafolder='./' & plotfolder='./'
+textitle='plot'
+texcomments='plot'
+topo=0
+extract='no'
+
+
+;
+; defining fields, coordinates, type of plot ... etc ...
+;
+@user.idl
+
+
+;
+; extracting/interpolating fields from WRF NETCDF files
+;
+if (extract eq 'yes') then begin
+	print, 'EXTRACT DATA. OK ?'
+	read, dumb, prompt='type 1 to proceed, 0 to keep the same input >>> '
+	if (dumb ne 0) then begin
+        	print, 'WE WILL EXTRACT DATA USING ARWPOST.EXE'
+		if (n_elements(nest) eq 0) then nest='d01'
+        	call_arwpost, nam1, nam2, nam3, nam4, nam5, tabnam, nest, datafolder
+	endif 
+endif
+if (already_data eq 'yes') then begin
+	if (nam5 eq " interp_method = 0 ") then coord='model_level'
+	if ((nam5 eq " interp_method = 1 ") and (tabnam(0) lt tabnam(1))) then coord='height'
+        SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.ctl input.ctl'
+        SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.dat input.dat'
+endif
+
+				
+;-----------------------------;
+; STARTING TO READ INPUT.CTL  ;
+;-----------------------------;
+
+
+;
+; get the local time
+;
+interv=0.
+openr, 99, 'timefil'
+readf,99,interv
+close, 99
+
+
+;
+; get preliminar info on coordinates
+;
+wnx=1
+wny=1
+wnz=1
+wnt=1
+txt=''
+param=[0.,0.,0.,0.,0.,0.,0.,0.]
+
+openr, 1, 'input.ctl'
+while not eof(1) do begin
+    readf,1,txt
+    match=STRPOS(txt,'linear')
+	if (match ne -1) then begin
+		wnx=(STRPOS(txt,'xdef') eq -1)*wnx  ;0 if linear
+		wny=(STRPOS(txt,'ydef') eq -1)*wny  ;0 if linear
+                wnz=(STRPOS(txt,'zdef') eq -1)*wnz  ;0 if linear 
+                wnt=(STRPOS(txt,'tdef') eq -1)*wnt  ;0 if linear
+                paramstart=STRSPLIT(txt, 'r', LENGTH=paramlength)
+        	paramchar=STRMID(txt,paramstart(1),paramlength(1))
+		READS, paramchar, start, step
+		param=param+[start*(STRPOS(txt,'xdef') ne -1),$
+			step*(STRPOS(txt,'xdef') ne -1),$
+			start*(STRPOS(txt,'ydef') ne -1),$
+			step*(STRPOS(txt,'ydef') ne -1),$
+			start*(STRPOS(txt,'zdef') ne -1),$
+			step*(STRPOS(txt,'zdef') ne -1),$
+			start*(STRPOS(txt,'tdef') ne -1),$
+			step*(STRPOS(txt,'tdef') ne -1)]
+	endif	
+endwhile
+close, 1
+timebegin=param(6)
+	
+
+;---------------------------------
+; READ .CTL FILE INFORMATIONS
+;---------------------------------
+
+info=read_ascii('input.ctl', missing_value=1e37)
+infodat=info.field1
+
+;
+; second column : dimensions
+;
+
+w=where((infodat(0,*) eq 1e37) and (infodat(1,*) lt 1e37))
+dimensions=reform(infodat(1,w))
+
+nx=round(dimensions(0)) 
+ny=round(dimensions(1)) 
+nz=round(dimensions(2)) 
+nt=round(dimensions(3)) 
+fields=round(dimensions(4)) 
+vertical=intarr(fields)
+for i=0,fields-1 do begin
+	vertical(i)=round(dimensions(5+i))
+endfor
+
+
+;
+; first column : coordinates
+;
+
+w=where((infodat(1,*) eq 1e37) and (infodat(0,*) lt 1e37))
+if (w(0) ne -1) then coordinates=reform(infodat(0,w))
+
+
+if (wnx ne 0) then begin
+
+	wnx=nx
+	x=coordinates(0:nx-1)
+
+endif else begin
+
+	xmin=param(0)
+	xmax=param(0)+param(1)*(nx-1) MOD 360
+	;inc=param(0)+param(1)*(nx-1)	;cas mercator
+	;x=start+inc*findgen(nx) 
+	x=xmin+(xmax-xmin)*findgen(nx)/(nx-1)
+	
+;param(1)=param(1)-param(0) ;;bricolo plot GCM
+;xmin=param(0)
+;xmax=param(0)+param(1)*(nx-1)
+;x=xmin+(xmax-xmin)*findgen(nx)/(nx-1)
+;;x = x - (LONG(x)/180)*360.0
+;print, x
+
+	;stop
+
+endelse
+
+
+if (wny ne 0) then begin
+        wny=ny
+	y=coordinates(wnx:wnx+wny-1)
+endif else begin
+        start=param(2)
+        step=param(3)
+        y=start+step*findgen(ny)
+endelse
+if (wnz ne 0) then begin
+        wnz=nz
+	z=coordinates(wnx+wny:wnx+wny+wnz-1)
+endif else begin
+        start=param(4)
+        step=param(5)
+        z=start+step*findgen(nz)
+endelse
+t=interv*findgen(nt)/3700. + timebegin + mean(x)/15.
+lct = round(t+24) MOD 24	
+	
+;
+; get info on fields
+;
+openr, 1, 'input.ctl'
+toto=5+wnx+1+wny+1+wnz+2+fields
+infofields=strarr(toto)
+readf, 1, infofields
+close, 1
+desc_field=transpose(infofields(toto-fields:toto-1))
+
+;
+; vert coord
+;
+if (z(0) lt z(1)) then coord='height'
+if (z(0) gt z(1)) then coord='pressure'
+if ((z(0) eq 1.) and (z(nz-1) eq (z(nz-2)+1.))) then coord='model_level'
+
+
+
+;---------------------------------
+; READ .DAT FILE DATA
+;---------------------------------
+; GrADS views gridded data sets as 5-dimensional arrays 
+; varying in longitude, latitude, vertical level, variable, and time.
+;---------------------------------
+
+;-----------------------------;
+; STARTING TO READ INPUT.DATA ;
+;-----------------------------;
+print, '----------------'
+print, 'reading data ...'
+print, '----------------'
+print, 'longitudes: ', min(x), max(x), nx, ' points'
+print, 'latitudes: ', min(y), max(y), ny, ' points' 
+print, 'altitudes: ', min(z), max(z), nz, ' points'
+print, 'local times: ', min(lct), max(lct), nt, ' points'
+print, fields, ' recorded fields :'
+print, desc_field
+print, '----------------'
+
+; see http://www.dfanning.com/tips/ascii_column_data.html	
+OPENR, lun, 'input.dat', /GET_LUN
+
+
+;
+; titles and plot name
+;
+denom=plot+'_'+coord+'_'+field1
+if ((field2 ne '') and (topo eq 0)) then denom=denom+'_'+field2
+if (topo eq 1) then denom=denom+'_HGT'
+if (winds(0) ne '') then denom=denom+'_'+winds(0)+winds(1)
+        case coord of
+	'height': charlev='Altitude (km)'
+	;'pressure': begin
+	;               H=10.
+	;               p0=6.1
+	;               z=H*alog(p0/z)
+	;               charlev='Log-Pressure altitude (km)'
+	;end
+	'model_level': charlev='Model level'
+	endcase
+																							
+
+;
+; graphics settings
+;
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+	; plot with topography
+	if (topo eq 1) then field2='HGT'
+
+save_ps='true'
+if (save_ps ne 'false') then begin
+;	set_plot, 'ps'
+endif else begin
+	set_plot, 'x'
+	!P.MULTI = [0, 2, 3]
+	window, 0, xsize=600, ysize=900
+endelse
+
+no3D='false'	
+print, 'GENERATE PLOTS ',min([nt-1,num-1])+1
+
+for l=0,min([nt-1,num-1]) do begin 						;time loop
+print, 'time loop ...', l+1, ' / ', string(nt,'(I0)')  
+T = SYSTIME(1)
+  for f=0, fields-1 do begin ;fields (whether 2D or 3D)	;variable loop
+  nzf=vertical(f)
+  print, 'scanning field ...', f+1, ' / ', string(fields,'(I0)')
+
+	data = FLTARR(1,nzf*ny*nx)
+	print, 'read data ...'
+	READF, lun, data	;; the IDL way, two times faster than 3 FOR loops
+	print, 'read data done'
+	
+	recognize=STRSPLIT(desc_field(f), /EXTRACT)
+	recognize=recognize[0]
+	
+;	IF (STRPOS(desc_field(f),field1) ne -1) then begin
+;       IF ( ( STRPOS(desc_field(f),field1) eq 0 ) and ( STRLEN(desc_field(f)) eq STRLEN(field1) ) ) then begin
+	IF (recognize eq field1) then begin
+		data_save=data
+		print, 'found field1 ', field1
+		data=REFORM(data,nx,ny,nzf,/OVERWRITE)
+			w=where(data eq -9999.)	; missing values: -9999 (before, was 1e20)
+			if (w(0) ne -1) then data[w]=1e37
+		CASE (plot) OF
+		'map': what_I_plot=reform(data(*,*,-1+min([level,nzf])))
+		'meridional': what_I_plot=reform(data(-1+min([nlon,nx]),*,*))
+		'zonal': what_I_plot=reform(data(*,-1+min([nlat,ny]),*))
+		ENDCASE
+		if (nzf eq 1) then no3D='true'
+		data=0. & data=data_save & data_save=0.
+	ENDIF
+;	IF ((STRPOS(desc_field(f),field2) ne -1) and (field2 ne '')) then begin
+;       IF ((STRPOS(desc_field(f),field2) eq 0) and (field2 ne '')) then begin
+;       IF ( ( STRPOS(desc_field(f),field2) eq 0 ) and ( field2 ne '' ) and ( STRLEN(desc_field(f)) eq STRLEN(field2) ) ) then begin
+        IF (recognize eq field2) then begin
+		data_save=data
+		print, 'found field2 ', field2
+		if (topo eq 1) then begin
+			data=data/100.
+			data=round(data)
+			data=float(data)/10.
+		endif	
+		data=REFORM(data,nx,ny,nzf,/OVERWRITE)
+                        w=where(data eq -9999.)   ; missing values
+			if (w(0) ne -1) then data[w]=1e37
+		CASE (plot) OF
+		'map': overcontour=reform(data(*,*,-1+min([level,nzf])))
+		'meridional': overcontour=reform(data(-1+min([nlon,nx]),*,*))
+		'zonal': overcontour=reform(data(*,-1+min([nlat,ny]),*))
+		ENDCASE
+		data=0. & data=data_save & data_save=0.
+	ENDIF   
+;	IF (STRPOS(desc_field(f),winds(0)) ne -1 and (winds(0) ne '')) then begin
+;       IF (STRPOS(desc_field(f),winds(0)) eq 0 and (winds(0) ne '')) then begin
+	IF (recognize eq winds(0)) then begin
+		data_save=data
+		print, 'found wind1 ', winds(0)
+	        data=REFORM(data,nx,ny,nzf,/OVERWRITE)
+                        w=where(data eq -9999.)   ; missing values
+			if (w(0) ne -1) then data[w]=!Values.F_NAN
+		CASE (plot) OF
+                'map': overvector_x=reform(data(*,*,-1+min([level,nzf])))
+                'meridional': overvector_x=reform(data(-1+min([nlon,nx]),*,*))
+                'zonal': overvector_x=reform(data(*,-1+min([nlat,ny]),*))
+		ENDCASE
+		data=0. & data=data_save & data_save=0.
+	ENDIF 
+;	IF (STRPOS(desc_field(f),winds(1)) ne -1 and (winds(1) ne '')) then begin
+;       IF (STRPOS(desc_field(f),winds(1)) eq 0 and (winds(1) ne '')) then begin
+        IF (recognize eq winds(1)) then begin
+		data_save=data
+		print, 'found wind2 ', winds(1)
+		data=REFORM(data,nx,ny,nzf,/OVERWRITE)
+                        w=where(data eq -9999.)   ; missing values
+	                if (w(0) ne -1) then data[w]=!Values.F_NAN
+                CASE (plot) OF
+                'map': overvector_y=reform(data(*,*,-1+min([level,nzf])))
+                'meridional': overvector_y=reform(data(-1+min([nlon,nx]),*,*))
+                'zonal': overvector_y=reform(data(*,-1+min([nlat,ny]),*))
+                ENDCASE
+		data=0. & data=data_save & data_save=0.
+	ENDIF
+	data=0.		;; free memory
+	data_save=0.         ;; free memory
+	
+  endfor
+
+	if (n_elements(overcontour) eq 0) then overcontour=0.
+	if (n_elements(overvector_x) eq 0) then overvector_x=0.
+	if (n_elements(overvector_y) eq 0) then overvector_y=0.
+	
+	@graphwrf_name.idl
+
+;;--------------------------------------------------------
+;; NB: you can use the winds fields to combine variables
+;;--------------------------------------------------------
+@wind_stress.idl	;** WIND STRESS
+@sea_level.idl		;** HYDROSTATIC REDUCTION TO LEVEL OF REFERENCE
+@ertel_vorticity.idl	;** ERTEL POTENTIAL VORTICITY
+@tau_cloud.idl          ;** CLOUD OPACITY
+@wind_velocity.idl	;** 3D WIND VELOCITY
+@hwind_velocity.idl	;** HORIZONTAL WIND VELOCITY 
+;;--------------------------------------------------------
+;; NB: you can use the winds fields to combine variables
+;;--------------------------------------------------------
+
+	title=title+', LT '+string(lct(l),'(I0)')
+
+	if (save_ps ne 'false') then begin
+	save_ps=denom+string(1000+l,'(I0)')
+;        device, filename=save_ps+'.ps', /color
+PS_Start, filename=save_ps+'.ps'
+	endif
+
+	CASE (plot) OF
+	'map': begin
+        	case coord of
+		   'height': charlev=string(round(z(level-1)*1000.),'(I0)')+' m'
+		   'pressure': charlev=string(round(z(level-1)*100.),'(I0)')+' Pa'
+		   'model_level': charlev=string(round(z(level-1)),'(I0)')
+		endcase
+        	if (no3D ne 'true') then title=title+', at level '+charlev
+		print, title
+	map_latlon, $
+        	what_I_plot, $                          ; 2D field
+        	x, $                                  ; 1D latitude
+        	y, $                                  ; 1D longitude
+        	minfield=0., $               ; minimum value of plotted field (=0: calculate)
+        	maxfield=0., $               ; maximum value of plotted field (=0: calculate)
+        	overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        	overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        	overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        	ct=pal, $                               ; color table (33-rainbow is default)
+        	colors=colors, $                        ; number of colors/levels (32 is default)
+        	title=title, $                     ; title of the plot ('' is default)
+        	format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+	end
+	'zonal': begin
+		displaylat=float(round(y(nlat-1)*10))/10.
+		title=title+ ', section at latitude '+string(displaylat,format='(1F6.1)')+ '!Uo!N '
+	        print, title
+	section, $
+                what_I_plot, $                          ; 2D field
+                x, $                                ; horizontal coordinate
+                z, $                             ; altitude coordinate
+                minfield=0., $               ; minimum value of plotted field (=0: calculate)
+                maxfield=0., $               ; maximum value of plotted field (=0: calculate)
+                minspace=0., $                    ; minimum value of space window (=0: calculate)
+                maxspace=0., $                    ; maximum value of space window (=0: calculate)
+                overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+                overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+                overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+                colors=colors, $                        ; number of colors/levels (32 is default)
+                title_plot=title, $                ; title of the plot ('Profile' is default)
+                title_axis=['Longitude',charlev], $             ; title of the [x,y] axis (['Field','Altitude'] is default)
+                ct=pal, $                               ; color table (33-rainbow is default)
+                format=format
+ 	end
+        'meridional': begin
+                displaylon=float(round(x(nlon-1)*10))/10.
+                title=title+', section at longitude '+string(displaylon,format='(1F6.1)')+ '!Uo!N '
+                print, title
+        section, $
+                what_I_plot, $                          ; 2D field
+                y, $                                ; horizontal coordinate
+                z, $                             ; altitude coordinate
+                minfield=0., $               ; minimum value of plotted field (=0: calculate)
+                maxfield=0., $               ; maximum value of plotted field (=0: calculate)
+                minspace=0., $                    ; minimum value of space window (=0: calculate)
+                maxspace=0., $                    ; maximum value of space window (=0: calculate)
+                overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+                overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+                overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+                colors=colors, $                        ; number of colors/levels (32 is default)
+                title_plot=title, $                ; title of the plot ('Profile' is default)
+                title_axis=['Latitude',charlev], $             ; title of the [x,y] axis (['Field','Altitude'] is default)
+                ct=pal, $                               ; color table (33-rainbow is default)
+                format=format
+        end
+ 	endcase	 
+
+	 if (save_ps ne 'false') then device, /close
+	 if (typeplot eq 's') then SPAWN, 'display '+save_ps+'.ps &'
+
+;PRINT, 1000*(SYSTIME(1) - T), ' milliSeconds'
+PRINT, SYSTIME(1) - T, ' seconds to process'
+endfor
+
+
+
+CLOSE, lun
+print, '...done !'
+help, /memory
+print, '---------'
+
+
+CASE (typeplot) OF
+'s': begin
+	;SPAWN, 'find '+denom+'????.ps -exec display {} \;'
+	SPAWN, 'cp -f graphwrf.def '+plotfolder+'/see_'+denom+'.def'
+	;SPAWN, 'mv -f ./'+denom+'????.ps '+plotfolder+'/'
+	SPAWN, '\rm ./'+denom+'????.ps' 
+end
+'t': begin
+	SPAWN, 'mv -f ./'+denom+'????.ps '+plotfolder+'/'
+	SPAWN, 'cp -f graphwrf.def '+plotfolder+'/'+denom+'.def'
+end
+'r': begin
+	SPAWN, 'touch report.comments ; \rm report.comments ; echo '+textitle+' > report.comments ; echo '+texcomments+' >> report.comments'
+	SPAWN, 'rm -f '+denom+'_.ps ; echo executing ... base '+denom+'????.ps < report.comments'
+	SPAWN, 'base '+denom+'????.ps < report.comments ; mv -f base.ps '+denom+'_.ps'
+
+	SPAWN, 'mv -f ./'+denom+'????.ps '+plotfolder+'/'
+	SPAWN, 'mv -f ./'+denom+'_.ps '+plotfolder+'/'
+	SPAWN, 'cp -f graphwrf.def '+plotfolder+'/'+denom+'.def'
+end
+'m': begin
+	print, 'generating movie ...'
+	SPAWN, 'rm -rf temp ; mkdir temp ; mv -f '+denom+'????.ps temp ; cp bigconvert200 temp ; cd temp'
+	SPAWN, 'bigconvert200 *.ps ; convert -delay 60 *.png movie.gif ; cd ..'
+	if (nomovie ne 'yes') then SPAWN, 'animate temp/movie.gif &' 
+	print, 'movie done'
+
+	SPAWN, 'mv -f temp/'+denom+'????.ps '+plotfolder+'/'
+	SPAWN, 'mv -f temp/movie.gif '+plotfolder+'/'+denom+'.gif'
+	SPAWN, 'mv -f temp/'+denom+'????.png '+plotfolder+'/'
+	SPAWN, 'cp -f graphwrf.def '+plotfolder+'/'+denom+'.def'
+end
+'w': begin
+;
+;
+netfolder='/u/aslmd/WWW/ANIMATIONS/'
+;
+; set also textitle
+;
+        print, 'generating frames ...'
+        SPAWN, 'rm -rf temp ; mkdir temp ; mv -f '+denom+'????.ps temp/ ; ls temp/'
+        SPAWN, "find temp/* -exec convert -density 100x100 -crop 0x0 {} '{}.png' \;"
+	SPAWN, 'ls temp/'
+        ;SPAWN, 'mv -f temp/'+denom+'????.ps '+plotfolder+'/'
+        SPAWN, 'cp -f graphwrf.def '+plotfolder+'/web_'+denom+'.def'
+	;; webpage
+	;SPAWN, 'rm -rf '+netfolder+textitle+'_'+denom+' ; mkdir '+netfolder+textitle+'_'+denom
+	SPAWN, 'mkdir '+netfolder+textitle
+	SPAWN, 'mv -f temp/'+denom+'????.ps.png '+netfolder+textitle+'/'
+	SPAWN, 'chmod 777 -R '+netfolder+textitle
+	SPAWN, 'rm -rf '+denom+'.html ; more header.html > '+textitle+'_'+denom+'.html'
+	genanim, num, textitle, denom 
+	SPAWN, 'more templist >> '+textitle+'_'+denom+'.html ; rm -rf templist'
+	SPAWN, 'more body.html >> '+textitle+'_'+denom+'.html'
+	SPAWN, 'mv -f '+textitle+'_'+denom+'.html '+netfolder+'/'
+end	
+ENDCASE
+
+if (backup_data eq 'yes') then SPAWN, 'cp -f namelist.ARWpost '+datafolder+'/'+coord+'.namelist.ARWpost'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.ctl '+datafolder+'/'+coord+'.input.ctl'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.dat '+datafolder+'/'+coord+'.input.dat'
+
+
+
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/header.html
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/header.html	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/header.html	(revision 1185)
@@ -0,0 +1,35 @@
+<html>
+<head>
+<meta http-equiv="Pragma" content="no-cache">
+<title>LMD Martian Mesoscale Model</title>
+
+<SCRIPT LANGUAGE="JavaScript">
+<!--
+// <!--
+
+//============================================================
+//                >> jsImagePlayer 1.0 <<
+//            for Netscape3.0+, September 1996
+//============================================================
+//                  by (c)BASTaRT 1996
+//             Praha, Czech Republic, Europe
+//
+// feel free to copy and use as long as the credits are given
+//          by having this header in the code
+//
+//          contact: xholecko@sgi.felk.cvut.cz
+//          http://sgi.felk.cvut.cz/~xholecko
+//
+//============================================================
+// Thanx to Karel & Martin for beta testing and suggestions!
+//============================================================
+//
+//     modified by D. Watson and A. Earnhart (CIRA/CSU), 7/30/97
+//     and Greg Thompson (NCAR/RAP) May 07, 2000
+//	   graphic & php enhancement, Kristin Conrad (NCAR/MMM) Dec 2004
+//
+//============================================================
+ 
+//********* SET UP THESE VARIABLES - MUST BE CORRECT!!!*********************
+modImages = new Array(); 
+
Index: trunk/UTIL/IDLplot/RESERVE/hovmuller.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/hovmuller.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/hovmuller.pro	(revision 1185)
@@ -0,0 +1,205 @@
+pro hovmuller, $
+	what_I_plot, $				; 2D field
+	space, $				; space coordinate
+	time, $					; time coordinate
+	minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+	maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+	minspace=minspace, $			; minimum value of space window (=0: calculate)
+	maxspace=maxspace, $			; maximum value of space window (=0: calculate)
+	overcontour=overcontour, $		; another 2D field to overplot with contour lines (=0: no)
+	ct=pal, $				; color table (33-rainbow is default)
+	colors=colors, $			; number of colors/levels (32 is default)
+	title=title				; title of the plot ('' is default)
+
+;--------------------------------------------
+;
+; A general routine to plot hovmuller maps
+;
+; USE:	- hovmuller, what_I_plot 	
+;	- hovmuller, what_I_plot, space, time
+;	- ... and see options above
+;
+;--------------------------------------------
+; A. Spiga, September 2007
+;--------------------------------------------
+
+
+
+
+;---------------------------
+; a few permanent settings
+;---------------------------
+;
+missing_value=1.e30
+@param_plot.idl
+;
+;------------------
+
+
+;------------------
+; user settings
+;------------------
+if (n_elements(space) eq 0) then begin
+	space=findgen(n_elements(what_I_plot(*,0)))
+endif
+if (n_elements(time) eq 0) then begin
+	time=findgen(n_elements(what_I_plot(0,*)))
+endif
+
+if (n_elements(minfield_init) eq 0) then minfield_init=0.
+if (n_elements(maxfield_init) eq 0) then maxfield_init=0.
+if (n_elements(minspace) eq 0) then minspace=0.
+if (n_elements(maxspace) eq 0) then maxspace=0.
+if (n_elements(colors) eq 0) then colors=32
+if (n_elements(title) eq 0) then title=''
+if (n_elements(pal) eq 0) then pal=33
+if (n_elements(overcontour) eq 0) then overcontour=0.
+if (n_elements(titlex) eq 0) then titlex='space'
+if (n_elements(titley) eq 0) then titley='time'
+
+;------------------
+; limits
+;------------------
+if (minfield_init*maxfield_init eq 0) then begin   
+	;---different min/max for each layer
+	w=where(abs(what_I_plot) lt missing_value)
+	if (w(0) ne -1) then begin
+		minfield=min(what_I_plot[w])
+		maxfield=max(what_I_plot[w])
+	endif else begin
+		what_I_plot=0.
+		print, 'no valid values in this field' 
+	endelse
+endif else begin
+	;---user-defined limits	
+	minfield=minfield_init 
+	maxfield=maxfield_init
+	;;w=where(what_I_plot lt minfield) & if (w(0) ne -1) then what_I_plot[w]=minfield
+	;;w=where(what_I_plot gt maxfield) & if (w(0) ne -1) then what_I_plot[w]=maxfield
+endelse
+
+if ((minfield+maxfield eq 0) and (abs(minfield) ne abs(maxfield))) then begin
+	print, 'nothing to plot ... skipping this plot ...'
+endif else begin
+
+
+
+;-----------------------------------------
+; fix the possible longitude ugliness :)
+; ...get rid of the -180/180 limit
+;-----------------------------------------
+
+w=where(space eq min(space))
+if (w(0) ne 0) then begin
+	space[0:w(0)-1]=space[0:w(0)-1]-360
+endif
+
+
+;---------------
+; adapt ticks
+;---------------
+if ((minspace eq 0) and (maxspace eq 0)) then begin
+	minspace=min(space)
+	maxspace=max(space)
+endif
+intervalx=round((maxspace-minspace)/8.)
+intervaly=round((max(time)-min(time))/5.)
+intervalx=60.
+intervaly=4.
+
+
+;------------------
+; plot window
+;------------------
+
+	; to ensure the right limits
+	dumb_what_I_plot=what_I_plot
+	dumb_what_I_plot(*,*)=minfield & print, minfield
+	dumb_what_I_plot(0,0)=maxfield & print, maxfield
+
+
+loadct,0,/silent  
+contour, $
+	/nodata, $ 
+	dumb_what_I_plot, $
+	space, $
+	time, $
+	title=title, $
+	xtitle=titlex, $
+	xrange=[minspace,maxspace], $
+	ytitle=titley, $
+	yrange=[min(time),max(time)], $
+	xtickinterval=intervalx, ytickinterval=intervaly, $
+;	position=[0.15, 0.15, 0.95, 0.75], $
+	color=0
+
+
+
+;------------------
+; plot field
+;------------------
+
+;lim=45.
+;ecart=5.
+;yeah=-lim + ecart*findgen(lim*2./5.)
+
+loadct,pal,/silent
+contour, what_I_plot, $
+	space, $
+	time, $
+	nlevels=colors, $
+;lev=yeah, $
+	/cell_fill, $
+	max_value=maxfield, $
+	min_value=minfield, $	
+	/overplot
+
+
+;------------------
+; colorbar
+;------------------
+
+;;format_colorbar='(F6.2)'
+;;format_colorbar='(F10.3)'
+;;format_colorbar='(F12.2)'
+;format_colorbar='(F4.0)'  ;temperature
+;colorbar, $
+;;	position=[0.15, 0.85, 0.95, 0.90], $
+;	/vertical, $
+;	divisions=8, $
+;	range=[minfield,maxfield], $
+;	format=format_colorbar
+
+;--------------------
+; overplot contour
+;--------------------
+if (n_elements(overcontour) ne 1) then begin
+
+	w=where(abs(overcontour) lt missing_value)
+	if (w(0) ne -1) then begin
+		min_contour=min(overcontour[w])
+		max_contour=max(overcontour[w])
+	endif
+
+loadct,0,/silent
+contour, overcontour, $
+	space,time, $
+	nlevels=colors/2, $
+	max_value=max_contour, $
+	min_value=min_contour, $	
+	c_labels=findgen(colors/2), $
+	color=0, $
+	/noerase, $
+	xtitle='space', $
+	xrange=[min(space),max(space)], $
+	ytitle='time', $
+	yrange=[min(time),max(time)], $
+	xtickinterval=intervalx, ytickinterval=intervaly, $
+	position=[0.15, 0.15, 0.95, 0.75]
+
+endif
+
+
+endelse
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/hwind_velocity.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/hwind_velocity.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/hwind_velocity.idl	(revision 1185)
@@ -0,0 +1,34 @@
+
+;
+; field1='U'
+; winds=['U','V']
+;
+
+if ( (field1 eq 'U') $
+	and (winds(0) eq 'U') $
+        and (winds(1) eq 'V')  ) then begin
+
+print, 'computing wind velocity'
+
+title='Horizontal wind velocity (!Nm!N.s!U-1!N)'
+
+u=overvector_x
+v=overvector_y
+
+help, u
+help, v
+
+velocity2=u^2+v^2
+what_I_plot=sqrt(velocity2)
+
+;overcontour=sqrt(velocity2)
+
+;;
+;; comment if you want wind vectors
+;;
+;overvector_x=0
+;overvector_y=0
+
+pal=22
+
+endif
Index: trunk/UTIL/IDLplot/RESERVE/map_ertel_vorticity.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/map_ertel_vorticity.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/map_ertel_vorticity.idl	(revision 1185)
@@ -0,0 +1,15 @@
+;----------------------------
+; ERTEL POTENTIAL VORTICITY
+;----------------------------
+
+; -- keep --
+plot='map'
+field1='T'
+winds=['U','V']
+; -- keep --
+
+colors=32
+field2=''
+range=0.
+topo=0
+level=-1
Index: trunk/UTIL/IDLplot/RESERVE/map_sea_level.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/map_sea_level.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/map_sea_level.idl	(revision 1185)
@@ -0,0 +1,16 @@
+;------------------
+;PRESSURE SEA LEVEL
+;------------------
+
+; -- keep --
+IF (coord ne 'model_level') THEN STOP
+plot='map'
+level=1		;;necessary for surface fields
+field1='PSFC'
+winds=['tk','HGT']
+; -- keep --
+
+colors=32
+field2=''
+range=0.
+topo=1
Index: trunk/UTIL/IDLplot/RESERVE/map_wind_stress.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/map_wind_stress.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/map_wind_stress.idl	(revision 1185)
@@ -0,0 +1,14 @@
+
+; -- keep --
+;;IF (coord ne 'model_level') THEN STOP
+plot='map'
+level=1		;;necessary for surface fields
+field1='U'
+field2='V'
+winds=['PSFC','tk']
+; -- keep --
+
+colors=32
+range=[0.,0.1]
+topo=0.
+format='(F6.3)'
Index: trunk/UTIL/IDLplot/RESERVE/model_levels.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/model_levels.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/model_levels.pro	(revision 1185)
@@ -0,0 +1,95 @@
+pro model_levels, plotlev
+;; first is one (as in gw.def)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+file = './zefolder/'
+file = file + 'wrfout_d01_2024-03-21_00:00:00'
+
+file = './wrfout_d01_9999-09-09_09:00:00' 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;
+;; ini
+;;
+;if (n_elements(plotlev) eq 0) then plotlev=7
+
+;set_plot, 'ps'
+;device, filename='model_levels.ps'
+
+;
+; constantes
+;
+grav = 3.72
+
+;
+; retrieve model geopotential
+;
+openr,unit,'heights.dat',/get_lun,error=err
+;IF (err ne 0) THEN BEGIN
+	getcdf, $
+	        file=file, $
+	        charvar='PHTOT', $
+	        invar=geop
+        getcdf, $
+                file=file, $
+                charvar='HGT', $
+                invar=hgt
+;	save, geop, filename='heights.dat'
+;ENDIF ELSE BEGIN
+;	restore, filename='heights.dat'
+;ENDELSE
+
+;
+; size
+;
+s = size(geop)
+nx = s[1] ;& print, nx 
+ny = s[2] ;& print, ny
+nz = s[3] ;& print, nz
+nt = s[4] ;& print, nt
+
+if (n_elements(plotlev) eq 0) then plotlev=nz-1
+
+for lev = 1, nz-1 do begin
+
+print, '*************************************************************************'
+print, 'model level ', lev
+ 
+;
+; heights of model levels
+;
+;height = (geop(*,*,lev-1,*) - geop(*,*,0.,*)) / grav
+height = fltarr(nx,ny,nt)
+for i=0,nt-1 do height(*,*,i) = geop(*,*,lev-1,i) / grav - hgt(*,*)
+
+;
+; spatial mean (temporal variations)
+;
+yes = TOTAL(TOTAL(height,1),1) / float(nx) / float(ny)
+print, 'spat. mean (temp. var.) ', mean(yes), max(yes), min(yes);, max(yes) - min(yes)
+
+;
+; temporal mean (spatial variations)
+;
+yet = TOTAL(height,3) / float(nt)  
+print, 'temp. mean (spat. var.) ', mean(yet), max(yet), min(yet);, max(yet) - min(yet)
+
+;
+; complete mean
+;
+ye = TOTAL(TOTAL(TOTAL(height,1),1),1) / float(nx) / float(ny) / float(nt)
+print, '******* mean ', ye 
+
+if (lev eq plotlev) then begin
+	!p.multi=[0,2,1]
+	contour, yet, /cell_fill, nlevels=30, title=string(min(yet))+string(max(yet))
+	plot, yes, yrange=[min(yes),max(yes)]
+	stop
+endif
+
+endfor
+
+;device, /close
+end
Index: trunk/UTIL/IDLplot/RESERVE/model_levels.sh
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/model_levels.sh	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/model_levels.sh	(revision 1185)
@@ -0,0 +1,4 @@
+#! /bin/bash
+
+\rm model_levels.txt
+echo "model_levels & exit" | /distrib/local/rsi/idl_6.1/bin/idl > model_levels.txt
Index: trunk/UTIL/IDLplot/RESERVE/movie.idl_old
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/movie.idl_old	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/movie.idl_old	(revision 1185)
@@ -0,0 +1,55 @@
+;;---------------------------------------
+;  MOVIES
+;
+;  check parameters then type:
+;
+;  @movie.idl
+;
+;;---------------------------------------
+
+@user.idl
+
+denom=plot+'_'+coord+'_'+field1
+
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+folder+'/'+coord+'.input.ctl input.ctl'
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+folder+'/'+coord+'.input.dat input.dat'
+
+SPAWN, '\rm map_latlon_user'
+SPAWN, 'tail -15 user.idl > map_latlon_user'
+.compile map_latlon
+
+SPAWN, '\rm section_user'
+SPAWN, 'tail -15 user.idl > section_user'
+.compile section
+
+for i=1,num do $
+	out_wrf, $
+	plot=plot, $
+	field1=field1, $
+	field2=field2, $
+	when=i, $
+	winds=winds, $
+	level=level,$
+        save_data=yeah,$
+	topo=topo,$
+	range=range,$
+	colors=colors, $
+	nlon=nlon, $
+	nlat=nlat 
+
+print, 'generating movie ...'
+SPAWN, 'rm -rf temp'
+SPAWN, 'mkdir temp'
+SPAWN, 'mv -f '+denom+'??.ps temp'
+SPAWN, 'cp bigconvert200 temp'
+SPAWN, 'cd temp ; bigconvert200 *.ps ; convert -delay 60 *.png movie.gif ; cd ..'
+if (nomovie ne 'yes') then SPAWN, 'animate temp/movie.gif &' 
+print, 'done'
+SPAWN, 'mv -f temp/'+denom+'??.ps '+folder+'/'
+SPAWN, 'mv -f temp/movie.gif '+folder+'/'+denom+'.gif'
+SPAWN, 'mv -f temp/'+denom+'??.png '+folder+'/'
+if (backup_data eq 'yes') then SPAWN, 'cp -f namelist.ARWpost '+folder+'/'+coord+'.namelist.ARWpost'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.ctl '+folder+'/'+coord+'.input.ctl'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.dat '+folder+'/'+coord+'.input.dat'
+
+SPAWN, 'cp -f user.idl '+folder+'/'+denom+'.idl'
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/movie.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/movie.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/movie.idl	(revision 1185)
@@ -0,0 +1,85 @@
+;;---------------------------------------
+;  MOVIE
+;
+;  **** DO NOT MODIFY ****
+;
+;  set parameters in plot.def then type:
+;
+;  @movie.idl
+;
+;;---------------------------------------
+
+field1='' & field2='' & winds=''
+backup_data='no' & already_data='no'  	
+datafolder='./' & plotfolder='./'
+nomovie='yes'
+topo=0
+extract='no'
+
+SPAWN, '\rm user.idl'
+SPAWN, 'grep -v grep plot.def > user.idl'
+
+;; to avoid dumb and useless warnings from IDL
+space=0. & altitude=0. & lon=0. & lat=0.
+what_I_plot=0. & title_user='' & missing_value=0.
+
+@user.idl
+if (nam5 eq " interp_method = 0 ") then coord='height'
+if ((nam5 eq " interp_method = 1 ") and (tabnam(0) lt tabnam(1))) then coord='height'
+
+.compile call_arwpost
+if (extract eq 'yes') then call_arwpost, nam1, nam2, nam3, nam4, nam5, tabnam
+
+denom=plot+'_'+coord+'_'+field1
+if ((field2 ne '') and (topo eq 0)) then denom=denom+'_'+field2
+if (topo eq 1) then denom=denom+'_HGT'
+if (winds(0) ne '') then denom=denom+'_'+winds(0)+winds(1)
+
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.ctl input.ctl'
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.dat input.dat'
+
+SPAWN, '\rm param_plot.idl'
+SPAWN, 'grep grepALL plot.def > param_plot.idl'
+if ((plot eq 'meridional') or (plot eq 'zonal')) then SPAWN, 'grep grepSEC plot.def >> param_plot.idl'
+if (plot eq 'map') then SPAWN, 'grep grepMAP plot.def >> param_plot.idl'
+.compile map_latlon
+.compile section
+
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+for i=1,num do $
+        out_wrf, $
+        plot=plot, $
+        field1=field1, $
+        field2=field2, $
+        when=i, $
+        winds=winds, $
+        level=level,$
+        save_data=yeah,$        ;; data is loaded only once
+        topo=topo,$
+;        range=range,$
+        colors=colors, $
+        nlon=nlon, $
+        nlat=nlat, $
+        save_ps=denom+string(1000+i,'(I0)')
+
+print, 'generating movie ...'
+SPAWN, 'rm -rf temp'
+SPAWN, 'mkdir temp'
+SPAWN, 'mv -f '+denom+'????.ps temp'
+SPAWN, 'cp bigconvert200 temp'
+SPAWN, 'cd temp ; bigconvert200 *.ps ; convert -delay 60 *.png movie.gif ; cd ..'
+if (nomovie ne 'yes') then SPAWN, 'animate temp/movie.gif &' 
+print, 'movie done'
+
+SPAWN, 'mv -f temp/'+denom+'????.ps '+plotfolder+'/'
+SPAWN, 'mv -f temp/movie.gif '+plotfolder+'/'+denom+'.gif'
+SPAWN, 'mv -f temp/'+denom+'????.png '+plotfolder+'/'
+if (backup_data eq 'yes') then SPAWN, 'cp -f namelist.ARWpost '+datafolder+'/'+coord+'.namelist.ARWpost'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.ctl '+datafolder+'/'+coord+'.input.ctl'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.dat '+datafolder+'/'+coord+'.input.dat'
+
+SPAWN, 'cp -f plot.def '+plotfolder+'/'+denom+'.def'
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/out_diagfi.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/out_diagfi.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/out_diagfi.pro	(revision 1185)
@@ -0,0 +1,471 @@
+pro out_diagfi,	$
+		plot=plot_user, $		; 'map', 'profile' (default is 'map')
+	;----------------
+	; input fields
+	;----------------
+		field1=field_user, $		; field to contour: 'u', 'v', 'temp', ... etc ...
+		field2=fieldc_user, $		; field to overplot (contour lines, optional)
+	;------------------------------------------------------
+	; 'map' options (no effect when plot is 'profile')
+	;------------------------------------------------------
+		topo=topo, $			; overplot topography contours (!! must load phisinit !! override field2)
+		winds=winds, $			; option to overplot winds (e.g. =['U','V'])
+		level=level, $			; vertical level subscript (starts at 1 ...)(if -1: all levels)
+	;------------------------------------------------------
+	; 'profile' options (no effect when plot is 'map')
+	;------------------------------------------------------
+		inprofile=inprofile, $		; a profile to compare with ... (override field2)
+		incolumn=incolumn, $		; altitudes ... in case /= column
+		;; NB: inprofile and incolumn may be used to output profiles
+		;; ... reset with inprofile=0, incolumn=0
+	;----------------
+	; choose time
+	;----------------
+		when=when, $			; time subscript (starts at 1 ...)(if -1: first time step)
+	;----------------
+	; plot options
+	;----------------
+		range=range_user, $		; range=[min,max]
+		colors=colors, $		; 16, 32, 64, ... etc
+	;-------------------------
+	; no useless data loading
+	;-------------------------
+		save_data=save_data		; to avoid loading data if already done once
+
+
+;---------------------------------------------------------------------------
+;
+; A general routine to plot diagfi.nc GCM outputs
+;
+; USE: see out_wrf
+;
+;---------------------------------------------------------------------------
+; A. Spiga, August 2007, adding plot keyword September 2007
+;---------------------------------------------------------------------------
+
+
+
+;-------------------------------------
+; default settings and user settings
+;-------------------------------------
+charend=''
+diff_scale=0  ;1
+if (n_elements(plot_user) eq 0) then plot_user='map'
+if (n_elements(field_user) eq 0) then field_user='all'
+if (n_elements(level) eq 0) then level=-1
+if (n_elements(when) eq 0) then when=-1
+if (n_elements(colors) eq 0) then colors=32
+if (n_elements(minfield_init)*n_elements(maxfield_init) eq 0) then begin
+	minfield_init = 0.
+	maxfield_init = 0.
+endif
+
+if (n_elements(range_user) eq 2) then begin
+	minfield_init=float(range_user(0))
+	maxfield_init=float(range_user(1))
+	print, 'setting user limits !', minfield_init, maxfield_init 
+	diff_scale=1
+endif
+
+
+
+;******************************************************************************
+;
+; BEGIN: different from out_wrf
+;
+;******************************************************************************
+
+;TEMP TEMP
+vert_coord='sigma'
+;vert_coord='pressure'
+;vert_coord='height'
+;TEMP TEMP
+
+;----------------------
+; set parameters
+;----------------------
+file='input.diagfi'
+if (n_elements(topo) ne 0) then fieldc_user='phisinit'	;case with topography
+
+
+
+;----------------------------------------------------
+; Open diagfi file GCM and get coordinates & field
+;----------------------------------------------------
+cdfid = ncdf_open(file)
+
+print, 'read coord ...'
+varid=ncdf_varid(cdfid,'latitude')
+        ncdf_varget, cdfid, varid, lat_gcm
+varid=ncdf_varid(cdfid,'longitude')
+        ncdf_varget, cdfid, varid, lon_gcm
+varid=ncdf_varid(cdfid,'Time')
+        ncdf_varget, cdfid, varid, hour
+lon=lon_gcm
+west_east=n_elements(lon)
+lat=lat_gcm
+south_north=n_elements(lat)
+print, 'done !'
+;;print, 'time ...', hour*24 MOD 24, ' hours and day number ', ceil(hour)
+
+; field
+if (n_elements(save_data) eq 0) then begin
+	print, 'read data ...'
+	varid=ncdf_varid(cdfid,field_user)
+		ncdf_varget, cdfid, varid, var
+		bottom_top=n_elements(var(0,0,*,0))
+		time=n_elements(var(0,0,0,*))
+;save_array=fltarr(3,west_east,south_north,bottom_top,time)
+;save_array(0,*,*,*,*)=var(*,*,*,*)
+;;**NB: ralentit beaucoup
+	print, 'done !'
+endif else begin	
+	var=reform(save_data(0,*,*,*,*))
+		bottom_top=n_elements(var(0,0,*,0))
+		time=n_elements(var(0,0,0,*))
+endelse
+
+print, 'vertical levels in file ... ', bottom_top
+print, 'time steps in file ...', time
+
+
+
+	;-----------------------------
+	; min/max on the whole field
+	;-----------------------------
+	w=where(abs(var) lt 1e30)
+	if (w(0) ne -1) then begin
+		minfield=min(var[w])
+		maxfield=max(var[w])
+			;;; manage unvalid points
+			;;;w=where(var eq 1e37)
+			;;;if (w(0) ne -1) then var[w]=!Values.F_NAN
+	endif else begin
+		var=0
+		print, 'no valid values in this field', charvar 
+	endelse
+
+
+
+;---------------------
+; Get altitude
+;---------------------
+if (vert_coord ne 'pressure') then begin
+	print, 'read altitude ...'
+	varid=ncdf_varid(cdfid,'aps')
+        	ncdf_varget, cdfid, varid, aps
+	varid=ncdf_varid(cdfid,'bps')
+        	ncdf_varget, cdfid, varid, bps
+	varid=ncdf_varid(cdfid,'ps')
+        	ncdf_varget, cdfid, varid, ps
+	varid=ncdf_varid(cdfid,'altitude')
+        	ncdf_varget, cdfid, varid, z
+	print, 'done !'
+endif else begin
+	print, 'read altitude ...'
+	varid=ncdf_varid(cdfid,'altitude')
+        	ncdf_varget, cdfid, varid, z
+	z=z/100.   ;mbar
+	print, 'done !'
+endelse
+
+
+;-------------
+; Get winds
+;-------------
+if (n_elements(winds) ne 0) then begin
+if (n_elements(save_data) eq 0) then begin
+	print, 'read winds ...'
+	varid=ncdf_varid(cdfid,winds(0))
+		ncdf_varget, cdfid, varid, u
+	varid=ncdf_varid(cdfid,winds(1))
+		ncdf_varget, cdfid, varid, v
+	;save_array(1,*,*,*,*)=u(*,*,*,*)
+	;save_array(2,*,*,*,*)=v(*,*,*,*)
+	print, 'done !'
+endif else begin	
+	u=reform(save_data(1,*,*,*,*))
+	v=reform(save_data(2,*,*,*,*))
+endelse
+endif
+
+;-------------------------------
+; Get another field to contour
+;-------------------------------
+if (n_elements(fieldc_user) ne 0) then begin
+	print, 'get alternate field ...'
+	varid=ncdf_varid(cdfid,fieldc_user)
+		ncdf_varget, cdfid, varid, varcontour
+	print, 'done !'
+endif
+
+
+;;-------------------------------
+;; Save data for further use ...
+;;-------------------------------
+;if (n_elements(save_data) eq 0) then begin
+;	save_data=save_array
+;	save_array=0. ;free 'save_array' array
+;endif
+
+
+;---------------------------------
+; Some stuff for continuity
+;---------------------------------
+;;if (vert_coord ne 'pressure') then surfpres=reform(ps(*,*,nt))
+;;A CORRIGER - A METTRE DANS LA BOUCLE
+if (vert_coord ne 'pressure') then surfpres=reform(ps(*,*,0))
+if (vert_coord eq 'sigma') then begin
+	z=aps/surfpres(0,0)+bps
+	z=z*100.
+	vert_coord='model_level'
+endif
+charend='_diagfi'
+
+case field_user of 
+'temp': charvar='tk'
+'u': charvar='U'
+'v': charvar='V'
+'ps': charvar='PSFC'
+else:
+endcase
+
+;;
+;;
+
+
+;******************************************************************************
+;
+; END: different from out_wrf
+;
+;******************************************************************************
+
+
+
+;----------------------
+; initialize graphics
+;----------------------
+
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+if (when ne -1) then charend=charend+string(when, '(I0)')
+
+set_plot, 'ps'
+device, filename=plot_user+'_'+vert_coord+'_'+charvar+charend+'.ps', /color
+
+case charvar of
+'tk': begin
+	title='Temperature (K)'
+	pal=3
+end
+'U': begin
+	title='Zonal wind (!Nm!N.s!U-1!N)'
+	pal=33
+end
+'V': begin
+	title='Zonal wind (!Nm!N.s!U-1!N)'
+	pal=33
+end
+'pressure': begin
+	title='Pressure (hPa)'
+	pal=16
+end
+'height': begin
+	title='Height (km)'
+	pal=16
+end
+'T': title='Potential temperature departure from t0 (K)'
+'W': title='Vertical wind (!Ncm!N.s!U-1!N)'
+else: title=''
+endcase
+title_save=title
+
+
+
+;---------------------------------
+; choose positioning ...
+;---------------------------------
+
+case plot_user of
+'map': begin
+;
+; 1. map: looping on vertical levels
+;
+	if (level eq -1) then begin
+		theloopmin=0
+		theloopmax=bottom_top-1
+	endif else begin
+		theloopmin=level-1 ;!! IDL arrays starts at 0
+		theloopmax=level-1
+	endelse	
+	if (when eq -1) then nt = 0 else nt=when-1
+end
+'profile': begin
+;
+; 2. profile: looping on time
+;
+	;;discrete=4
+	title_axis=strarr(2)
+	title_axis(0)=title_save
+	if (when eq -1) then begin
+		theloopmin=0
+		theloopmax=time-1
+	endif else begin
+		theloopmin=when-1 ;!! IDL arrays starts at 0
+		theloopmax=when-1
+	endelse	
+
+	column=z
+	case vert_coord of
+		'height': title_axis(1)='Altitude (km)'
+		'pressure': begin
+			H=10.
+			p0=6.1
+			column=H*alog(p0/z)
+			title_axis(1)='Log-Pressure altitude (km)'
+		end
+		'model_level': title_axis(1)='Model level'
+	endcase
+
+;****TEMP
+nx=round(west_east/2)
+ny=round(south_north/2)
+;****TEMP
+
+	displaylat=float(round(lat(ny)*100))/100.
+	displaylon=float(round(lon(nx)*100))/100.
+	description='WRF Profile at latitude '+string(displaylat,format='(1F6.2)')+$
+	'!Uo'+'!N and longitude '+string(displaylon,format='(1F7.2)')+'!Uo!N '
+	title=description
+
+end
+else: stop
+endcase
+
+
+;-------------
+; plot loop
+;-------------	
+for theloop=theloopmin,theloopmax do begin
+
+case plot_user of
+'map': begin
+	;
+	; case 1: map
+	;	
+	case vert_coord of
+	'height': charlev=string(round(z(theloop)*1000.),'(I0)')+' m'
+	'pressure': charlev=string(round(z(theloop)*100.),'(I0)')+' Pa'
+	'model_level': charlev=string(round(z(theloop)),'(I0)')
+	endcase
+	title=title_save+' at level '+charlev
+	print, title
+
+	;-------------
+	; draw map
+	;-------------
+
+	what_I_plot=var[*,*,theloop,nt]
+
+	if (diff_scale eq 0) then begin
+		minfield_init=minfield	;-same scale for all levels 
+		maxfield_init=maxfield	;-same scale for all levels
+	endif
+	if (n_elements(fieldc_user) eq 0) then begin
+		overcontour=0.
+	endif else begin
+		if (n_elements(topo) ne 0) then begin
+			overcontour=varcontour[*,*,0,0] ; other levels than 0 are blank !
+		endif else begin
+			overcontour=varcontour[*,*,theloop,nt]
+		endelse
+	endelse
+	if (n_elements(winds) eq 0) then begin
+		overvector_x=0.
+		overvector_y=0.
+	endif else begin
+		overvector_x=u[*,*,theloop,nt]
+		overvector_y=v[*,*,theloop,nt]
+	endelse
+
+
+	map_latlon, $
+		what_I_plot, $
+		lon, $
+		lat, $
+		ct=pal, $
+		minfield=minfield_init, $
+		maxfield=maxfield_init, $
+		overcontour=overcontour, $
+		overvector_x=overvector_x, $
+		overvector_y=overvector_y, $
+		colors=colors, $
+		title=title
+end
+'profile': begin
+	;
+	; case 2: profile
+	;
+	print, title
+
+	what_I_plot=var[nx,ny,*,theloop]
+	if (diff_scale eq 0) then begin
+		minfield_init=minfield	;-same scale for all levels 
+		maxfield_init=maxfield	;-same scale for all levels
+	endif
+	if (n_elements(fieldc_user) eq 0) then begin
+		overcontour=0.
+		overcontourz=0.
+	endif else begin
+		overcontour=varcontour[nx,ny,*,theloop]
+		overcontourz=0.
+	endelse
+	if (n_elements(inprofile) gt 1) then begin
+		overcontour=inprofile
+		overcontourz=0.
+		if (n_elements(incolumn) gt 1) then overcontourz=incolumn
+	endif
+
+	profile, $
+		what_I_plot, $				; 1D vertical profile
+		column, $				; altitudes	
+	;	alt=alt, $				; altitude range [altmin, altmax]
+		minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+		maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+		inprofile=overcontour, $		; another vertical profile to overplot
+		incolumn=overcontourz, $		; altitudes of the other vertical profile (in case /= column)
+		title_plot=title, $			; title of the plot ('Profile' is default)
+		title_axis=title_axis, $		; title of the [x,y] axis (['Field','Altitude'] is default)
+	;	mention=mention, $			; add text precision within the plot window (default is nothing or '')
+		discrete=discrete			; show the profile points (= type of points in !psym)
+end
+else: 
+endcase
+
+
+
+endfor
+device, /close
+
+	; save the profiles for another plot (last of the time loop)
+	if ((n_elements(inprofile) le 1) and (plot_user eq 'profile')) then begin
+		inprofile=what_I_plot
+		incolumn=column
+	endif
+
+
+;******************************************************************************
+;
+; BEGIN: different from out_wrf
+;
+;******************************************************************************
+;;;skip:
+;;;endfor
+
+end
+
+
+
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/out_diagfi_new.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/out_diagfi_new.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/out_diagfi_new.pro	(revision 1185)
@@ -0,0 +1,768 @@
+pro out_diagfi, $
+		plot=plot_user, $		; 'map', 'profile', 'hovmuller', 'meridional', 'zonal' (default is 'map')
+	;----------------
+	; input fields
+	;----------------
+		field1=field_user, $		; field to contour: 'U', 'V', 'tk', ... etc ...
+		field2=fieldc_user, $		; field to overplot (contour lines, optional)
+	;------------------------------------------------------
+	; 'map' options (no effect when plot is 'profile')
+	;------------------------------------------------------
+		topo=topo, $			; overplot topography contours (!! must load HGT !! override field2)
+		winds=winds, $			; option to overplot winds (e.g. =['U','V'])
+		level=level, $			; vertical level subscript (starts at 1 ...)(if -1: all levels)
+	;------------------------------------------------------
+	; 'profile' options (no effect when plot is 'map')
+	;------------------------------------------------------
+		inprofile=inprofile, $		; a profile to compare with ... (override field2)
+		incolumn=incolumn, $		; altitudes ... in case /= column
+		;; NB: inprofile and incolumn may be used to output profiles
+		;; ... reset with inprofile=0, incolumn=0
+	;----------------
+	; choose time
+	;----------------
+		when=when, $			; time subscript (starts at 1 ...)(if -1: first time step)
+	;----------------
+	; choose latitude/longitude
+	;----------------
+		nlat=nlat, $			; latitude subscript (starts at 1 ...)(if -1: all latitudes)(default is middle)
+		nlon=nlon, $			; longitude subscript (starts at 1 ...)(if -1: all longitudes)(default is middle)
+	;----------------
+	; plot options
+	;----------------
+		range=range_user, $		; range=[min,max]
+		colors=colors, $		; 16, 32, 64, ... etc
+	;-------------------------
+	; no useless data loading
+	;-------------------------
+		save_data=save_data		; to avoid loading data if already done once
+
+
+
+;---------------------------------------------------------------------------
+;
+; A general routine to plot ARWpost outputs
+;
+; USE:
+; - out_wrf	(will plot everything !)
+; - out_wrf, field1='tk', range=[160,300]
+;
+; - out_wrf, field1='pressure', field2='tk'
+; - out_wrf, field1=TSK, field2=HGT, winds=['U','V'] 
+;
+; - out_wrf, save_data=field
+;   ... then next calls including 'save_data=field' won't include the data loading 
+;
+; - out_wrf, field1='tk', winds=['umet','vmet'], topo=1, save_data=yeah, level=1, when=2
+;
+; - out_wrf, field1='tk', plot='profile'
+;
+; - out_wrf, plot='profile', field1='tk', when=1, inprofile=inprofile, incolumn=incolumn
+;   out_diagfi, plot='profile', field1='temp', when=112, inprofile=inprofile, incolumn=incolumn 	
+;
+; - out_wrf, plot='meridional',field1='U'
+;
+; - out_wrf, plot='hovmuller',field1='TSK'
+;
+; - out_wrf, plot='zonal',field1='V', nlat=-1
+; 
+;---------------------------------------------------------------------------
+; A. Spiga, August 2007, adding plot keyword September 2007
+;---------------------------------------------------------------------------
+
+
+    
+
+
+;-------------------------------------
+; default settings and user settings
+;-------------------------------------
+diff_scale=0  ;;1
+charend=''
+format=''
+if (n_elements(plot_user) eq 0) then plot_user='map'
+if (n_elements(field_user) eq 0) then field_user='all'
+if (n_elements(level) eq 0) then level=-1
+if (n_elements(when) eq 0) then when=-1
+;;if (n_elements(nlon) eq 0) then nlon=-1
+;;if (n_elements(nlat) eq 0) then nlat=-1
+if (n_elements(colors) eq 0) then colors=32
+if (n_elements(minfield_init)*n_elements(maxfield_init) eq 0) then begin
+	minfield_init = 0.
+	maxfield_init = 0.
+endif
+
+if (n_elements(range_user) eq 2) then begin
+	minfield_init=float(range_user(0))
+	maxfield_init=float(range_user(1))
+	print, 'setting user limits !', minfield_init, maxfield_init 
+	diff_scale=1
+endif
+
+if (n_elements(topo) ne 0) then fieldc_user='HGT'	;case with topography
+
+
+
+;******************************************************************************
+;
+; BEGIN: different from out_wrf
+;
+;******************************************************************************
+
+;TEMP TEMP
+vert_coord='sigma'
+;vert_coord='pressure'
+;vert_coord='height'
+;TEMP TEMP
+
+;----------------------
+; set parameters
+;----------------------
+file='input.diagfi'
+if (n_elements(topo) ne 0) then fieldc_user='phisinit'	;case with topography
+
+
+
+;----------------------------------------------------
+; Open diagfi file GCM and get coordinates & field
+;----------------------------------------------------
+cdfid = ncdf_open(file)
+
+print, 'read coord ...'
+varid=ncdf_varid(cdfid,'latitude')
+        ncdf_varget, cdfid, varid, lat_gcm
+varid=ncdf_varid(cdfid,'longitude')
+        ncdf_varget, cdfid, varid, lon_gcm
+varid=ncdf_varid(cdfid,'Time')
+        ncdf_varget, cdfid, varid, hour
+lon=lon_gcm
+west_east=n_elements(lon)
+lat=lat_gcm
+south_north=n_elements(lat)
+print, 'done !'
+;;print, 'time ...', hour*24 MOD 24, ' hours and day number ', ceil(hour)
+
+; field
+if (n_elements(save_data) eq 0) then begin
+	print, 'read data ...'
+	varid=ncdf_varid(cdfid,field_user)
+		ncdf_varget, cdfid, varid, var
+		bottom_top=n_elements(var(0,0,*,0))
+		time=n_elements(var(0,0,0,*))
+;save_array=fltarr(3,west_east,south_north,bottom_top,time)
+;save_array(0,*,*,*,*)=var(*,*,*,*)
+;;**NB: ralentit beaucoup
+	print, 'done !'
+endif else begin	
+	var=reform(save_data(0,*,*,*,*))
+		bottom_top=n_elements(var(0,0,*,0))
+		time=n_elements(var(0,0,0,*))
+endelse
+
+print, 'vertical levels in file ... ', bottom_top
+print, 'time steps in file ...', time
+
+
+
+	;-----------------------------
+	; min/max on the whole field
+	;-----------------------------
+	w=where(abs(var) lt 1e30)
+	if (w(0) ne -1) then begin
+		minfield=min(var[w])
+		maxfield=max(var[w])
+			;;; manage unvalid points
+			;;;w=where(var eq 1e37)
+			;;;if (w(0) ne -1) then var[w]=!Values.F_NAN
+	endif else begin
+		var=0
+		print, 'no valid values in this field', charvar 
+	endelse
+
+
+
+;---------------------
+; Get altitude
+;---------------------
+if (vert_coord ne 'pressure') then begin
+	print, 'read altitude ...'
+	varid=ncdf_varid(cdfid,'aps')
+        	ncdf_varget, cdfid, varid, aps
+	varid=ncdf_varid(cdfid,'bps')
+        	ncdf_varget, cdfid, varid, bps
+	varid=ncdf_varid(cdfid,'ps')
+        	ncdf_varget, cdfid, varid, ps
+	varid=ncdf_varid(cdfid,'altitude')
+        	ncdf_varget, cdfid, varid, z
+	print, 'done !'
+endif else begin
+	print, 'read altitude ...'
+	varid=ncdf_varid(cdfid,'altitude')
+        	ncdf_varget, cdfid, varid, z
+	z=z/100.   ;mbar
+	print, 'done !'
+endelse
+
+
+;-------------
+; Get winds
+;-------------
+if (n_elements(winds) ne 0) then begin
+if (n_elements(save_data) eq 0) then begin
+	print, 'read winds ...'
+	varid=ncdf_varid(cdfid,winds(0))
+		ncdf_varget, cdfid, varid, u
+	varid=ncdf_varid(cdfid,winds(1))
+		ncdf_varget, cdfid, varid, v
+	;save_array(1,*,*,*,*)=u(*,*,*,*)
+	;save_array(2,*,*,*,*)=v(*,*,*,*)
+	print, 'done !'
+endif else begin	
+	u=reform(save_data(1,*,*,*,*))
+	v=reform(save_data(2,*,*,*,*))
+endelse
+endif
+
+;-------------------------------
+; Get another field to contour
+;-------------------------------
+if (n_elements(fieldc_user) ne 0) then begin
+	print, 'get alternate field ...'
+	varid=ncdf_varid(cdfid,fieldc_user)
+		ncdf_varget, cdfid, varid, varcontour
+	print, 'done !'
+endif
+
+
+;;-------------------------------
+;; Save data for further use ...
+;;-------------------------------
+;if (n_elements(save_data) eq 0) then begin
+;	save_data=save_array
+;	save_array=0. ;free 'save_array' array
+;endif
+
+
+;---------------------------------
+; Some stuff for continuity
+;---------------------------------
+;;if (vert_coord ne 'pressure') then surfpres=reform(ps(*,*,nt))
+;;A CORRIGER - A METTRE DANS LA BOUCLE
+if (vert_coord ne 'pressure') then surfpres=reform(ps(*,*,0))
+if (vert_coord eq 'sigma') then begin
+	z=aps/surfpres(0,0)+bps
+	z=z*100.
+	vert_coord='model_level'
+endif
+charend='_diagfi'
+
+case field_user of 
+'temp': charvar='tk'
+'u': charvar='U'
+'v': charvar='V'
+'ps': charvar='PSFC'
+else:
+endcase
+
+;;
+;;
+
+
+;******************************************************************************
+;
+; END: different from out_wrf
+;
+;******************************************************************************
+
+
+
+;----------------------
+; initialize graphics
+;----------------------
+
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+if (when ne -1) then charend=charend+string(when, '(I0)')
+
+set_plot, 'ps'
+device, filename=plot_user+'_'+vert_coord+'_'+charvar+charend+'.ps', /color
+
+case charvar of
+'HGT': begin
+        title='Topography (km)'
+	pal=16
+	level=1
+	format='(F7.0)'
+end
+'tk': begin
+	title='Temperature (K)'
+	pal=3
+	format='(F4.0)'
+end
+'TSK': begin
+	title='Surface Temperature (K)'
+	pal=3
+	level=1
+end
+'U': begin
+	title='Zonal wind (!Nm!N.s!U-1!N)'
+	pal=33
+end
+'V': begin
+	title='Meridional wind (!Nm!N.s!U-1!N)'
+	pal=33
+end
+'pressure': begin
+	title='Pressure (hPa)'
+	pal=16
+end
+'height': begin
+	title='Height (km)'
+	pal=16
+end
+'T': title='Potential temperature departure from t0 (K)'
+'W': begin
+	title='Vertical wind (!Nm!N.s!U-1!N)'
+	pal=16
+	format='(F6.2)'
+end
+else: begin
+	title=''
+	pal=33
+end
+endcase
+title_save=title
+
+
+
+;---------------------------------
+; choose positioning ...
+;---------------------------------
+
+case plot_user of
+'map': begin
+;
+; 1. map: looping on vertical levels
+;
+	if (level eq -1) then begin
+		theloopmin=0
+		theloopmax=bottom_top-1
+	endif else begin
+		theloopmin=level-1 ;!! IDL arrays starts at 0
+		theloopmax=level-1
+	endelse	
+	if (when eq -1) then nt = 0 else nt=when-1
+end
+'profile': begin
+;
+; 2. profile: looping on time
+;
+	;;discrete=4
+	title_axis=strarr(2)
+	title_axis(0)=title_save
+	if (when eq -1) then begin
+		theloopmin=0
+		theloopmax=time-1
+	endif else begin
+		theloopmin=when-1 ;!! IDL arrays starts at 0
+		theloopmax=when-1
+	endelse	
+
+	column=z
+	case vert_coord of
+		'height': title_axis(1)='Altitude (km)'
+		'pressure': begin
+			H=10.
+			p0=6.1
+			column=H*alog(p0/z)
+			title_axis(1)='Log-Pressure altitude (km)'
+		end
+		'model_level': title_axis(1)='Model level'
+	endcase
+
+	displaylat=float(round(lat(nlat)*100))/100.
+	displaylon=float(round(lon(nlon)*100))/100.
+	description='WRF Profile at latitude '+string(displaylat,format='(1F6.2)')+$
+	'!Uo'+'!N and longitude '+string(displaylon,format='(1F7.2)')+'!Uo!N '
+	title=description
+end
+'hovmuller': begin
+;
+; 3. hovmuller: looping on vertical levels
+;
+	if (level eq -1) then begin
+		theloopmin=0
+		theloopmax=bottom_top-1
+	endif else begin
+		theloopmin=level-1 ;!! IDL arrays starts at 0
+		theloopmax=level-1
+	endelse	
+end
+'zonal': begin
+;
+; 4. zonal: looping on latitude
+;
+	if (nlat eq -1) then begin
+		theloopmin=0
+		theloopmax=south_north-1
+	endif else begin
+		theloopmin=nlat-1 ;!! IDL arrays starts at 0
+		theloopmax=nlat-1
+	endelse	
+	if (when eq -1) then nt = 0 else nt=when-1
+	case vert_coord of
+		'height': charlev='Altitude (km)'
+		'pressure': begin
+			H=10.
+			p0=6.1
+			z=H*alog(p0/z)
+			charlev='Log-Pressure altitude (km)'
+		end
+		'model_level': charlev='Model level'
+	endcase
+end
+'meridional': begin
+;
+; 5. meridional: looping on longitude
+;
+	if (nlon eq -1) then begin
+		theloopmin=0
+		theloopmax=west_east-1
+	endif else begin
+		theloopmin=nlon-1 ;!! IDL arrays starts at 0
+		theloopmax=nlon-1
+	endelse	
+	if (when eq -1) then nt = 0 else nt=when-1
+	case vert_coord of
+		'height': charlev='Altitude (km)'
+		'pressure': begin
+			H=10.
+			p0=6.1
+			z=H*alog(p0/z)
+			charlev='Log-Pressure altitude (km)'
+		end
+		'model_level': charlev='Model level'
+	endcase
+end
+else: stop
+endcase
+
+
+;-------------
+; plot loop
+;-------------	
+for theloop=theloopmin,theloopmax do begin
+
+case plot_user of
+'map': begin
+	;
+	; case 1: map
+	;	
+	case vert_coord of
+	'height': charlev=string(round(z(theloop)*1000.),'(I0)')+' m'
+	'pressure': charlev=string(round(z(theloop)*100.),'(I0)')+' Pa'
+	'model_level': charlev=string(round(z(theloop)),'(I0)')
+	endcase
+	title=title_save+' at level '+charlev
+	print, title
+
+	;-------------
+	; draw map
+	;-------------
+
+	what_I_plot=var[*,*,theloop,nt]
+
+	if (diff_scale eq 0) then begin
+		minfield_init=minfield	;-same scale for all levels 
+		maxfield_init=maxfield	;-same scale for all levels
+	endif
+	if (n_elements(fieldc_user) eq 0) then begin
+		overcontour=0.
+	endif else begin
+		if (n_elements(topo) ne 0) then begin
+			overcontour=varcontour[*,*,0,0] ; other levels than 0 are blank !
+		endif else begin
+			overcontour=varcontour[*,*,theloop,nt]
+		endelse
+	endelse
+	if (n_elements(winds) eq 0) then begin
+		overvector_x=0.
+		overvector_y=0.
+	endif else begin
+		overvector_x=u[*,*,theloop,nt]
+		overvector_y=v[*,*,theloop,nt]
+
+
+;--------------------------------------------------------
+; NB: you can use the winds fields to combine variables 
+;--------------------------------------------------------
+if (n_elements(winds) eq 2) then begin
+	;** HYDROSTATIC REDUCTION TO LEVEL OF REFERENCE
+	if ((winds(0) eq 'tk') and (winds(1) eq 'HGT')) then begin
+	overvector_x=reform(u[*,*,6,nt])	;;T 1km
+	overvector_y=reform(v[*,*,0,nt])	;;topo (m)
+	zref=mean(overvector_y)
+	;zref=median(overvector_y)
+	;zref=(max(overvector_y)-min(overvector_y))/2.
+	;zref=3000.
+	print, 'zref', zref
+	H=192.*overvector_x/3.72	;unit is m
+	what_I_plot=what_I_plot*exp((overvector_y-zref)/H)
+	overvector_x=0
+	overvector_y=0
+	endif
+endif
+;--------------------------------------------------------
+; NB: you can use the winds fields to combine variables
+;--------------------------------------------------------
+
+	endelse
+
+;;******************TEMP
+;;pressure anomaly
+;nday=3
+;oneday=reform(var[*,*,theloop,0:nday-1])
+;what_I_plot=what_I_plot-(total(oneday,3)/float(nday))
+;;******************TEMP
+
+	map_latlon, $
+		what_I_plot, $
+		lon, $
+		lat, $
+		ct=pal, $
+		minfield=minfield_init, $
+		maxfield=maxfield_init, $
+		overcontour=overcontour, $
+		overvector_x=overvector_x, $
+		overvector_y=overvector_y, $
+		colors=colors, $
+		title=title, $
+		format=format	
+end
+'profile': begin
+	;
+	; case 2: profile
+	;
+	print, title
+
+	what_I_plot=var[nlon,nlat,*,theloop]
+	if (diff_scale eq 0) then begin
+		minfield_init=minfield	;-same scale for all levels 
+		maxfield_init=maxfield	;-same scale for all levels
+	endif
+	if (n_elements(fieldc_user) eq 0) then begin
+		overcontour=0.
+		overcontourz=0.
+	endif else begin
+		overcontour=varcontour[nlon,nlat,*,theloop]
+		overcontourz=0.
+	endelse
+	if (n_elements(inprofile) gt 1) then begin
+		overcontour=inprofile
+		overcontourz=0.
+		if (n_elements(incolumn) gt 1) then overcontourz=incolumn
+	endif
+
+	profile, $
+		what_I_plot, $				; 1D vertical profile
+		column, $				; altitudes	
+	;	alt=alt, $				; altitude range [altmin, altmax]
+		minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+		maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+		inprofile=overcontour, $		; another vertical profile to overplot
+		incolumn=overcontourz, $		; altitudes of the other vertical profile (in case /= column)
+		title_plot=title, $			; title of the plot ('Profile' is default)
+		title_axis=title_axis, $		; title of the [x,y] axis (['Field','Altitude'] is default)
+	;	mention=mention, $			; add text precision within the plot window (default is nothing or '')
+		discrete=discrete			; show the profile points (= type of points in !psym)
+end
+'hovmuller': begin
+	;
+	; case 3: hovmuller
+	;
+	; NB: lat/lon hovmuller 
+	;
+	what_I_plot=reform(var[*,nlat,theloop,*])
+	space=lon
+	temps=findgen(time)*2
+	if (n_elements(fieldc_user) ne 0) then begin
+		overcontour=reform(varcontour[*,nlat,theloop,*])
+	endif else begin
+		overcontour=0.
+	endelse
+	minspace=0.
+	maxspace=0.
+
+;;******************TEMP
+;	minspace=-90.
+;	maxspace=90.
+
+if (n_elements(winds) ne 0) then begin		;;;winds sert à faire des calculs !!
+overvector_x=reform(u[*,nlat,4,*])	;;T 1km
+overvector_y=reform(v[*,nlat,0,*])	;;topo (m)
+zref=median(overvector_y)
+H=192.*overvector_x/3.72	;unit is m
+;print, (overvector_y-zref)/H
+what_I_plot=what_I_plot*exp((overvector_y-zref)/H)
+
+
+endif 
+;oneday=reform(var[*,nlat,0,0:11])
+;slice=(total(oneday,2)/12.)
+;for i=0, n_elements(var[*,0,0,0])-1 do begin
+;	what_I_plot(i,*)=what_I_plot(i,*)-slice(i)
+;endfor
+;;******************TEMP
+
+
+
+
+
+	hovmuller, $
+		what_I_plot, $				; 2D field
+		space, $				; space coordinate
+		temps, $				; time coordinate
+		minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+		maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+		minspace=minspace, $			; minimum value of space window (=0: calculate)
+		maxspace=maxspace, $			; maximum value of space window (=0: calculate)
+		overcontour=overcontour, $		; another 2D field to overplot with contour lines (=0: no)
+		ct=pal, $				; color table (33-rainbow is default)
+		colors=colors, $			; number of colors/levels (32 is default)
+		title=title				; title of the plot ('' is default)
+end
+'zonal': begin
+	;
+	; case 4: zonal section
+	; 
+	displaylat=float(round(lat(theloop)*100))/100.
+	title=title_save+ $
+		' section at latitude '+string(displaylat,format='(1F6.2)')+ $
+		'!Uo!N '
+	print, title
+
+	what_I_plot=reform(var[*,theloop,*,nt])
+	space=lon
+	altitude=z
+
+	if (n_elements(fieldc_user) ne 0) then begin
+		overcontour=reform(varcontour[*,theloop,*,nt])
+	endif else begin
+		overcontour=0.
+	endelse
+
+	if (n_elements(winds) eq 0) then begin
+		overvector_x=0.
+		overvector_y=0.
+	endif else begin
+		overvector_x=reform(u[*,theloop,*,nt])		;;horizontal component
+		overvector_y=reform(v[*,theloop,*,nt])		;;vertical component
+	endelse
+
+	minspace=0.
+	maxspace=0.
+
+	title_user=title
+	title_axis=['Longitude',charlev]
+
+	section, $
+		what_I_plot, $				; 2D field
+		space, $				; horizontal coordinate
+		altitude, $				; altitude coordinate
+		minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+		maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+		minspace=minspace, $			; minimum value of space window (=0: calculate)
+		maxspace=maxspace, $			; maximum value of space window (=0: calculate)
+		overcontour=overcontour, $		; another 2D field to overplot with contour lines (=0: no)
+		overvector_x=overvector_x, $		; wind vector - x component (=0: no)
+		overvector_y=overvector_y, $		; wind vector - y component (=0: no)
+		colors=colors, $			; number of colors/levels (32 is default)
+		title_plot=title_user, $		; title of the plot ('Profile' is default)
+		title_axis=title_axis, $		; title of the [x,y] axis (['Field','Altitude'] is default)
+		ct=pal, $				; color table (33-rainbow is default)
+		format=format
+end	
+'meridional': begin
+	;
+	; case 5: meridional section
+	; 
+	displaylon=float(round(lon(theloop)*100))/100.
+	title=title_save+ $
+		' section at longitude '+string(displaylon,format='(1F7.2)')+ $
+		'!Uo!N '
+	print, title
+
+	what_I_plot=reform(var[theloop,*,*,nt])
+	space=lat
+	altitude=z
+
+	if (n_elements(fieldc_user) ne 0) then begin
+		overcontour=reform(varcontour[theloop,*,*,nt])
+	endif else begin
+		overcontour=0.
+	endelse
+
+	if (n_elements(winds) eq 0) then begin
+		overvector_x=0.
+		overvector_y=0.
+	endif else begin
+		overvector_x=reform(u[theloop,*,*,nt])		;;horizontal component
+		overvector_y=reform(v[theloop,*,*,nt])		;;vertical component
+	endelse
+
+	minspace=0.
+	maxspace=0.
+
+	title_user=title
+	title_axis=['Latitude',charlev]
+
+	section, $
+		what_I_plot, $				; 2D field
+		space, $				; horizontal coordinate
+		altitude, $				; altitude coordinate
+		minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+		maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+		minspace=minspace, $			; minimum value of space window (=0: calculate)
+		maxspace=maxspace, $			; maximum value of space window (=0: calculate)
+		overcontour=overcontour, $		; another 2D field to overplot with contour lines (=0: no)
+		overvector_x=overvector_x, $		; wind vector - x component (=0: no)
+		overvector_y=overvector_y, $		; wind vector - y component (=0: no)
+		colors=colors, $			; number of colors/levels (32 is default)
+		title_plot=title_user, $		; title of the plot ('Profile' is default)
+		title_axis=title_axis, $		; title of the [x,y] axis (['Field','Altitude'] is default)
+		ct=pal					; color table (33-rainbow is default)
+end	
+
+
+
+
+
+
+
+
+else: 
+endcase
+
+
+
+endfor
+device, /close
+
+	; save the profiles for another plot (last of the time loop)
+	if (n_elements(inprofile) le 1) and (plot_user eq 'profile') then begin
+		inprofile=what_I_plot
+		incolumn=column
+	endif
+
+;******************************************************************************
+;
+; BEGIN: different from out_wrf
+;
+;******************************************************************************
+;;;skip:
+;;;endfor
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/out_wrf.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/out_wrf.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/out_wrf.pro	(revision 1185)
@@ -0,0 +1,808 @@
+pro out_wrf, $
+		plot=plot_user, $		; 'map', 'profile', 'hovmuller', 'meridional', 'zonal' (default is 'map')
+	;----------------
+	; input fields
+	;----------------
+		field1=field_user, $		; field to contour: 'U', 'V', 'tk', ... etc ...
+		field2=fieldc_user, $		; field to overplot (contour lines, optional)
+	;------------------------------------------------------
+	; 'map' options (no effect when plot is 'profile')
+	;------------------------------------------------------
+		topo=topo, $			; overplot topography contours (!! must load HGT !! override field2)
+		winds=winds, $			; option to overplot winds (e.g. =['U','V'])
+		level=level, $			; vertical level subscript (starts at 1 ...)(if -1: all levels)
+	;------------------------------------------------------
+	; 'profile' options (no effect when plot is 'map')
+	;------------------------------------------------------
+		inprofile=inprofile, $		; a profile to compare with ... (override field2)
+		incolumn=incolumn, $		; altitudes ... in case /= column
+		;; NB: inprofile and incolumn may be used to output profiles
+		;; ... reset with inprofile=0, incolumn=0
+	;----------------
+	; choose time
+	;----------------
+		when=when, $			; time subscript (starts at 1 ...)(if -1: first time step)
+	;----------------
+	; choose latitude/longitude
+	;----------------
+		nlat=nlat, $			; latitude subscript (starts at 1 ...)(if -1: all latitudes)(default is middle)
+		nlon=nlon, $			; longitude subscript (starts at 1 ...)(if -1: all longitudes)(default is middle)
+	;----------------
+	; plot options
+	;----------------
+;;NB: celles ci sont dorenavant indiquees dans le _user si besoin 
+		range=range_user, $		; range=[min,max]
+		colors=colors, $		; 16, 32, 64, ... etc
+save_ps=file_ps, $
+	;-------------------------
+	; no useless data loading
+	;-------------------------
+		save_data=save_data		; to avoid loading data if already done once
+
+
+
+;---------------------------------------------------------------------------
+;
+; A general routine to plot ARWpost outputs
+;
+; USE:
+; - out_wrf	(will plot everything !)
+; - out_wrf, field1='tk', range=[160,300]
+;
+; - out_wrf, field1='pressure', field2='tk'
+; - out_wrf, field1=TSK, field2=HGT, winds=['U','V'] 
+;
+; - out_wrf, save_data=field
+;   ... then next calls including 'save_data=field' won't include the data loading 
+;
+; - out_wrf, field1='tk', winds=['umet','vmet'], topo=1, save_data=yeah, level=1, when=2
+;
+; - out_wrf, field1='tk', plot='profile'
+;
+; - out_wrf, plot='profile', field1='tk', when=1, inprofile=inprofile, incolumn=incolumn
+;   out_diagfi, plot='profile', field1='temp', when=112, inprofile=inprofile, incolumn=incolumn 	
+;
+; - out_wrf, plot='meridional',field1='U'
+;
+; - out_wrf, plot='hovmuller',field1='TSK'
+;
+; - out_wrf, plot='zonal',field1='V', nlat=-1
+; 
+;---------------------------------------------------------------------------
+; A. Spiga, August 2007, adding plot keyword September 2007
+;---------------------------------------------------------------------------
+
+
+    
+
+
+;-------------------------------------
+; default settings and user settings
+;-------------------------------------
+diff_scale=0  ;;1
+charend=''
+format=''
+if (n_elements(plot_user) eq 0) then plot_user='map'
+if (n_elements(field_user) eq 0) then field_user='all'
+if (n_elements(level) eq 0) then level=-1
+if (n_elements(when) eq 0) then when=-1
+;;if (n_elements(nlon) eq 0) then nlon=-1
+;;if (n_elements(nlat) eq 0) then nlat=-1
+if (n_elements(colors) eq 0) then colors=32
+;if (n_elements(minfield_init)*n_elements(maxfield_init) eq 0) then begin
+if (n_elements(range_user) eq 0) then begin
+	minfield_init = 0.
+	maxfield_init = 0.
+diff_scale=1
+endif
+
+if (n_elements(range_user) eq 2) then begin
+	minfield_init=float(range_user(0))
+	maxfield_init=float(range_user(1))
+	print, 'setting user limits !', minfield_init, maxfield_init 
+	diff_scale=1
+endif
+
+if (n_elements(topo) eq 0) then topo=0
+if (topo eq 1) then fieldc_user='HGT'	;case with topography
+
+if (n_elements(fieldc_user) eq 0) then fieldc_user=''
+
+;goto, squeeze
+;------------------
+; read data
+;------------------
+;
+; read the file generated by ARWpost
+;
+;*********************************************
+if (n_elements(save_data) eq 0) then begin
+	read_dat, field, x, y, z, t, desc_field
+	;save_data=field
+endif else begin
+	read_dat, field, x, y, z, t, desc_field, nodata=1  ; read only the dimensions
+	field=save_data
+	save_data=0.	;;free memory
+endelse
+;;*********************************************
+;; opt: saved IDL files
+;squeeze:
+;restore, filename='OM_nonhydro.idl'
+;field=output
+;;nh=output
+;;restore, filename='OM_hydro.idl'
+;;h=output
+;;field=abs(nh-h)
+;;*********************************************
+
+;
+; dimensions
+;
+lon=x
+west_east=n_elements(x)
+if (n_elements(nlon) eq 0) then begin
+	nlon=round(west_east/2)
+endif 
+if (nlon eq 0) then nlon=round(west_east/2)
+
+lat=y
+south_north=n_elements(y)
+if (n_elements(nlat) eq 0) then begin
+	nlat=round(south_north/2)
+endif
+if (nlat eq 0) then nlat=round(south_north/2)
+	
+bottom_top=n_elements(z)
+
+time=n_elements(t)
+if ((time eq 1) and (plot_user eq 'hovmuller')) then stop
+
+nfields=n_elements(desc_field)
+if (z(0) lt z(1)) then vert_coord='height'
+if (z(0) gt z(1)) then vert_coord='pressure'
+if ((z(0) eq 1.) and (z(bottom_top-1) eq (z(bottom_top-2)+1.))) then vert_coord='model_level'
+;print, 'vert_coord is ... ', vert_coord
+
+;
+; find the field desired by the user
+;
+if (field_user ne 'all') then begin
+	match=-1
+	indice=-1
+	repeat begin
+		indice=indice+1
+		if (indice eq nfields) $
+			then match=9999 $
+			else match=STRPOS(desc_field(indice),field_user)  
+	endrep until match ne -1
+	if (match eq 9999) then begin
+		print, field_user, ' not found !'
+		stop
+	endif
+;print, 'selected for plot:  ',desc_field(indice)
+endif
+
+;
+; prepare loop for graphics
+;
+if (n_elements(indice) ne 0) then begin
+	field_loop_start=indice
+	field_loop_end=indice
+endif else begin
+	field_loop_start=0
+	field_loop_end=nfields-1	
+endelse
+
+;
+; overplot contour of another field ?
+;
+if (fieldc_user ne '') then begin
+	match=-1
+	indice=-1
+	repeat begin
+		indice=indice+1
+		if (indice eq nfields) $
+			then match=9999 $
+			else match=STRPOS(desc_field(indice),fieldc_user)  
+	endrep until match ne -1
+	if (match eq 9999) then begin
+		print, fieldc_user, ' not found !'
+		stop
+	endif
+;print, 'selected for over-contour:  ',desc_field(indice)
+	varcontour=reform(field(indice,*,*,*,*))
+endif
+
+;
+; overplot wind vectors ?
+;
+if (n_elements(winds) ge 2) then begin
+	; zonal wind
+	match=-1
+	indice=-1
+	repeat begin
+		indice=indice+1
+		if (indice eq nfields) $
+			then match=9999 $
+			else match=STRPOS(desc_field(indice),winds(0))  
+	endrep until match ne -1
+	if (match eq 9999) then begin
+		print, 'u not found !'
+		stop
+	endif
+;print, 'selected for vector_x:  ',desc_field(indice)
+	u=reform(field(indice,*,*,*,*))
+	; meridional wind
+	match=-1
+	indice=-1
+	repeat begin
+		indice=indice+1
+		if (indice eq nfields) $
+			then match=9999 $
+			else match=STRPOS(desc_field(indice),winds(1))  
+	endrep until match ne -1
+	if (match eq 9999) then begin
+		print, 'v not found !'
+		stop
+	endif
+;print, 'selected for vector_y:  ',desc_field(indice)
+	v=reform(field(indice,*,*,*,*))
+endif
+
+
+
+;
+; loop for graphics   
+;
+for field_loop=field_loop_start,field_loop_end do begin
+
+	charstart=STRSPLIT(desc_field(field_loop), ' ', LENGTH=charlength)
+	charvar=STRMID(desc_field(field_loop),charstart(0),charlength(0))
+	var=reform(field(field_loop,*,*,*,*))
+
+	; useless field ...
+	if (charvar eq vert_coord) then goto, skip
+
+	;
+	; min/max on the whole field
+	;
+	w=where(var ne 1e37)
+	if (w(0) ne -1) then begin
+		minfield=min(var[w])
+		maxfield=max(var[w])
+			;;; manage unvalid points
+			;;;w=where(var eq 1e37)
+			;;;if (w(0) ne -1) then var[w]=!Values.F_NAN
+	endif else begin
+		var=0
+		print, 'no valid values in this field', charvar 
+	endelse
+
+;----------------------
+; initialize graphics
+;----------------------
+
+;!p.charthick = 2.0
+;!p.thick = 3.0
+;!x.thick = 2.0
+;!y.thick = 2.0
+
+
+lct = round(t[when-1]+24) MOD 24
+
+;;lct = when  ;; on choisit de les numeroter dans l'ordre 
+;;if ((when ne -1) and (lct lt 10)) then charend=charend+'0'+string(lct, '(I0)')
+;;if (lct ge 10) then charend=charend+string(lct, '(I0)') 
+;;lct = round(t[when-1]) MOD 24
+;;denom=plot_user+'_'+vert_coord+'_'+charvar
+;;if (fieldc_user ne '') then denom=denom+'_'+fieldc_user
+;;if (winds(0) ne '') then denom=denom+'_'+winds(0)+winds(1)
+;;denom=denom+charend
+
+
+if (n_elements(file_ps) ne '') then begin
+	set_plot, 'ps'
+	device, filename=file_ps+'.ps', /color
+endif
+
+
+case charvar of
+'HGT': begin
+        title='Topography (km)'
+	level=1
+	pal=16
+	format='(F7.0)'
+end
+'tk': begin
+	title='Temperature (K)'
+	pal=3
+	format='(F4.0)'
+end
+'TSK': begin
+	title='Surface Temperature (K)'
+	pal=3
+	level=1
+end
+'U': begin
+	title='Zonal wind (!Nm!N.s!U-1!N)'
+	pal=33
+	if (winds(0) eq 'U') then title='Wind field (!Nm!N.s!U-1!N)'
+end
+'V': begin
+	title='Meridional wind (!Nm!N.s!U-1!N)'
+	pal=33
+	if (winds(0) eq 'V') then title='Wind field (!Nm!N.s!U-1!N)'
+end
+'pressure': begin
+	title='Pressure (hPa)'
+	pal=16
+end
+'height': begin
+	title='Height (km)'
+	pal=16
+end
+'T': title='Potential temperature departure from t0 (K)'
+'W': begin
+	title='Vertical wind (!Nm!N.s!U-1!N)'
+	pal=16
+	format='(F6.2)'
+end
+else: begin
+	title=''
+	pal=33
+end
+endcase
+
+if (when ne -1) then begin
+	title=title+', LT '+string(lct, '(I0)')
+endif else begin
+	title=title+', time '+string(when, '(I0)')
+endelse
+	
+title_save=title
+
+
+
+;---------------------------------
+; choose positioning ...
+;---------------------------------
+
+case plot_user of
+'map': begin
+;
+; 1. map: looping on vertical levels
+;
+	if (level eq -1) then begin
+		theloopmin=0
+		theloopmax=bottom_top-1
+	endif else begin
+		theloopmin=level-1 ;!! IDL arrays starts at 0
+		theloopmax=level-1
+	endelse	
+	if (when eq -1) then nt = 0 else nt=when-1
+end
+'profile': begin
+;
+; 2. profile: looping on time
+;
+	;;discrete=4
+	title_axis=strarr(2)
+	title_axis(0)=title_save
+	if (when eq -1) then begin
+		theloopmin=0
+		theloopmax=time-1
+	endif else begin
+		theloopmin=when-1 ;!! IDL arrays starts at 0
+		theloopmax=when-1
+	endelse	
+
+	column=z
+	case vert_coord of
+		'height': title_axis(1)='Altitude (km)'
+		'pressure': begin
+			H=10.
+			p0=6.1
+			column=H*alog(p0/z)
+			title_axis(1)='Log-Pressure altitude (km)'
+		end
+		'model_level': title_axis(1)='Model level'
+	endcase
+
+	displaylat=float(round(lat(nlat)*100))/100.
+	displaylon=float(round(lon(nlon)*100))/100.
+	description='WRF Profile at latitude '+string(displaylat,format='(1F6.2)')+$
+	'!Uo'+'!N and longitude '+string(displaylon,format='(1F7.2)')+'!Uo!N '
+	title=description
+end
+'hovmuller': begin
+;
+; 3. hovmuller: looping on vertical levels
+;
+	if (level eq -1) then begin
+		theloopmin=0
+		theloopmax=bottom_top-1
+	endif else begin
+		theloopmin=level-1 ;!! IDL arrays starts at 0
+		theloopmax=level-1
+	endelse	
+end
+'zonal': begin
+;
+; 4. zonal: looping on latitude
+;
+	if (nlat eq -1) then begin
+		theloopmin=0
+		theloopmax=south_north-1
+	endif else begin
+		theloopmin=nlat-1 ;!! IDL arrays starts at 0
+		theloopmax=nlat-1
+	endelse	
+	if (when eq -1) then nt = 0 else nt=when-1
+	case vert_coord of
+		'height': charlev='Altitude (km)'
+		'pressure': begin
+			H=10.
+			p0=6.1
+			z=H*alog(p0/z)
+			charlev='Log-Pressure altitude (km)'
+		end
+		'model_level': charlev='Model level'
+	endcase
+end
+'meridional': begin
+;
+; 5. meridional: looping on longitude
+;
+	if (nlon eq -1) then begin
+		theloopmin=0
+		theloopmax=west_east-1
+	endif else begin
+		theloopmin=nlon-1 ;!! IDL arrays starts at 0
+		theloopmax=nlon-1
+	endelse	
+	if (when eq -1) then nt = 0 else nt=when-1
+	case vert_coord of
+		'height': charlev='Altitude (km)'
+		'pressure': begin
+			H=10.
+			p0=6.1
+			z=H*alog(p0/z)
+			charlev='Log-Pressure altitude (km)'
+		end
+		'model_level': charlev='Model level'
+	endcase
+end
+else: stop
+endcase
+
+
+;-------------
+; plot loop
+;-------------	
+for theloop=theloopmin,theloopmax do begin
+
+case plot_user of
+'map': begin
+	;
+	; case 1: map
+	;	
+	case vert_coord of
+	'height': charlev=string(round(z(theloop)*1000.),'(I0)')+' m'
+	'pressure': charlev=string(round(z(theloop)*100.),'(I0)')+' Pa'
+	'model_level': charlev=string(round(z(theloop)),'(I0)')
+	endcase
+	if (n_elements(var(0,0,*,0) ge 2)) then title=title_save+', at level '+charlev
+	print, title
+
+	;-------------
+	; draw map
+	;-------------
+
+	what_I_plot=var[*,*,theloop,nt]
+
+	if (diff_scale eq 0) then begin
+		minfield_init=minfield	;-same scale for all levels 
+		maxfield_init=maxfield	;-same scale for all levels
+	endif
+	if (fieldc_user eq '') then begin
+		overcontour=0.
+	endif else begin
+		if (topo eq 1) then begin
+			overcontour=varcontour[*,*,0,0]/1000.  ; other levels than 0 are blank !
+		endif else begin
+			overcontour=varcontour[*,*,theloop,nt]
+		endelse
+	endelse
+	if (n_elements(winds) lt 2) then begin
+		overvector_x=0.
+		overvector_y=0.
+	endif else begin
+		overvector_x=u[*,*,theloop,nt]
+		overvector_y=v[*,*,theloop,nt]
+
+
+;--------------------------------------------------------
+; NB: you can use the winds fields to combine variables 
+;--------------------------------------------------------
+if (n_elements(winds) ge 2) then begin
+
+
+;** HYDROSTATIC REDUCTION TO LEVEL OF REFERENCE
+@sea_level.idl
+
+;** WIND STRESS
+@wind_stress.idl
+
+;** ERTEL POTENTIAL VORTICITY
+@ertel_vorticity.idl
+
+
+endif
+;--------------------------------------------------------
+; NB: you can use the winds fields to combine variables
+;--------------------------------------------------------
+
+	endelse
+
+;;******************TEMP
+;;pressure anomaly
+;nday=3
+;oneday=reform(var[*,*,theloop,0:nday-1])
+;what_I_plot=what_I_plot-(total(oneday,3)/float(nday))
+;;******************TEMP
+
+	map_latlon, $
+		what_I_plot, $
+		lon, $
+		lat, $
+		ct=pal, $
+		minfield=minfield_init, $
+		maxfield=maxfield_init, $
+		overcontour=overcontour, $
+		overvector_x=overvector_x, $
+		overvector_y=overvector_y, $
+		colors=colors, $
+		title=title, $
+		format=format	
+end
+'profile': begin
+	;
+	; case 2: profile
+	;
+	print, title
+
+	what_I_plot=var[nlon,nlat,*,theloop]
+	if (diff_scale eq 0) then begin
+		minfield_init=minfield	;-same scale for all levels 
+		maxfield_init=maxfield	;-same scale for all levels
+	endif
+	if (fieldc_user eq '') then begin
+		overcontour=0.
+		overcontourz=0.
+	endif else begin
+		overcontour=varcontour[nlon,nlat,*,theloop]
+		overcontourz=0.
+	endelse
+	if (n_elements(inprofile) gt 1) then begin
+		overcontour=inprofile
+		overcontourz=0.
+		if (n_elements(incolumn) gt 1) then overcontourz=incolumn
+	endif
+
+	profile, $
+		what_I_plot, $				; 1D vertical profile
+		column, $				; altitudes	
+	;	alt=alt, $				; altitude range [altmin, altmax]
+		minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+		maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+		inprofile=overcontour, $		; another vertical profile to overplot
+		incolumn=overcontourz, $		; altitudes of the other vertical profile (in case /= column)
+		title_plot=title, $			; title of the plot ('Profile' is default)
+		title_axis=title_axis, $		; title of the [x,y] axis (['Field','Altitude'] is default)
+	;	mention=mention, $			; add text precision within the plot window (default is nothing or '')
+		discrete=discrete			; show the profile points (= type of points in !psym)
+end
+'hovmuller': begin
+	;
+	; case 3: hovmuller
+	;
+	; NB: lat/lon hovmuller 
+	;
+	what_I_plot=reform(var[*,nlat,theloop,*])
+	space=lon
+	temps=findgen(time)*2
+	if (fieldc_user ne '') then begin
+		overcontour=reform(varcontour[*,nlat,theloop,*])
+	endif else begin
+		overcontour=0.
+	endelse
+	minspace=0.
+	maxspace=0.
+
+;;******************TEMP
+;	minspace=-90.
+;	maxspace=90.
+
+if (n_elements(winds) ge 2) then begin		;;;winds sert à faire des calculs !!
+overvector_x=reform(u[*,nlat,4,*])	;;T 1km
+overvector_y=reform(v[*,nlat,0,*])	;;topo (m)
+zref=median(overvector_y)
+H=192.*overvector_x/3.72	;unit is m
+;print, (overvector_y-zref)/H
+what_I_plot=what_I_plot*exp((overvector_y-zref)/H)
+
+
+endif 
+;oneday=reform(var[*,nlat,0,0:11])
+;slice=(total(oneday,2)/12.)
+;for i=0, n_elements(var[*,0,0,0])-1 do begin
+;	what_I_plot(i,*)=what_I_plot(i,*)-slice(i)
+;endfor
+;;******************TEMP
+
+
+
+
+
+	hovmuller, $
+		what_I_plot, $				; 2D field
+		space, $				; space coordinate
+		temps, $				; time coordinate
+		minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+		maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+		minspace=minspace, $			; minimum value of space window (=0: calculate)
+		maxspace=maxspace, $			; maximum value of space window (=0: calculate)
+		overcontour=overcontour, $		; another 2D field to overplot with contour lines (=0: no)
+		ct=pal, $				; color table (33-rainbow is default)
+		colors=colors, $			; number of colors/levels (32 is default)
+		title=title				; title of the plot ('' is default)
+end
+'zonal': begin
+	;
+	; case 4: zonal section
+	; 
+	displaylat=float(round(lat(theloop)*100))/100.
+	title=title_save+ $
+		' section at latitude '+string(displaylat,format='(1F6.2)')+ $
+		'!Uo!N '
+	print, title
+
+	what_I_plot=reform(var[*,theloop,*,nt])
+	space=lon
+	altitude=z
+
+if (topo eq 1) then begin
+	topography=varcontour[theloop,*,0,0] ; other levels than 0 are blank !
+        fieldc_user=''
+endif else begin
+	topography=0.
+endelse	
+		    
+	
+	if (fieldc_user ne '') then begin
+		overcontour=reform(varcontour[*,theloop,*,nt])
+	endif else begin
+		overcontour=0.
+	endelse
+
+	if (n_elements(winds) lt 2) then begin
+		overvector_x=0.
+		overvector_y=0.
+	endif else begin
+		overvector_x=reform(u[*,theloop,*,nt])		;;horizontal component
+		overvector_y=reform(v[*,theloop,*,nt])		;;vertical component
+	endelse
+
+	minspace=0.
+	maxspace=0.
+
+	title_user=title
+	title_axis=['Longitude',charlev]
+
+	section, $
+		what_I_plot, $				; 2D field
+		space, $				; horizontal coordinate
+		altitude, $				; altitude coordinate
+		minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+		maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+		minspace=minspace, $			; minimum value of space window (=0: calculate)
+		maxspace=maxspace, $			; maximum value of space window (=0: calculate)
+		overcontour=overcontour, $		; another 2D field to overplot with contour lines (=0: no)
+		overvector_x=overvector_x, $		; wind vector - x component (=0: no)
+		overvector_y=overvector_y, $		; wind vector - y component (=0: no)
+		colors=colors, $			; number of colors/levels (32 is default)
+		title_plot=title_user, $		; title of the plot ('Profile' is default)
+		title_axis=title_axis, $		; title of the [x,y] axis (['Field','Altitude'] is default)
+		ct=pal, $				; color table (33-rainbow is default)
+topo=topography, $
+		format=format
+end	
+'meridional': begin
+	;
+	; case 5: meridional section
+	; 
+	displaylon=float(round(lon(theloop)*100))/100.
+	title=title_save+ $
+		' section at longitude '+string(displaylon,format='(1F7.2)')+ $
+		'!Uo!N '
+	print, title
+
+	what_I_plot=reform(var[theloop,*,*,nt])
+	space=lat
+	altitude=z
+
+if (topo eq 1) then begin
+        topography=varcontour[theloop,*,0,0] ; other levels than 0 are blank !
+        fieldc_user=''
+endif else begin
+        topography=0.
+endelse
+			
+	if (fieldc_user ne '') then begin
+		overcontour=reform(varcontour[theloop,*,*,nt])
+	endif else begin
+		overcontour=0.
+	endelse
+
+	if (n_elements(winds) lt 2) then begin
+		overvector_x=0.
+		overvector_y=0.
+	endif else begin
+		overvector_x=reform(u[theloop,*,*,nt])		;;horizontal component
+		overvector_y=reform(v[theloop,*,*,nt])		;;vertical component
+	endelse
+
+	minspace=0.
+	maxspace=0.
+
+	title_user=title
+	title_axis=['Latitude',charlev]
+
+	section, $
+		what_I_plot, $				; 2D field
+		space, $				; horizontal coordinate
+		altitude, $				; altitude coordinate
+		minfield=minfield_init, $		; minimum value of plotted field (=0: calculate)
+		maxfield=maxfield_init, $		; maximum value of plotted field (=0: calculate)
+		minspace=minspace, $			; minimum value of space window (=0: calculate)
+		maxspace=maxspace, $			; maximum value of space window (=0: calculate)
+		overcontour=overcontour, $		; another 2D field to overplot with contour lines (=0: no)
+		overvector_x=overvector_x, $		; wind vector - x component (=0: no)
+		overvector_y=overvector_y, $		; wind vector - y component (=0: no)
+		colors=colors, $			; number of colors/levels (32 is default)
+		title_plot=title_user, $		; title of the plot ('Profile' is default)
+		title_axis=title_axis, $		; title of the [x,y] axis (['Field','Altitude'] is default)
+topo=topography, $
+		ct=pal, $				; color table (33-rainbow is default)
+		format=format
+end	
+
+
+
+
+
+
+
+
+else: 
+endcase
+
+
+print, '...ok'
+endfor
+if (n_elements(file_ps) ne '') then device, /close
+
+	; save the profiles for another plot (last of the time loop)
+	if (n_elements(inprofile) le 1) and (plot_user eq 'profile') then begin
+		inprofile=what_I_plot
+		incolumn=column
+	endif
+
+skip:
+endfor
+
+save_data=field
+field=0.	;; free memory
+
+end
+
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/plot.def
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/plot.def	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/plot.def	(revision 1185)
@@ -0,0 +1,159 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  -or- @report.idl
+;  -or- @movie.idl
+;
+;  this file will be saved !
+;
+;;---------------------------------------
+
+
+;-------------------------------
+;-------------------------------
+; namelist.ARWPOST parameters
+;-------------------------------
+;-------------------------------
+
+;; DEFAULT: ARWPOST.EXE ALREADY RUN (i.e. input.ctl and input.dat already there)
+;; UNCOMMENT FOLLOWING LINE TO EXTRACT FILES 
+
+;extract='yes'	;;   EXECUTE ARWPOST.EXE
+		;;   WITH THE FOLLOWING PARAMETERS :
+
+nam1=" fields = 'tk,HGT,PSFC,U,V,W' "		;; CHANGE HERE FIELDS TO BE EXTRACTED 
+nam1=" fields = 'tk' "
+nam1=" fields = 'HGT,U,V' "
+nam1=" fields = 'V,W' "
+nam1=" fields = 'HGT,ICETOT,RAVE,QH2O_ICE' "
+
+nam2=" start_date = '2024-04-04_06:00:00' "	;; CHANGE HERE START DATE
+nam3=" end_date   = '2024-04-04_08:00:00' "	;; CHANGE HERE END DATE
+nam4=" interval_seconds = 14800 "		;; SET INTERVAL   2h: 7400s, 4h: 14800s, 6h: 22200s	
+nam5=" interp_method = 1 "			;; SET VERT. COORD. 0: eta levels, 1: height (inc) or pressure (dec)
+tabnam=[1,30,0.5]   	;; SET HEIGHT/PRESSURE LEVELS WITH [first alt, last alt, step]
+
+
+
+;----------------------------------------------------
+;----------------------------------------------------
+; what do you want to plot ?
+; THIS MUST BE SET ACCORDINGLY TO PREVIOUS SECTION
+;   - do not plot a field not extracted
+;   - do not ask for more plot than data available
+;----------------------------------------------------
+;----------------------------------------------------
+
+num=1		   	;; how many plots ?
+num=6                   ;; how many plots ?
+;num=2                   ;; how many plots ?
+num=3
+
+;@map_sea_level.idl
+;@map_ertel_vorticity.idl
+;@map_wind_stress.idl
+;field1='HGT'
+;field2='U'
+;winds=['U','V']
+;topo=1
+
+;winds=['U','V'] & field1='U' & topo=1
+;winds=['V','W'] & field1='V' 
+field1='ICETOT' & topo=1
+;field1='QH2O_ICE'
+
+
+
+;----------------------------------
+;----------------------------------
+; what kind of plot do you want ? 
+;----------------------------------
+;----------------------------------
+
+plot='map' & level=-1	
+level=2		; first level is 1
+level=24
+;level=10
+;level=1
+
+;plot='meridional' & nlon=-1 	
+;nlon=75
+
+;plot='zonal' & nlat=-1		
+;nlat=100
+
+
+;----------------------------
+;----------------------------
+; change plot settings 
+;----------------------------
+;----------------------------
+
+;; uncomment to modify default plot settings
+;; | | | | | | | | | | | | | | | | | | | | |
+;; v v v v v v v v v v v v v v v v v v v v v
+
+minfield_init=0.		;; grepALL
+maxfield_init=16.		;; grepALL
+;intervalx=5.	           	;; grepALL
+;intervaly=5.	           	;; grepALL
+;title_user='my own plot'	;; grepALL
+;title_axis=['abs','ord']	;; grepALL
+;colors=30			;; grepALL
+;pal=33				;; grepALL
+;pal=0				;; grepALL
+;pal=22				;; grepALL
+;format='(I0)'			;; grepALL
+;windex=20.			;; grepALL
+;stride=2			;; grepALL
+;flag_cb='false'		;; grepALL
+;what_I_plot=what_I_plot*1e6    ;; grepALL
+
+;minalt=-4.			;; grepSEC
+;maxalt=1.5			;; grepSEC
+;;altitude=altitude*1000.  	;; grepSEC
+;factor=30.			   ;; grepSEC
+;space=space*58. & spacekm='true'   ;; grepSEC
+;minspace=10.4*58./factor             ;; grepSEC
+;maxspace=12.*58./factor            ;; grepSEC
+
+windowx=[-145,-100]	;; grepMAP
+windowy=[-25,25]	;; grepMAP
+;lon=lon*58.		;; grepMAP
+;lat=lat*58.		;; grepMAP
+
+;lim_max = 0.03 				;; 1/3 grepALL
+;w=where(what_I_plot ge lim_max) 		;; 2/3 grepALL
+;if (w[0] ne -1) then what_I_plot[w]=lim_max	;; 3/3 grepALL
+
+;lim_blank = 10 					;; 1/3 grepALL
+;w=where(abs(what_I_plot) le lim_blank)			;; 2/3 grepALL
+;if (w[0] ne -1) then what_I_plot[w]=missing_value	;; 3/3 grepALL
+
+;title_user='Sea-level surface pressure'+title_user	;; grepALL
+
+;what_I_plot=what_I_plot*1000.  				;; grepALL
+;title_user='Water ice column (!7l!3m-pr)'+title_user	;; grepALL
+subtitle_user='LMD mesoscale model'     		;; grepALL
+
+;what_I_plot(*,*)=missing_value		;; grepMAP
+
+
+;------------------------------
+;------------------------------
+; some last possible settings 
+;------------------------------
+;------------------------------
+
+backup_data='no'   	;; save ARWpost-generated text files ? default is no
+already_data='no'  	;; load ARWpost-generated text files ? default is no
+datafolder='./WHERE_RESULTS_ARE/'	;; default is ./
+plotfolder='./WHERE_PLOTS_ARE/'	        ;; default is ./
+
+textitle='TH20_WC'	;; one word.  default is 'plot'
+texcomments='sol4'	;; one word.  default is 'plot'
+
+
+
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/read_dat.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/read_dat.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/read_dat.pro	(revision 1185)
@@ -0,0 +1,220 @@
+pro read_dat, output, x, y, z, t, desc_field, nodata=nodata
+
+
+;---------------------------------------------------------------------------
+;
+; Read the files generated by ARWpost
+;
+; Please create symbolic link 'input.ctl' and 'input.dat'
+; --- or rename files
+;
+; - output contains all fields
+; - x,y,z,t contains coordinates
+; - desc_field contains strings describing fields
+; - if nodata is not blank, do not read the fields
+;
+;---------------------------------------------------------------------------
+; A. Spiga, August 2007
+;---------------------------------------------------------------------------
+
+
+;
+; info for localtime
+;
+interv=0.
+openr, 99, 'timefil'
+readf,99,interv
+close, 99
+
+
+
+; get preliminar info on coordinates
+;
+wnx=1
+wny=1
+wnz=1
+wnt=1
+txt=''
+param=[0.,0.,0.,0.,0.,0.,0.,0.]
+openr, 1, 'input.ctl'
+while not eof(1) do begin
+    readf,1,txt
+    match=STRPOS(txt,'linear')
+	if (match ne -1) then begin
+		wnx=(STRPOS(txt,'xdef') eq -1)*wnx  ;0 if linear
+		wny=(STRPOS(txt,'ydef') eq -1)*wny  ;0 if linear
+                wnz=(STRPOS(txt,'zdef') eq -1)*wnz  ;0 if linear 
+                wnt=(STRPOS(txt,'tdef') eq -1)*wnt  ;0 if linear
+                paramstart=STRSPLIT(txt, 'r', LENGTH=paramlength)
+        	paramchar=STRMID(txt,paramstart(1),paramlength(1))
+		READS, paramchar, start, step
+		param=param+[start*(STRPOS(txt,'xdef') ne -1),$
+			step*(STRPOS(txt,'xdef') ne -1),$
+			start*(STRPOS(txt,'ydef') ne -1),$
+			step*(STRPOS(txt,'ydef') ne -1),$
+			start*(STRPOS(txt,'zdef') ne -1),$
+			step*(STRPOS(txt,'zdef') ne -1),$
+			start*(STRPOS(txt,'tdef') ne -1),$
+			step*(STRPOS(txt,'tdef') ne -1)]
+	endif	
+endwhile
+close, 1
+timebegin=param(6)
+	
+;---------------------------------
+; READ .CTL FILE INFORMATIONS
+;---------------------------------
+
+info=read_ascii('input.ctl', missing_value=1e37)
+infodat=info.field1
+
+;
+; second column : dimensions
+;
+
+w=where((infodat(0,*) eq 1e37) and (infodat(1,*) lt 1e37))
+dimensions=reform(infodat(1,w))
+
+nx=round(dimensions(0)) 
+ny=round(dimensions(1)) 
+nz=round(dimensions(2)) 
+nt=round(dimensions(3)) 
+fields=round(dimensions(4)) 
+vertical=intarr(fields)
+for i=0,fields-1 do begin
+	vertical(i)=round(dimensions(5+i))
+endfor
+
+
+;
+; first column : coordinates
+;
+
+w=where((infodat(1,*) eq 1e37) and (infodat(0,*) lt 1e37))
+if (w(0) ne -1) then coordinates=reform(infodat(0,w))
+
+if (wnx ne 0) then begin
+	wnx=nx
+	x=coordinates(0:nx-1)
+endif else begin
+	xmin=param(0)
+	xmax=param(0)+param(1)*(nx-1) MOD 360
+	;inc=param(0)+param(1)*(nx-1)	;cas mercator
+	;x=start+inc*findgen(nx) 
+	x=xmin+(xmax-xmin)*findgen(nx)/(nx-1)
+	;print, x
+	;stop
+endelse
+if (wny ne 0) then begin
+        wny=ny
+	y=coordinates(wnx:wnx+wny-1)
+endif else begin
+        start=param(2)
+        step=param(3)
+        y=start+step*findgen(ny)
+endelse
+if (wnz ne 0) then begin
+        wnz=nz
+	z=coordinates(wnx+wny:wnx+wny+wnz-1)
+endif else begin
+        start=param(4)
+        step=param(5)
+        z=start+step*findgen(nz)
+endelse
+t=interv*findgen(nt)/3700. + timebegin + mean(x)/15.
+	
+
+;
+; get info on fields
+;
+openr, 1, 'input.ctl'
+toto=5+wnx+1+wny+1+wnz+2+fields
+infofields=strarr(toto)
+readf, 1, infofields
+close, 1
+
+;
+desc_field=transpose(infofields(toto-fields:toto-1))
+
+
+if (n_elements(nodata) eq 0) then begin
+;---------------------------------
+; READ .DAT FILE DATA
+;---------------------------------
+; GrADS views gridded data sets as 5-dimensional arrays 
+; varying in longitude, latitude, vertical level, variable, and time.
+;---------------------------------
+
+print, '----------------'
+print, 'reading data ...'
+print, '----------------'
+print, 'longitudes: ', min(x), max(x), nx, ' points'
+print, 'latitudes: ', min(y), max(y), ny, ' points' 
+print, 'altitudes: ', min(z), max(z), nz, ' points'
+print, 'local times: ', min(t), max(t), nt, ' points'
+print, fields, ' recorded fields :'
+print, desc_field
+print, '----------------'
+
+	;;very slow method
+	;;----------------	
+	;data=read_ascii('input.dat', missing_value=1e37)
+	;datadat=data.field1
+
+; see http://www.dfanning.com/tips/ascii_column_data.html	
+OPENR, lun, 'input.dat', /GET_LUN
+
+;count=0L
+output=fltarr(fields,nx,ny,nz,nt)
+dummy=0.
+
+for l=0,nt-1 do begin 						;time loop
+print, 'time loop ...', l+1, ' / ', string(nt,'(I0)')  	
+	for f=0, fields-1 do begin ;fields (whether 2D or 3D)	;variable loop
+	nzf=vertical(f)
+	print, 'reading field ...', f+1, ' / ', string(fields,'(I0)') 
+		for k=0,nzf-1 do begin  			;vertical loop
+			for j=0,ny-1 do begin			;latitude loop
+			for i=0,nx-1 do begin			;longitude loop
+
+				;;very slow method
+				;output(f,i,j,k,l)=datadat(count)
+                                ;count=count+1
+
+				READF, lun, dummy
+				output(f,i,j,k,l)=dummy
+
+			endfor
+			endfor
+		endfor
+	endfor
+endfor
+
+; missing values
+w=where(output eq 1e20)
+if (w(0) ne -1) then begin
+	print, 'change missing values ...'
+	output[w]=1e37
+endif
+
+
+CLOSE, lun
+;SPAWN, '\rm input.dat_tmp'
+print, '...done !'
+help, /memory
+print, '---------'
+
+;if (count ne n_elements(datadat)) then begin
+;	print, 'some data were not read !'
+;	stop
+;endif
+
+;;
+;; Manage missing data so as IDL recognize them
+;;
+;w=where(output eq 1e37)
+;if (w(0) ne -1) then output[w]=!Values.F_NAN
+
+endif
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/report.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/report.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/report.idl	(revision 1185)
@@ -0,0 +1,87 @@
+;;---------------------------------------
+;  REPORT
+;
+;  **** DO NOT MODIFY ****
+;
+;  set parameters in plot.def then type:
+;
+;  @report.idl
+;
+;;---------------------------------------
+
+
+field1='' & field2='' & winds=''
+backup_data='no' & already_data='no'  	
+datafolder='./' & plotfolder='./'
+topo=0
+extract='no'
+
+textitle='plot'
+texcomments='plot'	
+
+SPAWN, '\rm user.idl'
+SPAWN, 'grep -v grep plot.def > user.idl'
+
+;; to avoid dumb and useless warnings from IDL
+space=0. & altitude=0. & lon=0. & lat=0.
+what_I_plot=0. & title_user='' & missing_value=0.
+
+@user.idl
+if (nam5 eq " interp_method = 0 ") then coord='model_level'
+if ((nam5 eq " interp_method = 1 ") and (tabnam(0) lt tabnam(1))) then coord='height'
+
+.compile call_arwpost
+if (extract eq 'yes') then call_arwpost, nam1, nam2, nam3, nam4, nam5, tabnam
+
+denom=plot+'_'+coord+'_'+field1
+if ((field2 ne '') and (topo eq 0)) then denom=denom+'_'+field2
+if (topo eq 1) then denom=denom+'_HGT'
+if (winds(0) ne '') then denom=denom+'_'+winds(0)+winds(1)
+
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.ctl input.ctl'
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.dat input.dat'
+
+SPAWN, '\rm param_plot.idl'
+SPAWN, 'grep grepALL plot.def > param_plot.idl'
+if ((plot eq 'meridional') or (plot eq 'zonal')) then SPAWN, 'grep grepSEC plot.def >> param_plot.idl'
+if (plot eq 'map') then SPAWN, 'grep grepMAP plot.def >> param_plot.idl'
+.compile map_latlon
+.compile section
+
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+for i=1,num do $
+        out_wrf, $
+        plot=plot, $
+        field1=field1, $
+        field2=field2, $
+        when=i, $
+        winds=winds, $
+        level=level,$
+        save_data=yeah,$        ;; data is loaded only once
+        topo=topo,$
+;        range=range,$
+        colors=colors, $
+        nlon=nlon, $
+        nlat=nlat, $
+        save_ps=denom+string(1000+i,'(I0)')
+
+SPAWN, 'touch report.comments'
+SPAWN, '\rm report.comments'
+SPAWN, 'echo '+textitle+' > report.comments'
+SPAWN, 'echo '+texcomments+' >> report.comments'
+SPAWN, 'rm -f '+denom+'_.ps'
+print, 'executing ... ','base '+denom+'????.ps < report.comments'
+SPAWN, 'base '+denom+'????.ps < report.comments'
+SPAWN, 'mv -f base.ps '+denom+'_.ps'
+
+SPAWN, 'mv -f ./'+denom+'????.ps '+plotfolder+'/'
+SPAWN, 'mv -f ./'+denom+'_.ps '+plotfolder+'/'
+if (backup_data eq 'yes') then SPAWN, 'cp -f namelist.ARWpost '+datafolder+'/'+coord+'.namelist.ARWpost'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.ctl '+datafolder+'/'+coord+'.input.ctl'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.dat '+datafolder+'/'+coord+'.input.dat'
+
+SPAWN, 'cp -f plot.def '+plotfolder+'/'+denom+'.def'
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/see.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/see.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/see.idl	(revision 1185)
@@ -0,0 +1,76 @@
+;;---------------------------------------
+;  TRACE
+;
+;  **** DO NOT MODIFY ****
+;
+;  set parameters in plot.def then type:
+;
+;  @trace.idl
+;
+;;---------------------------------------
+
+field1='' & field2='' & winds=''
+backup_data='no' & already_data='no'  	
+datafolder='./' & plotfolder='./'
+extract='no'
+
+SPAWN, '\rm user.idl'
+SPAWN, 'grep -v grep plot.def > user.idl'
+
+;; to avoid dumb and useless warnings from IDL
+space=0. & altitude=0. & lon=0. & lat=0.  
+what_I_plot=0. & title_user='' & missing_value=0.
+
+@user.idl
+if (nam5 eq " interp_method = 0 ") then coord='model_level'
+if ((nam5 eq " interp_method = 1 ") and (tabnam(0) lt tabnam(1))) then coord='height'
+
+.compile call_arwpost
+if (extract eq 'yes') then call_arwpost, nam1, nam2, nam3, nam4, nam5, tabnam
+
+denom=plot+'_'+coord+'_'+field1
+if ((field2 ne '') and (topo eq 0)) then denom=denom+'_'+field2
+if (topo eq 1) then denom=denom+'_HGT'
+if (winds(0) ne '') then denom=denom+'_'+winds(0)+winds(1)
+
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.ctl input.ctl'
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.dat input.dat'
+
+SPAWN, '\rm param_plot.idl'
+SPAWN, 'grep grepALL plot.def > param_plot.idl'
+if ((plot eq 'meridional') or (plot eq 'zonal')) then SPAWN, 'grep grepSEC plot.def >> param_plot.idl'
+if (plot eq 'map') then SPAWN, 'grep grepMAP plot.def >> param_plot.idl'
+.compile map_latlon
+.compile section
+
+
+set_plot, 'x'
+!P.MULTI = [0, 2, 3]
+window, 0, xsize=600, ysize=900
+
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+
+
+for i=1,num do $
+	out_wrf, $
+	plot=plot, $
+	field1=field1, $
+	field2=field2, $
+	when=i, $
+	winds=winds, $
+	level=level,$
+        save_data=yeah,$	;; data is loaded only once
+	topo=topo,$
+;	range=range,$
+	colors=colors, $
+	nlon=nlon, $
+	nlat=nlat
+
+if (backup_data eq 'yes') then SPAWN, 'cp -f namelist.ARWpost '+datafolder+'/'+coord+'.namelist.ARWpost'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.ctl '+datafolder+'/'+coord+'.input.ctl'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.dat '+datafolder+'/'+coord+'.input.dat'
+SPAWN, 'cp -f plot.def '+plotfolder+'/'+denom+'.def'
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/trace.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/trace.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/trace.idl	(revision 1185)
@@ -0,0 +1,93 @@
+;;---------------------------------------
+;  TRACE
+;
+;  **** DO NOT MODIFY ****
+;
+;  set parameters in plot.def then type:
+;
+;  @trace.idl
+;
+;;---------------------------------------
+
+field1='' & field2='' & winds=''
+backup_data='no' & already_data='no'  	
+datafolder='./' & plotfolder='./'
+topo=0
+extract='no'
+
+SPAWN, '\rm user.idl'
+SPAWN, 'grep -v grep plot.def > user.idl'
+
+;; to avoid dumb and useless warnings from IDL
+space=0. & altitude=0. & lon=0. & lat=0.  
+what_I_plot=0. & title_user='' & missing_value=0.
+
+@user.idl
+if (nam5 eq " interp_method = 0 ") then coord='model_level'
+if ((nam5 eq " interp_method = 1 ") and (tabnam(0) lt tabnam(1))) then coord='height'
+
+.compile call_arwpost
+if (extract eq 'yes') then call_arwpost, nam1, nam2, nam3, nam4, nam5, tabnam
+
+denom=plot+'_'+coord+'_'+field1
+if ((field2 ne '') and (topo eq 0)) then denom=denom+'_'+field2
+if (topo eq 1) then denom=denom+'_HGT'
+if (winds(0) ne '') then denom=denom+'_'+winds(0)+winds(1)
+
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.ctl input.ctl'
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+datafolder+'/'+coord+'.input.dat input.dat'
+
+SPAWN, '\rm param_plot.idl'
+SPAWN, 'grep grepALL plot.def > param_plot.idl'
+if ((plot eq 'meridional') or (plot eq 'zonal')) then SPAWN, 'grep grepSEC plot.def >> param_plot.idl'
+if (plot eq 'map') then SPAWN, 'grep grepMAP plot.def >> param_plot.idl'
+.compile map_latlon
+.compile section
+
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+out_wrf, $
+        plot=plot, $
+        field1=field1, $
+        field2=field2, $
+        when=1, $
+        winds=winds, $
+        level=level,$
+        save_data=yeah,$        ;; data is loaded only once
+        topo=topo,$
+;        range=range,$
+        colors=colors, $
+        nlon=nlon, $
+        nlat=nlat, $
+        save_ps=denom+string(1001,'(I0)')
+;
+; display the first one as a sample
+;
+SPAWN, 'display ./'+denom+'1001.ps &'
+
+if (num ge 2) then for i=2,num do $
+	out_wrf, $
+	plot=plot, $
+	field1=field1, $
+	field2=field2, $
+	when=i, $
+	winds=winds, $
+	level=level,$
+        save_data=yeah,$	;; data is loaded only once
+	topo=topo,$
+	range=range,$
+	colors=colors, $
+	nlon=nlon, $
+	nlat=nlat, $
+	save_ps=denom+string(1000+i,'(I0)')
+
+SPAWN, 'mv -f ./'+denom+'????.ps '+plotfolder+'/'
+if (backup_data eq 'yes') then SPAWN, 'cp -f namelist.ARWpost '+datafolder+'/'+coord+'.namelist.ARWpost'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.ctl '+datafolder+'/'+coord+'.input.ctl'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.dat '+datafolder+'/'+coord+'.input.dat'
+
+SPAWN, 'cp -f plot.def '+plotfolder+'/'+denom+'.def'
+
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/trace.idl_old
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/trace.idl_old	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/trace.idl_old	(revision 1185)
@@ -0,0 +1,45 @@
+;;---------------------------------------
+;  TRACE
+;
+;  set parameters in user.idl then type:
+;
+;  @trace.idl
+;
+;;---------------------------------------
+
+@user.idl
+
+denom=plot+'_'+coord+'_'+field1
+
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+folder+'/'+coord+'.input.ctl input.ctl'
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+folder+'/'+coord+'.input.dat input.dat'
+
+SPAWN, '\rm map_latlon_user'
+SPAWN, 'tail -15 user.idl > map_latlon_user'
+.compile map_latlon
+
+SPAWN, '\rm section_user'
+SPAWN, 'tail -15 user.idl > section_user'
+.compile section
+
+for i=1,num do $
+	out_wrf, $
+	plot=plot, $
+	field1=field1, $
+	field2=field2, $
+	when=i, $
+	winds=winds, $
+	level=level,$
+        save_data=yeah,$
+	topo=topo,$
+	range=range,$
+	colors=colors, $
+	nlon=nlon, $
+	nlat=nlat 
+
+SPAWN, 'mv -f ./'+denom+'??.ps '+folder+'/'
+if (backup_data eq 'yes') then SPAWN, 'cp -f namelist.ARWpost '+folder+'/'+coord+'.namelist.ARWpost'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.ctl '+folder+'/'+coord+'.input.ctl'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.dat '+folder+'/'+coord+'.input.dat'
+
+SPAWN, 'cp -f user.idl '+folder+'/'+denom+'.idl'
Index: trunk/UTIL/IDLplot/RESERVE/obsolete/user.idl_old
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/obsolete/user.idl_old	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/obsolete/user.idl_old	(revision 1185)
@@ -0,0 +1,126 @@
+;;---------------------------------------
+;
+;  fill here plot parameters then type:
+;
+;  @trace.idl
+;  @report.idl
+;  @movie.idl
+;
+;;---------------------------------------
+
+;-----------------
+; initialization
+;-----------------
+winds=0.
+range=0.
+topo=0.
+colors=32
+backup_data='no' ;backup_data='yes'
+already_data='no' ;already_data='yes'
+folder='./WHERE_RESULTS_ARE/'
+
+
+;-----------------
+; check this first
+;-----------------
+num=6
+;
+;coord='height'
+coord='model_level'
+
+;----------------------------
+; general plot settings
+;----------------------------
+plot='map' & level=-1	
+plot='meridional' & nlon=-1 	;bug a corriger: 0
+;plot='zonal' & nlat=-1		;bug a corriger: 0
+
+;-------------------------------------------
+; easy access to already defined plots
+;-------------------------------------------
+;@map_sea_level.idl
+@map_winds_only.idl
+;@map_ertel_vorticity.idl
+;@map_wind_stress.idl
+
+;------------------------
+; user-defined settings
+;------------------------
+; keywords : plot, winds, field1, field2, range, topo, colors
+;------------------------
+
+;field1='tk'
+;nlon=100
+;range=[200,250]
+
+
+
+
+title_user=''     ;to avoid a warning later
+what_I_plot=0.    ;to avoid a warning later
+missing_value=0.  ;to avoid a warning later
+space=0.
+;;***************************************************
+;; below this line do not modify number of lines
+;; because this will be copied ... with command tail
+;; comment a line if you do not need it :)
+;;***************************************************
+;;------------------------
+;; modify plot parameters
+
+;; SECTION: 
+title_user, title_axis (2) 
+        xtitle='Horizontal coordinate'
+        ytitle='Altitude'
+endif else begin
+        xtitle=title_axis(0)
+        ytitle=title_axis(1)
+endelse
+
+if (n_elements(space) eq 0) then begin
+        space=findgen(n_elements(what_I_plot(*,0)))
+endif
+if (n_elements(altitude) eq 0) then begin
+        altitude=findgen(n_elements(what_I_plot(0,*)))
+endif
+
+if (n_elements(minfield_init) eq 0) then minfield_init=0.
+if (n_elements(maxfield_init) eq 0) then maxfield_init=0.
+if (n_elements(minspace) eq 0) then minspace=0.
+if (n_elements(maxspace) eq 0) then maxspace=0.
+if (n_elements(minalt) eq 0) then minalt=min(altitude)
+if (n_elements(maxalt) eq 0) then maxalt=max(altitude)
+if (n_elements(colors) eq 0) then colors=32
+if (n_elements(title) eq 0) then title=''
+if (n_elements(pal) eq 0) then pal=33
+if (n_elements(format) eq 0) then format='(F6.2)'
+if (format eq '') then format='(F6.2)'
+
+if ((n_elements(overvector_x) eq 0) or (n_elements(overvector_y) eq 0)) then begin
+        overvector_x=0.
+        overvector_y=0.
+endif
+
+;
+; dilatation factor for winds
+;
+if (n_elements(overvector_x)*n_elements(overvector_y) ne 1) then space=space/factor
+
+
+
+
+
+
+;;------------------------
+;;
+space=space 
+ ;minspace=158.5 & maxspace=160.
+minalt=-3 & maxalt=7
+ ;factor=15.
+ ;windex=20.
+ ;format='(F6.3)'
+ ;title_user='Sea-level surface pressure'+title_user
+pal=33
+ ;w=where(abs(what_I_plot) ge 0.03)
+ ;if (w[0] ne -1) then what_I_plot[w]=0.03
+;;**** END ****
Index: trunk/UTIL/IDLplot/RESERVE/out_geo.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/out_geo.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/out_geo.pro	(revision 1185)
@@ -0,0 +1,181 @@
+pro out_geo, $
+	field1=charvar, $
+	field2=charvar2, $
+	domain=domain, $
+	path=path
+
+;---------------------------------------------------------------;
+;                                                               ;
+; Use:                                                          ;
+;       out_geo, 'HGT_M'	(or) out_geo, 'TOPO'		;
+;	out_geo, 'THERMAL_INERTIA' (or) out_geo, 'TI'           ;
+;       out_geo, 'ALBEDO_GCM' (or) out_geo, 'ALBEDO'            ;
+;       out_geo, 'GHT'		                                ;
+;								;
+;	-- nested domain					;
+;	out_geo, 'HGT_M', domain='d02'				;
+;                                                               ;
+; Options:							;
+;		- domain: default is 'd01', 			;
+;			but can be 'd02', 'd03', etc ...	;
+;		- path: where the geo_em files are		; 
+;			'/my_root/my_folder/'			;
+;                                                               ;
+; A. Spiga, April 2007 - July 2007 - September 2007             ;
+;                                                               ;
+;---------------------------------------------------------------;
+
+
+
+
+;----------------------
+; set parameters
+;----------------------
+
+colors=32
+format='(F6.2)'
+minfield_init=0.
+maxfield_init=0.
+
+default_path='./'
+if (n_elements(path) eq 0) then path=default_path
+if (n_elements(domain) eq 0) then domain='d01'
+file=path+'/geo_em.'+domain+'.nc'
+
+
+
+;----------------------
+; equivalent inputs
+;----------------------
+case charvar of
+	'HGT_M':
+	'TOPO': charvar='HGT_M'
+	'THERMAL_INERTIA':
+	'TI': charvar='THERMAL_INERTIA'
+	'ALBEDO_GCM':
+	'ALBEDO': charvar='ALBEDO_GCM'
+	'GHT':
+	else:
+endcase	
+if (n_elements(charvar2) ne 0) then begin
+case charvar2 of
+        'HGT_M':
+        'TOPO': charvar2='HGT_M'
+        'THERMAL_INERTIA':
+        'TI': charvar2='THERMAL_INERTIA'
+        'ALBEDO_GCM':
+        'ALBEDO': charvar2='ALBEDO_GCM'
+        'GHT':
+	else:
+endcase
+endif							
+
+
+;----------------------
+; set graphics
+;----------------------
+
+set_plot, 'ps'
+device, file='geo_em.'+domain+'_'+charvar+'.ps', /color
+;set_plot, 'x'
+
+case charvar of
+        'HGT_M': pal=33 ;16  ;4
+        'THERMAL_INERTIA': pal=3
+        'ALBEDO_GCM': pal=0
+        'GHT': pal=33
+	else:
+endcase
+				
+
+
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+case charvar of
+	'HGT_M': title='Altimetry (km)'
+	'THERMAL_INERTIA': title='Thermal inertia (!NJ!N.m!U-2!N.s!U-1/2!N.K!U-1!N)'
+	'ALBEDO_GCM': title='Albedo LW (%)'
+	'GHT': title='Geopotential height (m)'
+	else: title=''
+endcase
+
+
+;-------------------------------
+; open file and read variables
+;-------------------------------
+cdfid = ncdf_open(file)
+
+; field
+print, charvar
+varid=ncdf_varid(cdfid,charvar)
+        ncdf_varget, cdfid, varid, var
+; lon
+varid=ncdf_varid(cdfid,'XLONG_M')
+        ncdf_varget, cdfid, varid, lon
+	lon=reform(lon[*,0])
+; lat
+varid=ncdf_varid(cdfid,'XLAT_M')
+        ncdf_varget, cdfid, varid, lat
+	lat=reform(lat[0,*])
+
+if (n_elements(charvar2) ne 0) then begin
+	print, charvar2
+	varid=ncdf_varid(cdfid,charvar2)
+	ncdf_varget, cdfid, varid, overcontour
+endif else begin
+	overcontour=0.
+endelse	
+	
+
+;-------------------------------
+; calculation on variables
+;-------------------------------
+case charvar of
+        'HGT_M': var=var/1000
+        'THERMAL_INERTIA': 
+        'ALBEDO_GCM': var=var*100
+        'GHT': 
+	else:
+endcase
+				
+	
+	
+;---------
+; plot !
+;---------
+
+minfield=min(var)
+maxfield=max(var)
+print, 'mM', minfield, maxfield
+
+what_I_plot=var
+
+
+map_set, -90, 0, /azimuthal, limit=[-90,-180,-60,180]
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat                                  ; 1D longitude
+ 
+
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+;        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+;        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title, $                          ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+												
+
+device, /close
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/out_geo_test.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/out_geo_test.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/out_geo_test.pro	(revision 1185)
@@ -0,0 +1,204 @@
+pro out_geo_test, $
+	field1=charvar, $
+	field2=charvar2, $
+	domain=domain, $
+	path=path
+
+;---------------------------------------------------------------;
+;                                                               ;
+; Use:                                                          ;
+;       out_geo, 'HGT_M'	(or) out_geo, 'TOPO'		;
+;	out_geo, 'THERMAL_INERTIA' (or) out_geo, 'TI'           ;
+;       out_geo, 'ALBEDO_GCM' (or) out_geo, 'ALBEDO'            ;
+;       out_geo, 'GHT'		                                ;
+;								;
+;	-- nested domain					;
+;	out_geo, 'HGT_M', domain='d02'				;
+;                                                               ;
+; Options:							;
+;		- domain: default is 'd01', 			;
+;			but can be 'd02', 'd03', etc ...	;
+;		- path: where the geo_em files are		; 
+;			'/my_root/my_folder/'			;
+;                                                               ;
+; A. Spiga, April 2007 - July 2007 - September 2007             ;
+;                                                               ;
+;---------------------------------------------------------------;
+
+
+
+
+;----------------------
+; set parameters
+;----------------------
+
+colors=32
+format='(F6.2)'
+minfield_init=0.
+maxfield_init=0.
+
+default_path='/donnees/aslmd/big_data/WRF/WPS'
+default_path='./'
+
+
+if (n_elements(charvar) eq 0) then charvar='HGT_M'
+if (n_elements(path) eq 0) then path=default_path
+if (n_elements(domain) eq 0) then domain='d01'
+file=path+'/geo_em.'+domain+'.nc'
+
+
+
+;----------------------
+; equivalent inputs
+;----------------------
+case charvar of
+	'HGT_M':
+	'TOPO': charvar='HGT_M'
+	'THERMAL_INERTIA':
+	'TI': charvar='THERMAL_INERTIA'
+	'ALBEDO_GCM':
+	'ALBEDO': charvar='ALBEDO_GCM'
+	'GHT':
+	else:
+endcase	
+if (n_elements(charvar2) ne 0) then begin
+case charvar2 of
+        'HGT_M':
+        'TOPO': charvar2='HGT_M'
+        'THERMAL_INERTIA':
+        'TI': charvar2='THERMAL_INERTIA'
+        'ALBEDO_GCM':
+        'ALBEDO': charvar2='ALBEDO_GCM'
+        'GHT':
+	else:
+endcase
+endif							
+
+
+;----------------------
+; set graphics
+;----------------------
+
+set_plot, 'ps'
+device, file='geo_em.'+domain+'_'+charvar+'.ps', /color
+;set_plot, 'x'
+
+case charvar of
+        'HGT_M': pal=33 ;16  ;4
+        'THERMAL_INERTIA': pal=3
+        'ALBEDO_GCM': pal=0
+        'GHT': pal=33
+	else: pal=33
+endcase
+				
+
+
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+
+case charvar of
+	'HGT_M': title='Altimetry (km)'
+	'THERMAL_INERTIA': title='Thermal inertia (!NJ!N.m!U-2!N.s!U-1/2!N.K!U-1!N)'
+	'ALBEDO_GCM': title='Albedo LW (%)'
+	'GHT': title='Geopotential height (m)'
+	else: title=''
+endcase
+
+
+;-------------------------------
+; open file and read variables
+;-------------------------------
+cdfid = ncdf_open(file)
+
+; field
+print, charvar
+varid=ncdf_varid(cdfid,charvar)
+        ncdf_varget, cdfid, varid, var
+; lon
+varid=ncdf_varid(cdfid,'XLONG_M')
+        ncdf_varget, cdfid, varid, lon
+	lon=reform(lon[*,0])
+; lat
+varid=ncdf_varid(cdfid,'XLAT_M')
+        ncdf_varget, cdfid, varid, lat
+	lat=reform(lat[0,*])
+
+if (n_elements(charvar2) ne 0) then begin
+	print, charvar2
+	varid=ncdf_varid(cdfid,charvar2)
+	ncdf_varget, cdfid, varid, overcontour
+endif else begin
+	overcontour=0.
+endelse	
+	
+
+;-------------------------------
+; calculation on variables
+;-------------------------------
+case charvar of
+        'HGT_M': var=var/1000.
+        'THERMAL_INERTIA': 
+        'ALBEDO_GCM': var=var*100.
+        'GHT': 
+	else:
+endcase
+
+!p.multi=[0,3,3]
+set_ls_tab=[90,270]
+set_lct_tab=[09,12,16]
+set_tau_tab=[0.3,1.5]
+
+for yeahyeahyeah=0,1 do begin
+for yeah=0,1 do begin
+for yeahyeah=0,2 do begin
+set_ls=set_ls_tab(yeah) & print, set_ls
+set_lct=set_lct_tab(yeahyeah) & print, set_lct 
+set_tau=set_tau_tab(yeahyeahyeah) & print, set_tau
+if ((set_ls eq 90) and (set_tau eq 1.5)) then begin
+		goto, beurk
+endif
+@slope.inc	
+
+;---------
+; plot !
+;---------
+
+minfield=min(var)
+maxfield=max(var)
+print, 'mM', minfield, maxfield
+
+yysize=150
+what_I_plot=var
+lon_=lon
+lat_=lat
+;what_I_plot=congrid(reform(var),yysize,yysize,/INTERP)
+;lon_=congrid(lon,yysize)
+;lat_=congrid(lat,yysize)
+
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon_, $                                  ; 1D latitude
+        lat_, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+;        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+;        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title, $                          ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+	
+;;;;;;;;;;;;;;;;;
+beurk:
+endfor
+endfor
+endfor
+;;;;;;;;;;;;;;;;;
+
+
+device, /close
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/ps2png
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/ps2png	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/ps2png	(revision 1185)
@@ -0,0 +1,52 @@
+#! /bin/bash
+# A. Spiga - October-December 2008
+# use: ps2png 
+# options: -r 200 indicates a resolution of 200
+#          -a indicates the alternate use of ps2epsi 
+
+##########
+resol=150
+##########
+
+while getopts "r:a" options; do
+  case $options in
+   r ) resol=${OPTARG} 
+       echo conversion resolution is ${resol} resolution ;;
+   a ) yeahyeah=1
+  esac
+done
+
+
+if [[ $(ls | grep "\.ps") != "" ]]
+then
+	if [[ "${yeahyeah}" == "1" ]]
+	then
+		echo convert $(ls | grep "\.ps" | wc -l) ps files with ps2epsi
+		find *.ps -exec ps2epsi {} \; 2> /dev/null
+		rename -f 's/.epsi/.eps/' *.epsi
+	else
+		echo convert $(ls | grep "\.ps" | wc -l) ps files with convert		
+		find *.ps -exec convert {} '{}.eps' \;
+		rename -f 's/.ps.eps/.eps/' *.ps.eps
+	fi
+fi
+
+if [[ $(ls | grep "\.eps") != "" ]]
+then
+echo convert $(ls | grep "\.eps" | wc -l) eps files
+find *.eps -exec gs -sDEVICE=png16m -dTextAlphaBits=4 -sOutputFile={}.png -dNOPAUSE -dBATCH -dEPSCrop -r${resol}x${resol} {} > /dev/null 2> /dev/null \;
+rename -f 's/.eps.png/.png/' *.eps.png
+fi
+
+#if [[ $(which pngnq) != "" ]]
+#then
+#echo optimizing ...
+#pngnq -vf -s1 *.png > /dev/null 2> /dev/null
+#rename -f 's/-nq8.png$/.png/' *.png
+#fi
+
+##if [[ $(which optipng) != "" ]]
+##then
+##echo optimizing 2 ...
+##optipng -o7 *.png > /dev/null 2> /dev/null
+##fi
Index: trunk/UTIL/IDLplot/RESERVE/report.idl_old
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/report.idl_old	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/report.idl_old	(revision 1185)
@@ -0,0 +1,55 @@
+;;---------------------------------------
+;  REPORT
+;
+;  set parameters in user.idl then type:
+;
+;  @report.idl
+;
+;;---------------------------------------
+
+@user.idl
+
+denom=plot+'_'+coord+'_'+field1
+
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+folder+'/'+coord+'.input.ctl input.ctl'
+if (already_data eq 'yes') then SPAWN, 'ln -sf  '+folder+'/'+coord+'.input.dat input.dat'
+
+SPAWN, '\rm map_latlon_user'
+SPAWN, 'tail -15 user.idl > map_latlon_user'
+.compile map_latlon
+
+SPAWN, '\rm section_user'
+SPAWN, 'tail -15 user.idl > section_user'
+.compile section
+
+for i=1,num do $
+	out_wrf, $
+	plot=plot, $
+	field1=field1, $
+	field2=field2, $
+	when=i, $
+	winds=winds, $
+	level=level,$
+        save_data=yeah,$
+	topo=topo,$
+	range=range,$
+	colors=colors, $
+	nlon=nlon, $
+	nlat=nlat 
+
+
+SPAWN, '\rm report.comments'
+SPAWN, 'echo '+plot+' > report.comments'
+SPAWN, 'echo '+plot+' >> report.comments'
+;SPAWN, 'echo '+coord+' >> report.comments'	;;attention avec le _
+SPAWN, 'rm -f '+denom+'_.ps'
+print, 'executing ... ','base '+denom+'??.ps < report.comments'
+SPAWN, 'base '+denom+'??.ps < report.comments'
+SPAWN, 'mv -f base.ps '+denom+'_.ps'
+SPAWN, 'mv -f ./'+denom+'??.ps '+folder+'/'
+SPAWN, 'mv -f ./'+denom+'_.ps '+folder+'/'
+if (backup_data eq 'yes') then SPAWN, 'cp -f namelist.ARWpost '+folder+'/'+coord+'.namelist.ARWpost'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.ctl '+folder+'/'+coord+'.input.ctl'
+if (backup_data eq 'yes') then SPAWN, 'cp -f input.dat '+folder+'/'+coord+'.input.dat'
+
+SPAWN, 'cp -f user.idl '+folder+'/'+denom+'.idl'
Index: trunk/UTIL/IDLplot/RESERVE/sea_level.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/sea_level.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/sea_level.idl	(revision 1185)
@@ -0,0 +1,323 @@
+
+if ((winds(0) eq 'tk') and (winds(1) eq 'HGT')) then begin
+
+print, 'computing sea-level pressure'
+title='Reduced surf. pressure (Pa)'
+;title='Equiv. Temperature (K)'
+pression=what_I_plot
+
+
+;what_I_plot = what_I_plot + 30.
+;overvector_x = overvector_x*0. + overvector_x(0,0) 
+
+;;
+;; TGCM
+;;
+;nx=n_elements(overvector_y(*,0))
+;ny=n_elements(overvector_y(0,*))
+;tgcm=(  overvector_x(0,0)+ $
+;        overvector_x(nx-1,0)+ $
+;        overvector_x(0,ny-1)+ $
+;        overvector_x(nx-1,ny-1) ) / 4.
+;print, overvector_x(0,0), overvector_x(nx-1,0), overvector_x(0,ny-1), overvector_x(nx-1,ny-1)
+;print, tgcm
+;;
+;; USUAL SYSTEMATIC BIAS
+;;
+;what_I_plot = what_I_plot + 20.
+;;
+;; ROUGH T EFFECT ON RADIATIVE TRANSFER
+;;
+;print, mean(overvector_x)
+;caca=tgcm - overvector_x
+;;caca=tgcm - mean(overvector_x)
+;what_I_plot = what_I_plot - caca
+;;
+;; TEMP FOR HYPSOMETRIC
+;; - attenue un peu - peu d'effets
+;overvector_x = overvector_x*0. + tgcm 
+;;
+;; NOISE OF 2.2 Pa
+;;
+;what_I_plot = what_I_plot + 2.2*(2.*(RANDOMU(seed,nx,ny)-0.5))
+
+;;; NON
+;;;ecart_t = 222. - overvector_x		;; tgcm - tmeso
+;;;ecart_p = - ecart_t			;; pgcm - pmeso
+;;;yeahyeah = what_I_plot - ecart_p  	;; pmeso + pgcm - pmeso = pgcm
+;;;what_I_plot = yeahyeah
+
+;;;;marche bof
+;;overvector_y=CONGRID(overvector_y,nx*50,ny*50)
+;;overvector_y=shift(overvector_y,1,1)
+;;overvector_y=CONGRID(overvector_y,nx,ny)
+
+
+
+;;augmen=10./100.
+;;augmen=0.
+;;mmm=mean(overvector_y)
+;;overvector_y=overvector_y-mmm
+;;overvector_y=overvector_y*(1.+augmen)
+;;print, max(overvector_y), min(overvector_y)
+;;overvector_y=mmm+overvector_y
+;;print, max(overvector_y), mean(overvector_y), min(overvector_y)
+
+
+;;*******************************BRUIT
+;;;;50m limite ...
+;noise=25.
+;print, max(overvector_y), mean(overvector_y), min(overvector_y)
+;overvector_y=overvector_y + noise*(2.*(RANDOMU(seed,nx,ny)-0.5))
+;print, max(overvector_y), mean(overvector_y), min(overvector_y)
+;;*******************************BRUIT
+
+
+
+
+
+
+
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+H=192.*overvector_x/3.72	;;unit is m
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zref=mean(overvector_y)         ;;topo (m)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+goto, notest
+;;;****************************************************************************************
+	;;; TEMPERATURE
+	;temp_meso=overvector_x	   ;;save if needed
+	;overvector_x=mean(overvector_x)
+	;H=192.*overvector_x/3.72
+	;tempbias=temp_meso-overvector_x
+
+;; PRESSURE
+;ptopo=610.*exp(-overvector_y/H) & what_I_plot=ptopo    ;; perfect case
+
+		;w1=where((overvector_y - median(overvector_y)) gt 200.) & w2=where((overvector_y - median(overvector_y)) lt -200.)
+		;tempbias=overvector_x*0. & tempbias[w1] = -20. & tempbias[w2] = +20.
+
+;; TEMPBIAS IN SCALE HEIGHT 
+;tempbias=mean(overvector_x)-overvector_x
+;tempbias=-10.
+
+;; ZREF
+;zref=0.	
+
+;; REFPRES
+;refpres=610.
+
+
+;;
+;; perfect case
+;;
+;ptopo=610.*exp(-overvector_y/H) & what_I_plot=ptopo 
+;tempbias=222.-overvector_x
+;zref=0.
+;refpres=610.
+
+;;
+;; comp OMEGA
+;;
+;tcst = 222. ;;230. 226. 206.
+;tempbias=tcst-overvector_x
+zref=-945.43469
+;refpres=0.
+;zref=-200.
+;zref=-400.
+;zref=-95.
+;;;****************************************************************************************
+notest:
+
+;goto, caca
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;                       ;;
+;; HYPSOMETRIC EQUATION  ;;
+;;			 ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+; recalculate H with temperature bias
+;
+if (n_elements(tempbias) eq 0) then tempbias=0.	;; verif: donne champ constant quand perfect
+H=192.*(overvector_x+tempbias)/3.72
+print, 'zref', zref, ' meanH', mean(H)
+;
+; hypsometric
+;
+what_I_plot=what_I_plot*exp((overvector_y-zref)/H)
+;
+; anomaly
+;
+if (n_elements(refpres) eq 0) then refpres=median(what_I_plot)
+if (refpres eq -9999) then refpres=median(what_I_plot)
+what_I_plot=what_I_plot-refpres
+refpres=-9999.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+caca:
+
+
+goto, coucou
+
+
+	;;for coco=0,100 do begin
+	;;altchosen = 100. - float(coco*10.)
+	;;print, altchosen
+
+
+;altchosen=-915.93644
+;altchosen=200.
+;altchosen=max(overvector_y)
+;altchosen=min(overvector_y)
+;altchosen=mean(overvector_y)
+;altchosen=0.
+;altchosen=-2000.
+;altchosen=-200.
+;altchosen=200.
+;altchosen=-400.
+;altchosen=1000.
+;altchosen=200.  ;; le meilleur match entre H et RT1km/g ATTENTION, NON !!
+;altchosen=-200.  ;; le meilleur pour 13h
+;altchosen=-400. ;;Tequiv trop hautes
+;altchosen=-90.
+;altchosen=-93.
+;altchosen=-95.
+;altchosen=-400.
+;altchosen=-890.
+
+altchosen=-50.
+;read, altchosen, prompt='alt?'
+
+;;-----------------------;;
+;; find nearest point !  ;;
+;;-----------------------;;
+dis=overvector_y-altchosen & w=where(abs(dis) eq min(abs(dis))) & zref=overvector_y[w(0)] & Pref=pression[w(0)]
+print, zref, Pref
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;
+;hache=192.* overvector_x / 3.72 & what_I_plot2=hache*alog(Pref/what_I_plot) - (overvector_y-altchosen)
+;what_I_plot=what_I_plot2
+;print, min(what_I_plot2), max(what_I_plot2), mean(what_I_plot2)
+;goto, coucou
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;-------------------------;;
+;; POSSIBLE 0/0 PROBLEMS   ;;
+;;-------------------------;;
+w=where(abs(alog(Pref/what_I_plot)) lt 0.02) & if (w(0) ne -1) then what_I_plot[w]=!Values.F_NAN
+w=where(abs(overvector_y-zref) lt 100.) & if (w(0) ne -1) then what_I_plot[w]=!Values.F_NAN 
+
+;;-------------------------;;
+;; EQUIVALENT TEMPERATURE  ;;
+;;-------------------------;;
+;
+; H
+;
+what_I_plot=(overvector_y-zref)/alog(Pref/what_I_plot)/1000.
+;
+; T
+;
+what_I_plot=what_I_plot*3.72*1000./192.			
+;what_I_plot=what_I_plot - overvector_x
+
+
+;;-----------------------;;
+;; MOYENNE OK AVEC NANs  ;;
+;;-----------------------;;
+;
+;w=where(FINITE(what_I_plot) ne 0) & moyen=mean(what_I_plot[w]) & print, moyen
+;what_I_plot=what_I_plot-moyen
+
+coucou:
+
+	;;endfor
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+
+;what_I_plot=what_I_plot-mean(what_I_plot)
+
+
+
+;;M1
+;what_I_plot=what_I_plot-ptopo-mean(what_I_plot-ptopo)
+
+
+;what_I_plot=caca
+;what_I_plot=tempbias
+;what_I_plot=topo_ecart
+
+
+
+;level_1km=6
+;;
+;; mean temperature for the whole period
+;;
+;temptmp=reform(u[*,*,level_1km,*])
+;meantemp=total(temptmp,3)/n_elements(temptmp(0,0,*))
+;Hmean=192.*meantemp/3.72
+;;
+;; mean surface pressure for the whole period
+;;
+;temppres=reform(var[*,*,theloop,*])
+;meanpres=total(temppres,3)/n_elements(temppres(0,0,*))
+;
+;
+;        ;** HYDROSTATIC REDUCTION TO LEVEL OF REFERENCE
+;	
+;	overvector_x=reform(u[*,*,level_1km,nt])        ;;T 1km
+;	H=192.*overvector_x/3.72        ;unit is m
+;
+;        overvector_y=reform(v[*,*,0,nt])        ;;topo (m)
+;        zref=mean(overvector_y)
+;        	;zref=median(overvector_y)
+;        	;zref=(max(overvector_y)-min(overvector_y))/2.
+;        	;zref=3000.
+;        print, 'zref', zref
+;
+;	;
+;	; HYPSOMETRIC EQUATION
+;	;
+;;**********
+;H=Hmean
+;;**********
+;	what_I_plot=what_I_plot*exp((overvector_y-zref)/H)
+;	meanpres=meanpres*exp((overvector_y-zref)/Hmean)
+;
+;
+;;
+;; pressure anomaly
+;;
+;what_I_plot=what_I_plot-meanpres
+;
+;
+;;presoro=610.*exp(overvector_y/10000.)
+;;what_I_plot=what_I_plot-presoro
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+
+overvector_x=0
+overvector_y=0
+
+endif
Index: trunk/UTIL/IDLplot/RESERVE/send_esa.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/send_esa.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/send_esa.pro	(revision 1185)
@@ -0,0 +1,35 @@
+restore, filename='yeahyeah'
+filename = 'mesoscale_profile'
+tab1 = HEIGHTP
+
+;tab2 = reform(WHAT_I_PLOT(*,0))
+
+tab2 = reform(WHAT_I_PLOT(*,1)+WHAT_I_PLOT(*,2)+WHAT_I_PLOT(*,3)+WHAT_I_PLOT(*,4)+WHAT_I_PLOT(*,5))/5.
+
+make_ascii, filename+'_MEAN', tab1, tab2
+
+plot, tab1, tab2
+
+tab2 = reform(WHAT_I_PLOT(*,1))
+make_ascii, filename+'_LT7', tab1, tab2
+plot, tab1, tab2
+
+tab2 = reform(WHAT_I_PLOT(*,2))
+make_ascii, filename+'_LT8', tab1, tab2
+plot, tab1, tab2
+
+tab2 = reform(WHAT_I_PLOT(*,3))
+make_ascii, filename+'_LT9', tab1, tab2
+plot, tab1, tab2
+
+tab2 = reform(WHAT_I_PLOT(*,4))
+make_ascii, filename+'_LT10', tab1, tab2
+plot, tab1, tab2
+
+tab2 = reform(WHAT_I_PLOT(*,5))
+make_ascii, filename+'_LT11', tab1, tab2
+plot, tab1, tab2, yrange=[0.,40.]
+
+
+
+
Index: trunk/UTIL/IDLplot/RESERVE/slope.inc
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/slope.inc	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/slope.inc	(revision 1185)
@@ -0,0 +1,124 @@
+;
+; horizontal coordinates (meters)
+;
+rad=3397000.
+deg_m=2*rad*!pi/360.
+dlon=deg_m*cos(lat*!pi/180)
+dlat=deg_m
+x=(lon-min(lon))*dlon
+y=(lat-min(lat))*dlat
+;print, x/1000.
+;print, y/1000.
+
+;;----------------------------
+;; methode directe
+;;----------------------------
+;; var is a 2D field
+;; must be HGT_M
+grad, hx, var*1000., x, y, 1
+grad, hy, var*1000., x, y, 2
+;hx=hx*100. ;pente en %
+
+;;-------------------------------
+;; methode "confiance en geogrid"
+;;-------------------------------
+	;varid=ncdf_varid(cdfid,'MAPFAC_M')
+        ;	ncdf_varget, cdfid, varid, msf
+
+
+varid=ncdf_varid(cdfid,'SLPX')
+	ncdf_varget, cdfid, varid, hxwrf
+varid=ncdf_varid(cdfid,'SLPY')
+	ncdf_varget, cdfid, varid, hywrf
+
+;print, 100.*mean(abs(hx-hxwrf*1000.)/hx)
+;print, 100.*mean(abs(hy-hywrf*1000.)/hy)
+
+hx=hxwrf*1000.
+hy=hywrf*1000.
+
+
+
+;; SLOPE ANGLE vs HORIZONTAL
+;;---------------------------	
+theta=atan(sqrt(hx^2+hy^2))
+theta=180.*theta/!pi
+var=round(theta)
+title='Slope angle (deg)'
+format='(I0)'
+pal=16
+
+;goto, squeeze
+;; SLOPE ORIENTATION
+;;--------------------
+;; cas où hx < 0
+	psi=-!pi/2 - atan(hy/hx)
+;; cas où hx > 0
+	w=where(hx ge 0)
+	psi[w]=psi[w]-!pi
+;; SOUTH 0 & WEST 90
+	psi=2*!pi+psi
+	psi=180.*psi/!pi
+;; NORTH 0 & EAST 90 (as MONTECARLO & PARAM)
+psi=(180.+psi) MOD 360
+
+var=round(psi)
+title='Slope orientation (deg)'
+format='(I0)'
+pal=6
+;;
+squeeze:
+
+
+;
+; latitude
+;
+varid=ncdf_varid(cdfid,'XLAT_M')
+        ncdf_varget, cdfid, varid, latyeah
+
+
+;
+; SCATTERED FLUX RATIO
+;
+
+nx=n_elements(latyeah(*,0))
+ny=n_elements(latyeah(0,*))
+
+ratio_s=dblarr(nx,ny)
+ratio_d=dblarr(nx,ny)
+
+count=0
+
+for i=0,nx-1 do begin
+for j=0,ny-1 do begin
+
+	param_slope, $
+        	ls=set_ls, $            ; < input *
+        	lct=set_lct, $          ; < input *
+        	lat=latyeah(i,j), $     ; < input *
+        	tau=set_tau, $         	; < input *
+        	spz=theta(i,j), $       ; < input *
+        	spa=psi(i,j), $         ; < input *
+        	r_s=tmps, $     ; > output
+        	r_d=tmpd     	; > output
+
+	;count=count+1
+	;print, count, tmps, tmpd
+
+	ratio_s(i,j)=tmps
+	ratio_d(i,j)=tmpd
+
+endfor
+endfor
+
+pal=0	
+format='(I0)'
+var=ratio_s*100. & title='Ratio S/S0 (%)'
+
+;var=ratio_d*100. & title='Ratio Fdir/Fdir0 (%)'
+
+title='Ls='+string(set_ls,'(I0)')+' LT='+string(set_lct,'(I0)')+' tau='+string(set_tau,'(F3.1)')
+minfield_init=30.
+maxfield_init=170.
+
+var=round(var)
Index: trunk/UTIL/IDLplot/RESERVE/tau_cloud.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/tau_cloud.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/tau_cloud.idl	(revision 1185)
@@ -0,0 +1,68 @@
+
+;
+; winds=['ICETOT','RAVE']
+;
+
+if ( (winds(0) eq 'ICETOT') $
+	and (winds(1) eq 'RAVE') ) then begin
+
+print, 'computing water ice cloud opacity'
+
+title='Water ice cloud opacity'
+
+mc=overvector_x		;; kg/m2
+rc=overvector_y		;; m
+
+;
+; VISIBLE BENSON
+;
+rc_mic=2.
+cext=24.655	;; lambda 1 mic
+pi = 3.14159265
+qext=cext/(pi*rc_mic^2)
+print, 'q ext - benson - 1 mic ', qext
+
+;
+; 12 mic.
+;
+cext=70. ;;Wolff 2003 pour 4 mic.
+rc_mic=4.
+pi = 3.14159265
+qext=cext/(pi*rc_mic^2)
+print, 'q ext - wolff - 12 mic ', qext
+;;;Montmessin 2003
+;qext=1.
+
+;
+; .4 microns (visible)
+;
+rc_mic=2.
+cext=20.613  ;;mike
+pi = 3.14159265
+qext=cext/(pi*rc_mic^2)
+print, 'q ext - wolff - 0.4 mic ', qext
+title=title+' at 0.4 !7l!3m'
+
+;;
+;; visible .4 microns
+;;
+;qext=1.8
+;qext=2.
+
+print, 'final q ext ', qext
+
+
+;
+; CALCUL
+;
+what_I_plot = 3.*qext*mc / (4.*917.*rc)
+what_I_plot[where(FINITE(what_I_plot) eq 0)]=0.
+
+;overcontour=3.*qext*mc / (4.*917.*rc)
+;overcontour[where(FINITE(overcontour) eq 0)]=0.
+
+
+overvector_x=0
+overvector_y=0
+
+endif
Index: trunk/UTIL/IDLplot/RESERVE/wind_analysis.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/wind_analysis.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/wind_analysis.pro	(revision 1185)
@@ -0,0 +1,90 @@
+pro wind_analysis
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+retrieve='true'
+;retrieve='false'
+file='zefolder/wrfout_d01_2024-03-21_00:00:00'
+start_time=0.
+interv=1.
+landing_site=[353.87-360.,-1.88]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+; graphics definition
+;
+PS_Start, filename='wind.ps'
+!P.Charsize = 1.2
+
+;!p.charthick = 2.0
+;!p.thick = 3.0
+;!x.thick = 2.0
+;!y.thick = 2.0
+
+if (retrieve eq 'true') then begin
+
+;
+; load WRF coordinates
+;
+getcdf, file=file, charvar='XLAT', invar=lat
+getcdf, file=file, charvar='XLONG', invar=lon
+getcdf, file=file, charvar='HGT', invar=elevation
+;
+; find simulated lander grid point
+;
+findxy, $
+	x=lon, $
+	y=lat, $
+        point=landing_site, $
+	ind=indp, $
+	flag=2
+;
+; get field
+;
+getcdf, file=file, charvar='U', invar=u
+getcdf, file=file, charvar='V', invar=v
+;;field=sqrt(u^2+v^2) & u=0. & v=0.
+;;what_I_plot=reform(field(indp[0],indp[1],*,*))
+  ;;; BEWARE: arrays not the same size... because staggering... u^2+v^2 is wrong and IDL does not complain...
+field=sqrt( u(indp[0],indp[1],*,*)^2 + v(indp[0],indp[1],*,*)^2 ) & u=0. & v=0.
+what_I_plot=reform(field)
+
+;
+; local time
+;
+localtime = float(start_time) + float(interv)*findgen(n_elements(field(0,0,0,*))) ;+ lon(indp[0],indp[1])/15. 
+;
+; get model height
+;
+getcdf, file=file, charvar='PHTOT', invar=ph
+height=reform(ph(indp[0],indp[1],*,*))
+height=total(height,2)/n_elements(height(0,*))
+height=height/1000./3.72
+heightp=height(0:n_elements(height(*))-2)-elevation(indp[0],indp[1])/1000.
+;
+; save
+;
+save, what_I_plot, localtime, heightp, filename='yeahyeah' 
+
+endif else begin
+
+restore, filename='yeahyeah'	
+	
+endelse	
+
+;yeah=where(localtime lt 0) & if (yeah(0) ne -1) then localtime[yeah]=24+localtime[yeah]
+;;; 24h issue
+;localtime=localtime MOD 24 & yeah=where(localtime eq 0) & if (yeah(0) ne -1) then localtime[yeah]=24
+;localtime=24.+localtime
+
+map_latlon, $
+        transpose(what_I_plot), $      ; 2D field
+        localtime, $                   ; 1D latitude
+        heightp, $                      ; 1D longitude
+	overcontour=0
+;        overcontour=transpose(what_I_plot)     ; another 2D field to overplot with contour lines (=0: no)
+
+PS_End, /PNG
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/wind_esa.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/wind_esa.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/wind_esa.pro	(revision 1185)
@@ -0,0 +1,77 @@
+pro wind_esa
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+filename='ok_mesoscale_profile'
+retrieve='true'
+;retrieve='false'
+file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_68.5/jour20/wrfout_d01_2024-03-20_06:00:00'
+start_time=6.
+interv=1.
+landing_site=[353.87-360.,-1.88]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+if (retrieve eq 'true') then begin
+
+;
+; load WRF coordinates
+;
+getcdf, file=file, charvar='XLAT', invar=lat
+getcdf, file=file, charvar='XLONG', invar=lon
+getcdf, file=file, charvar='HGT', invar=elevation
+;
+; find simulated lander grid point
+;
+findxy, $
+	x=lon, $
+	y=lat, $
+        point=landing_site, $
+	ind=indp, $
+	flag=2
+;
+; get field
+;
+getcdf, file=file, charvar='U', invar=u
+getcdf, file=file, charvar='V', invar=v
+  ;;; BEWARE: arrays not the same size... because staggering... u^2+v^2 is wrong and IDL does not complain...
+field=sqrt( u(indp[0],indp[1],*,*)^2 + v(indp[0],indp[1],*,*)^2 ) & u=0. & v=0.
+what_I_plot=reform(field)
+;
+; local time
+;
+localtime = float(start_time) + float(interv)*findgen(n_elements(field(0,0,0,*))) ;+ lon(indp[0],indp[1])/15. 
+;
+; get model height
+;
+getcdf, file=file, charvar='PHTOT', invar=ph
+height=reform(ph(indp[0],indp[1],*,*))
+;height=total(height,2)/n_elements(height(0,*))
+height=height/1000./3.72
+;heightp=height(0:n_elements(height(*))-2)-elevation(indp[0],indp[1])/1000.
+heightp = height - elevation(indp[0],indp[1]) / 1000.
+;
+; save
+;
+save, what_I_plot, localtime, heightp, filename='yeahyeah' 
+
+endif else begin
+
+restore, filename='yeahyeah'	
+	
+endelse	
+
+lctime=[7.,8.,9.,10.,11.]
+for ll=0,n_elements(lctime)-1 do begin
+  w = where(localtime eq lctime(ll))
+  print, localtime[w(0)]
+  tab1 = reform(heightp(*,w(0)))
+  tab2 = reform(what_I_plot(*,w(0)))
+  tab1 = tab1[0:n_elements(tab1)-14]
+  tab2 = tab2[0:n_elements(tab2)-14]
+  make_ascii, filename+'_LT'+string(lctime(ll),'(I0)'), tab1, tab2
+  plot, tab1, tab2
+endfor
+
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/wind_esa_gcm.pro
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/wind_esa_gcm.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/wind_esa_gcm.pro	(revision 1185)
@@ -0,0 +1,79 @@
+pro wind_esa_gcm
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+filename='gcm_profile'
+filetruc='/d6/vblmd/MERIDIANI_EXOMARS/etude_GCM/wrfinput_d01_2024-03-20_'
+start_time=7.
+landing_site=[353.87-360.,-1.88]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+for i=1,4 do begin
+
+if (start_time lt 10) then yeye='0' else yeye=''
+file = filetruc + yeye + string(start_time,'(I0)') + ':00:00'
+
+;
+; load WRF coordinates
+;
+getcdf, file=file, charvar='XLAT', invar=lat
+getcdf, file=file, charvar='XLONG', invar=lon
+getcdf, file=file, charvar='HGT', invar=elevation
+;
+; find simulated lander grid point
+;
+findxy, $
+	x=lon, $
+	y=lat, $
+        point=landing_site, $
+	ind=indp, $
+	flag=2
+;
+; get field
+;
+getcdf, file=file, charvar='U', invar=u
+getcdf, file=file, charvar='V', invar=v
+  ;;; BEWARE: arrays not the same size... because staggering... u^2+v^2 is wrong and IDL does not complain...
+  ;;; it is actually possible to do better with staggering... use XLAT_V and XLONG_U
+field=sqrt( u(indp[0],indp[1],*)^2 + v(indp[0],indp[1],*)^2 ) & u=0. & v=0.
+what_I_plot=reform(field)
+;
+; get model height
+;
+getcdf, file=file, charvar='PHTOT', invar=ph
+height=reform(ph(indp[0],indp[1],*))
+height=height/1000./3.72
+heightp = height - elevation(indp[0],indp[1]) / 1000.
+
+        ;getcdf, file=file, charvar='PTOT', invar=p
+        ;getcdf, file=file, charvar='PSFC', invar=psfc
+        ;hh = reform(p(0,0,*,0))
+        ;p0=610. & t0=220. & r_cp=1/4.4 & grav=3.72 & R=192.
+        ;getcdf, file=file, charvar='T', invar=tpot
+        ;tpot = tpot + t0
+        ;t = tpot * ( p / p0 ) ^ r_cp
+       ;hh(0) = - R * t(indp[0],indp[1],0) / grav / 1000. * alog(psfc(indp[0],indp[1]) / p(indp[0],indp[1],0))
+        ;for i=1,n_elements(hh)-1 do hh(i)    = hh(i-1) - R * t(indp[0],indp[1],i) / grav / 1000. * alog(p(indp[0],indp[1],i) / p(indp[0],indp[1],i-1))
+        ;;heightp = hh
+        ;print, heightp-hh  ;; PAREIL ! pb de density global au modele
+
+;
+; ASCII table
+;
+tab1 = heightp
+tab2 = what_I_plot
+tab1 = tab1[0:n_elements(tab1)-14]
+tab2 = tab2[0:n_elements(tab2)-14]
+make_ascii, filename+'_LT'+string(start_time,'(I0)'), tab1, tab2
+plot, tab1, tab2
+;
+;
+;
+start_time = start_time+1
+print, start_time
+
+endfor
+
+end
Index: trunk/UTIL/IDLplot/RESERVE/wind_stress.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/wind_stress.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/wind_stress.idl	(revision 1185)
@@ -0,0 +1,45 @@
+
+;
+; field1='U'
+; field2='V'
+; winds=['PSFC','tk']
+;
+
+if ((winds(0) eq 'PSFC') $
+	and (winds(1) eq 'tk') $
+	and (field1 eq 'U') $
+	and (field2 eq 'V')) then begin
+
+
+print, 'computing wind stress'
+
+title='Wind stress (!NN!N.m!U-2!N)'
+
+temp=overvector_y
+press=overvector_x
+gasconst=192.
+rho=press/(gasconst*temp)
+
+vonkar=0.4
+heightlay=5.66  ;; a calculer ??
+roughness=0.01
+cd=vonkar/(alog(heightlay/roughness))
+cd=cd^2
+
+velocity2=what_I_plot^2 + overcontour^2
+
+stress=rho*cd*velocity2
+what_I_plot=stress
+
+;;overcontour=-10.*alog(overvector_x/610.)
+overcontour=overvector_x
+
+overvector_x=0
+overvector_y=0
+
+;;tmpfield=reform(u[*,*,0,*])
+;;press_bg = total(tmpfield,3)/n_elements(tmpfield(0,0,*))
+;;overcontour=press_bg
+
+
+endif
Index: trunk/UTIL/IDLplot/RESERVE/wind_velocity.idl
===================================================================
--- trunk/UTIL/IDLplot/RESERVE/wind_velocity.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/RESERVE/wind_velocity.idl	(revision 1185)
@@ -0,0 +1,25 @@
+
+;
+; field1='U'
+; winds=['V','W']
+;
+
+if ( (field1 eq 'U') $
+	and (winds(0) eq 'V') $
+        and (winds(1) eq 'W')  ) then begin
+
+print, 'computing wind velocity'
+
+title='3D wind velocity (!NN!N.m!U-2!N)'
+
+u=what_I_plot
+v=overvector_x
+w=overvector_y
+
+velocity2=u^2+v^2+w^2
+what_I_plot=sqrt(velocity2)
+
+;;overvector_x=0
+;;overvector_y=0
+
+endif
Index: trunk/UTIL/IDLplot/SPEC/GCM/getget_gcm.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GCM/getget_gcm.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GCM/getget_gcm.pro	(revision 1185)
@@ -0,0 +1,129 @@
+function getget_gcm, name, charvar, count=count, offset=offset, stride=stride, coordmean=coordmean, anomaly=anomaly
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; name: char
+; charvar: char
+; count: 4 elements array   ; The dimensions of the sub-image
+; offset: 4 elements array  ; A variable that contains the offset for the sub-image
+; stride: 4 elements array  ; Create a variable to be used as a value for the STRIDE keyword
+; coordmean: 1 to 4 elements array (dimension 1 is 1)
+; anomaly: a non-null element that would be filled with mean
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;print, charvar
+
+
+nosave = 1  ;; comment to get an IDL data file
+notime = 1  ;; comment to get mention of time taken
+if (n_elements(notime) eq 0) then timetime = SYSTIME(1)
+
+;
+; MINIMAL ARGUMENTS
+;
+if (n_elements(name) eq 0) then stop
+if (n_elements(charvar) eq 0) then stop
+
+;
+; IDL DATA DIRECTORY
+;
+name_idl = charvar+name+'.idl'
+  if (n_elements(coordmean) ne 0) then begin
+    nc = n_elements(coordmean)
+    for i=0,nc-1 do begin
+     name_idl = string(coordmean(i),'(I0)')+name_idl   
+    endfor
+  endif
+name_idl = './idl_dat/'+name_idl
+
+;
+; TEST IF FILE EXISTS
+;
+openr,unit,name_idl,/get_lun,error=err
+
+;
+; IF IDL FILE EXISTS, THAT IS RATHER SIMPLE
+;
+IF (err EQ 0) THEN BEGIN
+
+   print, 'read from file'
+   free_lun,unit
+   restore, filename=name_idl
+
+;
+; IF IDL FILE DOES NOT EXIST, WELL, READ NETCDF
+;
+ENDIF ELSE BEGIN
+
+  ;
+  ; check save directory
+  ;
+  if (n_elements(nosave) eq 0) then SPAWN, 'mkdir -p idl_dat'  
+
+  ;
+  ; open file
+  ;
+  id=ncdf_open(name) 
+
+  ;
+  ; get dimensions
+  ;
+  var = intarr(4)
+  ;NCDF_DIMINQ, id, NCDF_DIMID(id, 'lon'  ), toto, titi & var(0) = titi
+  ;NCDF_DIMINQ, id, NCDF_DIMID(id, 'lat'  ), toto, titi & var(1) = titi 
+  ;NCDF_DIMINQ, id, NCDF_DIMID(id, 'sigma'), toto, titi & var(2) = titi
+  ;NCDF_DIMINQ, id, NCDF_DIMID(id, 'time' ), toto, titi & var(3) = titi 
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'longitude'  ), toto, titi & var(0) = titi
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'latitude'  ), toto, titi & var(1) = titi
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'altitude'), toto, titi & var(2) = titi
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time' ), toto, titi & var(3) = titi
+  ;print, var
+
+  ;
+  ; define default data windows
+  ;
+  if (n_elements(offset) le 3) then offset=[0,0,0,0]
+  if (n_elements(stride) le 3) then stride=[1,1,1,1]
+  if (n_elements(count) le 3) then count=intarr(4)
+  w = where(count eq 0) & if (w(0) ne -1) then count[w] = var[w] / stride[w]
+
+  ;
+  ; read variable
+  ;
+  varid=ncdf_varid(id,charvar) ;& print, 'get '+charvar 
+  if (n_elements(notime) eq 0) then timetime = SYSTIME(1) ;& help, /memory
+  ncdf_varget, id, varid, invar, count=count, offset=offset, stride=stride & if (n_elements(notime) eq 0) then print, SYSTIME(1) - timetime, ' s' ;& help, /memory
+  ncdf_close, id
+
+  ;
+  ; OPTIONAL: ANOMALY (value is returned in the keyword)
+  ; 
+  if (n_elements(anomaly) ne 0) then begin
+    anomaly=TOTAL(TOTAL(invar,1),1)/float(var[0])/float(var[1])
+    for i=0,var[0]-1 do for j=0,var[1]-1 do invar(i,j,*,*) = TEMPORARY(invar(i,j,*,*)) - anomaly  ; coute cher
+  endif
+
+  ;
+  ; OPTIONAL: MEAN 
+  ;
+  if (n_elements(coordmean) ne 0) then begin
+  for i=0,nc-1 do begin
+   print, 'mean over dimension '+string(coordmean(i),'(I0)')+' - '+string(var(coordmean(i)),'(I0)')+' elements'
+   invar=total(TEMPORARY(invar),coordmean(i))/var(coordmean(i))
+  endfor
+  endif
+
+  ;
+  ; SAVE
+  ;
+  if (n_elements(nosave) eq 0) then save, invar, filename=name_idl
+
+ENDELSE
+
+if (n_elements(notime) eq 0) then print, SYSTIME(1) - timetime, ' s'
+
+;
+; RETURN FIELD
+;
+return, invar
+
+end
Index: trunk/UTIL/IDLplot/SPEC/GCM/psurf_param_plot.idl
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GCM/psurf_param_plot.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GCM/psurf_param_plot.idl	(revision 1185)
@@ -0,0 +1,88 @@
+;;;;;*************************************** PLOT TITLES
+	subtitle_user	=	''
+	title_axis	=	['East longitude','North latitude']
+	title_user	=	'Surface pressure (Pa)'
+
+;;;;;*************************************** COLOR TABLES
+	flag_cb		=	'true'	
+	format		=	'(I0)'
+	colors		=	64
+	pal		=	16		;; GOOD: 4, 18, 22, 16, 37, 33, 39
+
+;;;;;*************************************** FILL LIMITS
+	minfield_init	=	0.      
+	maxfield_init	=	800. 
+
+;;;;;*************************************** LIMIT TRICKS
+		lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+		lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;		lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value 
+
+;;;;;*************************************** WINDS
+	windex		=	10.
+	stride		=	2.
+
+;;;;;*************************************** CONTOUR
+	lev		=	130. + 10.*findgen(20) 
+
+;;;;;*************************************** AXIS
+	isotropic	=	'true' 
+	intervalx	=	5.
+	intervaly	=	5.
+
+;;;;;*************************************** MAP LIMITS
+	windowx		=	[-145.,-125.]
+	windowy		=	[5.,30.]
+
+
+
+
+;;;;;*************************************** 
+;;;;;*************************************** 
+;;;;;*************************************** 
+;;;;;*************************************** 
+
+
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.		;; grepSEC
+;maxalt=40.		;; grepSEC
+;minspace=0.0  		;; grepSEC
+;maxspace=35.0 		;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
Index: trunk/UTIL/IDLplot/SPEC/GCM/psurf_plotplot.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GCM/psurf_plotplot.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GCM/psurf_plotplot.pro	(revision 1185)
@@ -0,0 +1,60 @@
+pro plotplot
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+file='hi_res_run_swordfish/3830.002/m4/diagfi.nc'
+set_name='psurf'
+it=0
+iz=1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+SPAWN, 'cp psurf_param_plot.idl param_plot.idl'
+
+	;
+	; graphics definition
+	;
+	if (n_elements(saveps) eq 0) then saveps='true'
+	if (saveps eq 'false') then begin 
+	   ;!p.multi=[0,3,2] 
+	   !P.CHARSIZE=2.
+	   WINDOW, /PIXMAP & WDELETE & DEVICE,BYPASS_TRANSLATION=0,DECOMPOSED=0,RETAIN=2
+	endif else begin
+	   PREF_SET, 'IDL_PATH', '/padata/beta/users/aspiga/Save/SOURCES/IDL/fsc_psconfig:<IDL_DEFAULT>', /COMMIT
+	endelse
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+getcdf, file=file, charvar='ps', invar=ps
+getcdf, file=file, charvar='u'    , invar=u
+getcdf, file=file, charvar='v'    , invar=v
+getcdf, file=file, charvar='lon'  , invar=lon
+getcdf, file=file, charvar='lat'  , invar=lat
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+what_I_plot = reform(ps(*,*,it))
+ox          = reform(u(*,*,iz,it))
+oy          = reform(v(*,*,iz,it))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	if (saveps eq 'true') then PS_Start, FILENAME=set_name+'.ps'
+	!P.Charsize = 1.2
+map_latlon, what_I_plot, lon, lat, overvector_x=ox, overvector_y=oy
+	if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+cmd='cp plotplot.pro '+set_name+'_plotplot.pro ; cp param_plot.idl '+set_name+'_param_plot.idl'
+SPAWN, cmd
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+end
Index: trunk/UTIL/IDLplot/SPEC/GCM/tsurf_param_plot.idl
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GCM/tsurf_param_plot.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GCM/tsurf_param_plot.idl	(revision 1185)
@@ -0,0 +1,91 @@
+;;;;;*************************************** PLOT TITLES
+	subtitle_user	=	''
+	subtitle_user	=	'' ;'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 42km [hires GCM]  /  Regular TI'
+	title_axis	=	['East longitude','North latitude']
+	title_user	=	'Wind velocity (m/s) and wind vectors' ;'Surface temperature (K)'
+
+;;;;;*************************************** COLOR TABLES
+	flag_cb		=	'true'	
+	format		=	'(F4.1)' ;'(I0)'
+	colors		=	64
+	pal		=	22		;; GOOD: 4, 18, 22, 16, 37, 33, 39
+
+;;;;;*************************************** FILL LIMITS
+	minfield_init	=	0.     
+	maxfield_init	=	25.  
+        ;minfield_init   =       155.
+        ;maxfield_init   =       175.
+
+;;;;;*************************************** LIMIT TRICKS
+		lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+		lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;		lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value 
+
+;;;;;*************************************** WINDS
+	windex		=	25.
+	stride		=	1. ;2.
+
+;;;;;*************************************** CONTOUR
+	lev 		= 	50. + 50.*findgen(20)
+
+;;;;;*************************************** AXIS
+	isotropic	=	'true' 
+	intervalx	=	2.
+	intervaly	=	2.
+
+;;;;;*************************************** MAP LIMITS
+	windowx		=	[-144.,-126.] ;[-146.,-126.]
+	windowy		=	[10.,26.] ;[10.,28.]
+
+
+
+
+;;;;;*************************************** 
+;;;;;*************************************** 
+;;;;;*************************************** 
+;;;;;*************************************** 
+
+
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.		;; grepSEC
+;maxalt=40.		;; grepSEC
+;minspace=0.0  		;; grepSEC
+;maxspace=35.0 		;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
Index: trunk/UTIL/IDLplot/SPEC/GCM/tsurf_plotplot.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GCM/tsurf_plotplot.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GCM/tsurf_plotplot.pro	(revision 1185)
@@ -0,0 +1,73 @@
+pro tsurf_plotplot
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+file='./diagfi.nc'
+set_name='tsurf'
+it=17
+iz=1
+;iz=0
+iz=3
+;it=4
+it=18 ;; GCM
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+SPAWN, 'cp -f tsurf_param_plot.idl param_plot.idl'
+
+	;
+	; graphics definition
+	;
+	if (n_elements(saveps) eq 0) then saveps='true'
+	if (saveps eq 'false') then begin 
+	   ;!p.multi=[0,3,2] 
+	   !P.CHARSIZE=2.
+	   WINDOW, /PIXMAP & WDELETE & DEVICE,BYPASS_TRANSLATION=0,DECOMPOSED=0,RETAIN=2
+	endif ;else begin
+	   ;PREF_SET, 'IDL_PATH', '/padata/beta/users/aspiga/Save/SOURCES/IDL/fsc_psconfig:<IDL_DEFAULT>', /COMMIT
+	;endelse
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+getcdf, file=file, charvar='tsurf', invar=tsurf
+getcdf, file=file, charvar='ps', invar=ps
+ox = getget_gcm(file, 'u', count=[0,0,1,1], offset=[0,0,iz,it])
+oy = getget_gcm(file, 'v', count=[0,0,1,1], offset=[0,0,iz,it])
+;getcdf, file=file, charvar='u'    , invar=u
+;getcdf, file=file, charvar='v'    , invar=v
+;getcdf, file=file, charvar='lon'  , invar=lon
+;getcdf, file=file, charvar='lat'  , invar=lat
+getcdf, file=file, charvar='longitude'  , invar=lon
+getcdf, file=file, charvar='latitude'  , invar=lat
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;what_I_plot = reform(tsurf(*,*,it))
+oc = reform(ps(*,*,it))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+what_I_plot = sqrt(ox^2 + oy^2)
+;what_I_plot = sqrt(oy^2)
+print, min(what_I_plot)
+print, mean(what_I_plot)
+print, max(what_I_plot)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	if (saveps eq 'true') then PS_Start, FILENAME=set_name+'.ps'
+	!P.Charsize = 1.2
+map_latlon, what_I_plot, lon, lat, overcontour=oc, overvector_x=ox, overvector_y=oy
+	if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;cmd='cp plotplot.pro '+set_name+'_plotplot.pro ; cp param_plot.idl '+set_name+'_param_plot.idl'
+;SPAWN, cmd
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+end
Index: trunk/UTIL/IDLplot/SPEC/GCM/tsurf_plotplot.pro.ou
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GCM/tsurf_plotplot.pro.ou	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GCM/tsurf_plotplot.pro.ou	(revision 1185)
@@ -0,0 +1,68 @@
+pro tsurf_plotplot
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+file='./diagfi.nc'
+set_name='tsurf'
+it=17
+iz=1
+it=4
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+SPAWN, 'cp tsurf_param_plot.idl param_plot.idl'
+
+	;
+	; graphics definition
+	;
+	if (n_elements(saveps) eq 0) then saveps='true'
+	if (saveps eq 'false') then begin 
+	   ;!p.multi=[0,3,2] 
+	   !P.CHARSIZE=2.
+	   WINDOW, /PIXMAP & WDELETE & DEVICE,BYPASS_TRANSLATION=0,DECOMPOSED=0,RETAIN=2
+	endif else begin
+	   PREF_SET, 'IDL_PATH', '/padata/beta/users/aspiga/Save/SOURCES/IDL/fsc_psconfig:<IDL_DEFAULT>', /COMMIT
+	endelse
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+getcdf, file=file, charvar='tsurf', invar=tsurf
+getcdf, file=file, charvar='ps', invar=ps
+ox = getget(file, 'u', count=[0,0,1,1], offset=[0,0,iz,it])
+oy = getget(file, 'v', count=[0,0,1,1], offset=[0,0,iz,it])
+;getcdf, file=file, charvar='u'    , invar=u
+;getcdf, file=file, charvar='v'    , invar=v
+getcdf, file=file, charvar='lon'  , invar=lon
+getcdf, file=file, charvar='lat'  , invar=lat
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+what_I_plot = reform(tsurf(*,*,it))
+oc = reform(ps(*,*,it))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+what_I_plot = sqrt(ox^2 + oy^2)
+;what_I_plot = sqrt(oy^2)
+print, min(what_I_plot)
+print, mean(what_I_plot)
+print, max(what_I_plot)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	if (saveps eq 'true') then PS_Start, FILENAME=set_name+'.ps'
+	!P.Charsize = 1.2
+map_latlon, what_I_plot, lon, lat, overcontour=oc, overvector_x=ox, overvector_y=oy
+	if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;cmd='cp plotplot.pro '+set_name+'_plotplot.pro ; cp param_plot.idl '+set_name+'_param_plot.idl'
+;SPAWN, cmd
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+end
Index: trunk/UTIL/IDLplot/SPEC/GCM/velocity_param_plot.idl
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GCM/velocity_param_plot.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GCM/velocity_param_plot.idl	(revision 1185)
@@ -0,0 +1,88 @@
+;;;;;*************************************** PLOT TITLES
+	subtitle_user	=	''
+	title_axis	=	['East longitude','North latitude']
+	title_user	=	'Horizontal velocity (!Nm.s!U-1!N)'
+
+;;;;;*************************************** COLOR TABLES
+	flag_cb		=	'true'	
+	format		=	'(I0)'
+	colors		=	64
+	pal		=	22		;; GOOD: 4, 18, 22, 16, 37, 33, 39
+
+;;;;;*************************************** FILL LIMITS
+	minfield_init	=	0.      
+	maxfield_init	=	20. 
+
+;;;;;*************************************** LIMIT TRICKS
+		lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+		lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;		lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value 
+
+;;;;;*************************************** WINDS
+	windex		=	10.
+	stride		=	2.
+
+;;;;;*************************************** CONTOUR
+	lev		=	130. + 10.*findgen(20) 
+
+;;;;;*************************************** AXIS
+	isotropic	=	'true' 
+	intervalx	=	5.
+	intervaly	=	5.
+
+;;;;;*************************************** MAP LIMITS
+	windowx		=	[-145.,-125.]
+	windowy		=	[5.,30.]
+
+
+
+
+;;;;;*************************************** 
+;;;;;*************************************** 
+;;;;;*************************************** 
+;;;;;*************************************** 
+
+
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.		;; grepSEC
+;maxalt=40.		;; grepSEC
+;minspace=0.0  		;; grepSEC
+;maxspace=35.0 		;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.	   ;; grepSEC
+;space=space*60. & spacekm='true'   	;; grepSEC
+;minspace=minspace*60./factor       	;; grepSEC
+;maxspace=maxspace*60./factor       	;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0						;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2	;; 2/4 grepMAP
+;what_I_plot(0,0)=0.				;; 3/4 grepMAP
+;flag_cb='false'					;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo 
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value) 	;; 2/9 grepALL
+;what_I_plot[w]=0.   				;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value) 	;; 4/9 grepALL
+;what_I_plot[w]=0.75 				;; 5/9 grepALL
+;w=where(what_I_plot eq 0.) 			;; 6/9 grepALL
+;what_I_plot[w]=missing_value   			;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.	;; 8/9 grepALL
+;flag_cb='false'                         	;; 9/9 grepALL
+
+
+
Index: trunk/UTIL/IDLplot/SPEC/GCM/velocity_plotplot.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GCM/velocity_plotplot.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GCM/velocity_plotplot.pro	(revision 1185)
@@ -0,0 +1,57 @@
+pro plotplot
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+file='hi_res_run_swordfish/3830.002/m4/diagfi.nc'
+set_name='velocity'
+it=0
+iz=1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+	;
+	; graphics definition
+	;
+	if (n_elements(saveps) eq 0) then saveps='true'
+	if (saveps eq 'false') then begin 
+	   ;!p.multi=[0,3,2] 
+	   !P.CHARSIZE=2.
+	   WINDOW, /PIXMAP & WDELETE & DEVICE,BYPASS_TRANSLATION=0,DECOMPOSED=0,RETAIN=2
+	endif else begin
+	   PREF_SET, 'IDL_PATH', '/padata/beta/users/aspiga/Save/SOURCES/IDL/fsc_psconfig:<IDL_DEFAULT>', /COMMIT
+	endelse
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+getcdf, file=file, charvar='u'    , invar=u
+getcdf, file=file, charvar='v'    , invar=v
+getcdf, file=file, charvar='lon'  , invar=lon
+getcdf, file=file, charvar='lat'  , invar=lat
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+what_I_plot = sqrt(reform(u(*,*,iz,it))^2 + reform(v(*,*,iz,it))^2)
+ox          = reform(u(*,*,iz,it))
+oy          = reform(v(*,*,iz,it))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	if (saveps eq 'true') then PS_Start, FILENAME=set_name+'.ps'
+	!P.Charsize = 1.2
+map_latlon, what_I_plot, lon, lat, overvector_x=ox, overvector_y=oy
+	if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+cmd='cp plotplot.pro '+set_name+'_plotplot.pro ; cp param_plot.idl '+set_name+'_param_plot.idl'
+SPAWN, cmd
+;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+end
Index: trunk/UTIL/IDLplot/SPEC/GW/gravitwave.pro.obsolete
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GW/gravitwave.pro.obsolete	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GW/gravitwave.pro.obsolete	(revision 1185)
@@ -0,0 +1,129 @@
+pro gravitwave
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+file='../EN_COURS/gw/ok_hires_wrfout_d01_9999-09-09_09:00:00_z'
+file='../EN_COURS/gw/_wrfout_d01_9999-09-09_09:00:00_z'
+file='../OUTILS_CONVERSION/wrfout_d01_9999-09-09_09:00:00_z'
+charvar='W' & charvarc='W'
+charvar='tk' & charvarc='W'
+charvar='tk' & charvarc='W' & cond=1
+;charvar='tpot' & charvarc='tpot'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;
+;
+what_I_plot=0. & overcontour=0.
+SPAWN, '\rm param_plot.idl ; cp gravitwave_inc.pro param_plot.idl'
+;
+;
+;
+getcdf, $
+        file=file, $
+        charvar=charvar, $
+        invar=invar
+getcdf, $
+        file=file, $
+        charvar=charvarc, $
+        invar=invarc
+getcdf, $
+        file=file, $
+        charvar='vert', $
+        invar=vert
+getcdf, $
+        file=file, $
+        charvar='PTOT', $
+        invar=columnp
+;
+;
+;
+for nt=1,10 do begin
+zefile='gravitwave_'+charvar+'_'+charvarc+'_'+string(nt+100,'(I0)')
+if (n_elements(cond) ne 0) then zefile = 'cond_' + zefile
+;
+;
+;
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+;
+;
+;
+what_I_plot = reform(invar(*,1,*,nt))
+
+
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   file='../LMD_MM_MARS/TESTGW/input_sounding' & header='' & nlines_header=1 & ncol = 5
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   nlines = FILE_LINES(file)-nlines_header & data=FLTARR(ncol,nlines)
+   OPENR, lun, file, /GET_LUN & READF, lun, header & READF, lun, data & CLOSE, lun & FREE_LUN, lun
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   mcd_tpot        = reform(data(1,*))
+   mcd_column      = reform(data(0,*)) ;& mcd_column = ( mcd_column - mcd_column(0) ) / 1000.
+
+   overplot = reform(what_I_plot(30,*))
+   overplot_column = vert/1000.
+   what_I_plot = mcd_tpot
+   column = mcd_column/1000.
+   mention = ''
+;   minfield_init = 0.0001
+;   maxfield_init = 2000.
+   minfield_init = 100.
+   maxfield_init = 240.
+   alt = [0.,100.]
+   SPAWN, '\rm param_plot.idl'
+   profile, $
+        what_I_plot, $                          ; 1D vertical profile
+        column, $                               ; altitudes     
+        alt=alt, $                              ; altitude range [altmin, altmax]
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        inprofile=overplot, $                   ; another vertical profile to overplot
+        incolumn=overplot_column, $             ; altitudes of the other vertical profile (in case /= column)
+;        discrete=discrete, $                    ; show the profile points (= type of points in !psym)
+;        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+;        title_axis=title_axis, $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+        mention=mention                         ; add text precision within the plot window (default is nothing or '')
+
+PS_End, /PNG
+endfor
+end
+
+
+   if (charvar eq 'tk') then what_I_plot = what_I_plot - 20.  ;; -20. because seasonal variability
+   if (n_elements(cond) ne 0) then begin
+     column = columnp
+     @tempcond.inc
+     yeye = reform(overplot(*,1,*,nt))
+     w = where(yeye le 0.) & yeye[w] = 0. 
+     what_I_plot = what_I_plot - yeye 
+   endif
+overcontour = reform(invarc(*,1,*,nt))
+xx = findgen(n_elements(what_I_plot(*,0)))
+zz = vert / 1000.
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        xx, $                                   ; 1D latitude
+        zz, $                                   ; 1D longitude
+;        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+;        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+;        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+;        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+;        ct=pal, $                               ; color table (33-rainbow is default)
+;        colors=colors, $                        ; number of colors/levels (32 is default)
+;        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;
+;
+PS_End, /PNG
+endfor
+end
Index: trunk/UTIL/IDLplot/SPEC/GW/gravitwave2.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GW/gravitwave2.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GW/gravitwave2.pro	(revision 1185)
@@ -0,0 +1,133 @@
+pro gravitwave2
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	;;;; KEEP REFERENCES of FIRST PLOTS 
+	;file='../EN_COURS/gw/ok_hires_wrfout_d01_9999-09-09_09:00:00_z'
+	;file='../EN_COURS/gw/_wrfout_d01_9999-09-09_09:00:00_z'
+	;file='../LMD_MM_MARS/TESTGW/_wrfout_d01_9999-09-09_09:00:00_z'
+	;;file='../LMD_MM_MARS/TESTGW/wind15_wrfout_d01_9999-09-09_09:00:00_z'
+	;file='../TESTGW/wind20c_wrfout_d01_9999-09-09_09:00:00_z'
+folder='/d5/aslmd/GRAVITWAVE/GW_MARS_highwind_3D.157077/'
+folder='/d5/aslmd/GRAVITWAVE/GW_MARS_highwind_narrowmountain_2D.156878/'
+;folder='/d5/aslmd/GRAVITWAVE/GW_MARS_highwind_narrowmountain_3D.157025/'
+folder='/d5/aslmd/GRAVITWAVE/GW_MARS_highwind_narrowmountain_2D.morepoints.160818/'
+folder='/d5/aslmd/GRAVITWAVE/GW_MARS_highwind_3D_loweropacity_morepoints_LT15.161544/'
+folder='/home/aslmd/GRAVITWAVE/GW_MARS_highwind_3D_loweropacity_morepoints.161542/'
+;folder='/home/aslmd/GRAVITWAVE/GW_MARS_highwind_3D_loweropacity_morepoints_LTcst.168440/'
+;folder='/home/aslmd/GRAVITWAVE/GW_MARS_highwind_3D_loweropacity_morepoints_widehill.168468/'
+file=folder+'wrfout_d01_9999-09-09_09:00:00_z'
+charvar='W' & charvarc='W'
+charvar='W' & charvarc='tk' & cond=0
+;charvar='tk' & charvarc='W'
+;charvar='tk' & charvarc='W' & cond=1
+;charvar='tk' & charvarc='tk' & cond=1
+;charvar='tk' & charvarc='tk' & cond=0
+;;charvar='tpot' & charvarc='tpot'
+charvar='HR_NLTE' & charvarc='tk' & cond=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	;folder='/home/aslmd/GRAVITWAVE/'
+	;file=folder+'GW_MARS_highwind_3D_loweropacity_morepoints_diff.nc'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;
+;
+what_I_plot=0. & overcontour=0.
+SPAWN, '\rm param_plot.idl ; cp gravitwave_inc.pro param_plot.idl'
+;
+;
+;
+getcdf, $
+        file=file, $
+        charvar=charvar, $
+        invar=invar
+getcdf, $
+        file=file, $
+        charvar=charvarc, $
+        invar=invarc
+;getcdf, $
+;        file=file, $
+;        charvar='vert', $
+;        invar=vert
+getcdf, $
+         file='/home/aslmd/GRAVITWAVE/GW_MARS_highwind_3D.157077/wrfout_d01_9999-09-09_09:00:00_z', $
+         charvar='vert', $
+         invar=vert
+getcdf, $
+        file=file, $
+        charvar='PTOT', $
+        invar=columnp
+;
+;
+;
+;for nt=4,10 do begin
+;for nt=27,27 do begin
+for nt=1,40 do begin
+;for nt=9,9 do begin
+;for nt=0,20 do begin
+zefile='gravitwave_'+charvar+'_'+charvarc+'_'+string(nt+100,'(I0)')
+if (n_elements(cond) ne 0) then if (cond ne 0) then zefile = 'cond_' + zefile
+;
+;
+;
+  PS_Start, filename=zefile+'.ps' & print, zefile+'.ps'
+;
+;
+;
+s = size(invar) & middle = floor(s[2]/2) & print, 'PLOT at y subs ', middle
+what_I_plot = reform(invar(*,middle,*,nt)) & print, min(what_I_plot), max(what_I_plot)
+overcontour = reform(invarc(*,middle,*,nt))
+   if (n_elements(cond) ne 0) then begin
+   if (cond ne 0) then begin
+     column = columnp
+     ;column = reform(columnp(*,1,*,1))
+     @tempcond.inc
+     yeye = reform(overplot(*,middle,*,nt))
+     w = where(yeye le 0.) & yeye[w] = 0. 
+     if (charvar eq 'tk') then what_I_plot = what_I_plot - yeye 
+     if (charvarc eq 'tk') then overcontour = overcontour - yeye 
+   endif
+   endif
+xx = findgen(n_elements(what_I_plot(*,0)))
+zz = vert / 1000.
+;
+	;;w = where(what_I_plot lt 2.)
+	;;w = where(what_I_plot lt 0.)
+	;w = where(what_I_plot lt -1.)
+	;;w = where(what_I_plot lt -3.)
+	;if (w(0) ne -1) then begin
+	;for i=0,n_elements(w)-1 do begin
+	; ind = ARRAY_INDICES(what_I_plot, w(i))
+	; print, 'x '+string(ind(0),'(I0)')+' z '+string(zz(ind(1)),'(I0)')+' t '+string(nt*925./3700.,'(F4.1)'), what_I_plot(ind[0],ind[1])
+	;endfor
+	;endif
+;
+;
+;
+if (charvar eq 'HR_NLTE') then begin
+	what_I_plot = what_I_plot * 3700. ;; en K/hour
+	;w = where((zz le 60.) and (zz ge 50.)) ;; pour enlever la ligne d'altitude ou le NLTE est active
+        ;if (w(0) ne -1) then what_I_plot(*,w) = 0.
+endif
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        xx, $                                   ; 1D latitude
+        zz, $                                   ; 1D longitude
+;        minfield_init, $               ; minimum value of plotted field (=0: calculate)
+;        maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+;        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+;        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+;        ct=pal, $                               ; color table (33-rainbow is default)
+;        colors=colors, $                        ; number of colors/levels (32 is default)
+;        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;
+;
+PS_End, /PNG
+SPAWN, 'mv '+zefile+'.png '+folder+' ; \rm '+zefile+'.*ps*'
+endfor
+end
Index: trunk/UTIL/IDLplot/SPEC/GW/gravitwave_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GW/gravitwave_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GW/gravitwave_inc.pro	(revision 1185)
@@ -0,0 +1,69 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;; W 
+colors        = 64
+minfield_init = -10.
+maxfield_init = 10. 
+ndiv	      = 10
+format        = '(I0)'
+pal           = 17 ;4 ;16 ;18 ;4
+title_user    = 'Vertical velocity (m s!U-1!N)'
+lev=80.+10.*findgen(30)
+;;;;;;;; tk
+;minfield_init = 110.
+;maxfield_init = 230.
+;ndiv	      = 12
+;format        = '(I0)'
+;pal	      = 33
+;title_user    = 'Temperature (K)'
+;lev = [-10.,-8.,-6.,-4.,-2.,2.,4.,6.,8.,10.]
+;lev=80.+10.*findgen(30)
+;;;;;;;; tk - tsat
+;minfield_init =  -4. ;-8.
+;maxfield_init =  4. ;+8.
+;ndiv	      =  8	
+;format        = '(F4.1)'
+;pal           =  0
+;title_user    = 'T!Datm!N - T!Dsat!N (K)'
+;lev = [-6.,-5.,-4.,-3.,-2.,-1.,0.]
+;;;;;;;;; hr_nlte
+;	minfield_init =  -6.
+;	maxfield_init =  6.
+;	ndiv          =  6
+;	format        = '(F4.1)'
+;	pal           =  33 
+;	title_user    = 'NLTE heating rate (K / hour)'
+lev=[-20.,-18.,-16.,-14.,-12.,-10.,-8.,-6.,-4.,-2.,2.,4.,6.,8.,10.,12.,14.,16.,18.,20.]
+title_user    = 'NLTE cooling rate (K hour!U-1!N)'
+w=where(abs(what_I_plot) le 1e5) & if (w[0] ne -1) then what_I_plot[w] = - what_I_plot[w]
+minfield_init = 0.
+maxfield_init = 20.
+ndiv          = 10
+pal	      = 1 ;4 ;22
+lev=80.+10.*findgen(30)
+format	      = '(I0)'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+flag_cb = 'true'
+windowx = [5.,55.]
+windowy = [0.,100.]
+windowy = [75.,85.]
+windowx = [5., 35.] 
+intervalx = 5.
+intervaly = 5.
+windowy = [0.,130.]
+windowx = [10., 110.] 
+;windowy = [50.,130.]
+intervalx = 10.
+intervaly = 10.
+title_axis = ['horizontal coordinate (x5km)','altitude (km)']
+poscb=0.55
+;isotropic='false'
+;lev = 10.*findgen(100)
+;lev = [-6.,-4.,-2.,2.,4.,6.]
+;;lev = [-8.,-5.,-1.,1.,5.,8.]
+;;lev = [-6.,-5.,-4.,-3.,-2.,-1.,0.]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Index: trunk/UTIL/IDLplot/SPEC/GW/gravitwaveprof.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GW/gravitwaveprof.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GW/gravitwaveprof.pro	(revision 1185)
@@ -0,0 +1,297 @@
+pro gravitwaveprof
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;
+; faire avant api avec kappa 3.9
+;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	path='../TESTGW/'
+	path='/tmp7/aslmd/'
+path='/home/aslmd/GRAVITWAVE/'
+	experiment='mcd_lt16_rcpcst'
+	;experiment='mcd_lt16'
+	;experiment='short_mcd_lt16_rcpcst'
+	;experiment='short_mcd_lt16'
+	;experiment='short_mcd_lt16_calcprho'
+	;experiment='mcd_lt16_calcprho'
+	;experiment='short_mcd_lt16_calcprho_tot'
+	;experiment='colder_gcm_add_short'
+	;experiment='colder_gcm_add'
+	experiment=''
+	;experiment='wind15'
+	;experiment='wind20c'
+	;experiment='colder_gcm_add_3.9_fine_rad_mountain'
+	experiment='test'
+experiment='GW_MARS_highwind_3D.157077'
+experiment='GW_MARS_highwind_3D_lower_opacity.161436'
+experiment='GW_MARS_highwind_3D_loweropacity_lotspoints.161468'
+experiment='GW_MARS_highwind_3D_loweropacity_morepoints.161542'
+;experiment='GW_MARS_highwind_3D_loweropacity_morepoints_LT15.161544'
+;experiment='GW_MARS_highwind_3D_loweropacity_morepoints_LTcst.168440'
+;experiment='GW_MARS_highwind_3D_loweropacity_morepoints_widehill.168468'
+	file=path+experiment+'_wrfout_d01_9999-09-09_09:00:00_z'
+file=path+experiment+'/wrfout_d01_9999-09-09_09:00:00_z'
+;file=path+experiment+'/wrfout_d01_9999-09-09_10:00:00_z'
+;file=path+experiment+'/wrfout_d01_9999-09-09_11:00:00_z'
+charvar='W' & charvarc='W'
+charvar='tk' & charvarc='W'
+charvar='tk' & charvarc='W' & cond=1
+charvar='tpot' & charvarc='tpot'
+;charvar='PTOT' & charvarc='PTOT'
+charvar='tk' & charvarc='tk'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+nts=1  & nte=15   & nxs=0   & nxe=59
+nts=3  & nte=nts  & nxs=999 & nxe=999 ;; moyenne ;; attention a la montagne !!!
+nts=4  & nte=nts  & nxs=31  & nxe=nxs ;; AU CENTRE ! sinon choisir le point en traçant de 0a 59
+nts=1  & nte=nts  & nxs=0   & nxe=59
+nts=4  & nte=nts  & nxs=0   & nxe=59
+nts=1  & nte=15   & nxs=31  & nxe=31
+nts=1  & nte=15   & nxs=45  & nxe=45
+nts=9  & nte=9    & nxs=0   & nxe=59
+nts=1  & nte=13   & nxs=59  & nxe=59
+nts=8  & nte=8    & nxs=0   & nxe=121
+nts=1  & nte=9    & nxs=59  & nxe=59
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+nts=1  & nte=10  & nxs=50   & nxe=50
+;nts=1  & nte=1  & nxs=6   & nxe=6
+nts=1  & nte=100  & nxs=50   & nxe=50
+nts=1  & nte=100  & nxs=60   & nxe=60
+;nts=1  & nte=100  & nxs=20   & nxe=20
+nts=29 & nte=29   & nxs=60   & nxe=60
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;
+;
+what_I_plot=0. & overcontour=0.
+;SPAWN, '\rm param_plot.idl ; cp gravitwave_inc2.pro param_plot.idl'
+;
+;
+;
+getcdf, $
+        file=file, $
+        charvar=charvar, $
+        invar=invar
+;getcdf, $
+;        file=file, $
+;        charvar=charvarc, $
+;        invar=invarc
+getcdf, $
+        file=file, $
+        charvar='vert', $
+        invar=vert
+getcdf, $
+        file=file, $
+        charvar='PTOT', $
+        invar=columnp
+;;
+;; 
+;;
+	s = size(invar) & middle = floor(s[2]/2) & print, 'PLOT at y subs ', middle
+        nte = min(s[4]-1,nte) & print, 'nte ', nte
+        mean_invar = TOTAL(invar(*,*,*,nts:nte),4) / float(nte-nts+1)
+	;mean_columnp = TOTAL(columnp(*,*,*,nts:nte),4) / float(nte-nts+1)
+        anomal_invar = invar & for i=0,s[4]-1 do anomal_invar(*,*,*,i) = anomal_invar(*,*,*,i) - mean_invar
+;;
+;;
+;;
+;	goto, perturb
+for nt=nts,nte do begin
+for nx=nxs,nxe do begin
+;
+zefile=experiment+'_'+charvar+'_'+string(nt+100,'(I0)')+'_'+string(nx+100,'(I0)')
+;
+;
+;
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+;
+;
+;
+;;what_I_plot = reform(invar(*,1,*,nt))
+;what_I_plot = reform(invar(*,59,*,nt))
+what_I_plot = reform(invar(*,middle,*,nt))
+
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   file=path+experiment+'/input_sounding' & header='' & nlines_header=1 & ncol = 5
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   nlines = FILE_LINES(file)-nlines_header & data=FLTARR(ncol,nlines)
+   OPENR, lun, file, /GET_LUN & READF, lun, header & READF, lun, data & CLOSE, lun & FREE_LUN, lun
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   mcd_column      = reform(data(0,*)) 
+   calc_tpot       = reform(data(1,*))
+
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   file=path+experiment+'/input_therm' & ncol = 5
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   nlines = FILE_LINES(file) & data=FLTARR(ncol,nlines)
+   OPENR, lun, file, /GET_LUN & READF, lun, data & CLOSE, lun & FREE_LUN, lun
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   pressure        = reform(data(2,*))
+   mcd_tpot        = reform(data(4,*))   
+
+   if (nx lt 999) then begin
+     what_I_plot = reform(what_I_plot(nx,*))
+   endif else begin
+     what_I_plot = TOTAL(what_I_plot,1) / n_elements(reform(what_I_plot(*,0)))
+   endelse
+
+     ;;;;;;;;;;;
+     ;;;;;;;;;;;
+     ;;;;;;;;;;;
+     column = vert/1000.
+     overplot_column = mcd_column/1000.
+     alt = [20.,150.]
+     alt = [40.,100.]
+     alt = [40.,80.]
+     alt = [0.,120.]
+     alt = [10.,110.]
+     ;;;;;;;;;;;
+     ;;;;;;;;;;;
+     ;mention = ''
+     SPAWN, '\rm param_plot.idl'
+     minfield_init = 85.  ;100.
+     maxfield_init = 185. ;250.
+     minfield_init = 90.
+     maxfield_init = 230.
+     title_axis = ['Temperature (K)','Altitude (km)']
+     overplot = mcd_tpot
+     ;;;;;;;;;;;
+     SPAWN, "echo 'intervaly=10.' >> param_plot.idl"
+     SPAWN, "echo 'intervalx=5.' >> param_plot.idl"
+     SPAWN, "echo 'intervalx=10.' >> param_plot.idl"
+     ;;;;;;;;;;;
+
+	;overplot = reform(mean_invar(nx,middle,*))
+	;overplot_column = column
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;; PLOT PRESSION mettre profile en log
+;column = reform(columnp(nx,middle,*,nt))
+;overplot_column = pressure
+;	;;overplot = mean_invar
+;	;;overplot_column = mean_columnp
+;alt = [1.e2,1.e-3]
+;title_axis = ['Temperature (K)','Pressure (Pa)']
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PLOT PRESSION
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; calculer la CAPE ? Tsat - Tenv / Tenv
+
+
+			;what_I_plot = pressure
+			;	what_I_plot = calc_tpot
+			;overplot = alog(overplot) / alog(10.)
+			;overplot = overplot[where(overplot lt 35.)] ;; evite les valeurs impossibles
+			;what_I_plot = alog(what_I_plot) / alog(10.)
+			;minfield_init = -5.
+			;maxfield_init = 3.
+			;	;;tpot
+			;	minfield_init = 2.
+			;	maxfield_init = 4.
+			;what_I_plot = 100. * abs(calc_tpot - overplot) / overplot
+			;minfield_init = 0.000001
+			;maxfield_init = 100.
+
+   profile, $
+        what_I_plot, $                          ; 1D vertical profile
+        column, $                               ; altitudes     
+        alt=alt, $                              ; altitude range [altmin, altmax]
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        inprofile=overplot, $                   ; another vertical profile to overplot
+        incolumn=overplot_column, $             ; altitudes of the other vertical profile (in case /= column)
+;        discrete=discrete, $                    ; show the profile points (= type of points in !psym)
+;        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+        title_axis=title_axis, $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+        mention=mention                         ; add text precision within the plot window (default is nothing or '')
+
+	;;; sponge layer
+	;w=where(FINITE(overplot) ne 0)
+	;oplot, [minfield_init,maxfield_init], [max(overplot_column[w])-50.,max(overplot_column[w])-50.], linestyle=1
+
+	;column = columnp
+	;@tempcond.inc
+	;yeye = reform(overplot(nx,1,*,nt)) 
+	;;w = where(yeye le 0.) & yeye[w] = !VALUES.F_NAN
+	;;oplot, yeye, vert/1000., linestyle=1
+
+
+loadct, 4
+for i=16,37 do begin  ;10-37
+for j=0,40 do begin
+dec = j - 20  
+overoverplot = reform(invar(nx+dec,middle+dec,*,i))
+oplot, overoverplot, column, color=220  ;psym=3
+endfor
+endfor
+
+!p.thick = 4.0
+oplot, overplot, overplot_column, linestyle=2
+!p.thick = 2.0
+
+!p.thick = 4.0
+oplot, reform(invar(nx,middle,*,28)), column
+!p.thick = 2.0
+
+@tempcond.inc
+overplot = reform(overplot(nx,middle,*,nt))
+w = where(overplot le 0.) & overplot[w] = !VALUES.F_NAN
+oplot, overplot, overplot_column, linestyle=1
+
+	;calc_tk = calc_tpot * (pressure/610.)^(1/4.4)
+	;oplot, calc_tk, column, linestyle=3
+
+PS_End, /PNG
+endfor
+endfor
+
+perturb:
+PS_Start, filename=experiment+'_'+charvar+'_perturb_'+string(nxs+100,'(I0)')+'.ps'
+
+     what_I_plot_loop = reform(anomal_invar(nxs,middle,*,*))
+
+     what_I_plot = reform(what_I_plot_loop(*,nts))
+     column = vert/1000.
+     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+     alt = [0.,120.]
+     minfield_init = -30. 
+     maxfield_init = 30. 
+     title_axis = ['Temperature anomaly (K)','Altitude (km)']
+		;; peut pas changer	
+		;SPAWN, "echo 'intervaly=10.' >> param_plot.idl"
+     		;SPAWN, "echo 'intervalx=5.' >> param_plot.idl"
+     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+     profile, $
+        what_I_plot, $                          ; 1D vertical profile
+        column, $                               ; altitudes     
+        alt=alt, $                              ; altitude range [altmin, altmax]
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        inprofile=overplot, $                   ; another vertical profile to overplot
+        incolumn=overplot_column, $             ; altitudes of the other vertical profile (in case /= column)
+;        discrete=discrete, $                    ; show the profile points (= type of points in !psym)
+;        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+        title_axis=title_axis, $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+        mention=mention                         ; add text precision within the plot window (default is nothing or '')
+
+     for iii=nts+1, nte do begin
+        overplot = reform(what_I_plot_loop(*,iii))
+        overplot_column = column
+        oplot, overplot, overplot_column
+     endfor
+
+	;temppp = reform(mean_invar(nxs,middle,*))
+	;hache = 191.*temppp/3.72/1000.
+	;ok = column / ( 2. * hache )
+	;print, exp(ok)
+	;yeah = exp(ok)
+	;oplot, yeah, column
+
+PS_End, /PNG
+
+end
Index: trunk/UTIL/IDLplot/SPEC/GW/gravitwaveprof.pro.bak
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GW/gravitwaveprof.pro.bak	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GW/gravitwaveprof.pro.bak	(revision 1185)
@@ -0,0 +1,152 @@
+pro gravitwaveprof
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+path='/donnees/aslmd/MODELES/LMD_MM_MARS/TESTGW/'
+experiment='mcd_lt16_rcpcst'
+;experiment='mcd_lt16'
+;experiment='short_mcd_lt16_rcpcst'
+;experiment='short_mcd_lt16'
+;experiment='short_mcd_lt16_calcprho'
+;experiment='mcd_lt16_calcprho'
+;experiment='short_mcd_lt16_calcprho_tot'
+;experiment='colder_gcm_add_short'
+;experiment='colder_gcm_add'
+experiment=''
+;experiment='colder_gcm_add_3.9_fine_rad_mountain'
+file=path+experiment+'_wrfout_d01_9999-09-09_09:00:00_z'
+charvar='W' & charvarc='W'
+charvar='tk' & charvarc='W'
+charvar='tk' & charvarc='W' & cond=1
+charvar='tpot' & charvarc='tpot'
+;charvar='PTOT' & charvarc='PTOT'
+charvar='tk' & charvarc='tk'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;
+;
+what_I_plot=0. & overcontour=0.
+;SPAWN, '\rm param_plot.idl ; cp gravitwave_inc2.pro param_plot.idl'
+;
+;
+;
+getcdf, $
+        file=file, $
+        charvar=charvar, $
+        invar=invar
+getcdf, $
+        file=file, $
+        charvar=charvarc, $
+        invar=invarc
+getcdf, $
+        file=file, $
+        charvar='vert', $
+        invar=vert
+getcdf, $
+        file=file, $
+        charvar='PTOT', $
+        invar=columnp
+;
+;
+;
+for nt=1,10 do begin
+;for nt=3,3 do begin
+;for nt=1,1 do begin
+;for nx=0,59 do begin
+;for nx=1,1 do begin
+;for nx=999,999 do begin  ;; moyenne ;; attention a la montagne !!!
+for nx=30,30 do begin
+zefile=experiment+'_'+charvar+'_'+string(nt+100,'(I0)')+'_'+string(nx+100,'(I0)')
+;
+;
+;
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+;
+;
+;
+what_I_plot = reform(invar(*,1,*,nt))
+
+   ;logp = -10.*alog(reform(columnp(nx,1,*,nt))/610.)
+   ;vert = logp
+
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   file=path+experiment+'/input_sounding' & header='' & nlines_header=1 & ncol = 5
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   nlines = FILE_LINES(file)-nlines_header & data=FLTARR(ncol,nlines)
+   OPENR, lun, file, /GET_LUN & READF, lun, header & READF, lun, data & CLOSE, lun & FREE_LUN, lun
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   mcd_column      = reform(data(0,*)) 
+   calc_tpot       = reform(data(1,*))
+
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   file=path+experiment+'/input_therm' & ncol = 5
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   nlines = FILE_LINES(file) & data=FLTARR(ncol,nlines)
+   OPENR, lun, file, /GET_LUN & READF, lun, data & CLOSE, lun & FREE_LUN, lun
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   pressure        = reform(data(2,*))
+   mcd_tpot        = reform(data(4,*))   
+
+
+   ;nx = 1;30;59;10
+   if (nx lt 999) then begin
+     overplot = reform(what_I_plot(nx,*))
+   endif else begin
+     overplot = TOTAL(what_I_plot,1) / n_elements(reform(what_I_plot(*,0)))
+   endelse 
+   overplot_column = vert/1000.
+   column = mcd_column/1000.
+   mention = ''
+   alt = [0.,150.]
+   SPAWN, '\rm param_plot.idl'
+
+;what_I_plot = pressure
+;	what_I_plot = calc_tpot
+;overplot = alog(overplot) / alog(10.)
+;overplot = overplot[where(overplot lt 35.)] ;; evite les valeurs impossibles
+;what_I_plot = alog(what_I_plot) / alog(10.)
+;minfield_init = -5.
+;maxfield_init = 3.
+;	;;tpot
+;	minfield_init = 2.
+;	maxfield_init = 4.
+
+what_I_plot = mcd_tpot
+minfield_init = 100.
+maxfield_init = 250.
+
+;what_I_plot = 100. * abs(calc_tpot - overplot) / overplot
+;minfield_init = 0.000001
+;maxfield_init = 100.
+
+   profile, $
+        what_I_plot, $                          ; 1D vertical profile
+        column, $                               ; altitudes     
+        alt=alt, $                              ; altitude range [altmin, altmax]
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        inprofile=overplot, $                   ; another vertical profile to overplot
+        incolumn=overplot_column, $             ; altitudes of the other vertical profile (in case /= column)
+;        discrete=discrete, $                    ; show the profile points (= type of points in !psym)
+;        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+;        title_axis=title_axis, $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+        mention=mention                         ; add text precision within the plot window (default is nothing or '')
+
+;; sponge layer
+w=where(FINITE(overplot) ne 0)
+oplot, [minfield_init,maxfield_init], [max(overplot_column[w])-50.,max(overplot_column[w])-50.], linestyle=1
+
+;calc_tk = calc_tpot * (pressure/610.)^(1/4.4)
+;oplot, calc_tk, column, linestyle=3
+
+PS_End, /PNG
+endfor
+endfor
+end
Index: trunk/UTIL/IDLplot/SPEC/GW/scorerprof.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/GW/scorerprof.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/GW/scorerprof.pro	(revision 1185)
@@ -0,0 +1,157 @@
+pro scorerprof
+;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+path='../TESTGW/'
+experiment=''
+	;;path='../TESTGW_save/gw/TESTGW/'
+	;;experiment='mcd_lt16_calcprho'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;
+;
+what_I_plot=0. & overcontour=0.
+zefile=experiment+"_scorer"
+;
+;
+;
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+;
+;
+;
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   file=path+experiment+'/input_sounding' & header='' & nlines_header=1 & ncol = 5
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   nlines = FILE_LINES(file)-nlines_header & data=FLTARR(ncol,nlines)
+   OPENR, lun, file, /GET_LUN & READF, lun, header & READF, lun, data & CLOSE, lun & FREE_LUN, lun
+   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+   z      = reform(data(0,*))  
+   theta  = reform(data(1,*))
+   windu  = reform(data(3,*))   
+           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+           file=path+experiment+'/input_therm' & ncol = 5
+           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+           nlines = FILE_LINES(file) & data=FLTARR(ncol,nlines)
+           OPENR, lun, file, /GET_LUN & READF, lun, data & CLOSE, lun & FREE_LUN, lun
+           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+           rrr      = reform(data(0,*))
+           press    = reform(data(2,*))
+           rho      = reform(data(3,*))
+           temp     = reform(data(4,*))
+
+nsmooth=1
+;nsmooth=3
+;nsmooth=5
+nsmooth=7  ;; 1 lev each km interp, 1 lev each 7 km GCM
+;nsmooth=10  
+nsmooth=15
+nsmooth=20
+nsmooth=22
+z = smooth(z,nsmooth,/EDGE_TRUNCATE)
+theta = smooth(theta,nsmooth,/EDGE_TRUNCATE) 
+windu  = smooth(windu,nsmooth,/EDGE_TRUNCATE)
+	;windu  = smooth(windu,60,/EDGE_TRUNCATE) ;; juste pour lower shear
+
+;;; altitude above local surface
+z = z - z(0)
+
+;;; brunt vaisala frequency
+g=3.72 & dlnthetadz=DERIV(z,alog(theta)) & n2=g*dlnthetadz
+st2 = n2 / (windu^2) 
+	;;w = where(n2 le 0.) 
+  	;;n = n2 & n[w] = 0. & n = sqrt(TEMPORARY(n)) & n[w] = -1.
+	;;st2[w] = 0. 
+
+;;; shear term
+dudz=DERIV(z,windu)
+d2udz2=DERIV(z,dudz)
+dlnrhodz = DERIV(z,alog(rho))
+sh2 = - d2udz2 / windu + dlnrhodz * dudz / windu
+
+;;;; scale height term
+drhodz = DERIV(z,rho)
+d2rhodz2 = DERIV(z,drhodz)
+hh2 = d2rhodz2 / 2. / rho - 0.75 * dlnrhodz * dlnrhodz
+
+	;for i=0,n_elements(windu)-1 do begin
+	;  ;print, windu(i), n2 / (windu^2), - d2udz2(i) / windu(i), dlnrhodz(i) * dudz(i) / windu(i), d2rhodz2 / 2. / rho, - 0.75 * dlnrhodz * dlnrhodz
+	;  print, 'YO YO ... ', st2(i), sh2(i), hh2(i)
+	;endfor
+	;stop
+
+;;; scorer parameter ;; erreur dans article Tobie, Lott98 OK
+scorer2 = st2 + sh2 + hh2    
+
+;;; relative contributions 
+part_buoy = 100. * abs(st2) / (abs(st2)+abs(sh2)+abs(hh2))
+part_shea = 100. * abs(sh2) / (abs(st2)+abs(sh2)+abs(hh2))
+part_heig = 100. * abs(hh2) / (abs(st2)+abs(sh2)+abs(hh2))
+
+;;; scorer wavelength
+scorer = sqrt(scorer2)
+lscorer = scorer & w = where(FINITE(lscorer) eq 0) & if (w(0) ne -1) then lscorer[w] = !Values.F_NAN 
+lscorer = 2 * !pi / lscorer
+
+        for i=0, n_elements(z)-1, 5 do begin
+         print, 'alt, buoy, shear, sc. height, scorer, scorer wvl'
+         print, z(i), part_buoy(i), part_shea(i), part_heig(i), scorer2(i), lscorer(i)/1000.
+        endfor
+
+     ;;;;;;;;;;;
+     what_I_plot = lscorer / 1000.
+     column = z / 1000.
+     overplot_column = column 
+     alt = [0.,150.]
+     mention = ''
+     minfield_init = 0.001 
+     maxfield_init = 200. 
+     title_axis = ['Scorer wavelength (km)','Altitude above local surface (km)']
+     ;;;;;;;;;;;
+
+!p.multi=[0,2,1]
+
+	;plot, temp, column, $
+	;      xtickinterval=50., $
+	;      ytickinterval=10., $
+	;      xtitle=title_axis(0), $
+	;      ytitle=title_axis(1), $
+	;      xrange=[50.,200.], $
+	;      yrange=alt
+	;oplot, 200.+windu, column, linestyle=1
+
+plot, what_I_plot, column, $
+      xtickinterval=50., $
+      ytickinterval=10., $
+      xtitle=title_axis(0), $
+      ytitle=title_axis(1), $
+      xrange=[minfield_init,maxfield_init], $
+      yrange=alt
+oplot, temp, column, linestyle=2
+oplot, 150.+windu, column, linestyle=1
+xyouts, 40., 20., 'dotted: 150+U(z) [m s!U-1!N]', charsize=0.8
+xyouts, 40., 10., 'dashed: T(z) [K]', charsize=0.8
+
+plot, part_buoy, column, $
+      xtickinterval=20., $
+      ytickinterval=10., $
+      xtitle='Contributions to Scorer parameter (%)', $
+      ytitle=title_axis(1), $
+      xrange=[minfield_init,100.], $
+      yrange=alt, $
+      linestyle=0
+oplot, part_shea, column, linestyle=2
+oplot, part_heig, column, linestyle=1
+xyouts, 30., 140., 'full: buoyancy';, charsize=0.8
+xyouts, 30., 130., 'dashed: shear';, charsize=0.8
+xyouts, 30., 120., 'dotted: sc. height';, charsize=0.8
+
+
+
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/THERMALS/gettherm.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/THERMALS/gettherm.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/THERMALS/gettherm.pro	(revision 1185)
@@ -0,0 +1,2686 @@
+PRO gettherm
+
+spawn, 'clear'
+print, ''
+print, '** Thermals Analysis **'
+print, ' (usine à gaz) '
+print, ''
+
+full='true'
+f_offset='false'
+overplot_convadj='false'
+plot_3d = 'false'
+
+lctu_gcm = 8.
+
+; *********** Best values for LES thermals with tau =0.5
+betalpha = 1.3
+afact = 1.8
+fact_epsilon = 0.0008
+detr_min = 0.0007
+
+
+;betalpha = 1.
+;afact = 2.4
+;fact_epsilon = 0.0007
+;detr_min = 0.0007
+
+; --------
+
+; *********** Best values for LES thermals with tau =1.
+;betalpha = 1.
+;afact = 1.1
+;fact_epsilon = 0.00025
+;detr_min = 0.0007
+; --------
+
+;datname='thermiques.dat.scale1.2'
+;datname='thermiques.dat.scale1.4'
+;datname='thermiques.dat.scale0.6'
+datname='thermiques.dat'
+;datname='thermiques.dat.scale0.8'
+;datname='thermiques.dat'           ;scale =1.0, sigmao =1.0
+
+ns = 0     ; number of points for time-smoothing of LES data : 2*ns+1 points, ns = 9 eq to 30mn (-15mn//+15mn)
+nstot = float(2.*ns+1.)
+
+GcmSubCase = ''
+LayerCase=''
+s_trac1 = 'qtrac1'
+s_trac2 = 'qtrac2'
+got_pdt = 'true'
+TestCase = 'Case_A'
+SubCase = '_11_shorter'
+Histo = 'true'
+newtest = ''
+visualization_mode = 'false'
+label_init:
+spawn, 'clear'
+print, ' Available simulations :'
+print, '----'
+print, ' 1/ Case_A_11 : 45x45x71,   ztop=10km,dx=100m,dz=140m,Ls=47.1°,(21.8N;205.0E),55tiu,A=0.275,Tau=0.5'
+print, ' 2/ Case_A_4  : 101x101x201 ztop=15km,dx=100m,dz= 75m,Ls=47.1°,(21.8N;205.0E),55tiu,A=0.275,Tau=0.5'
+print, ' 3/ Case_A_4_shorter  : Case A4 with Dtrac1 = 5 mn and Dtrac2 = 10 mn (compared to 20 and 100)'
+print, ' 4/ Case_A_4_shorter_winds  : Case A4_shorter with bckgrnd wind u=10 m/s'
+print, ' 5/ Case_A_4_shorter_winds_30  : Case A4_shorter with bckgrnd wind u=30 m/s'
+print, ' 6/ Case_A_4_shorter_winds_tau1  : Case A4_shorter with bckgrnd wind u=10 m/s and tau=1'
+print, ' 7/ Case_A_4_shorter_winds_tau2  : Case A4_shorter with bckgrnd wind u=10 m/s and tau=2'
+print, ' 8/ Case_ExtremeCase  : 101x101x201 ztop=15km,dx=100m,dz=75m,Ls=0°,(0.N;0.E),50tiu,A=0.1,Tau=0.05'
+print, '----'
+print, ' 9/ Case_C_4_shorter_winds  : '
+print, ' 10/ Case_I_4_shorter_winds  : '
+print, ' 11/ Case_Z_4_shorter_winds  : '
+print, ' 12/ 1D : 124 layers'
+print, ' 13/ 1D : 32 layers'
+print, ' 14/ 1D : low dt'
+print, ''
+print, ' 0/ PLUME VISUALISATION : '+visualization_mode
+print, ' 999/ CLEAR thermiques.dat for considered case'
+print, ' 100/ OVERPLOT CONVADJ ONLY RESULTS : '+overplot_convadj
+print, ''
+print, ' SIMULATION NUMBER  : '
+print, ' ** '+TestCase+SubCase+LayerCase+' ** '
+print, ''
+print, 'Any change ? (number of new case to change, or any other key to continue)'
+read, newtest
+if (newtest eq '1') then begin
+TestCase = 'Case_A'
+SubCase = '_11'
+pGround = 867.5594
+goto,label_init
+endif
+if (newtest eq '2') then begin
+TestCase = 'Case_A'
+SubCase = '_4'
+got_pdt = 'false'
+pGround = 867.5594
+goto,label_init
+endif
+if (newtest eq '3') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter'
+;s_trac1 = 'qtrac2'
+;s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 867.5594
+goto,label_init
+endif
+if (newtest eq '4') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter_wind'
+;s_trac1 = 'qtrac2'
+;s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 867.5594
+goto,label_init
+endif
+if (newtest eq '5') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter_wind_30'
+GcmSubCase = '_wind_30'
+;s_trac1 = 'qtrac2'
+;s_trac2 = 'qtrac1'
+full = 'true'
+pGround = 867.5594
+f_offset='false'
+goto,label_init
+endif
+if (newtest eq '6') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter_wind_tau1'
+GcmSubCase = '_tau1'
+;s_trac1 = 'qtrac2'
+;s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 867.5594
+goto,label_init
+endif
+if (newtest eq '7') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter_wind_tau2'
+GcmSubCase = '_tau2'
+;s_trac1 = 'qtrac2'
+;s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 867.5594
+goto,label_init
+endif
+if (newtest eq '8') then begin
+TestCase = 'ExtremeCase'
+SubCase = ''
+GcmSubCase = ''
+;s_trac1 = 'qtrac2'
+;s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 677.722
+;lctu_gcm = 6.
+goto,label_init
+endif
+if (newtest eq '9') then begin
+TestCase = 'Case_C'
+SubCase = '_4_shorter_wind'
+;s_trac1 = 'qtrac2'
+;s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 483.
+goto,label_init
+endif
+if (newtest eq '10') then begin
+TestCase = 'Case_I'
+SubCase = '_4_shorter_wind'
+;s_trac1 = 'qtrac2'
+;s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 630.
+goto,label_init
+endif
+if (newtest eq '11') then begin
+TestCase = 'Case_Z'
+SubCase = '_4_shorter_wind'
+;s_trac1 = 'qtrac2'
+;s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 266.
+goto,label_init
+endif
+if (newtest eq '12') then begin
+LayerCase=''
+goto,label_init
+endif
+if (newtest eq '13') then begin
+LayerCase='_32lev'
+goto,label_init
+endif
+if (newtest eq '14') then begin
+LayerCase='_low_dt'
+goto,label_init
+endif
+if (newtest eq '100') then begin
+if (overplot_convadj eq 'true') then overplot_convadj = 'false' else overplot_convadj = 'true'
+goto,label_init
+endif
+if (newtest eq '0') then begin
+visualization_mode = 'true'
+spawn, 'clear'
+print, 'The first timestep of the considered file will be shown.'
+print, 'Defaut file is : file 6 (lt ~ 13h10)'
+print, 'Which file do you want ? (lt ~= file_number + 7)'
+loop_special = '6'
+read, loop_special
+print, 'Do you wish to plot histograms or manipulate volumic data ?'
+print, '1/ Histogram'
+print, '2/ Volumic data'
+x=''
+read, x
+if (x eq '1') then Histo='true' else Histo='false'
+goto,label_init
+endif
+
+;les_path='/san0/acolmd/SIMUS/LES_'+TestCase+SubCase
+;gcm_path='/san0/acolmd/SIMUS/GCM_'+TestCase+LayerCase+'_2'
+;gcm_path='/san0/acolmd/SIMUS/GCM_'+TestCase+GcmSubCase+LayerCase
+;gcm_convadj_path=gcm_path+'_convadj'
+
+;les_path='/data/acolmd/Thermiques/LES_Case_A_4_2trac_wind10_tau05/'
+;les_path='/data/acolmd/Thermiques/LES_Case_A_257x257x301_wind10_tau05'
+;les_path='/data/acolmd/Thermiques/LES_Case_E_257x257x301_wind10_tau005'
+;les_path='/data/acolmd/Thermiques/LES_Case_A_4_2trac_wind30_tau05/'
+;les_path='/data/acolmd/Thermiques/LES_Case_A_4_2trac_wind10_tau1/'
+;les_path='/data/acolmd/Thermiques/LES_Case_A_4_2trac_wind10_tau2/'
+;les_path='/data/acolmd/Thermiques/LES_Case_C_4_2trac_wind10_tau05/'
+;les_path='/data/acolmd/Thermiques/LES_Case_I_4_2trac_wind10_tau05/'
+;les_path='/data/acolmd/Thermiques/LES_Case_Z_4_2trac_wind10_tau05/'
+;les_path='/data/acolmd/Thermiques/ExtremeCase/'
+
+;les_path='/data/acolmd/Thermiques/LES_Case_A_101x101x201_tracup_wind10_tau05_gcmsoil/'
+;les_path='/data/acolmd/Thermiques/LES_Case_E_101x101x201_tracup_wind10_tau005_gcmsoil/'
+;les_path='/data/acolmd/Thermiques/LES_Case_C_101x101x201_tracup_wind10_tau05_gcmsoil'
+;les_path='/data/acolmd/Thermiques/LES_Case_I_101x101x201_tracup_wind10_tau05_gcmsoil'
+;les_path='/data/acolmd/Thermiques/LES_Case_Z_101x101x201_tracup_wind10_tau05_gcmsoil'
+;les_path='/data/acolmd/Thermiques/LES_Case_A_101x101x201_tracup_wind30_tau05_gcmsoil'
+les_path='/data/acolmd/Thermiques/LES_Case_A_101x101x201_tracup_wind10_tau2_gcmsoil'
+
+gcm_path='/data/acolmd/Thermiques/THgcm/'
+gcm_convadj_path=gcm_path+'_convadj'
+
+
+if (newtest eq '999') then spawn, 'rm -f '+les_path+'/'+datname
+print, ''
+print, ' -- Loading LES data -- '
+
+print, 'LES DATA IN : '
+print, les_path
+print, 'GCM DATA IN : '
+print, gcm_path
+
+p0=610. & t0=220. & r_cp=1./3.89419 & grav=3.72 & R=191.182
+history_interval_s = 100.
+;lctu_gcm = 8.                      ; Initial local time of gcm 1d simu
+scale = 1.                         ; Scaling factor for conditional sampling
+decimate = 10.			   ; Coeff for subsampling the data for sigma integral
+sigmao= 0.3			   ; multiplicative coeff for the computation of Sigma0 in the CS
+sigmao_ude = 0.2		   ; number of standard deviation away from mean for the selection of downdraft in UDE
+NBINS=100.
+
+openr,unit,les_path+'/'+datname,/get_lun,error=err
+IF (err ne 0) THEN BEGIN
+
+OPENR, 22, les_path+'/input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+OPENR, 23, les_path+'/input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+
+domain='d01' & filesWRF = FindFile(les_path+'/wrfout_'+domain+'_????-??-??_??:??:??') & nf=n_elements(filesWRF)
+;print, filesWRF
+;domain='d01' & filesWRF = les_path+'/'+['wrfout_d01_9999-01-01_03:05:00','wrfout_d01_9999-01-01_04:06:40'] & nf=n_elements(filesWRF)
+;ce fichier utilise aussi offset_localtime = 3.05
+
+; WARNING WARNING : FOR THE CASE 4_SHORTER, THE TRAC2 HAS 10 MN LIFETIME, WE WANT TO USE IT MORE EXTENSIVELY THAN THE TRAC1 (5mn) SO
+; we switch the names of trac1 and trac2 in the initialization of this routine, in the "case".
+
+; WARNING WARNING : in this version (thermiques2), one of the tracers in the data is just a neutral tracer which will be used to compute the turbulent flux of tracer MMR.  This is a priori done by the tracer 2 (after inversion)
+
+id=ncdf_open(filesWRF(0))
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), dummy, nx & NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), dummy, ny
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'bottom_top'   ), dummy, nz & NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), dummy, nt
+NCDF_CLOSE, id
+id=ncdf_open(filesWRF(nf-1))  ;; for interrupted runs
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), dummy, ntlast
+NCDF_CLOSE, id
+nttot = (nf-1)*nt + ntlast
+wt  = fltarr(nz,nttot) & wq = fltarr(nz,nttot) & wq_updraft = fltarr(nz,nttot) & wq_downdraft = fltarr(nz,nttot) & wq_env_ude=fltarr(nz,nttot)
+q_mean_up = fltarr(nz,nttot) & q_mean_down = fltarr(nz,nttot) & q_mean_env_ude = fltarr(nz,nttot) & q_mean = fltarr(nz,nttot)
+tke_les = fltarr(nz,nttot) & ztke = fltarr(nz,nttot) & t = fltarr(nz,nttot)
+p = fltarr(nz) & ph = fltarr(nz) & pht = fltarr(nz,nttot) & pt = fltarr(nz,nttot)
+xtke = fltarr(nz,nttot) & ytke = fltarr(nz,nttot) & temp_les = fltarr(nz,nttot)
+wmax = fltarr(nttot) 
+alpha1 = fltarr(nz) & alpha2 = fltarr(nz)
+alpha1out = fltarr(nz,nttot) & alpha2out = fltarr(nz,nttot)
+zqtrac1 = dblarr(nx,ny,nz) & zqtrac2 = dblarr(nx,ny,nz)
+sigmazqtrac1 = fltarr(nz) & sigmazqtrac2 = fltarr(nz)
+sigmazminqtrac1 = fltarr(nz) & sigmazminqtrac2 = fltarr(nz)
+fm_trac1_les = fltarr(nz,nttot) & fm_trac2_les = fltarr(nz,nttot)
+anomalqtrac1 = fltarr(nx,ny,nz) & anomalqtrac2 = fltarr(nx,ny,nz)
+e_trac1_les = fltarr(nz,nttot) & e_trac2_les = fltarr(nz,nttot)
+dtempdztmp = fltarr(nx,ny,nz)
+localtime = lctu + history_interval_s*findgen(nttot)/3700.
+w_mean1 = fltarr(nz,nttot) & w_mean2 = fltarr(nz,nttot)
+w_mean1_env = fltarr(nz,nttot) & w_mean1_down = fltarr(nz,nttot)
+w_mean1_env_ude = fltarr(nz,nttot) & w_mean1_full = fltarr(nz,nttot)
+buoyancy1_les = fltarr(nz,nttot) & buoyancy2_les = fltarr(nz,nttot)
+e1_term2 = fltarr(nz,nttot) & e1_term3 = fltarr(nz,nttot) 
+dtetadttmp = fltarr(nx,ny,nz)
+rhomoy1 = fltarr(nz,nttot)
+plumeIndex1out = make_array(nx*ny,nz,VALUE=-1.)	& envIndex1out = make_array(nx*ny,nz,VALUE=-1.)
+hf1tmp = fltarr(nz,nttot) & hf1tmpenv = fltarr(nz,nttot)
+tplume1moy = fltarr(nz,nttot) & tenv1moy = fltarr(nz,nttot) & tenv1moy_ude = fltarr(nz,nttot)
+tmoy_full = fltarr(nz,nttot) & tdown1moy = fltarr(nz,nttot)
+dteta1moydt_entr = fltarr(nz,nttot) & dteta1moydt_detr = fltarr(nz,nttot)
+d1_term1 = fltarr(nz,nttot) & d1_term2 = fltarr(nz,nttot) & d1_term3=fltarr(nz,nttot)
+hf1_term1 = fltarr(nz,nttot) & hf1_term2 = fltarr(nz,nttot) & hf1_term3 = fltarr(nz,nttot)
+d1_term1_ude = fltarr(nz,nttot) & d1_term2_ude = fltarr(nz,nttot) & d1_term3_ude=fltarr(nz,nttot)
+e1_term1_ude = fltarr(nz,nttot) & e1_term2_ude = fltarr(nz,nttot) & e1_term3_ude=fltarr(nz,nttot)
+downward_flux1 = fltarr(nz,nttot) & beta1out = fltarr(nz,nttot)
+hf1_ude_term1 = fltarr(nz,nttot) & hf1_ude_term2 = fltarr(nz,nttot) & hf1_ude_term3 = fltarr(nz,nttot) & hf1_ude_term4 = fltarr(nz,nttot)
+hf1tmpenv_ude = fltarr(nz,nttot) & hf1tmp_down = fltarr(nz,nttot)
+dTeta_phys = make_array(nz,nttot) 
+exner = fltarr(nz,nttot)
+uv_moy = fltarr(nz,nttot)
+tsurf = fltarr(nttot)
+Gamma_1 = fltarr(nz,nttot) & Gamma_2 = fltarr(nz,nttot) & Gamma_3 = fltarr(nz,nttot)
+Gamma_1_tmp = fltarr(nz,nttot) & dgamma1tmp = fltarr(nz,nttot)
+ptotprime = fltarr(nx,ny,nz) & anomalptot = fltarr(nx,ny,nz) & dptotprimedztmp  = fltarr(nx,ny,nz)
+hfx = fltarr(nttot) & flxrad = fltarr(nttot) & flxgrd = fltarr(nttot) & lwdownz = fltarr(nttot) & swdownz = fltarr(nttot)
+
+;wBin = fltarr(NBINS,nttot) & wBinEnv_ude = fltarr(NBINS,nttot) & wBinUp = fltarr(NBINS,nttot) & wBinDown = fltarr(NBINS,nttot)
+l=0
+
+FOR loop  = 0, nf-1 DO BEGIN
+  timetime = SYSTIME(1)
+  if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
+  if (loop ne 0) then loop2_init=0 else loop2_init=1                ;le tout premier pas de temps est l'initialisation, certains champs sont à 0 => bug
+        FOR loop2 = loop2_init, nloop2-1 DO BEGIN
+	pht(*,l) = TOTAL(TOTAL(getget(filesWRF(loop), 'PHTOT',  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny) / 1000. / 3.72
+        ph = TEMPORARY(ph) + pht(*,l) / (nttot-1)
+        ENDFOR
+        print, 'computing altitudes, file '+string(loop+1,'(I0)'), SYSTIME(1) - timetime, ' s'
+ENDFOR
+altitudes_LES  = 1000.*(TEMPORARY(ph)  - hgtu/1000.)  ;; altitude above ground
+pht = fltarr(nz,nttot)
+ph = fltarr(nz)
+
+FOR loop  = 0, nf-1 DO BEGIN
+  timetime = SYSTIME(1)
+  if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
+  if (loop ne 0) then loop2_init=0 else loop2_init=1                ;le tout premier pas de temps est l'initialisation, certains champs sont à 0 => bug
+	FOR loop2 = loop2_init, nloop2-1 DO BEGIN
+	
+	anomalt = 1. & anomalu = 1. & anomalv = 1. & anomalw = 1.
+	; --------------------------------------------------------
+	; u' = u and v' = v   (car PAS de background wind !)
+	; tke = 0.5 ( <u'^2> + <v'^2> + <w'^2> ) ; u' = u ; v' = v
+	; --------------------------------------------------------
+	
+	tprime = getget(filesWRF(loop), 'T', anomaly=anomalt, count=[0,0,0,1], offset=[0,0,0,loop2])  ;; t' = t - <t>
+        t(*,l) = t0 + temporary(anomalt)
+	ztke(*,l) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'W', anomaly=anomalw, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
+	xtke(*,l) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'U', anomaly=anomalu, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
+	ytke(*,l) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'V', anomaly=anomalv, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
+	uv_moy(*,l) = TOTAL(TOTAL(sqrt(getget(filesWRF(loop), 'U', count=[0,0,0,1], offset=[0,0,0,loop2])^2 + getget(filesWRF(loop), 'V', count=[0,0,0,1], offset=[0,0,0,loop2])^2),1),1) / float(nx) / float(ny)
+	tke_les(*,l) = xtke(*,l) + ytke(*,l) + ztke(*,l)
+        wprime = getget(filesWRF(loop), 'W', anomaly=anomalw, count=[0,0,0,1], offset=[0,0,0,loop2])
+        pht(*,l) = TOTAL(TOTAL(getget(filesWRF(loop), 'PHTOT',  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny) / 1000. / 3.72
+	pt(*,l)  = TOTAL(TOTAL(getget(filesWRF(loop), 'PTOT' ,  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny)
+        tsurf(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'TSURF' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
+        hfx(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'HFX' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
+        flxrad(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'FLXRAD' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
+        flxgrd(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'FLXGRD' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
+        lwdownz(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'LWDOWNZ' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
+        swdownz(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'SWDOWNZ' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
+
+        temp_les(*,l) = t(*,l)*(pt(*,l)/p0)^r_cp
+	IF (got_pdt eq 'true') then begin
+	exner(*,l) = (pt(*,l)/p0)^r_cp
+	dTeta_phys(*,l) = (TOTAL(TOTAL(getget(filesWRF(loop), 'PDT', count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny))/exner(*,l)
+	ENDIF
+	ph = TEMPORARY(ph) + pht(*,l) / (nttot-1)
+	p  = TEMPORARY(p ) + pt(*,l) / nttot
+        ptotprime = getget(filesWRF(loop), 'PTOT', count=[0,0,0,1], offset=[0,0,0,loop2])
+	FOR k=0, nz-1 DO BEGIN
+		rhomoy1(*,l) = TOTAL(TOTAL(reform(((ptotprime(*,*,k)/(R*(t(k,l)+tprime(*,*,k))))*(p0/ptotprime(*,*,k))^r_cp)),1),1)/(float(nx)*float(ny))
+		anomalptot(*,*,k) = ptotprime(*,*,k) - total(total(ptotprime(*,*,k),1),1)/ float(nx) / float(ny)    ; prime par rapport a la moyenne du niveau (plus continu)
+        ENDFOR
+	zqtrac1 = getget(filesWRF(loop), s_trac1, count=[0,0,0,1], offset=[0,0,0,loop2])
+;        zqtrac2 = getget(filesWRF(loop), s_trac2, count=[0,0,0,1], offset=[0,0,0,loop2])
+	FOR i=0,nx-1 DO BEGIN
+		FOR j=0, ny-1 DO BEGIN
+			dtempdztmp(i,j,*) = deriv(altitudes_LES, tprime(i,j,*) + t(*,l))
+	                dptotprimedztmp(i,j,*) = deriv(altitudes_LES, anomalptot(i,j,*))
+		ENDFOR
+	ENDFOR
+
+        FOR k=0,nz-1 DO BEGIN
+	        anomalqtrac1(*,*,k) = zqtrac1(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac1(*,*,k)),1),1)/ float(nx) / float(ny)
+;                anomalqtrac2(*,*,k) = zqtrac2(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac2(*,*,k)),1),1)/ float(nx) / float(ny)
+                sigmazqtrac1(k) = STDDEV(REFORM(zqtrac1(*,*,k)))
+	        IF (k ne 0) THEN BEGIN
+         	        subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
+        	       	sigmazminqtrac1(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac1(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
+	        ENDIF ELSE BEGIN
+        	        sigmazminqtrac1(k) = sigmazqtrac1(k)
+	        ENDELSE
+		plumeIndex1 =  WHERE((anomalqtrac1(*,*,k) GT scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) AND ((anomalw(k)+wprime(*,*,k)) GT 0.))
+		envIndex1 = WHERE((anomalqtrac1(*,*,k) LE scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) OR ((anomalw(k)+wprime(*,*,k)) LE 0.))
+;		plumeIndex1 =  WHERE(anomalqtrac1(*,*,k) GT scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)]))
+;		envIndex1 = WHERE(anomalqtrac1(*,*,k) LE scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)]))
+		IF(plumeIndex1(0) EQ -1) THEN BEGIN
+		fm_trac1_les(k,l)=0.
+	        e_trac1_les(k,l)=0.
+		alpha1out(k,l)=0.
+		buoyancy1_les(k,l)=0.
+		w_mean1(k,l)=0.
+		w_mean1_env(k,l)=0.
+		w_mean1_down(k,l)=0.
+		w_mean1_full(k,l)=0.
+		w_mean1_env_ude(k,l)=0.
+		e1_term2(k,l)=0.
+		e1_term3(k,l)=0.
+                e1_term1_ude(k,l)=0.
+                e1_term2_ude(k,l)=0.
+                e1_term3_ude(k,l)=0.
+		hf1tmp(k,l)=0.
+		hf1tmpenv(k,l)=0.
+		Gamma_1_tmp(k,l)=0.
+		plumeIndex1out(*,k)=-1.
+		envIndex1out(*,k)=-1.
+		d1_term1(k,l)=0.
+		d1_term2(k,l)=0.
+		d1_term3(k,l)=0.
+                d1_term1_ude(k,l)=0.
+                d1_term2_ude(k,l)=0.
+                d1_term3_ude(k,l)=0.
+		downward_flux1(k,l)=0.
+		beta1out(k,l)=0.
+		tmoy_full(k,l)=0.
+		tdown1moy(k,l)=0.
+                wq_updraft(k,l)=0.
+                wq_downdraft(k,l)=0.
+                q_mean_up(k,l)=0.
+                q_mean_down(k,l)=0.
+		Gamma_2(k,l)=0.
+		Gamma_3(k,l)=0.
+		ENDIF ELSE BEGIN
+		FOR n=0L,n_elements(plumeIndex1)-1 DO BEGIN
+ 	        	plumeIndex1out(n,k)=plumeIndex1(n)
+		ENDFOR
+		FOR n=0L,n_elements(envIndex1)-1 DO BEGIN
+                        envIndex1out(n,k)=envIndex1(n)
+                ENDFOR
+		alpha1(k) = n_elements(plumeIndex1) / float(nx) / float(ny)
+                wprimetmp = reform(reform((anomalw(k)+wprime(*,*,k))),[nx*ny,1])
+		w_mean1_full(k,l) = mean(wprimetmp)
+                w_mean1(k,l) = mean(wprimetmp(plumeIndex1))
+                w_mean1_env(k,l) = mean(wprimetmp(envIndex1))
+		downdraft_index1 = WHERE((abs(anomalw(k)+wprime(*,*,k)) gt sigmao_ude*STDDEV(wprimetmp(envIndex1))) and (anomalw(k)+wprime(*,*,k) lt 0.))
+		
+		envIndex1_ude = WHERE(((abs(anomalw(k)+wprime(*,*,k)) le sigmao_ude*STDDEV(wprimetmp(envIndex1))) or (anomalw(k)+wprime(*,*,k) ge 0.)) AND ((anomalqtrac1(*,*,k) LE scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) OR ((anomalw(k)+wprime(*,*,k)) LE 0.)))
+		IF (envIndex1_ude(0) ne -1) THEN w_mean1_env_ude(k,l) = mean(wprimetmp(envIndex1_ude)) ELSE w_mean1_env_ude(k,l) =0.
+		if (downdraft_index1(0) ne -1) then begin
+		w_mean1_down(k,l)=mean(wprimetmp(downdraft_index1))
+		wprimetmp=0.
+		beta1 = n_elements(downdraft_index1) / float(nx) / float(ny) 
+		beta1out(k,l)=beta1
+		downward_flux1(k,l) = beta1*rhomoy1(k,l)*w_mean1_down(k,l)
+		endif else begin
+		downward_flux1(k,l)=0.
+		beta1out(k,l)=0.
+		w_mean1_down(k,l)=0.
+		tdown1moy(k,l)=0.
+		endelse
+		fm_trac1_les(k,l) = alpha1(k)*rhomoy1(k,l)*w_mean1(k,l)
+		dtempdztmplin = reform(reform(dtempdztmp(*,*,k)),[nx*ny,1])
+                alpha1out(k,l)=alpha1(k)
+		tfull=reform(tprime(*,*,k)+t(k,l),[nx*ny,1])
+		if (downdraft_index1(0) ne -1) then tdown1moy(k,l)=mean(tfull(downdraft_index1)) 
+		tplume1moy(k,l)=mean(tfull(plumeIndex1))
+		tenv1moy(k,l)=mean(tfull(envIndex1))
+		if (envIndex1_ude(0) ne -1) then tenv1moy_ude(k,l) = mean(tfull(envIndex1_ude)) else tenv1moy_ude(k,l)=0.
+		tmoy_full(k,l) = mean(tfull)
+		buoyancy1_les(k,l)=grav*(tplume1moy(k,l)/tenv1moy(k,l)-1.)
+		e_trac1_les(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy(k,l)-tplume1moy(k,l)))*(dtempdztmplin(plumeIndex1)),1)/float(n_elements(plumeIndex1))
+		d1_term1(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy(k,l)-tplume1moy(k,l)))*(temporary(dtempdztmplin(envIndex1))),1)/float(n_elements(envIndex1))
+		if (envIndex1_ude(0) ne -1) then begin
+                e1_term1_ude(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy_ude(k,l)-tplume1moy(k,l)))*(dtempdztmplin(plumeIndex1)),1)/float(n_elements(plumeIndex1))
+                d1_term1_ude(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy_ude(k,l)-tplume1moy(k,l)))*(temporary(dtempdztmplin(envIndex1_ude))),1)/float(n_elements(envIndex1_ude))
+	     	endif else begin
+		e1_term1_ude(k,l) = 0.
+		d1_term1_ude(k,l) = 0.
+		endelse
+		wtmp=reform(wprime(*,*,k)+anomalw(k),[nx*ny,1])
+		ttmp=reform(tprime(*,*,k)+t(k,l),[nx*ny,1])
+                qtmp=reform(zqtrac1(*,*,k),[nx*ny,1])
+                pttmp=reform(ptotprime(*,*,k),[nx*ny,1])
+                pt_mean1=mean(pttmp(plumeIndex1))
+                pttmp=0.
+;                anomalptot(*,*,k) = ptotprime(*,*,k) - temporary(pt_mean1)    ;prime par rapport a la moyenne dans la plume (oscille fortement : probleme de bonne definition verticale de la plume)
+                Gamma_1_tmp(k,l) = alpha1out(k,l)*rhomoy1(k,l)*TOTAL((wtmp(plumeIndex1)-w_mean1(k,l))^2,1) / float(n_elements(plumeIndex1))
+		anomalptotlin = reform(anomalptot(*,*,k),[nx*ny,1])
+                dptotprimedztmplin = reform(dptotprimedztmp(*,*,k),[nx*ny,1])
+                Gamma_2(k,l) = -(TOTAL(dptotprimedztmplin(plumeIndex1),1)/float(n_elements(plumeIndex1)))/rhomoy1(k,l)
+                Gamma_3(k,l) = -grav*(TOTAL(anomalptotlin(plumeIndex1),1)/float(n_elements(plumeIndex1)))/pt(k,l)
+		hf1tmp(k,l) = TOTAL((wtmp(plumeIndex1)-w_mean1(k,l))*(ttmp(plumeIndex1)-tplume1moy(k,l)),1) / float(n_elements(plumeIndex1))
+		hf1tmpenv(k,l) = TOTAL((wtmp(envIndex1)-w_mean1_env(k,l))*(ttmp(envIndex1)-tenv1moy(k,l)),1) / float(n_elements(envIndex1))
+                q_mean_up(k,l)=mean(qtmp(plumeIndex1))
+		wq_updraft(k,l) = TOTAL((wtmp(plumeIndex1)-w_mean1(k,l))*(qtmp(plumeIndex1)-mean(qtmp(plumeIndex1))),1) / float(n_elements(plumeIndex1))
+
+		if (envIndex1_ude(0) ne -1) then begin
+                hf1tmpenv_ude(k,l) = TOTAL((wtmp(envIndex1_ude)-w_mean1_env_ude(k,l))*(ttmp(envIndex1_ude)-tenv1moy_ude(k,l)),1) / float(n_elements(envIndex1_ude)) 
+                q_mean_env_ude(k,l)=mean(qtmp(envIndex1_ude))
+                wq_env_ude(k,l)= TOTAL((wtmp(envIndex1_ude)-mean(wtmp(envIndex1_ude)))*(qtmp(envIndex1_ude)-mean(qtmp(envIndex1_ude))),1) / float(n_elements(envIndex1_ude))
+                endif else begin
+                hf1tmpenv_ude(k,l) =0.
+                wq_env_ude(k,l)=0.
+                endelse
+		if (downdraft_index1(0) ne -1) then begin
+                hf1tmp_down(k,l) = TOTAL((wtmp(downdraft_index1)-w_mean1_down(k,l))*(ttmp(downdraft_index1)-tdown1moy(k,l)),1) / float(n_elements(downdraft_index1))
+                q_mean_down(k,l)=mean(qtmp(downdraft_index1))
+                wq_downdraft(k,l) = TOTAL((wtmp(downdraft_index1)-mean(wtmp(downdraft_index1)))*(qtmp(downdraft_index1)-mean(qtmp(downdraft_index1))),1) / float(n_elements(downdraft_index1))
+                endif else begin
+                hf1tmp_down(k,l)=0.
+		wq_downdraft(k,l)=0.
+                endelse
+                q_mean(k,l)=mean(qtmp)
+		IF((n_elements(plumeIndex1) + n_elements(envIndex1)) ne float(nx*ny)) then print, 'WARNING : INDEX PROBLEM : plume / env : ', n_elements(plumeIndex1), n_elements(envIndex1)
+;		IF((n_elements(plumeIndex1) + n_elements(envIndex1_ude) + n_elements(downdraft_index1)) ne float(nx*ny)) then print, 'WARNING : INDEX PROBLEM : plume / env / downdraft : ', n_elements(plumeIndex1), n_elements(envIndex1_ude), n_elements(downdraft_index1)
+		ENDELSE
+	ENDFOR
+
+;        FOR i=0, nx-1 DO BEGIN
+;            FOR j=0, ny-1 DO BEGIN
+;                dptotprimedztmp(i,j,*) = deriv(altitudes_LES, anomalptot(i,j,*))
+;            ENDFOR
+;        ENDFOR
+;
+;        FOR k=0, nz-1 DO BEGIN
+;		IF(plumeIndex1out(0,k) eq -1) THEN BEGIN
+;			Gamma_2(k,l)=0.
+;                ENDIF ELSE BEGIN
+;			wpi=where(plumeIndex1out ne -1)
+;			plumeIndex1=reform(plumeIndex1out(temporary(wpi),k))
+;		        dptotprimedztmplin = reform(dptotprimedztmp(*,*,k),[nx*ny,1])
+;		        Gamma_2(k,l) = -(TOTAL(dptotprimedztmplin(plumeIndex1),1)/float(n_elements(plumeIndex1)))/rhomoy1(k,l)
+;		ENDELSE
+;	ENDFOR
+
+        dgamma1tmp(*,l) = deriv(altitudes_LES,Gamma_1_tmp(*,l))
+        FOR k=0, nz-1 DO BEGIN
+	        IF (alpha1out(k,l) ne 0.) THEN BEGIN
+		        Gamma_1(k,l) = -(1./(alpha1out(k,l)*rhomoy1(k,l)))*dgamma1tmp(k,l)
+	        ENDIF ELSE BEGIN
+		        Gamma_1(k,l)=0.
+	 	ENDELSE
+        ENDFOR
+        drhoahfdztmp = deriv(altitudes_LES,rhomoy1(*,l)*alpha1out(*,l)*hf1tmp(*,l))
+        drhoahfdztmpDetr = deriv(altitudes_LES,rhomoy1(*,l)*(1.-alpha1out(*,l))*hf1tmpenv(*,l))
+        drhoahfdztmpDetr_ude = deriv(altitudes_LES,rhomoy1(*,l)*(1.-alpha1out(*,l)-beta1out(*,l))*hf1tmpenv_ude(*,l))
+
+;	wBin(*,l)=HISTOGRAM(wtmp,nbins=NBINS)
+;       wBinEnv_ude(*,l)=HISTOGRAM(wtmp(envIndex1_ude),nbins=NBINS)
+;	wBinUp(*,l)=HISTOGRAM(wtmp(plumeIndex1),nbins=NBINS)
+;	wBinDown(*,l)=HISTOGRAM(wtmp(downdraft_index1),nbins=NBINS)
+	wtmp=0.
+	ttmp=0.
+	
+	FOR k=0,nz-1 DO BEGIN
+		IF(plumeIndex1out(0,k) eq -1) THEN BEGIN
+		e1_term2(k,l)=0.
+		e1_term2_ude(k,l)=0.
+		ENDIF ELSE BEGIN
+		e1_term2(k,l)=drhoahfdztmp(k)/(tenv1moy(k,l)-tplume1moy(k,l))
+		e1_term2_ude(k,l)=drhoahfdztmp(k)/(tenv1moy_ude(k,l)-tplume1moy(k,l))
+		ENDELSE
+
+		IF(envIndex1out(0,k) eq -1) THEN BEGIN
+                d1_term2(k,l)=0.
+		d1_term2_ude(k,l)=0.
+                ENDIF ELSE BEGIN
+		d1_term2(k,l)=-drhoahfdztmpDetr(k)/(tenv1moy(k,l)-tplume1moy(k,l))
+                d1_term2_ude(k,l)=-drhoahfdztmpDetr_ude(k)/(tenv1moy_ude(k,l)-tplume1moy(k,l))
+		ENDELSE
+	ENDFOR
+
+
+	tfull1=0.
+
+        zqtrac1=0.
+;        zqtrac2 = getget(filesWRF(loop), s_trac2, count=[0,0,0,1], offset=[0,0,0,loop2])
+;        FOR k=0,nz-1 DO BEGIN
+;		anomalqtrac2(*,*,k) = zqtrac2(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac2(*,*,k)),1),1)/ float(nx) / float(ny)
+;                sigmazqtrac2(k) = STDDEV(zqtrac2(*,*,k))
+;	        IF (k ne 0) THEN BEGIN
+;	                subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
+;	                sigmazminqtrac2(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac2(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
+;	        ENDIF ELSE BEGIN
+;        	        sigmazminqtrac2(k) = sigmazqtrac2(k)
+;	        ENDELSE
+;                plumeIndex2 = WHERE((anomalqtrac2(*,*,k) GT scale*MAX([sigmazqtrac2(k),sigmazminqtrac2(k)])) AND ((wprime(*,*,k)+anomalw(k)) GT 0.))
+;                envIndex2 = WHERE((anomalqtrac2(*,*,k) LE scale*MAX([sigmazqtrac2(k),sigmazminqtrac2(k)])) OR ((wprime(*,*,k)+anomalw(k)) LE 0.))
+;                IF(plumeIndex2(0) EQ -1) THEN BEGIN
+;		 fm_trac2_les(k,l)=0.
+;		 e_trac2_les(k,l)=0.
+;                alpha2out(k,l)=0.
+;                buoyancy2_les(k,l)=0.
+;		w_mean2(k,l)=0.
+;                ENDIF ELSE BEGIN
+;		alpha2(k) = n_elements(plumeIndex2) / float(nx) / float(ny)
+;                wprimetmp = reform(reform((anomalw(k)+wprime(*,*,k))),[nx*ny,1])
+;                w_mean2(k,l) = mean(wprimetmp(plumeIndex2))
+;		wprimetmp=0.
+;                fm_trac2_les(k,l) = alpha2(k)*rhomoy1(k,l)*w_mean2(k,l)
+;                tprimetmp = reform(reform(-tprime(*,*,k)),[nx*ny,1])
+;                dtempdztmplin = reform(reform(dtempdztmp(*,*,k)),[nx*ny,1])
+;                e_trac2_les(k,l) = TOTAL((1./(temporary(tprimetmp(plumeIndex2))))*(temporary(dtempdztmplin(plumeIndex2))),1)/n_elements(plumeIndex2)
+;                alpha2out(k,l)=alpha2(k)
+;                tfull=reform(tprime(*,*,k)+t(k,l),[nx*ny,1])
+;                tplume2moy=mean(tfull(plumeIndex2))
+;                tenv2moy=mean(tfull(envIndex2))
+;                buoyancy2_les(k,l)=grav*(tplume2moy/tenv2moy-1.)
+;		ENDELSE
+;        ENDFOR
+;        zqtrac2=0.
+
+        wt(*,l) = TOTAL(TOTAL(TEMPORARY(tprime)*wprime,1),1) / float(nx) / float(ny)
+	wq(*,l) = TOTAL(TOTAL(TEMPORARY(wprime)*anomalqtrac1,1),1) / float(nx) / float(ny)
+
+	wmax(l) = max(w_mean1(*,l))
+        l=l+1
+	ENDFOR
+   	print, 'file '+string(loop+1,'(I0)'), SYSTIME(1) - timetime, ' s'
+
+ENDFOR
+
+hf1_term1 = hf1tmp*alpha1out
+hf1_term2 = temporary(hf1tmpenv)*(1.-alpha1out)
+hf1_term3 = alpha1out*(1.-alpha1out)*(w_mean1 - w_mean1_env)*(tplume1moy - tenv1moy)
+
+hf1_ude_term1 = temporary(hf1tmp)*alpha1out
+hf1_ude_term2 = temporary(hf1tmp_down)*beta1out
+hf1_ude_term3 = temporary(hf1tmpenv_ude)*(1.-(alpha1out+beta1out))
+hf1_ude_term4 = alpha1out*(w_mean1 - w_mean1_full)*(tplume1moy - tmoy_full) + beta1out*(w_mean1_down - w_mean1_full)*(tdown1moy - tmoy_full) + (1.- (alpha1out+beta1out))*(w_mean1_env_ude - w_mean1_full)*(tenv1moy_ude - tmoy_full)
+
+FOR k=0, nz-1 DO BEGIN
+;       dteta1moydt_entr(k,*) = deriv(localtime,tplume1moy(k,*))/3700. - dTeta_phys(k,*)
+;       dteta1moydt_detr(k,*) = deriv(localtime,tplume1moy(k,*))/3700. + dTeta_phys(k,*)
+	dteta1moydt_entr(k,*) = deriv(localtime,tplume1moy(k,*))/3700. - dTeta_phys(k,*)
+	dteta1moydt_detr(k,*) =  dTeta_phys(k,*) - deriv(localtime,tplume1moy(k,*))/3700. 
+ENDFOR
+
+FOR k=0, nz-1 DO BEGIN
+	FOR l=0, nttot-1 DO BEGIN
+		IF (tenv1moy(k,l) ne tplume1moy(k,l)) THEN e1_term3(k,l) = rhomoy1(k,l)*alpha1out(k,l)*dteta1moydt_entr(k,l)/(tenv1moy(k,l)-tplume1moy(k,l)) ELSE e1_term3(k,l)=0.
+                IF (tenv1moy_ude(k,l) ne tplume1moy(k,l)) THEN e1_term3_ude(k,l) = rhomoy1(k,l)*alpha1out(k,l)*dteta1moydt_entr(k,l)/(tenv1moy_ude(k,l)-tplume1moy(k,l)) ELSE e1_term3_ude(k,l)=0
+;		IF (tenv1moy(k,l) ne tplume1moy(k,l)) THEN d1_term3(k,l) = rhomoy1(k,l)*(1.-alpha1out(k,l))*dteta1moydt_detr(k,l)/(tenv1moy(k,l)-tplume1moy(k,l)) ELSE d1_term3(k,l)=0.
+		IF (tenv1moy(k,l) ne tplume1moy(k,l)) THEN d1_term3(k,l) = rhomoy1(k,l)*(1.-alpha1out(k,l))*dteta1moydt_detr(k,l)/(tenv1moy(k,l)-tplume1moy(k,l)) ELSE d1_term3(k,l)=0.
+                IF (tenv1moy_ude(k,l) ne tplume1moy(k,l)) THEN d1_term3_ude(k,l) = rhomoy1(k,l)*(1.-alpha1out(k,l)-beta1out(k,l))*dteta1moydt_detr(k,l)/(tenv1moy_ude(k,l)-tplume1moy(k,l)) ELSE d1_term3_ude(k,l)=0.
+	ENDFOR
+ENDFOR
+
+
+ht = TEMPORARY(pht) - hgtu/1000.
+save, hfx, flxrad, flxgrd, lwdownz, swdownz, q_mean_up, q_mean_down, q_mean_env_ude, q_mean, Gamma_1, Gamma_2, Gamma_3, w_mean1_env, tsurf, wq, wq_updraft, wq_downdraft, wq_env_ude, d1_term1_ude, d1_term2_ude, d1_term3_ude, e1_term1_ude, e1_term2_ude, e1_term3_ude, tplume1moy, tdown1moy, w_mean1_full, tmoy_full, tenv1moy_ude, w_mean1_env_ude, uv_moy, hf1_ude_term1, hf1_ude_term2, hf1_ude_term3, hf1_ude_term4, w_mean1_down, downward_flux1, beta1out, hf1_term1, hf1_term2, hf1_term3, d1_term1, d1_term2, d1_term3, e1_term2, e1_term3, buoyancy1_les, buoyancy2_les, w_mean1, w_mean2, nx, ny, alpha1out, alpha2out, e_trac1_les, e_trac2_les, tke_les, ztke, altitudes_LES, ht, t, p, pt, localtime, xtke, ytke, wt, temp_les, wmax, fm_trac1_les, fm_trac2_les,filename=les_path+'/'+datname
+
+nz = n_elements(altitudes_LES)
+
+ENDIF ELSE BEGIN
+
+print, 'OK, file is here'
+restore, filename=les_path+'/'+datname
+nz = n_elements(altitudes_LES)
+nttot = n_elements(tmoy_full(0,*))
+
+OPENR, 23, les_path+'/input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+
+ENDELSE
+
+tenv1moy = tplume1moy/((buoyancy1_les/grav)+1.)
+
+taverage = string((localtime(nstot)-localtime(1))*3700./60.)
+print, ''
+print, ' -- Loading testphys1d data -- '
+
+file1=gcm_path+'/diagfi.nc'
+file2=gcm_convadj_path+'/diagfi.nc'
+file3='/san0/acolmd/SIMUS/GCM3D_TestBed/diagfi.nc'
+
+getcdf, file=file1, charvar='q2', invar=tke_gcm
+getcdf, file=file1, charvar='aps', invar=aps
+getcdf, file=file1, charvar='bps', invar=bps
+getcdf, file=file1, charvar='co2col', invar=co2_col
+;getcdf, file=file1, charvar='arcol', invar=ar_col
+getcdf, file=file1, charvar='tkecol', invar=tke_col
+;getcdf, file=file1, charvar='ar', invar=ar
+getcdf, file=file1, charvar='heatFlux_up', invar=heatFlux_up
+getcdf, file=file1, charvar='heatFlux_down', invar=heatFlux_down
+getcdf, file=file1, charvar='pplay', invar=pplay
+getcdf, file=file1, charvar='pplev', invar=pplev
+getcdf, file=file1, charvar='temp', invar=temp_gcm
+getcdf, file=file1, charvar='zw2', invar=zw2_lev
+getcdf, file=file1, charvar='fm_therm', invar=fm_therm_gcm_lev
+getcdf, file=file1, charvar='entr_therm', invar=zdz_entr_therm_gcm
+getcdf, file=file1, charvar='detr_therm', invar=zdz_detr_therm_gcm
+getcdf, file=file1, charvar='fraca', invar=alpha_gcm_lev
+getcdf, file=file1, charvar='buoyancyOut', invar=buoyancy_gcm
+getcdf, file=file1, charvar='buoyancyEst', invar=buoyancy_est_gcm
+getcdf, file=file1, charvar='zkh', invar=zkh
+getcdf, file=file1, charvar='zh', invar=zh
+getcdf, file=file1, charvar='tsurf', invar=tsurf_gcm
+
+if (overplot_convadj eq 'true') then begin
+getcdf, file=file2, charvar='temp', invar=temp_gcm_convadj
+getcdf, file=file2, charvar='pplay', invar=pplay_convadj
+endif
+if (plot_3d eq 'true') then begin
+getcdf, file=file3, charvar='temp', invar=temp_gcm_3d
+getcdf, file=file3, charvar='pplay', invar=pplay_3d
+getcdf, file=file3, charvar='latitude', invar=latitude_3d
+getcdf, file=file3, charvar='longitude', invar=longitude_3d
+nWEmx_3d = n_elements(reform(temp_gcm_3d(*,0,0,0)))
+nNSmx_3d = n_elements(reform(temp_gcm_3d(0,*,0,0)))
+nZmx_3d = n_elements(reform(temp_gcm_3d(0,0,*,0)))
+nTmx_3d = n_elements(reform(temp_gcm_3d(0,0,0,*)))
+ndays_3d = 1.
+lctu_gcm_3d = 0.
+history_interval_s_gcm_3d = ndays_3d*88800./float(nTmx_3d)  ; Timestep interval of gcm 1d simu in sec
+localtime_lon0 = lctu_gcm_3d + history_interval_s_gcm_3d*findgen(nTmx_3d)/3700.
+Xc = 205.
+Yc = 21.8
+plot_index_x = (Xc-longitude_3d(0))/(longitude_3d(1)-longitude_3d(0))
+plot_index_y = (Yc-latitude_3d(0))/(latitude_3d(1)-latitude_3d(0))
+localtime_true = localtime_lon0 -(12./180.)*Xc
+endif
+
+
+nTmx = n_elements(reform(temp_gcm(0,*)))
+if (overplot_convadj eq 'true') then begin
+nTmx_convadj = n_elements(reform(temp_gcm_convadj(0,*)))
+endif else begin
+nTmx_convadj =  10000.
+endelse
+ndays = 1.
+print, ''
+print, 'WARNING ----------------------- '
+print, 'CONFIGURATION : '+string(ndays,format='(I0)')+' days simulation'
+print, ''
+history_interval_s_gcm = ndays*88800./float(nTmx)  ; Timestep interval of gcm 1d simu in sec
+history_interval_s_gcm_convadj = ndays*88800./float(nTmx_convadj)
+localtime_gcm = lctu_gcm + history_interval_s_gcm*findgen(nTmx)/3700.
+localtime_gcm_convadj = lctu_gcm + history_interval_s_gcm_convadj*findgen(nTmx_convadj)/3700.
+; **********************************
+; ******** PLOTS ******************
+if (f_offset eq 'true') then begin
+offset_localtime = 3.108100
+endif else begin
+offset_localtime = 0.
+endelse
+localtime=localtime+offset_localtime
+print, '****************************************************************************************************'
+print, 'local time LES'
+print, localtime
+print, '****************************************************************************************************'
+print, 'local time GCM'
+print, localtime_gcm
+print, '****************************************************************************************************'
+
+time_offset = (ndays-1.)*24.
+
+lt_plot_ini = 8.
+lt_plotindex_les_ini = where(localtime eq lt_plot_ini)
+lt_plotindex_gcm_ini = where(localtime_gcm eq (lt_plot_ini+time_offset))
+
+lt_plot0 = 10.
+lt_plotindex_les0 = where(localtime eq lt_plot0)
+lt_plotindex_gcm0 = where(localtime_gcm eq (lt_plot0+time_offset))
+lt_plotindex_gcm_convadj0 = where(localtime_gcm_convadj eq (lt_plot0+time_offset))
+
+;lt_plot = 8.25
+lt_plot = 12.
+lt_plotindex_les = where((localtime lt lt_plot+0.01) and (localtime gt lt_plot-0.01))
+lt_plotindex_gcm = where(localtime_gcm eq (lt_plot+time_offset))
+lt_plotindex_gcm_convadj = where(localtime_gcm_convadj eq (lt_plot+time_offset))
+print, 'lt plotindex les 12h'
+print, lt_plotindex_les
+
+lt_plot2 = 14.
+lt_plotindex_les2 = where(localtime eq lt_plot2)
+lt_plotindex_gcm2 = where(localtime_gcm eq (lt_plot2+time_offset))
+lt_plotindex_gcm_convadj2 = where(localtime_gcm_convadj eq (lt_plot2+time_offset))
+
+lt_plot3 = 16.
+lt_plotindex_les3 = where(localtime eq lt_plot3)
+lt_plotindex_gcm3 = where(localtime_gcm eq (lt_plot3+time_offset))
+lt_plotindex_gcm_convadj3 = where(localtime_gcm_convadj eq (lt_plot3+time_offset))
+
+lt_plot4 = 18.
+lt_plotindex_les4 = where(localtime eq lt_plot4)
+lt_plotindex_gcm4 = where(localtime_gcm eq (lt_plot4+time_offset))
+lt_plotindex_gcm_convadj4 = where(localtime_gcm_convadj eq (lt_plot4+time_offset))
+;--------------------------------------------------------------------------------
+;---------------------------------------------------------------------------------
+
+nTmx_les=n_elements(reform(wt(0,*)))
+nZmx=n_elements(aps)          ; number of vertical levels
+H_low=9650.                   ; scale height at low altitudes
+H_high=15000.                 ; scale height at high altitudes
+trans_window=10.              ; # of levels over which H(:) goes from H_low to H_high
+lev_trans=32.+trans_window/2. ; level at which H(lev_trans)=(H_low+H_high)/2
+P_ref=p0                    ; reference surface pressure used to build zsurface -610 Pa-
+Hgcm = make_array(nZmx)
+altitudes_GCM = make_array(nZmx)
+; Build scale heights
+;FOR k=0,nZmx-1 DO BEGIN
+;	 Hgcm(k)=H_low+(H_high-H_low)*0.5*(1.0+tanh(6.*(k-lev_trans)/trans_window))
+;ENDFOR
+
+FOR k=0,nZmx-1 DO BEGIN
+        Hgcm(k)=R*temp_gcm(k,lt_plotindex_gcm)/grav
+ENDFOR
+print, 'Hgcm'
+print, Hgcm
+; Compute altitudes_GCM
+FOR k=0,nZmx-1 DO BEGIN
+	altitudes_GCM(k)=-Hgcm(k)*alog(pplay(k,lt_plotindex_gcm)/pGround)
+ENDFOR
+Hgcm=0.
+
+teta_gcm = temp_gcm * (p0/pplay)^r_cp
+if (overplot_convadj eq 'true') then begin
+teta_gcm_convadj = temp_gcm_convadj * (p0/pplay_convadj)^r_cp
+endif
+
+OPENR, 1, gcm_path+'/profile'
+data=FLTARR(nZmx+1)
+READF, 1, data
+temp_gcm_0_ground = data(0)
+temp_gcm_0 = data(1:nZmx-1)
+data = 0.
+CLOSE, 1
+
+teta_gcm_0 = temp_gcm_0 * (p0/pplay)^r_cp
+approx_zdz_gcm = make_array(nZmx)
+approx_zdz_gcm(0)=altitudes_GCM(1)
+FOR k=1, nZmx-2 DO BEGIN
+       approx_zdz_gcm(k) = altitudes_GCM(k+1) - altitudes_GCM(k)
+ENDFOR
+approx_zdz_gcm(nZmx-1)=approx_zdz_gcm(nZmx-2)
+
+print, 'approx zdz gcm'
+print, approx_zdz_gcm
+
+print, '****************************************************************************************************'
+print, 'altitudes LES based on phtot : inter-levels'
+print, altitudes_LES
+print, '****************************************************************************************************'
+print, 'altitudes GCM based on pplay : inter-levels'
+print, altitudes_GCM
+print, '****************************************************************************************************'
+
+; Compute tracer deviation :
+
+co2_col = co2_col/co2_col(0)
+;ar_col = ar_col/ar_col(0)
+tke_col = tke_col+1.
+
+; Compute <teta> les
+
+teta_les = temporary(t) 
+
+
+; ========================================================================
+; ========================================================================
+
+IF (visualization_mode eq 'true') THEN BEGIN
+
+print,' *****************************************-----------------------------------'
+print,' ************ PLUME **********************-----------------------------------'
+print,' *****************************************-----------------------------------'
+
+; We are evaluating the first time-step element of the file number 'loop-1' :
+; file 1 starts at 8h (loop =0, loop2 =0)
+; file 6 starts at 13h  (roughly)  (loop =5, loops2=0)
+; file 12 starts at 18h (roughly) (loop = 11,loop2 = 0)
+
+loop=uint(loop_special)-1
+;loop2=34
+loop2=10
+domain='d01'
+filesWRF = FindFile(les_path+'/wrfout_'+domain+'_????-??-??_??:??:??')
+anomalw=1.
+
+zqtrac1 = dblarr(nx,ny,nz) & zqtrac2 = dblarr(nx,ny,nz)
+sigmazqtrac1 = fltarr(nz) & sigmazqtrac2 = fltarr(nz)
+sigmazminqtrac1 = fltarr(nz) & sigmazminqtrac2 = fltarr(nz)
+anomalqtrac1 = fltarr(nx,ny,nz) & anomalqtrac2 = fltarr(nx,ny,nz)
+zqtrac1 = getget(filesWRF(loop), 'qtrac1', count=[0,0,0,1], offset=[0,0,0,loop2])
+zqtrac2 = getget(filesWRF(loop), 'qtrac2', count=[0,0,0,1], offset=[0,0,0,loop2])
+wprime = getget(filesWRF(loop), 'W', anomaly = anomalw, count=[0,0,0,1], offset=[0,0,0,loop2])
+supermask1 = fltarr(nx,ny,nz)
+supermask2 = fltarr(nx,ny,nz)
+k_out_histo = 8
+k_out_hist = [1,10,25,50,70,85]
+nbtest=n_elements(k_out_hist)
+b=0
+FOR k=0,nz-1 DO BEGIN
+        mask1=fltarr(nx*ny)
+        mask2=fltarr(nx*ny)
+        anomalqtrac1(*,*,k) = zqtrac1(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac1(*,*,k)),1),1)/ float(nx) / float(ny)
+        sigmazqtrac1(k) = STDDEV(REFORM(zqtrac1(*,*,k)))
+	IF (k ne 0) THEN BEGIN
+	        subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
+		sigmazminqtrac1(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac1(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
+	ENDIF ELSE BEGIN
+		sigmazminqtrac1(k) = sigmazqtrac1(k)
+	ENDELSE
+	print, sigmazqtrac1(k),sigmazminqtrac1(k)
+        plumeIndex1 =  WHERE((anomalqtrac1(*,*,k) GT scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) AND ((anomalw(k)+wprime(*,*,k)) GT 0.))
+;        anomalqtrac2(*,*,k) = zqtrac2(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac2(*,*,k)),1),1)/ float(nx) / float(ny)
+;        sigmazqtrac2(k) = STDDEV(REFORM(zqtrac2(*,*,k)))
+        IF (k ne 0) THEN BEGIN
+                subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
+;                sigmazminqtrac2(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac2(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
+	ENDIF ELSE BEGIN
+;                sigmazminqtrac2(k) = sigmazqtrac2(k)
+        ENDELSE
+;        plumeIndex2 =  WHERE((anomalqtrac2(*,*,k) GT scale*MAX([sigmazqtrac2(k),sigmazminqtrac2(k)])) AND ((anomalw(k)+wprime(*,*,k)) GT 0.))
+        IF(plumeIndex1(0) NE -1 ) THEN BEGIN
+        mask1(plumeIndex1) = 1.
+        ENDIF ELSE BEGIN
+        mask1(*)=0.
+        ENDELSE
+        IF(plumeIndex2(0) NE -1 ) THEN BEGIN
+        mask2(plumeIndex2) = 1.
+        ENDIF ELSE BEGIN
+        mask2(*)=0.
+        ENDELSE
+        mask1 = reform(mask1,[nx,ny])
+        supermask1(*,*,k) = mask1(*,*)
+        mask2 = reform(mask2,[nx,ny])
+        supermask2(*,*,k) = mask2(*,*)
+;	IF (k eq k_out_histo) THEN BEGIN
+;		plume1_out = plumeIndex1
+;		plume2_out = plumeIndex2
+;	ENDIF	
+
+	IF (k eq k_out_hist(0)) THEN BEGIN
+		c1=plumeIndex1
+		c2=plumeIndex2
+	ENDIF
+        IF (k eq k_out_hist(1)) THEN BEGIN
+                d1=plumeIndex1
+                d2=plumeIndex2
+        ENDIF
+        IF (k eq k_out_hist(2)) THEN BEGIN
+                e1=plumeIndex1
+                e2=plumeIndex2
+        ENDIF
+        IF (k eq k_out_hist(3)) THEN BEGIN
+                f1=plumeIndex1
+                f2=plumeIndex2
+        ENDIF
+        IF (k eq k_out_hist(4)) THEN BEGIN
+                g1=plumeIndex1
+                g2=plumeIndex2
+        ENDIF
+        IF (k eq k_out_hist(5)) THEN BEGIN
+                h1=plumeIndex1
+                h2=plumeIndex2
+        ENDIF
+ENDFOR
+
+IF (Histo eq 'false') THEN BEGIN
+IVOLUME, supermask1
+IVOLUME, supermask2
+ENDIF ELSE BEGIN
+
+; -------------------------------------------------------------------------------
+; THIS IS THE ULTRA-GORE UN-ESTHETIC UGLY-AS-HELL LOOP FOR CONCENTRATION PLOTTING
+; but well, this is just because idl cannot handle arrays as well as I would like
+; -------------------------------------------------------------------------------
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Distrib.ps'
+PSOPEN, THICK=100, CHARSIZE=60, FILE = filename, FONT = 5, TFONT = 5,XPLOTS=2,YPLOTS=3,MARGIN=2000 
+
+FOR n=0, nbtest-1 DO BEGIN
+
+CASE n OF
+	0:BEGIN
+		plume1_out=c1 & plume2_out=c2
+	END
+        1:BEGIN
+                plume1_out=d1 & plume2_out=d2
+        END
+        2:BEGIN
+                plume1_out=e1 & plume2_out=e2
+        END
+        3:BEGIN
+                plume1_out=f1 & plume2_out=f2
+        END
+        4:BEGIN
+                plume1_out=g1 & plume2_out=g2
+        END
+        5:BEGIN
+                plume1_out=h1 & plume2_out=h2
+        END
+ENDCASE
+ 
+ToBin1 = reform(zqtrac1(*,*,k_out_hist(n)),[nx*ny,1])
+;ToBin2 = reform(zqtrac2(*,*,k_out_hist(n)),[nx*ny,1])
+svmin1=min(ToBin1) & svmin2=min(ToBin2)
+svmax1=max(ToBin1) & svmax2=max(ToBin2)
+NBINS=100
+ds1=(svmax1-svmin1+1.)/(NBINS-1) & ds2=(svmax2-svmin2+1.)/(NBINS-1)
+Xaxis1 = svmin1+((svmax1-svmin1)/(NBINS-1))*indgen(NBINS)
+Xaxis2 = svmin2+((svmax2-svmin2)/(NBINS-1))*indgen(NBINS)
+Bin1=HISTOGRAM(ToBin1,nbins=NBINS)
+Bin2=INTERPOL(HISTOGRAM(ToBin2,nbins=NBINS),Xaxis2,Xaxis1,/SPLINE)
+
+what_I_plot = [[Bin1],[Bin2]]
+labels=['LES tracer 1 conc. distrib.','LES tracer 2 conc. distrib.']
+
+title_user = TestCase+SubCase+' LES tracer 1&2 concentration distribution at '+string(altitudes_LES(k_out_hist(n)))+'m AGL'
+IF (n lt 3) THEN BEGIN
+	POS, XPOS=1, YPOS=uint(n+1)
+ENDIF ELSE BEGIN
+	POS, XPOS=2, YPOS=uint(n+1)-3
+ENDELSE
+MAP
+CS, SCALE=28
+GSET, XMIN=0, XMAX=20, YMIN=0, YMAX=300, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=Xaxis1, Y=what_I_plot, /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 4, XTITLE='Trac concentration (kg/kg)', YSTEP=50, YTITLE='Counts',NDECS=1
+
+ToBin1 = reform(zqtrac1(*,*,k_out_hist(n)),[nx*ny,1])
+ToBin2 = reform(zqtrac2(*,*,k_out_hist(n)),[nx*ny,1])
+ToBin1 = ToBin1(plume1_out)
+ToBin2 = ToBin2(plume2_out)
+svmin1=min(ToBin1) & svmin2=min(ToBin2)
+svmax1=max(ToBin1) & svmax2=max(ToBin2)
+NBINS=50
+ds1=(svmax1-svmin1+1.)/(NBINS-1) & ds2=(svmax2-svmin2+1.)/(NBINS-1)
+Xaxis1 = svmin1+((svmax1-svmin1)/(NBINS-1))*indgen(NBINS)
+Xaxis2 = svmin2+((svmax2-svmin2)/(NBINS-1))*indgen(NBINS)
+Bin1=HISTOGRAM(ToBin1,nbins=NBINS)
+Bin2=HISTOGRAM(ToBin2,nbins=NBINS)
+oplot,  Xaxis1, Bin1, psym=4
+oplot,  Xaxis2, Bin2, psym=5
+
+ENDFOR
+
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+ENDELSE
+
+ENDIF ELSE BEGIN
+
+; =========================================================================
+; =========================================================================
+
+print, '........ ALPHA'
+
+alpha_interlay_gcm = make_array(nZmx)
+FOR k=0, nZmx-2 DO BEGIN
+        alpha_interlay_gcm(k) = (alpha_gcm_lev(k,lt_plotindex_gcm)+alpha_gcm_lev(k+1,lt_plotindex_gcm))/2.
+ENDFOR
+alpha_interlay_gcm(nZmx-1)=0.
+
+smoothed_alpha1_les = make_array(nz)
+smoothed_alpha2_les = make_array(nz)
+smoothed_beta1_les = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_alpha1_les = smoothed_alpha1_les + REFORM(alpha1out(*,lt_plotindex_les+t))
+        smoothed_alpha2_les = smoothed_alpha2_les + REFORM(alpha2out(*,lt_plotindex_les+t))
+        smoothed_beta1_les = smoothed_beta1_les + REFORM(beta1out(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_alpha1_les = smoothed_alpha1_les/nstot
+smoothed_alpha2_les = smoothed_alpha2_les/nstot
+smoothed_beta1_les = smoothed_beta1_les/nstot
+
+; =========================================================================
+
+; *** Temperatures ***
+
+print, '........ TEMPERATURES'
+
+xmin = 190
+xmax = 250
+if (TestCase eq 'Case_Z') then begin
+xmin = 170
+xmax = 250
+endif
+
+
+what_I_plot = [[reform(temp_gcm(*,lt_plotindex_gcm_ini))],[reform(temp_gcm(*,lt_plotindex_gcm0))],[reform(temp_gcm(*,lt_plotindex_gcm))],[reform(temp_gcm(*,lt_plotindex_gcm2))],[reform(temp_gcm(*,lt_plotindex_gcm3))],[reform(temp_gcm(*,lt_plotindex_gcm4))]]
+labels=['TH temp 1d, lt='+string(lt_plot_ini),'TH temp 1d, lt='+string(lt_plot0),'TH temp 1d, lt='+string(lt_plot),'TH temp 1d, lt='+string(lt_plot2),'TH temp 1d, lt='+string(lt_plot3),'TH temp 1d, lt='+string(lt_plot4)]
+title_user = TestCase+SubCase+LayerCase+' Temperatures Comparison'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Temperature.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=12, TITLE=title_user
+cols=INDGEN(6)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Temperature (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+oplot, temp_les(*,lt_plotindex_les_ini), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les0), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les2), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les3), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les4), altitudes_LES/1000., psym=4
+
+if(overplot_convadj EQ 'true') then begin
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj0), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj2), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj3), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj4), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+endif
+
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; *** Pressions ***
+
+print, '........ PRESSURES'
+
+;what_I_plot = make_array(nZmx)
+;labels=['TH P 1d, lt='+string(lt_plot)]
+;title_user = TestCase+SubCase+' Pressure Comparisons'
+;filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Pressure.ps'
+;PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+;CS, SCALE=28
+;GSET, XMIN=600, XMAX=900, YMIN=0, YMAX=0.5, TITLE=title_user
+;cols=INDGEN(1)+2
+;GPLOT, X=pplay(*,lt_plotindex_gcm), Y=-alog(pplay(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+;AXES, XSTEP = 25, XTITLE='Log P', YSTEP=0.1, YTITLE='Altitude (km)',NDECS=1
+;
+;oplot, pt(*,lt_plotindex_les),-alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;
+;PSCLOSE, /NOVIEW
+;
+;spawn, 'ps2png '+filename
+
+what_I_plot = make_array(nZmx)
+labels=['TH P 1d, lt='+string(lt_plot)]
+title_user = TestCase+SubCase+LayerCase+' Pressure Comparisons'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Pressure.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=400, XMAX=900, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=pplay(*,lt_plotindex_gcm), Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 25, XTITLE='Pression (Pa)', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+oplot, pt(*,lt_plotindex_les),altitudes_LES/1000., psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; *** Temperatures potentielles ***
+if(full eq 'true') then begin
+
+xmin = 185
+xmax = 240
+if (TestCase eq 'Case_C') then begin
+xmin = 200
+xmax = 255
+endif
+if (TestCase eq 'Case_I') then begin
+xmin = 195
+xmax = 250
+endif
+if (TestCase eq 'Case_Z') then begin
+xmin = 230
+xmax = 290
+endif
+if (TestCase eq 'ExtremeCase') then begin
+xmin = 195
+xmax = 260
+endif
+
+print, '........ POTENTIAL TEMPERATURES'
+what_I_plot = [[reform(teta_gcm(*,lt_plotindex_gcm_ini))],[reform(teta_gcm(*,lt_plotindex_gcm0))],[reform(teta_gcm(*,lt_plotindex_gcm))],[reform(teta_gcm(*,lt_plotindex_gcm2))],[reform(teta_gcm(*,lt_plotindex_gcm3))],[reform(teta_gcm(*,lt_plotindex_gcm4))]]
+labels=['TH teta 1d, lt='+string(lt_plot_ini),'TH teta 1d, lt='+string(lt_plot0),'TH teta 1d, lt='+string(lt_plot),'TH teta 1d, lt='+string(lt_plot2),'TH teta 1d, lt='+string(lt_plot3),'TH teta 1d, lt='+string(lt_plot4)]
+title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=1.4, TITLE=title_user
+cols=INDGEN(6)+2
+GPLOT, X=what_I_plot, Y=-alog(pplay(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.2, YTITLE='-Log(P/P0) ',NDECS=1
+
+oplot, teta_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+if(overplot_convadj EQ 'true') then begin
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj0), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj0)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj2), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj2)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj3), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj3)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj4), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj4)/pGround), thick=0.1,color=8,linestyle=3
+endif
+oplot, teta_gcm_0(*), -alog(pplay(*,lt_plotindex_gcm)/pGround)
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+xmin = 230
+xmax = 245
+what_I_plot = [[reform(teta_gcm(*,lt_plotindex_gcm)),tsurf_gcm(lt_plotindex_gcm)],[reform(teta_gcm(*,lt_plotindex_gcm2)),tsurf_gcm(lt_plotindex_gcm2)]]
+labels=['TH teta 1d, lt='+string(lt_plot),'TH teta 1d, lt='+string(lt_plot2)]
+title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta_zoom.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=0.05, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=[0.,-alog(pplay(*,lt_plotindex_gcm)/pGround)], /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.005, YTITLE='-Log(P/P0) ',NDECS=1
+
+;oplot, teta_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;oplot, teta_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+if(overplot_convadj EQ 'true') then begin
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj0), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj0)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj2), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj2)/pGround), thick=0.1,color=8,linestyle=3
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj3), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj3)/pGround), thick=0.1,color=8,linestyle=3
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj4), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj4)/pGround), thick=0.1,color=8,linestyle=3
+endif
+;oplot, teta_gcm_0(*), -alog(pplay(*,lt_plotindex_gcm)/pGround)
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+if (plot_3d eq 'true') then begin
+what_I_plot = [[reform(teta_gcm(*,lt_plotindex_gcm_ini))],[reform(teta_gcm(*,lt_plotindex_gcm0))],[reform(teta_gcm(*,lt_plotindex_gcm))],[reform(teta_gcm(*,lt_plotindex_gcm2))],[reform(teta_gcm(*,lt_plotindex_gcm3))],[reform(teta_gcm(*,lt_plotindex_gcm4))]]
+labels=['TH teta 1d, lt='+string(lt_plot_ini),'TH teta 1d, lt='+string(lt_plot0),'TH teta 1d, lt='+string(lt_plot),'TH teta 1d, lt='+string(lt_plot2),'TH teta 1d, lt='+string(lt_plot3),'TH teta 1d, lt='+string(lt_plot4)]
+title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=1.4, TITLE=title_user
+cols=INDGEN(6)+2
+GPLOT, X=what_I_plot, Y=-alog(pplay_3d(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.2, YTITLE='-Log(P/P0) ',NDECS=1
+
+oplot, teta_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+endif
+
+endif else begin
+
+print, '........ POTENTIAL TEMPERATURES'
+
+what_I_plot = reform(teta_gcm(*,lt_plotindex_gcm))
+labels=['TH teta 1d, lt='+string(lt_plot)]
+title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=210, XMAX=240, YMIN=0, YMAX=2, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=-alog(pplay(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.2, YTITLE='-Log(P/P0) ',NDECS=1
+
+oplot, teta_les(*,lt_plotindex_les),-alog(pt(*,lt_plotindex_les)/pGround), psym=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+endelse
+
+print, '........ SURFACE TEMPERATURES'
+what_I_plot = tsurf_gcm
+labels=['TH 1d tsurf']
+title_user = TestCase+SubCase+LayerCase+' Surface temperatures (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_tsurf.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=200, YMAX=300, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=localtime_gcm, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=5., YTITLE='Surface temperature',NDECS=1
+
+oplot, localtime, tsurf, psym=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; ---------------------- *** Vitesses verticales *** -------------------------------
+; ------------ Verification de l'approx terrestre wmax = vmoy dans la couche instable
+
+print, '........ CHECKING wmax = vmoy in unstable layer'
+
+what_I_plot = uv_moy(*,lt_plotindex_les)
+labels=['LES uv_moy']
+title_user = TestCase+SubCase+LayerCase+' LES mean UV comp to max W in plume trac1'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_UV.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0, XMAX=10, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, YSTEP = 1, YTITLE='Altitude (km)', XSTEP=1, XTITLE='Mean horizontal velocity inside domain (m/s)',NDECS=1
+
+oplot, make_array(nz,value=wmax(lt_plotindex_les)), altitudes_LES/1000., psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; ------------ Profil de vitesse
+
+print, '........ VERTICAL VELOCITY'
+
+what_I_plot = make_array(nZmx)
+FOR k=0, nZmx-2 DO BEGIN
+        what_I_plot(k) = 0.5*(zw2_lev(k,lt_plotindex_gcm) + zw2_lev(k+1,lt_plotindex_gcm))
+ENDFOR
+what_I_plot(nZmx-1) = 0.
+
+smoothed_w_mean1_les = make_array(nz)
+smoothed_w_mean2_les = make_array(nz)
+smoothed_w_mean1_down_les = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_w_mean1_les = smoothed_w_mean1_les + REFORM(w_mean1(*,lt_plotindex_les+t))
+        smoothed_w_mean2_les = smoothed_w_mean2_les + REFORM(w_mean2(*,lt_plotindex_les+t))
+	smoothed_w_mean1_down_les = smoothed_w_mean1_down_les + REFORM(w_mean1_down(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_w_mean1_les = smoothed_w_mean1_les/nstot
+smoothed_w_mean2_les = smoothed_w_mean2_les/nstot
+smoothed_w_mean1_down_les = smoothed_w_mean1_down_les/nstot
+
+ratio = make_array(nz)
+FOR k=0, nz-1 DO BEGIN
+	IF(smoothed_w_mean1_les(k) ne 0.) then ratio(k) = smoothed_w_mean1_down_les(k)/smoothed_w_mean1_les(k) else ratio(k)=0.
+ENDFOR
+
+labels=['TH 1d w, lt='+string(lt_plot)]
+title_user = TestCase+SubCase+LayerCase+' Vertical velocity comparisons (inside thermal)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Wprofile.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-6, XMAX=8, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, YSTEP = 2, YTITLE='Altitude (km)', XSTEP=1, XTITLE='Vertical velocity inside thermal (m/s)',NDECS=1
+
+oplot, smoothed_w_mean1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_w_mean2_les, altitudes_LES/1000., psym=5
+oplot, smoothed_w_mean1_down_les, altitudes_LES/1000., psym=6
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; *** Static stability ***
+
+print, '........ STATIC STABILITY'
+
+dteta_dz_gcm = deriv(altitudes_GCM,reform(teta_gcm(*,lt_plotindex_gcm)))
+dteta_dz_les = deriv(altitudes_LES,reform(teta_les(*,lt_plotindex_les)))
+
+what_I_plot = dteta_dz_gcm
+labels=['TH static stability 1d']
+title_user = TestCase+SubCase+LayerCase+' Static stability comparison'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_dTetadz.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.002, XMAX=0.006, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.0005 , XTITLE='Static stability (K.m-1)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+oplot, dteta_dz_les, altitudes_LES/1000., psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+print,' -----------------------------------------------------------------------------------------------------------------------'
+print,' ***  LES diagnostics of the PLUME *** MUAHAHAHAHAHA'
+print,' V2 with E and D computed for a UDE plume'
+print,' -----------------------------------------------------------------------------------------------------------------------'
+
+print, '........ EXTRACTING DATA'
+
+; --- Reinterpolation of F
+
+fm_therm_gcm_interlay = make_array(nZmx,nTmx)
+
+FOR k=0, nZmx-2 DO BEGIN
+        fm_therm_gcm_interlay(k,*) = (fm_therm_gcm_lev(k,*) + fm_therm_gcm_lev(k+1,*))/2.
+ENDFOR
+fm_therm_gcm_interlay(nZmx-1,*)=0.
+
+; --- Calculation of gcm df/dz using entrainment and detrainments and NOT F
+
+df_dz_gcm = deriv(altitudes_GCM,reform(fm_therm_gcm_interlay(*,lt_plotindex_gcm)))
+ 
+; --- Smoothing of the mass flux on a user-defined window
+
+smoothed_fm_trac1_les = make_array(nz)
+smoothed_fm_trac2_les = make_array(nz)
+smoothed_downward_fm_trac1_les = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+	smoothed_fm_trac1_les = smoothed_fm_trac1_les + REFORM(fm_trac1_les(*,lt_plotindex_les+t))
+	smoothed_fm_trac2_les = smoothed_fm_trac2_les + REFORM(fm_trac2_les(*,lt_plotindex_les+t))
+	smoothed_downward_fm_trac1_les = smoothed_downward_fm_trac1_les + REFORM(downward_flux1(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_fm_trac1_les = smoothed_fm_trac1_les/nstot
+smoothed_fm_trac2_les = smoothed_fm_trac2_les/nstot
+smoothed_downward_fm_trac1_les = smoothed_downward_fm_trac1_les/nstot
+
+; --- Calculation of the entrainement rate according to Rio(2010)
+; done in the heavy part at the begining (reeaaaally heavy)
+
+; --- Smoothing of the entrainment on a ~30min window
+
+; term 1
+
+
+smoothed_e_term1_trac1_les = make_array(nz)
+smoothed_e_term1_trac2_les = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_e_term1_trac1_les = smoothed_e_term1_trac1_les + REFORM(e_trac1_les(*,lt_plotindex_les+t))
+        smoothed_e_term1_trac2_les = smoothed_e_term1_trac2_les + REFORM(e_trac2_les(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_e_term1_trac1_les = smoothed_e_term1_trac1_les/nstot
+smoothed_e_term1_trac2_les = smoothed_e_term1_trac2_les/nstot
+
+smoothed_e_rate_term1_trac1_les = make_array(nz)
+smoothed_e_rate_trac2_les = smoothed_e_term1_trac2_les
+
+; it already is an entrainment rate ! KIND OF : it is E/Mc, and Mc is not F !! NOW it is Mc/deltaTeta * dchi/dz
+FOR k=0, nz-1 DO BEGIN
+	IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term1_trac1_les(k) = smoothed_e_term1_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term1_trac1_les(k) =0.
+;        IF (smoothed_fm_trac2_les(k) ne 0.) THEN smoothed_e_rate_trac2_les(k) = smoothed_e_trac2_les(k)/smoothed_fm_trac2_les(k) ELSE smoothed_e_rate_trac2_les(k) =0.
+ENDFOR
+
+; term 2  & 3
+
+
+smoothed_e_term2_trac1_les = make_array(nz)
+smoothed_e_term3_trac1_les = make_array(nz)
+smoothed_e_term1_ude_trac1_les = make_array(nz)
+smoothed_e_term2_ude_trac1_les = make_array(nz)
+smoothed_e_term3_ude_trac1_les = make_array(nz)
+
+FOR t=-ns,ns DO BEGIN
+        smoothed_e_term2_trac1_les = smoothed_e_term2_trac1_les + REFORM(e1_term2(*,lt_plotindex_les+t))
+        smoothed_e_term2_trac1_les = smoothed_e_term2_trac1_les + REFORM(e1_term2(*,lt_plotindex_les+t))
+	smoothed_e_term1_ude_trac1_les = smoothed_e_term1_ude_trac1_les + REFORM(e1_term1_ude(*,lt_plotindex_les+t))
+        smoothed_e_term2_ude_trac1_les = smoothed_e_term2_ude_trac1_les + REFORM(e1_term2_ude(*,lt_plotindex_les+t))
+        smoothed_e_term3_ude_trac1_les = smoothed_e_term3_ude_trac1_les + REFORM(e1_term3_ude(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_e_term2_trac1_les = smoothed_e_term2_trac1_les/nstot
+smoothed_e_term3_trac1_les = smoothed_e_term3_trac1_les/nstot
+smoothed_e_term1_ude_trac1_les = smoothed_e_term1_ude_trac1_les/nstot
+smoothed_e_term2_ude_trac1_les = smoothed_e_term2_ude_trac1_les/nstot
+smoothed_e_term3_ude_trac1_les = smoothed_e_term3_ude_trac1_les/nstot
+
+smoothed_e_rate_term2_trac1_les = make_array(nz)
+smoothed_e_rate_term3_trac1_les = make_array(nz)
+smoothed_e_rate_term1_ude_trac1_les = make_array(nz)
+smoothed_e_rate_term2_ude_trac1_les = make_array(nz)
+smoothed_e_rate_term3_ude_trac1_les = make_array(nz)
+
+FOR k=0, nz-1 DO BEGIN
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term2_trac1_les(k) = smoothed_e_term2_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term2_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term3_trac1_les(k) = smoothed_e_term3_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term3_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term1_ude_trac1_les(k) = smoothed_e_term1_ude_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term1_ude_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term2_ude_trac1_les(k) = smoothed_e_term2_ude_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term2_ude_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term3_ude_trac1_les(k) = smoothed_e_term3_ude_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term3_ude_trac1_les(k) =0.
+
+ENDFOR
+
+; --- Summing...
+
+smoothed_e_rate_trac1_les = smoothed_e_rate_term1_trac1_les + smoothed_e_rate_term2_trac1_les + smoothed_e_rate_term3_trac1_les
+smoothed_e_rate_ude_trac1_les = smoothed_e_rate_term1_ude_trac1_les + smoothed_e_rate_term2_ude_trac1_les + smoothed_e_rate_term3_ude_trac1_les
+
+;print, 'ommiting term3'
+;smoothed_e_rate_trac1_les = smoothed_e_rate_term1_trac1_les + smoothed_e_rate_term2_trac1_les
+
+; --- Smoothing of the detrainment rate
+
+smoothed_d_term1_trac1_les = make_array(nz)
+smoothed_d_term2_trac1_les = make_array(nz)
+smoothed_d_term3_trac1_les = make_array(nz)
+smoothed_d_term1_ude_trac1_les = make_array(nz)
+smoothed_d_term2_ude_trac1_les = make_array(nz)
+smoothed_d_term3_ude_trac1_les = make_array(nz)
+
+FOR t=-ns,ns DO BEGIN
+        smoothed_d_term1_trac1_les = smoothed_d_term1_trac1_les + REFORM(d1_term1(*,lt_plotindex_les+t))
+        smoothed_d_term2_trac1_les = smoothed_d_term2_trac1_les + REFORM(d1_term2(*,lt_plotindex_les+t))
+        smoothed_d_term3_trac1_les = smoothed_d_term3_trac1_les + REFORM(d1_term3(*,lt_plotindex_les+t))
+        smoothed_d_term1_ude_trac1_les = smoothed_d_term1_ude_trac1_les + REFORM(d1_term1_ude(*,lt_plotindex_les+t))
+        smoothed_d_term2_ude_trac1_les = smoothed_d_term2_ude_trac1_les + REFORM(d1_term2_ude(*,lt_plotindex_les+t))
+        smoothed_d_term3_ude_trac1_les = smoothed_d_term3_ude_trac1_les + REFORM(d1_term3_ude(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_d_term1_trac1_les = smoothed_d_term1_trac1_les/nstot
+smoothed_d_term2_trac1_les = smoothed_d_term2_trac1_les/nstot
+smoothed_d_term3_trac1_les = smoothed_d_term3_trac1_les/nstot
+smoothed_d_term1_ude_trac1_les = smoothed_d_term1_ude_trac1_les/nstot
+smoothed_d_term2_ude_trac1_les = smoothed_d_term2_ude_trac1_les/nstot
+smoothed_d_term3_ude_trac1_les = smoothed_d_term3_ude_trac1_les/nstot
+
+smoothed_d_rate_term1_trac1_les = make_array(nz)
+smoothed_d_rate_term2_trac1_les = make_array(nz)
+smoothed_d_rate_term3_trac1_les = make_array(nz)
+smoothed_d_rate_term1_ude_trac1_les = make_array(nz)
+smoothed_d_rate_term2_ude_trac1_les = make_array(nz)
+smoothed_d_rate_term3_ude_trac1_les = make_array(nz)
+
+FOR k=0, nz-1 DO BEGIN
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_term1_trac1_les(k) = smoothed_d_term1_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_term1_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_term2_trac1_les(k) = smoothed_d_term2_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_term2_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_term3_trac1_les(k) = smoothed_d_term3_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_term3_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN BEGIN
+	smoothed_d_rate_term1_ude_trac1_les(k) = smoothed_d_term1_ude_trac1_les(k)/smoothed_fm_trac1_les(k)
+	smoothed_d_rate_term2_ude_trac1_les(k) = smoothed_d_term2_ude_trac1_les(k)/smoothed_fm_trac1_les(k)
+	smoothed_d_rate_term3_ude_trac1_les(k) = smoothed_d_term3_ude_trac1_les(k)/smoothed_fm_trac1_les(k)
+	ENDIF ELSE BEGIN
+	smoothed_d_rate_term1_ude_trac1_les(k)=0.
+	smoothed_d_rate_term2_ude_trac1_les(k)=0.
+	smoothed_d_rate_term3_ude_trac1_les(k)=0.
+	ENDELSE
+ENDFOR
+
+; --- Summing...
+
+smoothed_d_rate_trac1_les = smoothed_d_rate_term1_trac1_les+smoothed_d_rate_term2_trac1_les+smoothed_d_rate_term3_trac1_les
+smoothed_d_rate_ude_trac1_les = smoothed_d_rate_term1_ude_trac1_les+smoothed_d_rate_term2_ude_trac1_les+smoothed_d_rate_term3_ude_trac1_les
+;print, 'ommiting term3'
+;smoothed_d_rate_trac1_les = smoothed_d_rate_term1_trac1_les+smoothed_d_rate_term2_trac1_les
+
+; --- PLOTTING : BUOYANCY TERM
+
+smoothed_buoyancy_trac1_les = make_array(nz)
+smoothed_buoyancy_ude_trac1_les = make_array(nz)
+smoothed_buoyancy_trac2_les = make_array(nz)
+smoothed_buoyancy_downdraft1_les_ude = make_array(nz)
+
+FOR t=-ns,ns DO BEGIN
+        smoothed_buoyancy_trac1_les = smoothed_buoyancy_trac1_les + REFORM(buoyancy1_les(*,lt_plotindex_les+t))
+	smoothed_buoyancy_ude_trac1_les = smoothed_buoyancy_ude_trac1_les + REFORM(grav*(tplume1moy(*,lt_plotindex_les+t)/tenv1moy_ude(*,lt_plotindex_les+t)-1.))
+        smoothed_buoyancy_trac2_les = smoothed_buoyancy_trac2_les + REFORM(buoyancy2_les(*,lt_plotindex_les+t))
+	smoothed_buoyancy_downdraft1_les_ude = smoothed_buoyancy_downdraft1_les_ude + REFORM(grav*(tdown1moy(*,lt_plotindex_les+t)/tenv1moy_ude(*,lt_plotindex_les+t)-1.))
+ENDFOR
+
+smoothed_buoyancy_trac1_les = smoothed_buoyancy_trac1_les/nstot
+smoothed_buoyancy_ude_trac1_les = smoothed_buoyancy_ude_trac1_les/nstot
+smoothed_buoyancy_trac2_les = smoothed_buoyancy_trac2_les/nstot
+smoothed_buoyancy_downdraft1_les_ude = smoothed_buoyancy_downdraft1_les_ude/nstot
+
+print, '........ BUOYANCY'
+
+what_I_plot = [[buoyancy_gcm(*,lt_plotindex_gcm)],[buoyancy_est_gcm(*,lt_plotindex_gcm)]]
+labels=['TH buoyancy term','TH estimated buoyancy in plume']
+title_user = TestCase+SubCase+LayerCase+' UDE plume buoyancy'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_B.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.06, XMAX=0.06, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.01 , XTITLE='N.m-1', YSTEP=1, YTITLE=' Altitude (km)',NDECS=3
+
+;oplot, smoothed_buoyancy_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_buoyancy_trac2_les, altitudes_LES/1000., psym=5
+print, smoothed_buoyancy_ude_trac1_les
+oplot, smoothed_buoyancy_ude_trac1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_buoyancy_downdraft1_les_ude, altitudes_LES/1000., psym=7
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; --- PLOTTING : MASS FLUX 
+
+print, '........ MASS FLUX'
+
+f_gcm = fm_therm_gcm_interlay(*,lt_plotindex_gcm)
+what_I_plot = f_gcm
+labels=['TH mass flux']
+title_user = TestCase+SubCase+LayerCase+' mass flux comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_f.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.008, XMAX=0.008, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.002 , XTITLE='Kg.m-2.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+oplot, smoothed_fm_trac1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_fm_trac2_les, altitudes_LES/1000., psym=5
+oplot, smoothed_downward_fm_trac1_les, altitudes_LES/1000., psym=6
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; --- PLOTTING : MASS FLUX DERIVATIVE
+
+print, '........ MASS FLUX DERIVATIVE'
+
+df_dz_les1 = deriv(altitudes_LES,reform(smoothed_fm_trac1_les))
+df_dz_les2 = deriv(altitudes_LES,reform(smoothed_fm_trac2_les))
+
+what_I_plot = df_dz_gcm
+labels=['TH mass flux vertical derivative']
+title_user = TestCase+SubCase+LayerCase+' mass flux vertical derivative comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_dfdz.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.00002, XMAX=0.00002, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.000005 , XTITLE='Kg.m-3.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=6
+oplot, df_dz_les1, altitudes_LES/1000., psym=4
+oplot, df_dz_les2, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : ENTRAINMENT RATE e = E/f 
+
+print, '........ ENTRAINMENT RATE'
+
+e_gcm = make_array(nZmx)
+
+FOR k=0, nZmx-1 DO BEGIN
+	IF (fm_therm_gcm_interlay(k,lt_plotindex_gcm) ne 0.) THEN BEGIN
+		e_gcm(k) = zdz_entr_therm_gcm(k,lt_plotindex_gcm)/(approx_zdz_gcm(k)*fm_therm_gcm_interlay(k,lt_plotindex_gcm))
+	ENDIF ELSE BEGIN
+		e_gcm(k) = 0.
+	ENDELSE
+ENDFOR
+
+
+what_I_plot = e_gcm
+labels=['TH entrainment rate']
+title_user = TestCase+SubCase+LayerCase+' UDE entrainment rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.003, XMAX=0.003, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.0006 , XTITLE='entrainment rate m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+oplot, smoothed_e_rate_ude_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_e_rate_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_e_rate_trac2_les, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : EXTENDED ENTRAINMENT RATE 
+
+print, '........ EXTENDED ENTRAINMENT RATE'
+
+;what_I_plot = [[smoothed_e_rate_term1_trac1_les],[smoothed_e_rate_term2_trac1_les],[smoothed_e_rate_term3_trac1_les],[smoothed_e_rate_trac1_les]]
+what_I_plot = [[smoothed_e_rate_term1_ude_trac1_les],[smoothed_e_rate_term2_ude_trac1_les],[smoothed_e_rate_term3_ude_trac1_les],[smoothed_e_rate_ude_trac1_les]]
+labels=['LES base entrainment rate','LES term2 e rate','LES term3 e rate','LES total e rate']
+title_user = TestCase+SubCase+LayerCase+' UDE entrainment rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e_terms.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.01, XMAX=0.01, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.005 , XTITLE='entrainment rate m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=3
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; --- PLOTTING : EXTENDED DETRAINMENT RATE 
+
+print, '........ EXTENDED DETRAINMENT RATE'
+
+what_I_plot = [[smoothed_d_rate_term1_ude_trac1_les],[smoothed_d_rate_term2_ude_trac1_les],[smoothed_d_rate_term3_ude_trac1_les],[smoothed_d_rate_ude_trac1_les]]
+labels=['LES term 1 detrainment rate','LES term2 d rate','LES term3 d rate','LES Total d rate']
+title_user = TestCase+SubCase+LayerCase+' UDE detrainment rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d_terms.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.01, XMAX=0.01, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.002 , XTITLE='detrainment rate m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : DETRAINMENT RATE d = D/f
+
+print, '........ DETRAINMENT RATE'
+
+;smoothed_d_rate_trac2_les = make_array(nz)
+;
+;FOR k=0, nz-1 DO BEGIN
+;        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_trac1_les(k) = smoothed_e_rate_trac1_les(k) - df_dz_les1(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_trac1_les(k) =0.
+;        IF (smoothed_fm_trac2_les(k) ne 0.) THEN smoothed_d_rate_trac2_les(k) = smoothed_e_rate_trac2_les(k) - df_dz_les2(k)/smoothed_fm_trac2_les(k) ELSE smoothed_d_rate_trac2_les(k) =0.
+;ENDFOR
+;
+d_gcm = make_array(nZmx)
+FOR k=0, nZmx-1 DO BEGIN
+        IF (fm_therm_gcm_interlay(k,lt_plotindex_gcm) ne 0.) THEN BEGIN
+                d_gcm(k) = zdz_detr_therm_gcm(k,lt_plotindex_gcm)/(approx_zdz_gcm(k)*fm_therm_gcm_interlay(k,lt_plotindex_gcm))
+        ENDIF ELSE BEGIN
+                d_gcm(k) = 0.
+        ENDELSE
+ENDFOR
+
+what_I_plot = d_gcm
+labels=['TH detrainment rate']
+title_user = TestCase+SubCase+LayerCase+' UDE detrainment rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=0.03, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.005 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=2
+
+oplot, smoothed_d_rate_ude_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_d_rate_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_d_rate_trac2_les, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : FRACTION COVERAGE
+
+print, '........ EXTENDED ALPHA'
+
+what_I_plot = alpha_interlay_gcm
+labels=['TH alpha']
+title_user = TestCase+SubCase+LayerCase+' fraction coverage comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_alpha.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=1., YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.1 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+oplot, smoothed_alpha1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_alpha2_les, altitudes_LES/1000., psym=5
+oplot, smoothed_beta1_les, altitudes_LES/1000., psym=6
+
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : THEORETICAL ENTRAINMENT RATE FROM LES DATA 
+
+print, '........ PARAMETRIZED RATES'
+
+approx_zdz_les = make_array(nz)
+
+approx_zdz_les(0)=altitudes_LES(1)
+FOR k=1, nz-2 DO BEGIN
+	approx_zdz_les(k) = altitudes_LES(k+1) - altitudes_LES(k)
+ENDFOR
+approx_zdz_les(nz-1)=approx_zdz_les(nz-2)
+
+
+theoretical_e_trac1_les = make_array(nz)
+theoretical_e_trac2_les = make_array(nz)
+
+
+FOR k=0, nz-1 DO BEGIN
+        theoretical_e_trac1_les(k) = MAX([0.,(betalpha/(1.+betalpha))*((afact*smoothed_buoyancy_trac1_les(k)/((smoothed_w_mean1_les(k))^2.)) - fact_epsilon)])
+        theoretical_e_trac2_les(k) = MAX([0.,(betalpha/(1.+betalpha))*((afact*smoothed_buoyancy_trac2_les(k)/((smoothed_w_mean2_les(k))^2.)) - fact_epsilon)])
+ENDFOR
+
+
+what_I_plot = [[theoretical_e_trac1_les],[theoretical_e_trac2_les]]
+labels=['LES TH theo e rate trac1','LES TH theo e rate trac2']
+title_user = TestCase+SubCase+LayerCase+' comp. theor. entr. rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e_theoretical.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.015, XMAX=0.03, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.003 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=3
+
+oplot, smoothed_e_rate_trac1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_e_rate_trac2_les, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : THEORETICAL DETRAINMENT RATE FROM LES DATA
+; ZDZ STUFF REMOVED
+
+print, '........ PARAMETRIZED DETRAINMENT'
+
+theoretical_d_trac1_les = make_array(nz)
+theoretical_d_trac2_les = make_array(nz)
+
+FOR k=0, nz-1 DO BEGIN
+	theoretical_d_trac1_les(k) = MAX([detr_min,-afact*(betalpha/(1.+betalpha))*(smoothed_buoyancy_trac1_les(k)/((smoothed_w_mean1_les(k))^2.))])
+	theoretical_d_trac2_les(k) = MAX([detr_min,-afact*(betalpha/(1.+betalpha))*(smoothed_buoyancy_trac2_les(k)/((smoothed_w_mean2_les(k))^2.))])
+ENDFOR
+
+what_I_plot = [[theoretical_d_trac1_les],[theoretical_d_trac2_les]]
+labels=['LES TH theo d rate trac1','LES TH theo d rate trac2']
+title_user = TestCase+SubCase+LayerCase+' comp. theor. detr. rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d_theoretical.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.1, XMAX=0.1, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.01 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=2
+
+oplot, smoothed_d_rate_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_d_rate_trac2_les, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : THEORETICAL E-D  RATE FROM LES DATA
+
+print, '........ PARAMETRIZED MASS FLUX DERIVATIVE'
+
+theoretical_dfdz_f_trac1_les = make_array(nz)
+theoretical_dfdz_f_trac2_les = make_array(nz)
+
+theoretical_dfdz_f_trac1_les = theoretical_e_trac1_les - theoretical_d_trac1_les
+theoretical_dfdz_f_trac2_les = theoretical_e_trac2_les - theoretical_d_trac2_les
+
+df_dz_f_les1 = make_array(nz)
+df_dz_f_les2 = make_array(nz)
+
+FOR k=0, nz-1 DO BEGIN
+	IF (smoothed_fm_trac1_les(k) ne 0.) THEN df_dz_f_les1(k) = df_dz_les1(k)/smoothed_fm_trac1_les(k) ELSE df_dz_f_les1(k)=0.
+        IF (smoothed_fm_trac2_les(k) ne 0.) THEN df_dz_f_les2(k) = df_dz_les2(k)/smoothed_fm_trac2_les(k) ELSE df_dz_f_les2(k)=0.
+ENDFOR
+
+what_I_plot = [[theoretical_dfdz_f_trac1_les],[theoretical_dfdz_f_trac2_les]]
+labels=['LES TH theo 1/f df/dz trac1','LES TH theo 1/f df/dz trac2']
+title_user = TestCase+SubCase+LayerCase+' comp. theor. entr. - detr. rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_dfdzf_theoretical.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.02, XMAX=0.02, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.01 , XTITLE='entr - detr (rates) m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+oplot, df_dz_f_les1, altitudes_LES/1000., psym=4
+oplot, df_dz_f_les2, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : e versus B/w2
+
+print, '........ BUOYANCY AND VERTICAL VELOCITY ENTRAINMENT RATE DEPENDENCY'
+
+B_w2_trac1 = make_array(nz)
+B_w2_trac2 = make_array(nz)
+;dwdz_trac1 = deriv(altitudes_LES,smoothed_w_mean1_les)
+;dwdz_trac2 = deriv(altitudes_LES,smoothed_w_mean2_les)
+;full_dwdz_trac1 = make_array(nz,nttot)
+;full_dadz_trac1 = make_array(nz,nttot)
+;FOR l=0, nttot -1 DO BEGIN
+;	full_dwdz_trac1(*,l) = deriv(altitudes_LES,w_mean1(*,l))
+;	full_dadz_trac1(*,l) = deriv(altitudes_LES,alpha1out(*,l))
+;ENDFOR
+;alpha = 0.
+
+FOR k=0, nz-1 DO BEGIN
+	IF (smoothed_e_rate_trac1_les(k) ne 0.) THEN B_w2_trac1(k) = smoothed_buoyancy_ude_trac1_les(k)/(smoothed_w_mean1_les(k))^2 ELSE B_w2_trac1(k)=-0.
+;	IF (smoothed_e_rate_trac2_les(k) ne 0.) THEN B_w2_trac2(k) = smoothed_buoyancy_trac2_les(k)/(smoothed_w_mean2_les(k))^2 ELSE B_w2_trac2(k)=-0.
+ENDFOR
+
+;FOR zzz=0.,30 DO BEGIN
+
+;alpha = zzz/10.
+;
+;FOR k=0, nz-1 DO BEGIN
+;        IF (smoothed_e_rate_trac1_les(k) ne 0. and smoothed_w_mean1_les(k) ne 0.) THEN B_w2_trac1(k) = 0.5*(smoothed_buoyancy_trac1_les(k)/(smoothed_w_mean1_les(k))^2 - alpha*(1./smoothed_w_mean1_les(k))*dwdz_trac1(k)) ELSE B_w2_trac1(k)=0.
+;        IF (smoothed_e_rate_trac2_les(k) ne 0. and smoothed_w_mean2_les(k) ne 0.) THEN B_w2_trac2(k) = 0.5*(smoothed_buoyancy_trac2_les(k)/(smoothed_w_mean2_les(k))^2 - alpha*(1./smoothed_w_mean2_les(k))*dwdz_trac2(k)) ELSE B_w2_trac2(k)=0.
+;ENDFOR
+
+;print, smoothed_buoyancy_trac1_les(*)/(smoothed_w_mean1_les(*))^2
+;print, (1./smoothed_w_mean1_les(*))*dwdz_trac1(*)
+
+full_e1 = make_array(nz,nttot)
+full_bw2 = make_array(nz,nttot)
+FOR k=0, nz-1 DO BEGIN
+FOR l=0, nttot-1 DO BEGIN
+	if(fm_trac1_les(k,l) ne 0.) then full_e1(k,l)=(e1_term1_ude(k,l)+e1_term2_ude(k,l)+e1_term3_ude(k,l))/fm_trac1_les(k,l) else full_e1(k,l)=0.
+        if(w_mean1(k,l) ne 0.) then full_bw2(k,l)=grav*(tplume1moy(k,l)/tenv1moy_ude(k,l) -1.)/(w_mean1(k,l)^2) else full_bw2(k,l)=-0.
+;        if(w_mean1(k,l) ne 0.) then full_bw2(k,l)=0.5*(alpha*buoyancy1_les(k,l)/(w_mean1(k,l)^2) - full_dwdz_trac1(k,l)/w_mean1(k,l)) else full_bw2(k,l)=0.
+ENDFOR
+ENDFOR
+
+what_I_plot = smoothed_e_rate_ude_trac1_les
+labels=['e_rate trac1']
+title_user = TestCase+SubCase+LayerCase+' LES UDE entrainment rate dep with B/w2, average over '+taverage+' mn,' 
+;filename = TestCase+SubCase+LayerCase+string(alpha,format='(F3.1)')+'Gcm_Les_Comp_e_Bw2.ps'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e_Bw2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=0.4, YMIN=0., YMAX=0.4, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=B_w2_trac1, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30, SYM=5, /NOLINES
+AXES, XSTEP = 0.05 , XTITLE='LES Entrainment rate m-1', YSTEP=0.05, YTITLE='Parametrized entrainement rate m-1',NDECS=4
+
+;oplot, smoothed_e_rate_trac2_les, B_w2_trac2, psym=5
+FOR l=0, nttot-1 DO BEGIN
+	oplot, full_e1(*,l),full_bw2(*,l),thick=0.05,psym=1
+ENDFOR
+;mean_full_e1 = make_array(nz) & mean_full_bw2 = make_array(nz)
+;FOR k=0, nz-1 DO BEGIN
+;	mean_full_e1(k) = MEAN(reform(full_e1(k,*)))
+;	mean_full_bw2(k) = MEAN(reform(full_bw2(k,*)))
+;ENDFOR
+;oplot, mean_full_e1, mean_full_bw2, thick=0.3, psym = 2,color=5
+;oplot, theoretical_e_trac1_les, B_w2_trac1,psym=2,thick=0.8,color=7
+oplot,(B_w2_trac1)/2.2222 + 0.0005,B_w2_trac1,thick=0.3,color=7
+;oplot, 0.0118*(B_w2_trac1/0.043)^(1./1.65),B_w2_trac1,thick=0.3,color=7
+oplot, 0.0113*(B_w2_trac1/0.043)^(1./1.65),B_w2_trac1,thick=0.3,color=7
+oplot, 0.0105*(B_w2_trac1/0.048)^(1./1.7),B_w2_trac1,thick=0.3,color=6
+;oplot, alog((B_w2_trac1 - 0.000942361)/0.0444855) - 3.85453, B_w2_trac1, thick=0.3,color=7
+
+;print, alog((B_w2_trac1)/0.0444855) - 3.85453
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+;ENDFOR
+
+what_I_plot = full_bw2(*,lt_plotindex_les)
+labels=['B/w2']
+title_user = TestCase+SubCase+LayerCase+' LES UDE B/w2, average over '+taverage+' mn,'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Bw2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.01, XMAX=0.01, YMIN=0., YMAX=6., TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.002 , XTITLE='B/w2 term in LES UDE', YSTEP=0.5, YTITLE='Altitude (km)',NDECS=4
+
+;FOR l=0, nttot-1 DO BEGIN
+;        oplot, full_bw2(*,l),altitudes_LES/1000.,thick=0.05,psym=1
+;ENDFOR
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+print, '........ BUOYANCY AND VERTICAL VELOCITY DETRAINMENT RATE DEPENDENCY'
+
+full_d1 = make_array(nz,nttot)
+;full_dSiebesma = make_array(nz,nttot)
+
+
+FOR k=0, nz-1 DO BEGIN
+FOR l=0, nttot-1 DO BEGIN
+        if(fm_trac1_les(k,l) ne 0.) then full_d1(k,l)=(d1_term1_ude(k,l)+d1_term2_ude(k,l)+d1_term3_ude(k,l))/fm_trac1_les(k,l) else full_d1(k,l)=-0.
+;        if(w_mean1(k,l) ne 0.) then full_dSiebesma(k,l)=0.5*buoyancy1_les(k,l)/(w_mean1(k,l)^2) -1.5*full_dwdz_trac1(k,l)/w_mean1(k,l) - full_dadz_trac1(k,l)/alpha1out(k,l) else full_dSiebesma(k,l)=-0.
+ENDFOR
+ENDFOR
+
+what_I_plot = smoothed_d_rate_ude_trac1_les
+labels=['d_rate trac1']
+title_user = TestCase+SubCase+LayerCase+' LES UDE detrainment rate dep with B/w2, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d_Bw2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0, XMAX=0.4, YMIN=0., YMAX=0.4, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=full_bw2(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30, SYM=5, /NOLINES
+AXES, XSTEP = 0.05 , XTITLE='Detrainment rate m-1', YSTEP=0.05, YTITLE='B/w²',NDECS=4
+
+FOR l=0, nttot-1 DO BEGIN
+        oplot, full_d1(*,l),full_bw2(*,l),thick=0.05,psym=1
+ENDFOR
+;oplot, theoretical_d_trac1_les, full_bw2(*,lt_plotindex_les),psym=2,thick=0.8,color=7
+;oplot,B_w2_trac1/2.7 + 0.0002,B_w2_trac1,thick=0.3,color=7
+oplot,B_w2_trac1/2.222 + 0.0002,B_w2_trac1,thick=0.3,color=7
+oplot, 0.0105*(B_w2_trac1/0.048)^(1./1.7),B_w2_trac1,thick=0.3,color=7
+oplot, 0.0118*(B_w2_trac1/0.043)^(1./1.65),B_w2_trac1,thick=0.3,color=6
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; --- PLOTTING : 0.5*dwu2/dz
+print, '........ ///////////// starting local thermal model ///////////'
+
+print, ' -> alimentation'
+a_star = make_array(nz, value=0.)
+f_star = make_array(nz, value=0.)
+f_star(0) = 1.
+teta_est = make_array(nz, value=0.)
+teta_p = make_array(nz, value=0.)
+zw2 = make_array(nz,value=0.)
+w_est = make_array(nz,value=0.)
+entr_star = make_array(nz,value=0.)
+detr_star = make_array(nz,value=0.)
+zbuoy_est = make_array(nz,value=0.)
+zbuoy = make_array(nz,value=0.)
+a_star_tot = 0.
+
+zw2(1)= 0.4*0.3811552*2*grav*(teta_les(0,lt_plotindex_les)/teta_les(1,lt_plotindex_les) -1.)*approx_zdz_les(0)
+w_est(1) = zw2(1)
+FOR k=0, nz-2 DO BEGIN
+        if ((teta_les(k,lt_plotindex_les) GT (teta_les(k+1,lt_plotindex_les) +0.1)) AND (teta_les(0,lt_plotindex_les) GE teta_les(k,lt_plotindex_les))) then begin
+	a_star(k) = MAX([(teta_les(k,lt_plotindex_les)-teta_les(k+1,lt_plotindex_les)),0.])*sqrt(altitudes_LES(k))
+	a_star_tot = a_star_tot + a_star(k)
+        lalim = k+1.
+        endif
+ENDFOR
+FOR k=0, nz-1 DO BEGIN
+        a_star(k) = a_star(k)/a_star_tot
+ENDFOR
+print, 'alimentation :'
+;print, a_star
+f_star(0)=0.
+f_star(1) = a_star(0)
+teta_p(0) = teta_les(0,lt_plotindex_les)
+teta_est(0) = teta_les(0,lt_plotindex_les)
+print, ' -> plume'
+FOR k=1, nz-2 DO BEGIN
+	if (k LT lalim) then begin
+		teta_est(k) = (f_star(k)*teta_p(k-1)+a_star(k)*0.5*(teta_les(k,lt_plotindex_les) + teta_p(k-1)))/(f_star(k) + a_star(k))
+	endif else begin
+		teta_est(k) = teta_p(k-1)
+	endelse
+	zbuoy_est(k) = grav*(teta_est(k)/teta_les(k,lt_plotindex_les) -1.)
+	zw2fact=fact_epsilon*2.*approx_zdz_les(k)/(1.+betalpha)
+	zdw2=afact*zbuoy_est(k)/fact_epsilon
+        w_est(k+1) = MAX([0.0001,exp(-zw2fact)*(w_est(k)-zdw2)+zdw2])
+	if (w_est(k+1) lt 0.) then begin
+                w_est(k+1)=zw2(k)
+        endif
+	if (w_est(k+1) gt 0.001) then begin
+		entr_star(k)=f_star(k)*approx_zdz_les(k)*(betalpha/(1.+betalpha))*MAX([0.,afact*zbuoy_est(k)/w_est(k+1)])
+		detr_star(k)=f_star(k)*approx_zdz_les(k)*MAX([detr_min,-afact*(betalpha/(1.+betalpha))*zbuoy_est(k)/w_est(k+1)])
+	endif
+        if (k lt lalim) then begin
+          a_star(k)=max([a_star(k),entr_star(k)])
+          entr_star(k)=0.
+        endif
+	if (w_est(k+1) gt 0.001) then begin
+	f_star(k+1)=f_star(k)+a_star(k)+entr_star(k)-detr_star(k)
+	if (k lt lalim) then begin
+	teta_p(k)=(f_star(k)*teta_p(k-1)+(a_star(k)+entr_star(k))*0.5*(teta_p(k-1) + teta_les(k,lt_plotindex_les)))/(f_star(k+1)+detr_star(k))
+	endif else begin
+	teta_p(k)=(f_star(k)*teta_p(k-1)+(a_star(k)+entr_star(k))*teta_les(k,lt_plotindex_les))/(f_star(k+1)+detr_star(k))
+	endelse
+	zbuoy(k) = grav*(teta_p(k)/teta_les(k,lt_plotindex_les) -1.)
+        zw2fact=fact_epsilon*2.*approx_zdz_les(k)/(1.+betalpha)
+        zdw2=afact*zbuoy(k)/fact_epsilon
+        zw2(k+1) = MAX([0.0001,exp(-zw2fact)*(zw2(k)-zdw2)+zdw2])
+	endif
+ENDFOR
+print, ' -> done'
+
+print, '........ CHECKING VERTICAL VELOCITY FORMULATION'
+what_I_plot = make_array(nz,value=0.)
+what_I_overplot = make_array(nz,value=0.)
+FOR k=0, nz-2 DO BEGIN
+        what_I_plot(k) = 0.5*(sqrt(zw2(k)) + sqrt(zw2(k+1)))
+ENDFOR
+FOR k=0, nZmx-2 DO BEGIN
+        what_I_overplot(k) = 0.5*(zw2_lev(k,lt_plotindex_gcm) + zw2_lev(k+1,lt_plotindex_gcm))
+ENDFOR
+labels=['zw2 in les calc as in TH']
+title_user = TestCase+SubCase+LayerCase+' LES vertical velocity formulation check'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_w2_check.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=8., YMIN=0., YMAX=7, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1 , XTITLE='w2 in LES from TH calc m/s', YSTEP=1., YTITLE='Altitude (km)',NDECS=3
+
+oplot, w_mean1(*,lt_plotindex_les), altitudes_LES/1000.
+oplot, what_I_overplot, altitudes_GCM/1000.,psym =4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+print, '........ CHECKING TETA ESTIMATIONS FORMULATION'
+
+what_I_plot = [[teta_est],[teta_p],[tplume1moy(*,lt_plotindex_les)]]
+labels=['LES estimated teta','LES teta plume calc as in TH','LES teta plume']
+title_user = TestCase+SubCase+LayerCase+' LES estimated teta formulation check'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_teta_check.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=214., XMAX=220., YMIN=0., YMAX=7, TITLE=title_user
+cols=INDGEN(3)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1 , XTITLE='Teta plume and Est in LES from TH calc K', YSTEP=1., YTITLE='Altitude (km)',NDECS=3
+
+oplot, teta_gcm(*,lt_plotindex_gcm)*(buoyancy_gcm(*,lt_plotindex_gcm)/grav +1.), altitudes_GCM/1000.
+oplot, teta_gcm(*,lt_plotindex_gcm)*(buoyancy_est_gcm(*,lt_plotindex_gcm)/grav +1.), altitudes_GCM/1000.
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+print, '........ CHECKING MASS FLUX FORMULATION'
+
+what_I_plot = [[f_star/MAX(f_star)],[smoothed_fm_trac1_les(*,lt_plotindex_les)/MAX(smoothed_fm_trac1_les(*,lt_plotindex_les))]]
+labels=['LES normalized f_star ','LES normalized updraft mass flux']
+title_user = TestCase+SubCase+LayerCase+' LES normalized f_star formulation check'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fm_check.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=1., YMIN=0., YMAX=7, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.1 , XTITLE='f*/max(f*) in LES from TH calc', YSTEP=1., YTITLE='Altitude (km)',NDECS=3
+
+oplot,fm_therm_gcm_interlay(*,lt_plotindex_gcm)/MAX(fm_therm_gcm_interlay(*,lt_plotindex_gcm)), altitudes_GCM/1000.,psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; COMPUTING THE CONTINUITY EQUATION IN THE QUASI-BOUSSINESQ APPROX
+
+da_dt = make_array(nz,n_elements(localtime))
+smoothed_da_dt = make_array(nz)
+FOR k=0, nz-1 DO BEGIN
+	da_dt(k,*) = deriv(localtime,reform(alpha1out(k,*)))/3700.
+ENDFOR
+FOR t=-ns,ns DO BEGIN
+        smoothed_da_dt = smoothed_da_dt + REFORM(da_dt(*,lt_plotindex_les+t))
+ENDFOR
+smoothed_da_dt = smoothed_da_dt/nstot
+
+rho = pt/(R*temp_les)
+smoothed_rho = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_rho = smoothed_rho + REFORM(rho(*,lt_plotindex_les+t))
+ENDFOR
+smoothed_rho = smoothed_rho/nstot
+
+continuity1 = smoothed_rho*smoothed_da_dt + df_dz_les1 - smoothed_e_rate_ude_trac1_les*smoothed_fm_trac1_les + smoothed_d_rate_ude_trac1_les*smoothed_fm_trac1_les
+print, '........ CONTINUITY CHECK'
+
+what_I_plot = [[continuity1],[smoothed_rho*smoothed_da_dt],[df_dz_les1],[-smoothed_e_rate_ude_trac1_les*smoothed_fm_trac1_les],[smoothed_d_rate_ude_trac1_les*smoothed_fm_trac1_les]]
+labels=['total continuity','rho*da/dt','df/dz','-E','D']
+title_user = TestCase+SubCase+LayerCase+' LES UDE continuity check, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_continuity.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.0005, XMAX=0.0005, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(5)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30 
+AXES, XSTEP = 0.0001 , XTITLE='kg.m-2.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; COMPUTING THE E-D TERM FROM THE CONTINUITY EQUATION
+
+eminusd1=make_array(nz)
+FOR k=0, nz-1 DO BEGIN
+	IF(smoothed_fm_trac1_les(k) ne 0.) THEN eminusd1(k) = (smoothed_rho(k)*smoothed_da_dt(k) - df_dz_les1(k))/smoothed_fm_trac1_les(k) ELSE eminusd1(k)=0.
+ENDFOR
+what_I_plot = eminusd1
+labels=['e-d']
+title_user = TestCase+SubCase+LayerCase+' LES e-d, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_EminusD.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.002, XMAX=0.002, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.0005 , XTITLE='kg.m-2.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; COMPUTING THE TURBULENT FLUX DECOMPOSITION IN PASSIVE ENV AND ACTIVE PLUME
+; TO CHECK CONSISTENCY
+
+print, '........ CHECKING CONSISTENCY OF UPDRAFT/ENV DECOMPOSITION'
+
+smoothed_hf1_term1 = make_array(nz)
+smoothed_hf1_term2 = make_array(nz)
+smoothed_hf1_term3 = make_array(nz)
+smoothed_wt = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+	smoothed_hf1_term1 = smoothed_hf1_term1 + REFORM(hf1_term1(*,lt_plotindex_les+t))
+	smoothed_hf1_term2 = smoothed_hf1_term2 + REFORM(hf1_term2(*,lt_plotindex_les+t))
+	smoothed_hf1_term3 = smoothed_hf1_term3 + REFORM(hf1_term3(*,lt_plotindex_les+t))
+	smoothed_wt = smoothed_wt + REFORM(wt(*,lt_plotindex_les+t))
+ENDFOR
+smoothed_hf1_term1 = smoothed_hf1_term1/nstot
+smoothed_hf1_term2 = smoothed_hf1_term2/nstot
+smoothed_hf1_term3 = smoothed_hf1_term3/nstot
+smoothed_wt = smoothed_wt/nstot
+
+what_I_plot = [[smoothed_hf1_term1],[smoothed_hf1_term2],[smoothed_hf1_term3],[smoothed_hf1_term1+smoothed_hf1_term2+smoothed_hf1_term3]]
+labels=['within plume turbulence','within env. turbulence','organized turbulence','TOTAL']
+title_user = TestCase+SubCase+LayerCase+' LES turbulence decomposition check, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_turbu.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=1.5, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.5 , XTITLE='m.K/s', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+oplot, smoothed_wt, altitudes_LES/1000.,psym=3
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+
+; COMPUTING THE TURBULENT FLUX DECOMPOSITION IN PASSIVE ENV ,ACTIVE PLUME and ACTIVE DOWNDRAFT
+; TO CHECK CONSISTENCY
+
+print, '........ CHECKING CONSISTENCY OF UPDRAFT/DOWNDRAFT/ENV DECOMPOSITION'
+
+smoothed_hf1_ude_term1 = make_array(nz)
+smoothed_hf1_ude_term2 = make_array(nz)
+smoothed_hf1_ude_term3 = make_array(nz)
+smoothed_hf1_ude_term4 = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_hf1_ude_term1 = smoothed_hf1_ude_term1 + REFORM(hf1_ude_term1(*,lt_plotindex_les+t))
+        smoothed_hf1_ude_term2 = smoothed_hf1_ude_term2 + REFORM(hf1_ude_term2(*,lt_plotindex_les+t))
+        smoothed_hf1_ude_term3 = smoothed_hf1_ude_term3 + REFORM(hf1_ude_term3(*,lt_plotindex_les+t))
+        smoothed_hf1_ude_term4 = smoothed_hf1_ude_term4 + REFORM(hf1_ude_term4(*,lt_plotindex_les+t))
+ENDFOR
+smoothed_hf1_ude_term1 = smoothed_hf1_ude_term1/nstot
+smoothed_hf1_ude_term2 = smoothed_hf1_ude_term2/nstot
+smoothed_hf1_ude_term3 = smoothed_hf1_ude_term3/nstot
+smoothed_hf1_ude_term4 = smoothed_hf1_ude_term4/nstot
+
+what_I_plot = [[smoothed_hf1_ude_term1],[smoothed_hf1_ude_term2],[smoothed_hf1_ude_term3],[smoothed_hf1_ude_term4],[smoothed_hf1_ude_term1+smoothed_hf1_ude_term2+smoothed_hf1_ude_term3+smoothed_hf1_ude_term4]]
+labels=['within plume turbulence','within downdraft turbulence','within env. turbulence','organized turbulence','TOTAL']
+title_user = TestCase+SubCase+LayerCase+' LES UDE turbulence decomposition check, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_turbu_ude.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=1.5, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(5)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.25 , XTITLE='m.K/s', YSTEP=0.5, YTITLE='Altitude (km)',NDECS=3
+oplot, smoothed_wt, altitudes_LES/1000.,psym=3
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; CHECK CONSISTENCY OF We = W and THETA e = THETA approximation
+
+print, '........ CHECKING CONSISTENCY OF env variable (w_e,theta_e) = mean variable (w_overbar,theta_overbar)'
+print, 'as well as mean(w) = 0, in the UDE decomposition'
+
+smoothed_delta_theta_ude = make_array(nz)
+smoothed_delta_w_ude = make_array(nz)
+smoothed_w_mean1_full = make_array(nz)
+
+FOR t=-ns,ns DO BEGIN
+        smoothed_delta_theta_ude = smoothed_delta_theta_ude + REFORM(w_mean1_env_ude(*,lt_plotindex_les+t)-w_mean1_full(*,lt_plotindex_les+t))
+        smoothed_delta_w_ude = smoothed_delta_w_ude + REFORM(tenv1moy_ude(*,lt_plotindex_les+t)-tmoy_full(*,lt_plotindex_les+t))
+        smoothed_w_mean1_full = smoothed_w_mean1_full + REFORM(w_mean1_full(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_delta_theta_ude = smoothed_delta_theta_ude/nstot
+smoothed_delta_w_ude = smoothed_delta_w_ude/nstot
+smoothed_w_mean1_full = smoothed_w_mean1_full/nstot
+
+what_I_plot = [[smoothed_delta_theta_ude],[smoothed_delta_w_ude],[smoothed_w_mean1_full]]
+labels=['theta env_ude - theta moy','w env_ude - w moy','mean w over domain (*,*,k)']
+title_user = TestCase+SubCase+LayerCase+' LES UDE env/mean approximation check, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_approx_ude.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-2, XMAX=2, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(3)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.5 , XTITLE='(m/s) and (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; GETTING SOME INSIGHT ON PLUME'S INSIDE TEMPERATURES
+
+print, '........ STRUCTURE POTENTIAL TEMPERATURES'
+xmin = 210
+xmax = 220
+if (TestCase eq 'Case_Z') then begin
+xmin = 260
+xmax = 270
+endif
+ztva = teta_gcm*(buoyancy_gcm/grav +1.)
+ztva_est = teta_gcm*(buoyancy_est_gcm/grav +1.)
+what_I_plot = [[tplume1moy(*,lt_plotindex_les)],[tenv1moy(*,lt_plotindex_les)],[teta_les(*,lt_plotindex_les)]]
+labels=['Teta updraft','Teta env ','Teta moy']
+title_user = TestCase+SubCase+LayerCase+' LES Teta in the structures, no average'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fullTeta.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(3)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1 , XTITLE='Potential Temperature (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+oplot, ztva(*,lt_plotindex_gcm), altitudes_GCM/1000., thick=0.3
+oplot, ztva_est(*,lt_plotindex_gcm), altitudes_GCM/1000., thick=0.3
+oplot, teta_gcm(*,lt_plotindex_gcm), altitudes_GCM/1000., thick=0.3
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+
+print, '........ UDE STRUCTURE POTENTIAL TEMPERATURES'
+
+what_I_plot = [[tplume1moy(*,lt_plotindex_les)],[tdown1moy(*,lt_plotindex_les)],[tenv1moy_ude(*,lt_plotindex_les)],[teta_les(*,lt_plotindex_les)]]
+labels=['Teta updraft','Teta downdraft','Teta env (UDE)','Teta moy']
+title_user = TestCase+SubCase+LayerCase+' LES UDE Teta in the structures, no average'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fullTeta_ude.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=210, XMAX=220, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1 , XTITLE='Potential Temperature (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; -----------------------------------------------------------------------------------------------------------------------
+; End of PLUME diagnostics
+; -----------------------------------------------------------------------------------------------------------------------
+
+; *** TKE ***
+
+print, '........ TKE'
+
+what_I_plot = reform(tke_gcm(*,lt_plotindex_gcm))
+labels=['TH tke 1d']
+title_user = TestCase+SubCase+LayerCase+' TKE comparison'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_tke.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=8, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='Turbulent kinetic energy (kg.m-3)', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+oplot, tke_les(*,lt_plotindex_les), altitudes_LES/1000., psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; *** HEAT FLUX ***
+
+print, '........ HEAT FLUX'
+
+lay_heatFlux_up = make_array(nZmx,nTmx)
+lay_heatFlux_down = make_array(nZmx,nTmx)
+
+FOR k=1, nZmx-1 DO BEGIN
+	lay_heatFlux_up(k,*) = 0.5*(heatFlux_up(k,*) + heatFlux_up(k-1,*))
+	lay_heatFlux_down(k,*) = 0.5*(heatFlux_down(k,*) + heatFlux_down(k-1,*))
+ENDFOR
+lay_heatFlux_up(0,*)=0.5*(heatFlux_up(0,*))
+lay_heatFlux_down(0,*)=0.5*(heatFlux_down(0,*))
+zkh_gcm_int = make_array(nZmx)
+
+FOR k=0, nZmx-2 DO BEGIN
+	zkh_gcm_int(k) = 0.5*(zkh(k,lt_plotindex_gcm) + zkh(k+1,lt_plotindex_gcm))
+ENDFOR
+MY_gcm = -zkh_gcm_int*(deriv(altitudes_GCM,reform(zh(*,lt_plotindex_gcm)))); - 0.025*max(lay_heatFlux_up(*,lt_plotindex_gcm)))
+
+
+;what_I_plot = [[lay_heatFlux_up(*,lt_plotindex_gcm)],[MY_gcm],[lay_heatFlux_up(*,lt_plotindex_gcm)+MY_gcm]]
+what_I_plot = [[lay_heatFlux_up(*,lt_plotindex_gcm)],[MY_gcm],[lay_heatFlux_down(*,lt_plotindex_gcm)],[lay_heatFlux_down(*,lt_plotindex_gcm)+lay_heatFlux_up(*,lt_plotindex_gcm)+MY_gcm]]
+
+;labels=['TH updraft heat flux','Mellor and Yamada gcm heat flux','Total']
+labels=['TH updraft heat flux','Mellor and Yamada gcm heat flux','TH downdraft heat flux','Total']
+
+title_user = TestCase+SubCase+LayerCase+' TH vertical heat flux'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_WT.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-2, XMAX=3, YMIN=0, YMAX=10, TITLE=title_user
+;cols=INDGEN(3)+2
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='vertical turbulent heat flux', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+;hf1_ude_term4 = alpha1out*(w_mean1 - w_mean1_full)*(tplume1moy - tmoy_full) + beta1out*(w_mean1_down - w_mean1_full)*(tdown1moy - tmoy_full) + (1.- (alpha1out+beta1out))*(w_mean1_env_ude - w_mean1_full)*(tenv1moy_ude - tmoy_full)
+
+oplot, alpha1out(*,lt_plotindex_les)*(w_mean1(*,lt_plotindex_les) - w_mean1_full(*,lt_plotindex_les))*(tplume1moy(*,lt_plotindex_les) - tmoy_full(*,lt_plotindex_les)), altitudes_LES/1000., color=2
+
+oplot, beta1out(*,lt_plotindex_les)*(w_mean1_down(*,lt_plotindex_les) - w_mean1_full(*,lt_plotindex_les))*(tdown1moy(*,lt_plotindex_les) - tmoy_full(*,lt_plotindex_les)), altitudes_LES/1000.,color=6
+
+oplot, smoothed_hf1_ude_term4, altitudes_LES/1000., color = 5
+
+;oplot, smoothed_hf1_term1, altitudes_LES/1000.,thick=0.1,LINESTYLE = 5
+;oplot, smoothed_hf1_term2, altitudes_LES/1000.,color=2,thick=0.1,LINESTYLE = 5
+;oplot, smoothed_hf1_term3, altitudes_LES/1000.,color=8,thick=0.1,LINESTYLE = 5
+
+oplot, wt(*,lt_plotindex_les), altitudes_LES/1000. 
+
+;oplot, smoothed_hf1_term3(*,lt_plotindex_les), altitudes_LES/1000., psym=7
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; *** TRACERS ***
+
+print, '........ TRACER PLOTS DEACTIVATED'
+
+; trying stuff 
+
+buoyancy_downdraft = grav*(tdown1moy/tenv1moy_ude-1.)
+lmix = make_array(nttot,value=-1.)
+altitudes_rel_LES = make_array(nz,nttot)
+FOR l=0, nttot-1 DO BEGIN
+;	kmax = where(w_mean1(*,l) eq max(w_mean1(*,l)))
+;	if (kmax(0) ne -1) then lmix(l) = altitudes_LES(kmax(0)) else lmix(l) = -1.
+;FOR k=nz-2, 1,-1 DO BEGIN
+;	if ((buoyancy_downdraft(k,l) gt 0.) and (buoyancy_downdraft(k-1,l) lt 0.)) then lmix(l) = 0.5*(altitudes_LES(k)+altitudes_LES(k+1))
+;ENDFOR
+FOR k=nz-2, 1,-1 DO BEGIN
+	if (tdown1moy(k,l) eq 0.) then lmix(l) = altitudes_LES(k)
+ENDFOR
+ENDFOR
+
+FOR l=0, nttot-1 DO BEGIN
+FOR k=0, nz-1 DO BEGIN
+	altitudes_rel_LES(k,l) = altitudes_LES(k)/lmix(l)
+ENDFOR
+ENDFOR
+
+print, '........ Teta down / Teta up in UDE'
+
+stuff2=tdown1moy/tenv1moy_ude
+
+what_I_plot = stuff2(*,lt_plotindex_les)
+labels=['Teta d/Teta env 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuff2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0.992, XMAX=1.004, YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.002, XTITLE='Teta d/ Teta env', YSTEP=0.2, YTITLE='Altitude/zi ',NDECS=3
+
+FOR i=0,nttot-1 DO BEGIN
+	if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.075)/187.931 + 0.9977, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, (altitudes_rel_LES(*,lt_plotindex_les))/19.231 + 0.9938, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.60)/(-1333) + 1.00025, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+print, '........ Teta down / Teta up in UDE'
+
+stuff2=tdown1moy/tplume1moy
+
+what_I_plot = stuff2(*,lt_plotindex_les)
+labels=['Teta d/Teta u 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuff2.5.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0.95, XMAX=1.1, YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.01, XTITLE='Teta d/ Teta u', YSTEP=0.2, YTITLE='Altitude/zi ',NDECS=3
+
+FOR i=0,nttot-1 DO BEGIN
+        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+;oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.075)/187.931 + 0.9977, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, (altitudes_rel_LES(*,lt_plotindex_les))/19.231 + 0.9938, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.60)/(-1333) + 1.00025, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+print, '........ B down / B up in UDE'
+
+stuff2 = (tdown1moy/tenv1moy_ude -1.)/(tplume1moy/tenv1moy_ude -1.)
+what_I_plot = stuff2(*,lt_plotindex_les)
+labels=['B down/B up 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff Bd/Bu'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuffBuBd.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=1., YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.1, XTITLE='B down/ B up', YSTEP=0.1, YTITLE='Altitude/zi ',NDECS=1
+
+FOR i=0,nttot-1 DO BEGIN
+        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+;oplot, ((altitudes_rel_LES(*,lt_plotindex_les)-0.06)/0.839841)^2 - 0.3, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, ((altitudes_rel_LES(*,lt_plotindex_les)-0.06)/1.16847)^2 - 0.3, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.7)/1., altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, (altitudes_rel_LES(*,lt_plotindex_les))/0.08333333-1., altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, sqrt(altitudes_rel_LES(*,lt_plotindex_les)/0.122449)-1., altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+print, '........ F down / F up in UDE'
+
+stuff2 = downward_flux1/fm_trac1_les
+what_I_plot = stuff2(*,lt_plotindex_les)
+labels=['f down/f up 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff f down/f up'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stufffufd.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-8, XMAX=0.5, YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.5, XTITLE='f down/ f up', YSTEP=0.1, YTITLE='Altitude/zi ',NDECS=1
+
+FOR i=0,nttot-1 DO BEGIN
+        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.0149259)/0.00333)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.02)/0.006)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+print, '........ dFdz down / dzFdz up in UDE'
+stuff3=make_array(nz,nttot)
+FOR l=0, nttot-1 DO BEGIN
+	stuff3(*,l) = deriv(altitudes_LES,downward_flux1(*,l))/deriv(altitudes_LES,fm_trac1_les(*,l))
+ENDFOR
+what_I_plot = stuff3(*,lt_plotindex_les)
+labels=['dfdz down/dfdz up 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff f down/f up'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuffdfudfd.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-30, XMAX=30, YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='dfdz down/ dfdz up', YSTEP=0.1, YTITLE='Altitude/zi ',NDECS=1
+
+FOR i=0,nttot-1 DO BEGIN
+        if(lmix(i) ne -1) then oplot, stuff3(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+;oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.0149259)/0.00333)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.02)/0.006)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+;
+;what_I_plot = [[ar_col],[co2_col],[tke_col]] 
+;labels=['Ar deviation','Co2 deviation','TKE deviation']
+;title_user = TestCase+SubCase+' TH 1d tracer conservation'
+;filename = TestCase+SubCase+'Gcm_Les_Comp_tracer.ps'
+;PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+;CS, SCALE=28
+;GSET, XMIN=localtime_gcm(0), XMAX=localtime_gcm(nTmx-1), YMIN=0, YMAX=2, TITLE=title_user
+;cols=INDGEN(3)+2
+;GPLOT, X=localtime_gcm, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+;AXES, XSTEP = 2, XTITLE='Local time (h)', YSTEP=0.1, YTITLE='Tracer integrated column mass deviation from origin (%)',NDECS=1
+;
+;PSCLOSE, /NOVIEW
+;
+;spawn, 'ps2png '+filename
+;
+;title_user = TestCase+SubCase+' TH argon propagation from first layer'
+;PS_START, file = TestCase+SubCase+'Gcm_Les_Comp_Argon.ps'
+;
+;what_I_plot = transpose(ar(0:6,*))
+;
+;maxfield_init = 0.05
+;minfield_init = 0
+;pal=33
+;lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+;lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+;
+;section, $
+;        what_I_plot, $                          ; 2D field
+;        localtime_gcm, $                                ; horizontal coordinate
+;        altitudes_gcm(0:6), $                                ; altitude coordinate
+;        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+;        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+;;       minspace=minspace, $                    ; minimum value of space window (=0: calculate)
+;;       maxspace=maxspace, $                    ; maximum value of space window (=0: calculate)
+;;       overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+;;       overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+;;       overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+;;       colors=colors, $                        ; number of colors/levels (32 is default)
+;        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+;        title_axis=['Martian hour (h)','Height above ground (m)'], $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+;        ct=pal, $                               ; color table (33-rainbow is default)
+;;       topo=topography, $
+;        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;PS_END, /PNG
+;
+;INTERVAL_VOLUME, supermask1, 0.5, 1.,verts, conn
+;conn = TETRA_SURFACE(verts, conn)  
+;oRain = OBJ_NEW('IDLgrPolygon', verts, POLYGONS=conn, $  
+;   COLOR=[255,255,255], SHADING=1)  
+;XOBJVIEW, oRain, BACKGROUND=[150,200,255]
+
+;INTERVAL_VOLUME, supermask2, 0.5, 1.5,verts, conn
+;conn = TETRA_SURFACE(verts, conn)
+;oRain = OBJ_NEW('IDLgrPolygon', verts, POLYGONS=conn, $
+;   COLOR=[255,255,255], SHADING=1)
+;XOBJVIEW, oRain, BACKGROUND=[150,200,255]
+
+ENDELSE
+
+print, ''
+print, '........ ALL DONE'
+print, ''
+
+END
Index: trunk/UTIL/IDLplot/SPEC/LES/THERMALS/thermiques.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/THERMALS/thermiques.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/THERMALS/thermiques.pro	(revision 1185)
@@ -0,0 +1,3863 @@
+FUNCTION myfunct, Bw2, A
+   G = A[0]*Bw2 + A[1]
+   RETURN,[ [G], [Bw2] , [1.0] ]
+END
+
+FUNCTION myfunct2, Gammaw2, A
+   G = A[0]*(Gammaw2)^A[1]
+   RETURN,[ [G], [(Gammaw2)^A[1]] , [G*alog(Gammaw2)] ]
+END
+
+FUNCTION myfunct3, Gammaw2, A
+   G = A[0]*(Gammaw2)^A[1]+A[2]
+   RETURN,[ [G], [(Gammaw2)^A[1]] , [G*alog(Gammaw2)] , [1.0] ]
+END
+
+FUNCTION myfunct4, Bw2, A
+   G = A*Bw2
+   RETURN,[[G], [Bw2]]
+END
+
+PRO thermiques
+
+spawn, 'clear'
+print, ''
+print, '** Thermals Analysis **'
+print, ' (usine à gaz) '
+print, ''
+
+full='true'
+f_offset='false'
+overplot_convadj='false'
+plot_3d = 'false'
+les_special=''
+lctu_gcm = 6.
+got_swdownz='false'
+got_tracer_flux='false'
+got_hfx='false'
+
+;got_swdownz='true'
+;got_hfx='true'
+;got_tracer_flux='true'
+
+; *********** Best values for LES thermals with tau =0.5
+betalpha = 1.3
+afact = 1.8
+fact_epsilon = 0.0008
+detr_min = 0.0007
+
+
+;betalpha = 1.
+;afact = 2.4
+;fact_epsilon = 0.0007
+;detr_min = 0.0007
+
+; --------
+
+; *********** Best values for LES thermals with tau =1.
+;betalpha = 1.
+;afact = 1.1
+;fact_epsilon = 0.00025
+;detr_min = 0.0007
+; --------
+
+;datname='thermiques.dat.scale1.2'
+;datname='thermiques.dat.scale1.4'
+;datname='thermiques.dat.scale0.6'
+datname='thermiques.dat'
+;datname='thermiques.dat.scale0.8'
+;datname='thermiques.dat'           ;scale =1.0, sigmao =1.0
+
+ns = 0     ; number of points for time-smoothing of LES data : 2*ns+1 points, ns = 9 eq to 30mn (-15mn//+15mn)
+nstot = float(2.*ns+1.)
+
+GcmSubCase = ''
+LayerCase=''
+s_trac1 = 'qtrac1'
+s_trac2 = 'qtrac2'
+got_pdt = 'true'
+TestCase = 'Case_A'
+SubCase = '_11_shorter'
+Histo = 'true'
+newtest = ''
+visualization_mode = 'false'
+got_updrafts='false'
+
+label_init:
+spawn, 'clear'
+print, ' Available simulations :'
+print, '----'
+print, ' 1/ Case_A_11 : 45x45x71,   ztop=10km,dx=100m,dz=140m,Ls=47.1°,(21.8N;205.0E),55tiu,A=0.275,Tau=0.5'
+print, ' 2/ Case_A_4  : 101x101x201 ztop=15km,dx=100m,dz= 75m,Ls=47.1°,(21.8N;205.0E),55tiu,A=0.275,Tau=0.5'
+print, ' 3/ Case_A_4_shorter  : Case A4 with Dtrac1 = 5 mn and Dtrac2 = 10 mn (compared to 20 and 100)'
+print, ' 4/ Case_A_4_shorter_winds  : Case A4_shorter with bckgrnd wind u=10 m/s'
+print, ' 5/ Case_A_4_shorter_winds_30  : Case A4_shorter with bckgrnd wind u=30 m/s'
+print, ' 6/ Case_A_4_shorter_winds_tau1  : Case A4_shorter with bckgrnd wind u=10 m/s and tau=1'
+print, ' 7/ Case_A_4_shorter_winds_tau2  : Case A4_shorter with bckgrnd wind u=10 m/s and tau=2'
+print, ' 8/ Case_ExtremeCase  : 101x101x201 ztop=15km,dx=100m,dz=75m,Ls=0°,(0.N;0.E),50tiu,A=0.1,Tau=0.05'
+print, '----'
+print, ' 9/ Case_C_4_shorter_winds  : '
+print, ' 10/ Case_I_4_shorter_winds  : '
+print, ' 11/ Case_Z_4_shorter_winds  : '
+print, ' 12/ 1D : 124 layers'
+print, ' 13/ 1D : 32 layers'
+print, ' 14/ 1D : low dt'
+print, ' 15/ LES HR run (257x257x301)'
+print, ' 16/ 1D : 13 layers : gcm to 15km'
+print, ''
+print, ' 0/ PLUME VISUALISATION : '+visualization_mode
+print, ' 999/ CLEAR thermiques.dat for considered case'
+print, ' 100/ OVERPLOT CONVADJ ONLY RESULTS : '+overplot_convadj
+print, ''
+print, ' SIMULATION NUMBER  : '
+print, ' ** '+TestCase+SubCase+LayerCase+' ** '
+print, ''
+print, 'Any change ? (number of new case to change, or any other key to continue)'
+read, newtest
+if (newtest eq '1') then begin
+TestCase = 'Case_A'
+SubCase = '_11'
+pGround = 867.5594
+goto,label_init
+endif
+if (newtest eq '2') then begin
+TestCase = 'Case_A'
+SubCase = '_4'
+got_pdt = 'false'
+pGround = 867.5594
+goto,label_init
+endif
+if (newtest eq '3') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter'
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 867.5594
+goto,label_init
+endif
+if (newtest eq '4') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter_wind'
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+lctu_gcm = 6.
+pGround = 856.997    ;6h
+;pGround = 867.5594   ;8h
+;got_swdownz='true'
+;got_hfx='true'
+;got_tracer_flux='true'
+goto,label_init
+endif
+if (newtest eq '5') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter_wind_30'
+GcmSubCase = '_wind_30'
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+pGround = 856.997    ;6h
+f_offset='false'
+goto,label_init
+endif
+if (newtest eq '6') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter_wind_tau1'
+GcmSubCase = '_tau1'
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+pGround = 856.997    ;6h
+f_offset='false'
+goto,label_init
+endif
+if (newtest eq '7') then begin
+TestCase = 'Case_A'
+SubCase = '_4_shorter_wind_tau2'
+GcmSubCase = '_tau2'
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 856.997    ;6h
+goto,label_init
+endif
+if (newtest eq '8') then begin
+TestCase = 'ExtremeCase'
+SubCase = ''
+GcmSubCase = ''
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 670.018      ;6h
+;pGround = 677.722    ;8h
+lctu_gcm = 6.
+;got_swdownz='true'
+;got_hfx='true'
+;got_tracer_flux='true'
+goto,label_init
+endif
+if (newtest eq '9') then begin
+TestCase = 'Case_C'
+SubCase = '_4_shorter_wind'
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 480.6
+goto,label_init
+endif
+if (newtest eq '10') then begin
+TestCase = 'Case_I'
+SubCase = '_4_shorter_wind'
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 630.
+goto,label_init
+endif
+if (newtest eq '11') then begin
+TestCase = 'Case_Z'
+SubCase = '_4_shorter_wind'
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+pGround = 266.
+goto,label_init
+endif
+if (newtest eq '12') then begin
+LayerCase=''
+goto,label_init
+endif
+if (newtest eq '13') then begin
+LayerCase='_32lev'
+goto,label_init
+endif
+if (newtest eq '14') then begin
+LayerCase='_low_dt'
+goto,label_init
+endif
+if (newtest eq '15') then begin
+les_special='_HR'
+got_swdownz='true'
+got_hfx='true'
+got_tracer_flux='true'
+goto,label_init
+endif
+if (newtest eq '16') then begin
+LayerCase='_13lev'
+got_swdownz='true'
+goto,label_init
+endif
+if (newtest eq '17') then begin
+TestCase = 'Exomars'
+SubCase = ''
+GcmSubCase = ''
+s_trac1 = 'qtrac2'
+s_trac2 = 'qtrac1'
+full = 'true'
+f_offset='false'
+;pGround = 717.899 ;6h
+pGround = 718.
+lctu_gcm = 6.
+;got_swdownz='true'
+;got_hfx='true'
+;got_tracer_flux='true'
+goto,label_init
+endif
+
+if (newtest eq '100') then begin
+if (overplot_convadj eq 'true') then overplot_convadj = 'false' else overplot_convadj = 'true'
+goto,label_init
+endif
+if (newtest eq '0') then begin
+visualization_mode = 'true'
+spawn, 'clear'
+print, 'The first timestep of the considered file will be shown.'
+print, 'Defaut file is : file 6 (lt ~ 13h10)'
+print, 'Which file do you want ? (lt ~= file_number + 7)'
+loop_special = '6'
+read, loop_special
+print, 'Do you wish to plot histograms or manipulate volumic data ?'
+print, '1/ Histogram'
+print, '2/ Volumic data'
+x=''
+read, x
+if (x eq '1') then Histo='true' else Histo='false'
+goto,label_init
+endif
+
+les_path='/san0/acolmd/SIMUS/LES_'+TestCase+SubCase+les_special
+;gcm_path='/san0/acolmd/SIMUS/GCM_'+TestCase+LayerCase+'_2'
+gcm_path='/san0/acolmd/SIMUS/GCM_'+TestCase+GcmSubCase+LayerCase
+gcm_convadj_path=gcm_path+'_convadj'
+
+if (newtest eq '999') then spawn, 'rm -f '+les_path+'/'+datname
+print, ''
+print, ' -- Loading LES data -- '
+
+print, 'LES DATA IN : '
+print, les_path
+print, 'GCM DATA IN : '
+print, gcm_path
+
+p0=610. & t0=220. & r_cp=1./3.89419 & grav=3.72 & R=191.182
+history_interval_s = 100.
+;lctu_gcm = 8.                      ; Initial local time of gcm 1d simu
+scale = 1.                         ; Scaling factor for conditional sampling
+decimate = 10.			   ; Coeff for subsampling the data for sigma integral
+sigmao= 1.			   ; multiplicative coeff for the computation of Sigma0 in the CS
+sigmao_ude = 0.3		   ; number of standard deviation away from mean for the selection of downdraft in UDE
+
+openr,unit,les_path+'/'+datname,/get_lun,error=err
+IF (err ne 0) THEN BEGIN
+
+OPENR, 22, les_path+'/input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+OPENR, 23, les_path+'/input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+
+domain='d01' & filesWRF = FindFile(les_path+'/wrfout_'+domain+'_????-??-??_??:??:??') & nf=n_elements(filesWRF)
+;print, filesWRF
+;domain='d01' & filesWRF = les_path+'/'+['wrfout_d01_9999-01-01_03:05:00','wrfout_d01_9999-01-01_04:06:40'] & nf=n_elements(filesWRF)
+;ce fichier utilise aussi offset_localtime = 3.05
+
+; WARNING WARNING : FOR THE CASE 4_SHORTER, THE TRAC2 HAS 10 MN LIFETIME, WE WANT TO USE IT MORE EXTENSIVELY THAN THE TRAC1 (5mn) SO
+; we switch the names of trac1 and trac2 in the initialization of this routine, in the "case".
+
+id=ncdf_open(filesWRF(0))
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), dummy, nx & NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), dummy, ny
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'bottom_top'   ), dummy, nz & NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), dummy, nt
+NCDF_CLOSE, id
+id=ncdf_open(filesWRF(nf-1))  ;; for interrupted runs
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), dummy, ntlast
+NCDF_CLOSE, id
+nttot = (nf-1)*nt + ntlast
+wt  = fltarr(nz,nttot)
+tke_les = fltarr(nz,nttot) & ztke = fltarr(nz,nttot) & t = fltarr(nz,nttot)
+p = fltarr(nz) & ph = fltarr(nz) & pht = fltarr(nz,nttot) & pt = fltarr(nz,nttot)
+xtke = fltarr(nz,nttot) & ytke = fltarr(nz,nttot) & temp_les = fltarr(nz,nttot)
+wmax = fltarr(nttot) 
+alpha1 = fltarr(nz) & alpha2 = fltarr(nz)
+alpha1out = fltarr(nz,nttot) & alpha2out = fltarr(nz,nttot)
+zqtrac1 = dblarr(nx,ny,nz) & zqtrac2 = dblarr(nx,ny,nz)
+sigmazqtrac1 = fltarr(nz) & sigmazqtrac2 = fltarr(nz)
+sigmazminqtrac1 = fltarr(nz) & sigmazminqtrac2 = fltarr(nz)
+fm_trac1_les = fltarr(nz,nttot) & fm_trac2_les = fltarr(nz,nttot)
+anomalqtrac1 = fltarr(nx,ny,nz) & anomalqtrac2 = fltarr(nx,ny,nz)
+e_trac1_les = fltarr(nz,nttot) & e_trac2_les = fltarr(nz,nttot)
+dtempdztmp = fltarr(nx,ny,nz)
+localtime = lctu + history_interval_s*findgen(nttot)/3700.
+w_mean1 = fltarr(nz,nttot) & w_mean2 = fltarr(nz,nttot)
+w_mean1_env = fltarr(nz,nttot) & w_mean1_down = fltarr(nz,nttot)
+w_mean1_env_ude = fltarr(nz,nttot) & w_mean1_full = fltarr(nz,nttot)
+buoyancy1_les = fltarr(nz,nttot) & buoyancy2_les = fltarr(nz,nttot)
+e1_term2 = fltarr(nz,nttot) & e1_term3 = fltarr(nz,nttot) 
+dtetadttmp = fltarr(nx,ny,nz)
+rhomoy1 = fltarr(nz,nttot)
+plumeIndex1out = make_array(nx*ny,nz,VALUE=-1.)	& envIndex1out = make_array(nx*ny,nz,VALUE=-1.)
+hf1tmp = fltarr(nz,nttot) & hf1tmpenv = fltarr(nz,nttot)
+tplume1moy = fltarr(nz,nttot) & tenv1moy = fltarr(nz,nttot) & tenv1moy_ude = fltarr(nz,nttot)
+tmoy_full = fltarr(nz,nttot) & tdown1moy = fltarr(nz,nttot)
+dteta1moydt_entr = fltarr(nz,nttot) & dteta1moydt_detr = fltarr(nz,nttot)
+d1_term1 = fltarr(nz,nttot) & d1_term2 = fltarr(nz,nttot) & d1_term3=fltarr(nz,nttot)
+hf1_term1 = fltarr(nz,nttot) & hf1_term2 = fltarr(nz,nttot) & hf1_term3 = fltarr(nz,nttot)
+d1_term1_ude = fltarr(nz,nttot) & d1_term2_ude = fltarr(nz,nttot) & d1_term3_ude=fltarr(nz,nttot)
+e1_term1_ude = fltarr(nz,nttot) & e1_term2_ude = fltarr(nz,nttot) & e1_term3_ude=fltarr(nz,nttot)
+downward_flux1 = fltarr(nz,nttot) & beta1out = fltarr(nz,nttot)
+hf1_ude_term1 = fltarr(nz,nttot) & hf1_ude_term2 = fltarr(nz,nttot) & hf1_ude_term3 = fltarr(nz,nttot) & hf1_ude_term4 = fltarr(nz,nttot)
+hf1tmpenv_ude = fltarr(nz,nttot) & hf1tmp_down = fltarr(nz,nttot)
+dTeta_phys = make_array(nz,nttot) 
+exner = fltarr(nz,nttot)
+uv_moy = fltarr(nz,nttot)
+Gamma_1 = fltarr(nz,nttot) & Gamma_2 = fltarr(nz,nttot) & Gamma_3 = fltarr(nz,nttot)
+Gamma_1_tmp = fltarr(nz,nttot)
+ptotprime = fltarr(nx,ny,nz) & anomalptot = fltarr(nx,ny,nz) & dptotprimedztmp  = fltarr(nx,ny,nz)
+l=0
+tsurf_les = fltarr(nttot)
+
+FOR loop  = 0, nf-1 DO BEGIN
+  timetime = SYSTIME(1)
+  if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
+  if (loop ne 0) then loop2_init=0 else loop2_init=1                ;le tout premier pas de temps est l'initialisation, certains champs sont à 0 => bug
+        FOR loop2 = loop2_init, nloop2-1 DO BEGIN
+	pht(*,l) = TOTAL(TOTAL(getget(filesWRF(loop), 'PHTOT',  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny) / 1000. / 3.72
+        ph = TEMPORARY(ph) + pht(*,l) / (nttot-1)
+        ENDFOR
+        print, 'computing altitudes, file '+string(loop+1,'(I0)'), SYSTIME(1) - timetime, ' s'
+ENDFOR
+altitudes_LES  = 1000.*(TEMPORARY(ph)  - hgtu/1000.)  ;; altitude above ground
+pht = fltarr(nz,nttot)
+ph = fltarr(nz)
+
+FOR loop  = 0, nf-1 DO BEGIN
+  timetime = SYSTIME(1)
+  if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
+  if (loop ne 0) then loop2_init=0 else loop2_init=1                ;le tout premier pas de temps est l'initialisation, certains champs sont à 0 => bug
+	FOR loop2 = loop2_init, nloop2-1 DO BEGIN
+	
+	anomalt = 1. & anomalu = 1. & anomalv = 1. & anomalw = 1.
+	; --------------------------------------------------------
+	; u' = u and v' = v   (car PAS de background wind !)
+	; tke = 0.5 ( <u'^2> + <v'^2> + <w'^2> ) ; u' = u ; v' = v
+	; --------------------------------------------------------
+	
+	tprime = getget(filesWRF(loop), 'T', anomaly=anomalt, count=[0,0,0,1], offset=[0,0,0,loop2])  ;; t' = t - <t>
+        t(*,l) = t0 + temporary(anomalt)
+	ztke(*,l) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'W', anomaly=anomalw, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
+	xtke(*,l) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'U', anomaly=anomalu, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
+	ytke(*,l) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'V', anomaly=anomalv, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
+	uv_moy(*,l) = TOTAL(TOTAL(sqrt(getget(filesWRF(loop), 'U', count=[0,0,0,1], offset=[0,0,0,loop2])^2 + getget(filesWRF(loop), 'V', count=[0,0,0,1], offset=[0,0,0,loop2])^2),1),1) / float(nx) / float(ny)
+	tke_les(*,l) = xtke(*,l) + ytke(*,l) + ztke(*,l)
+        wprime = getget(filesWRF(loop), 'W', anomaly=anomalw, count=[0,0,0,1], offset=[0,0,0,loop2])
+        pht(*,l) = TOTAL(TOTAL(getget(filesWRF(loop), 'PHTOT',  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny) / 1000. / 3.72
+	pt(*,l) = TOTAL(TOTAL(getget(filesWRF(loop), 'PTOT' ,  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny)
+        temp_les(*,l) = t(*,l)*(pt(*,l)/p0)^r_cp
+	IF (got_pdt eq 'true') then begin
+	exner(*,l) = (pt(*,l)/p0)^r_cp
+	dTeta_phys(*,l) = (TOTAL(TOTAL(getget(filesWRF(loop), 'PDT', count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny))/exner(*,l)
+	ENDIF
+	ph = TEMPORARY(ph) + pht(*,l) / (nttot-1)
+	p  = TEMPORARY(p ) + pt(*,l) / nttot
+        tsurf_les(l)=TOTAL(TOTAL(getget(filesWRF(loop), 'TSURF', count=[0,0,1], offset=[0,0,loop2]),1),1)/ float(nx) / float(ny)
+
+IF (got_updrafts EQ 'true') THEN BEGIN
+
+        ptotprime(*,*,*) = getget(filesWRF(loop), 'PTOT', count=[0,0,0,1], offset=[0,0,0,loop2])
+	FOR k=0, nz-1 DO BEGIN
+		rhomoy1(*,l) = TOTAL(TOTAL(reform(((ptotprime(*,*,k)/(R*(t(k,l)+tprime(*,*,k))))*(p0/ptotprime(*,*,k))^r_cp)),1),1)/(float(nx)*float(ny))
+		anomalptot(*,*,k) = ptotprime(*,*,k) - pt(k,l)
+        ENDFOR
+	zqtrac1 = getget(filesWRF(loop), s_trac1, count=[0,0,0,1], offset=[0,0,0,loop2])
+	FOR i=0,nx-1 DO BEGIN
+		FOR j=0, ny-1 DO BEGIN
+			dtempdztmp(i,j,*) = deriv(altitudes_LES, tprime(i,j,*) + t(*,l))
+                        dptotprimedztmp(i,j,*) = deriv(altitudes_LES, anomalptot(i,j,*))
+		ENDFOR
+	ENDFOR
+	FOR k=0, nz-1 DO BEGIN
+                Gamma_2(k,l) = -(TOTAL(TOTAL(dptotprimedztmp(*,*,k),1),1)/float(nx) /float(ny))/rhomoy1(k,l)
+                Gamma_3(k,l) = -grav*(TOTAL(TOTAL(anomalptot(*,*,k),1),1)/float(nx) /float(ny))/pt(k,l)
+	ENDFOR
+        FOR k=0,nz-1 DO BEGIN
+	        anomalqtrac1(*,*,k) = zqtrac1(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac1(*,*,k)),1),1)/ float(nx) / float(ny)
+                sigmazqtrac1(k) = STDDEV(REFORM(zqtrac1(*,*,k)))
+	        IF (k ne 0) THEN BEGIN
+         	        subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
+        	       	sigmazminqtrac1(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac1(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
+	        ENDIF ELSE BEGIN
+        	        sigmazminqtrac1(k) = sigmazqtrac1(k)
+	        ENDELSE
+;		plumeIndex1 =  WHERE((anomalqtrac1(*,*,k) GT scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) AND ((anomalw(k)+wprime(*,*,k)) GT 0.))
+;		envIndex1 = WHERE((anomalqtrac1(*,*,k) LE scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) OR ((anomalw(k)+wprime(*,*,k)) LE 0.))
+		plumeIndex1 =  WHERE(anomalqtrac1(*,*,k) GT scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)]))
+		envIndex1 = WHERE(anomalqtrac1(*,*,k) LE scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)]))
+		IF(plumeIndex1(0) EQ -1) THEN BEGIN
+		fm_trac1_les(k,l)=0.
+	        e_trac1_les(k,l)=0.
+		alpha1out(k,l)=0.
+		buoyancy1_les(k,l)=0.
+		w_mean1(k,l)=0.
+		w_mean1_env(k,l)=0.
+		w_mean1_down(k,l)=0.
+		w_mean1_full(k,l)=0.
+		w_mean1_env_ude(k,l)=0.
+		e1_term2(k,l)=0.
+		e1_term3(k,l)=0.
+                e1_term1_ude(k,l)=0.
+                e1_term2_ude(k,l)=0.
+                e1_term3_ude(k,l)=0.
+		hf1tmp(k,l)=0.
+		hf1tmpenv(k,l)=0.
+		plumeIndex1out(*,k)=-1.
+		envIndex1out(*,k)=-1.
+		d1_term1(k,l)=0.
+		d1_term2(k,l)=0.
+		d1_term3(k,l)=0.
+                d1_term1_ude(k,l)=0.
+                d1_term2_ude(k,l)=0.
+                d1_term3_ude(k,l)=0.
+		downward_flux1(k,l)=0.
+		beta1out(k,l)=0.
+		tmoy_full(k,l)=0.
+		tdown1moy(k,l)=0.
+		ENDIF ELSE BEGIN
+		FOR n=0,n_elements(plumeIndex1)-1 DO BEGIN
+ 	        	plumeIndex1out(n,k)=plumeIndex1(n)
+		ENDFOR
+		FOR n=0,n_elements(envIndex1)-1 DO BEGIN
+                        envIndex1out(n,k)=envIndex1(n)
+                ENDFOR
+		alpha1(k) = n_elements(plumeIndex1) / float(nx) / float(ny)
+                wprimetmp = reform(reform((anomalw(k)+wprime(*,*,k))),[nx*ny,1])
+		w_mean1_full(k,l) = mean(wprimetmp)
+                w_mean1(k,l) = mean(wprimetmp(plumeIndex1))
+                w_mean1_env(k,l) = mean(wprimetmp(envIndex1))
+		downdraft_index1 = WHERE((abs(anomalw(k)+wprime(*,*,k)) gt sigmao_ude*STDDEV(wprimetmp(envIndex1))) and (anomalw(k)+wprime(*,*,k) lt 0.))
+		
+		envIndex1_ude = WHERE(((abs(anomalw(k)+wprime(*,*,k)) le sigmao_ude*STDDEV(wprimetmp(envIndex1))) or (anomalw(k)+wprime(*,*,k) ge 0.)) AND ((anomalqtrac1(*,*,k) LE scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) OR ((anomalw(k)+wprime(*,*,k)) LE 0.)))
+		IF (envIndex1_ude(0) ne -1) THEN w_mean1_env_ude(k,l) = mean(wprimetmp(envIndex1_ude)) ELSE w_mean1_env_ude(k,l) =0.
+		if (downdraft_index1(0) ne -1) then begin
+		w_mean1_down(k,l)=mean(wprimetmp(downdraft_index1))
+		wprimetmp=0.
+		beta1 = n_elements(downdraft_index1) / float(nx) / float(ny) 
+		beta1out(k,l)=beta1
+		downward_flux1(k,l) = beta1*rhomoy1(k,l)*w_mean1_down(k,l)
+		endif else begin
+		downward_flux1(k,l)=0.
+		beta1out(k,l)=0.
+		w_mean1_down(k,l)=0.
+		tdown1moy(k,l)=0.
+		endelse
+		fm_trac1_les(k,l) = alpha1(k)*rhomoy1(k,l)*w_mean1(k,l)
+		dtempdztmplin = reform(reform(dtempdztmp(*,*,k)),[nx*ny,1])
+                alpha1out(k,l)=alpha1(k)
+		tfull=reform(tprime(*,*,k)+t(k,l),[nx*ny,1])
+		if (downdraft_index1(0) ne -1) then tdown1moy(k,l)=mean(tfull(downdraft_index1)) 
+		tplume1moy(k,l)=mean(tfull(plumeIndex1))
+		tenv1moy(k,l)=mean(tfull(envIndex1))
+		if (envIndex1_ude(0) ne -1) then tenv1moy_ude(k,l) = mean(tfull(envIndex1_ude)) else tenv1moy_ude(k,l)=0.
+		tmoy_full(k,l) = mean(tfull)
+		buoyancy1_les(k,l)=grav*(tplume1moy(k,l)/tenv1moy(k,l)-1.)
+		e_trac1_les(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy(k,l)-tplume1moy(k,l)))*(dtempdztmplin(plumeIndex1)),1)/float(n_elements(plumeIndex1))
+		d1_term1(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy(k,l)-tplume1moy(k,l)))*(temporary(dtempdztmplin(envIndex1))),1)/float(n_elements(envIndex1))
+		if (envIndex1_ude(0) ne -1) then begin
+                e1_term1_ude(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy_ude(k,l)-tplume1moy(k,l)))*(dtempdztmplin(plumeIndex1)),1)/float(n_elements(plumeIndex1))
+                d1_term1_ude(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy_ude(k,l)-tplume1moy(k,l)))*(temporary(dtempdztmplin(envIndex1_ude))),1)/float(n_elements(envIndex1_ude))
+	     	endif else begin
+		e1_term1_ude(k,l) = 0.
+		d1_term1_ude(k,l) = 0.
+		endelse
+		wtmp=reform(wprime(*,*,k)+anomalw(k),[nx*ny,1])
+		ttmp=reform(tprime(*,*,k)+t(k,l),[nx*ny,1])
+                Gamma_1_tmp (k,l) = alpha1out(k,l)*rhomoy1(k,l)*(wtmp(plumeIndex1)-w_mean1(k,l))^2
+		hf1tmp(k,l) = TOTAL((wtmp(plumeIndex1)-w_mean1(k,l))*(ttmp(plumeIndex1)-tplume1moy(k,l)),1) / float(n_elements(plumeIndex1))
+		hf1tmpenv(k,l) = TOTAL((wtmp(envIndex1)-w_mean1_env(k,l))*(ttmp(envIndex1)-tenv1moy(k,l)),1) / float(n_elements(envIndex1))
+		if (envIndex1_ude(0) ne -1) then hf1tmpenv_ude(k,l) = TOTAL((wtmp(envIndex1_ude)-w_mean1_env_ude(k,l))*(ttmp(envIndex1_ude)-tenv1moy_ude(k,l)),1) / float(n_elements(envIndex1_ude)) else hf1tmpenv_ude(k,l) =0.
+		if (downdraft_index1(0) ne -1) then hf1tmp_down(k,l) = TOTAL((wtmp(downdraft_index1)-w_mean1_down(k,l))*(ttmp(downdraft_index1)-tdown1moy(k,l)),1) / float(n_elements(downdraft_index1)) else hf1tmp_down(k,l)=0.
+		IF((n_elements(plumeIndex1) + n_elements(envIndex1)) ne float(nx*ny)) then print, 'WARNING : INDEX PROBLEM : plume / env : ', n_elements(plumeIndex1), n_elements(envIndex1)
+;		IF((n_elements(plumeIndex1) + n_elements(envIndex1_ude) + n_elements(downdraft_index1)) ne float(nx*ny)) then print, 'WARNING : INDEX PROBLEM : plume / env / downdraft : ', n_elements(plumeIndex1), n_elements(envIndex1_ude), n_elements(downdraft_index1)
+		ENDELSE
+	ENDFOR
+	
+        Gamma_1(*,l) = -(1./(alpha1out(*,l)*rhomoy1(*,l)))*deriv(altitudes_LES,Gamma_1_tmp(*,l))
+        drhoahfdztmp = deriv(altitudes_LES,rhomoy1(*,l)*alpha1out(*,l)*hf1tmp(*,l))
+        drhoahfdztmpDetr = deriv(altitudes_LES,rhomoy1(*,l)*(1.-alpha1out(*,l))*hf1tmpenv(*,l))
+        drhoahfdztmpDetr_ude = deriv(altitudes_LES,rhomoy1(*,l)*(1.-alpha1out(*,l)-beta1out(*,l))*hf1tmpenv_ude(*,l))
+	
+	wtmp=0.
+	ttmp=0.
+	
+	FOR k=0,nz-1 DO BEGIN
+		IF(plumeIndex1out(0,k) eq -1) THEN BEGIN
+		e1_term2(k,l)=0.
+		e1_term2_ude(k,l)=0.
+		ENDIF ELSE BEGIN
+		e1_term2(k,l)=drhoahfdztmp(k)/(tenv1moy(k,l)-tplume1moy(k,l))
+		e1_term2_ude(k,l)=drhoahfdztmp(k)/(tenv1moy_ude(k,l)-tplume1moy(k,l))
+		ENDELSE
+
+		IF(envIndex1out(0,k) eq -1) THEN BEGIN
+                d1_term2(k,l)=0.
+		d1_term2_ude(k,l)=0.
+                ENDIF ELSE BEGIN
+		d1_term2(k,l)=-drhoahfdztmpDetr(k)/(tenv1moy(k,l)-tplume1moy(k,l))
+                d1_term2_ude(k,l)=-drhoahfdztmpDetr_ude(k)/(tenv1moy_ude(k,l)-tplume1moy(k,l))
+		ENDELSE
+	ENDFOR
+
+
+	tfull1=0.
+
+        zqtrac1=0.
+        zqtrac2 = getget(filesWRF(loop), s_trac2, count=[0,0,0,1], offset=[0,0,0,loop2])
+        FOR k=0,nz-1 DO BEGIN
+		anomalqtrac2(*,*,k) = zqtrac2(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac2(*,*,k)),1),1)/ float(nx) / float(ny)
+                sigmazqtrac2(k) = STDDEV(zqtrac2(*,*,k))
+	        IF (k ne 0) THEN BEGIN
+	                subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
+	                sigmazminqtrac2(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac2(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
+	        ENDIF ELSE BEGIN
+        	        sigmazminqtrac2(k) = sigmazqtrac2(k)
+	        ENDELSE
+                plumeIndex2 = WHERE((anomalqtrac2(*,*,k) GT scale*MAX([sigmazqtrac2(k),sigmazminqtrac2(k)])) AND ((wprime(*,*,k)+anomalw(k)) GT 0.))
+                envIndex2 = WHERE((anomalqtrac2(*,*,k) LE scale*MAX([sigmazqtrac2(k),sigmazminqtrac2(k)])) OR ((wprime(*,*,k)+anomalw(k)) LE 0.))
+                IF(plumeIndex2(0) EQ -1) THEN BEGIN
+		 fm_trac2_les(k,l)=0.
+		 e_trac2_les(k,l)=0.
+                alpha2out(k,l)=0.
+                buoyancy2_les(k,l)=0.
+		w_mean2(k,l)=0.
+                ENDIF ELSE BEGIN
+		alpha2(k) = n_elements(plumeIndex2) / float(nx) / float(ny)
+                wprimetmp = reform(reform((anomalw(k)+wprime(*,*,k))),[nx*ny,1])
+                w_mean2(k,l) = mean(wprimetmp(plumeIndex2))
+		wprimetmp=0.
+                fm_trac2_les(k,l) = alpha2(k)*rhomoy1(k,l)*w_mean2(k,l)
+                tprimetmp = reform(reform(-tprime(*,*,k)),[nx*ny,1])
+                dtempdztmplin = reform(reform(dtempdztmp(*,*,k)),[nx*ny,1])
+                e_trac2_les(k,l) = TOTAL((1./(temporary(tprimetmp(plumeIndex2))))*(temporary(dtempdztmplin(plumeIndex2))),1)/n_elements(plumeIndex2)
+                alpha2out(k,l)=alpha2(k)
+                tfull=reform(tprime(*,*,k)+t(k,l),[nx*ny,1])
+                tplume2moy=mean(tfull(plumeIndex2))
+                tenv2moy=mean(tfull(envIndex2))
+                buoyancy2_les(k,l)=grav*(tplume2moy/tenv2moy-1.)
+		ENDELSE
+        ENDFOR
+        zqtrac2=0.
+
+ENDIF
+
+        wt(*,l) = TOTAL(TOTAL(TEMPORARY(tprime)*TEMPORARY(wprime),1),1) / float(nx) / float(ny)
+;	wmax(l) = max(w_mean1(*,l))
+        l=l+1
+	ENDFOR
+   	print, 'file '+string(loop+1,'(I0)'), SYSTIME(1) - timetime, ' s'
+
+ENDFOR
+
+IF (got_updrafts EQ 'true') THEN BEGIN
+
+
+hf1_term1 = hf1tmp*alpha1out
+hf1_term2 = temporary(hf1tmpenv)*(1.-alpha1out)
+hf1_term3 = alpha1out*(1.-alpha1out)*(w_mean1 - temporary(w_mean1_env))*(tplume1moy - tenv1moy)
+
+hf1_ude_term1 = temporary(hf1tmp)*alpha1out
+hf1_ude_term2 = temporary(hf1tmp_down)*beta1out
+hf1_ude_term3 = temporary(hf1tmpenv_ude)*(1.-(alpha1out+beta1out))
+hf1_ude_term4 = alpha1out*(w_mean1 - w_mean1_full)*(tplume1moy - tmoy_full) + beta1out*(w_mean1_down - w_mean1_full)*(tdown1moy - tmoy_full) + (1.- (alpha1out+beta1out))*(w_mean1_env_ude - w_mean1_full)*(tenv1moy_ude - tmoy_full)
+
+FOR k=0, nz-1 DO BEGIN
+;       dteta1moydt_entr(k,*) = deriv(localtime,tplume1moy(k,*))/3700. - dTeta_phys(k,*)
+;       dteta1moydt_detr(k,*) = deriv(localtime,tplume1moy(k,*))/3700. + dTeta_phys(k,*)
+	dteta1moydt_entr(k,*) = deriv(localtime,tplume1moy(k,*))/3700. - dTeta_phys(k,*)
+	dteta1moydt_detr(k,*) =  dTeta_phys(k,*) - deriv(localtime,tplume1moy(k,*))/3700. 
+ENDFOR
+
+FOR k=0, nz-1 DO BEGIN
+	FOR l=0, nttot-1 DO BEGIN
+		IF (tenv1moy(k,l) ne tplume1moy(k,l)) THEN e1_term3(k,l) = rhomoy1(k,l)*alpha1out(k,l)*dteta1moydt_entr(k,l)/(tenv1moy(k,l)-tplume1moy(k,l)) ELSE e1_term3(k,l)=0.
+                IF (tenv1moy_ude(k,l) ne tplume1moy(k,l)) THEN e1_term3_ude(k,l) = rhomoy1(k,l)*alpha1out(k,l)*dteta1moydt_entr(k,l)/(tenv1moy_ude(k,l)-tplume1moy(k,l)) ELSE e1_term3_ude(k,l)=0
+;		IF (tenv1moy(k,l) ne tplume1moy(k,l)) THEN d1_term3(k,l) = rhomoy1(k,l)*(1.-alpha1out(k,l))*dteta1moydt_detr(k,l)/(tenv1moy(k,l)-tplume1moy(k,l)) ELSE d1_term3(k,l)=0.
+		IF (tenv1moy(k,l) ne tplume1moy(k,l)) THEN d1_term3(k,l) = rhomoy1(k,l)*(1.-alpha1out(k,l))*dteta1moydt_detr(k,l)/(tenv1moy(k,l)-tplume1moy(k,l)) ELSE d1_term3(k,l)=0.
+                IF (tenv1moy_ude(k,l) ne tplume1moy(k,l)) THEN d1_term3_ude(k,l) = rhomoy1(k,l)*(1.-alpha1out(k,l)-beta1out(k,l))*dteta1moydt_detr(k,l)/(tenv1moy_ude(k,l)-tplume1moy(k,l)) ELSE d1_term3_ude(k,l)=0.
+	ENDFOR
+ENDFOR
+
+ENDIF
+
+ht = TEMPORARY(pht) - hgtu/1000.
+save, tsurf_les, w_mean1_env, d1_term1_ude, d1_term2_ude, d1_term3_ude, e1_term1_ude, e1_term2_ude, e1_term3_ude, tplume1moy, tdown1moy, w_mean1_full, tmoy_full, tenv1moy_ude, w_mean1_env_ude, uv_moy, hf1_ude_term1, hf1_ude_term2, hf1_ude_term3, hf1_ude_term4, w_mean1_down, downward_flux1, beta1out, hf1_term1, hf1_term2, hf1_term3, d1_term1, d1_term2, d1_term3, e1_term2, e1_term3, buoyancy1_les, buoyancy2_les, w_mean1, w_mean2, nx, ny, alpha1out, alpha2out, e_trac1_les, e_trac2_les, tke_les, ztke, altitudes_LES, ht, t, p, pt, localtime, xtke, ytke, wt, temp_les, wmax, fm_trac1_les, fm_trac2_les,filename=les_path+'/'+datname
+
+nz = n_elements(altitudes_LES)
+
+ENDIF ELSE BEGIN
+
+print, 'OK, file is here'
+restore, filename=les_path+'/'+datname
+nz = n_elements(altitudes_LES)
+nttot = n_elements(tmoy_full(0,*))
+
+OPENR, 23, les_path+'/input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+
+ENDELSE
+
+tenv1moy = tplume1moy/((buoyancy1_les/grav)+1.)
+
+taverage = string((localtime(nstot)-localtime(1))*3700./60.)
+print, ''
+print, ' -- Loading testphys1d data -- '
+
+file1=gcm_path+'/diagfi.nc'
+file2=gcm_convadj_path+'/diagfi.nc'
+file3='/san0/acolmd/SIMUS/GCM3D_TestBed/diagfi.nc'
+
+getcdf, file=file1, charvar='q2', invar=tke_gcm
+getcdf, file=file1, charvar='aps', invar=aps
+getcdf, file=file1, charvar='bps', invar=bps
+getcdf, file=file1, charvar='co2col', invar=co2_col
+;getcdf, file=file1, charvar='arcol', invar=ar_col
+;getcdf, file=file1, charvar='ar', invar=ar
+getcdf, file=file1, charvar='heatFlux_up', invar=heatFlux_up
+getcdf, file=file1, charvar='heatFlux_down', invar=heatFlux_down
+getcdf, file=file1, charvar='pplay', invar=pplay
+getcdf, file=file1, charvar='pplev', invar=pplev
+getcdf, file=file1, charvar='temp', invar=temp_gcm
+getcdf, file=file1, charvar='zw2', invar=zw2_lev
+getcdf, file=file1, charvar='fm_therm', invar=fm_therm_gcm_lev
+getcdf, file=file1, charvar='entr_therm', invar=zdz_entr_therm_gcm
+getcdf, file=file1, charvar='detr_therm', invar=zdz_detr_therm_gcm
+getcdf, file=file1, charvar='fraca', invar=alpha_gcm_lev
+getcdf, file=file1, charvar='buoyancyOut', invar=buoyancy_gcm
+getcdf, file=file1, charvar='buoyancyEst', invar=buoyancy_est_gcm
+getcdf, file=file1, charvar='zkh', invar=zkh
+getcdf, file=file1, charvar='zh', invar=zh
+getcdf, file=file1, charvar='tsurf', invar=tsurf_gcm
+;getcdf, file=file1, charvar='zmax', invar=zi_gcm
+getcdf, file=file1, charvar='lmax_th', invar=lmax_gcm
+getcdf, file=file1, charvar='hfmax_th', invar=hfmax_th1d
+getcdf, file=file1, charvar='wmax_th', invar=wmax_th1d
+
+if (overplot_convadj eq 'true') then begin
+getcdf, file=file2, charvar='temp', invar=temp_gcm_convadj
+getcdf, file=file2, charvar='pplay', invar=pplay_convadj
+endif
+if (plot_3d eq 'true') then begin
+getcdf, file=file3, charvar='temp', invar=temp_gcm_3d
+getcdf, file=file3, charvar='pplay', invar=pplay_3d
+getcdf, file=file3, charvar='latitude', invar=latitude_3d
+getcdf, file=file3, charvar='longitude', invar=longitude_3d
+nWEmx_3d = n_elements(reform(temp_gcm_3d(*,0,0,0)))
+nNSmx_3d = n_elements(reform(temp_gcm_3d(0,*,0,0)))
+nZmx_3d = n_elements(reform(temp_gcm_3d(0,0,*,0)))
+nTmx_3d = n_elements(reform(temp_gcm_3d(0,0,0,*)))
+ndays_3d = 1.
+lctu_gcm_3d = 0.
+history_interval_s_gcm_3d = ndays_3d*88800./float(nTmx_3d)  ; Timestep interval of gcm 1d simu in sec
+localtime_lon0 = lctu_gcm_3d + history_interval_s_gcm_3d*findgen(nTmx_3d)/3700.
+Xc = 205.
+Yc = 21.8
+plot_index_x = (Xc-longitude_3d(0))/(longitude_3d(1)-longitude_3d(0))
+plot_index_y = (Yc-latitude_3d(0))/(latitude_3d(1)-latitude_3d(0))
+localtime_true = localtime_lon0 -(12./180.)*Xc
+endif
+
+
+nTmx = n_elements(reform(temp_gcm(0,*)))
+if (overplot_convadj eq 'true') then begin
+nTmx_convadj = n_elements(reform(temp_gcm_convadj(0,*)))
+endif else begin
+nTmx_convadj =  10000.
+endelse
+ndays = 1.
+print, ''
+print, 'WARNING ----------------------- '
+print, 'CONFIGURATION : '+string(ndays,format='(I0)')+' days simulation'
+print, ''
+history_interval_s_gcm = ndays*88800./float(nTmx)  ; Timestep interval of gcm 1d simu in sec
+history_interval_s_gcm_convadj = ndays*88800./float(nTmx_convadj)
+localtime_gcm = lctu_gcm + history_interval_s_gcm*findgen(nTmx)/3700.
+localtime_gcm_convadj = lctu_gcm + history_interval_s_gcm_convadj*findgen(nTmx_convadj)/3700.
+; **********************************
+; ******** PLOTS ******************
+
+if (f_offset eq 'true') then begin
+offset_localtime = 3.108100
+lt_plot=11.
+endif else begin
+offset_localtime = 0.
+lt_plot=12.
+endelse
+localtime=localtime+offset_localtime  
+;localtime_gcm=localtime_gcm+history_interval_s_gcm/3700. ; we add the offset from the fact that we output (non sense :) )
+localtime_gcm=localtime_gcm
+; par contre il faut prendre en compte le fait que la premiere frame du les est decalee de 1 !
+localtime=localtime
+
+print, '****************************************************************************************************'
+print, 'local time LES'
+print, localtime
+print, '****************************************************************************************************'
+print, 'local time GCM'
+print, localtime_gcm
+print, '****************************************************************************************************'
+
+time_offset = (ndays-1.)*24.
+
+print, 'TIME STEP LES : ',(localtime(1)-localtime(0))*3700.
+
+
+lt_plot_ini = 6.
+lt_plotindex_les_ini = where(localtime eq lt_plot_ini)
+lt_plotindex_gcm_ini = where(localtime_gcm eq (lt_plot_ini+time_offset))
+;lt_plotindex_gcm_ini = where(localtime_gcm eq (lt_plot_ini+time_offset+history_interval_s_gcm/3700.))
+
+lt_plot0 = 10.
+lt_plotindex_les0 = where(localtime eq lt_plot0)
+lt_plotindex_gcm0 = where(localtime_gcm eq (lt_plot0+time_offset))
+lt_plotindex_gcm_convadj0 = where(localtime_gcm_convadj eq (lt_plot0+time_offset))
+
+lt_plot0a = 11.
+lt_plotindex_les0a = where(localtime eq lt_plot0a)
+lt_plotindex_gcm0a = where(localtime_gcm eq (lt_plot0a+time_offset))
+
+lt_plotindex_les = where((localtime lt lt_plot+0.01) and (localtime gt lt_plot-0.01))
+lt_plotindex_gcm = where(localtime_gcm eq (lt_plot+time_offset))
+lt_plotindex_gcm_convadj = where(localtime_gcm_convadj eq (lt_plot+time_offset))
+print, 'lt plotindex les 12h'
+print, lt_plotindex_les
+
+lt_plota = 13.
+lt_plotindex_lesa = where(localtime eq lt_plota)
+lt_plotindex_gcma = where(localtime_gcm eq (lt_plota+time_offset))
+
+lt_plot2 = 14.
+lt_plotindex_les2 = where(localtime eq lt_plot2)
+lt_plotindex_gcm2 = where(localtime_gcm eq (lt_plot2+time_offset))
+lt_plotindex_gcm_convadj2 = where(localtime_gcm_convadj eq (lt_plot2+time_offset))
+
+lt_plot2a = 15.
+lt_plotindex_les2a = where(localtime eq lt_plot2a)
+lt_plotindex_gcm2a = where(localtime_gcm eq (lt_plot2a+time_offset))
+
+lt_plot3 = 16.
+lt_plotindex_les3 = where(localtime eq lt_plot3)
+lt_plotindex_gcm3 = where(localtime_gcm eq (lt_plot3+time_offset))
+lt_plotindex_gcm_convadj3 = where(localtime_gcm_convadj eq (lt_plot3+time_offset))
+
+lt_plot3a = 17.
+lt_plotindex_les3a = where(localtime eq lt_plot3a)
+lt_plotindex_gcm3a = where(localtime_gcm eq (lt_plot3a+time_offset))
+
+lt_plot4 = 18.
+lt_plotindex_les4 = where(localtime eq lt_plot4)
+lt_plotindex_gcm4 = where(localtime_gcm eq (lt_plot4+time_offset))
+lt_plotindex_gcm_convadj4 = where(localtime_gcm_convadj eq (lt_plot4+time_offset))
+;--------------------------------------------------------------------------------
+;---------------------------------------------------------------------------------
+
+nTmx_les=n_elements(reform(wt(0,*)))
+nZmx=n_elements(aps)          ; number of vertical levels
+H_low=9650.                   ; scale height at low altitudes
+H_high=15000.                 ; scale height at high altitudes
+trans_window=10.              ; # of levels over which H(:) goes from H_low to H_high
+lev_trans=32.+trans_window/2. ; level at which H(lev_trans)=(H_low+H_high)/2
+P_ref=p0                    ; reference surface pressure used to build zsurface -610 Pa-
+Hgcm = make_array(nZmx)
+altitudes_GCM = make_array(nZmx)
+; Build scale heights
+;FOR k=0,nZmx-1 DO BEGIN
+;	 Hgcm(k)=H_low+(H_high-H_low)*0.5*(1.0+tanh(6.*(k-lev_trans)/trans_window))
+;ENDFOR
+
+FOR k=0,nZmx-1 DO BEGIN
+        Hgcm(k)=R*temp_gcm(k,lt_plotindex_gcm)/grav
+ENDFOR
+print, 'Hgcm'
+print, Hgcm
+; Compute altitudes_GCM
+FOR k=0,nZmx-1 DO BEGIN
+	altitudes_GCM(k)=-Hgcm(k)*alog(pplay(k,lt_plotindex_gcm)/pGround)
+ENDFOR
+Hgcm=0.
+
+teta_gcm = temp_gcm * (p0/pplay)^r_cp
+if (overplot_convadj eq 'true') then begin
+teta_gcm_convadj = temp_gcm_convadj * (p0/pplay_convadj)^r_cp
+endif
+
+OPENR, 1, gcm_path+'/profile'
+data=FLTARR(nZmx+1)
+READF, 1, data
+temp_gcm_0_ground = data(0)
+temp_gcm_0 = data(1:nZmx-1)
+data = 0.
+CLOSE, 1
+
+teta_gcm_0 = temp_gcm_0 * (p0/pplay)^r_cp
+approx_zdz_gcm = make_array(nZmx)
+approx_zdz_gcm(0)=altitudes_GCM(1)
+FOR k=1, nZmx-2 DO BEGIN
+       approx_zdz_gcm(k) = altitudes_GCM(k+1) - altitudes_GCM(k)
+ENDFOR
+approx_zdz_gcm(nZmx-1)=approx_zdz_gcm(nZmx-2)
+
+print, 'approx zdz gcm'
+print, approx_zdz_gcm
+
+print, '****************************************************************************************************'
+print, 'altitudes LES based on phtot : inter-levels'
+print, altitudes_LES
+print, '****************************************************************************************************'
+print, 'altitudes GCM based on pplay : inter-levels'
+print, altitudes_GCM
+print, '****************************************************************************************************'
+
+; Compute tracer deviation :
+
+co2_col = co2_col/co2_col(0)
+;ar_col = ar_col/ar_col(0)
+;tke_col = tke_col+1.
+
+; Compute <teta> les
+
+teta_les = temporary(t) 
+
+rho = pt/(R*temp_les)
+
+;print, 'bidouille'
+;
+;FOR l=0,nTmx -1 DO BEGIn
+;print, (1300.*hfmax_th1d(l)/(TOTAL(temp_gcm(0:lmax_gcm(l),l),1)/(lmax_gcm(l)+1.)))/wmax_th1d(l)
+;ENDFOR
+
+
+; ========================================================================
+; ========================================================================
+
+IF (visualization_mode eq 'true') THEN BEGIN
+
+print,' *****************************************-----------------------------------'
+print,' ************ PLUME **********************-----------------------------------'
+print,' *****************************************-----------------------------------'
+
+; We are evaluating the first time-step element of the file number 'loop-1' :
+; file 1 starts at 8h (loop =0, loop2 =0)
+; file 6 starts at 13h  (roughly)  (loop =5, loops2=0)
+; file 12 starts at 18h (roughly) (loop = 11,loop2 = 0)
+
+loop=uint(loop_special)-1
+;loop2=34
+loop2=10
+domain='d01'
+filesWRF = FindFile(les_path+'/wrfout_'+domain+'_????-??-??_??:??:??')
+anomalw=1.
+
+zqtrac1 = dblarr(nx,ny,nz) & zqtrac2 = dblarr(nx,ny,nz)
+sigmazqtrac1 = fltarr(nz) & sigmazqtrac2 = fltarr(nz)
+sigmazminqtrac1 = fltarr(nz) & sigmazminqtrac2 = fltarr(nz)
+anomalqtrac1 = fltarr(nx,ny,nz) & anomalqtrac2 = fltarr(nx,ny,nz)
+zqtrac1 = getget(filesWRF(loop), 'qtrac1', count=[0,0,0,1], offset=[0,0,0,loop2])
+zqtrac2 = getget(filesWRF(loop), 'qtrac2', count=[0,0,0,1], offset=[0,0,0,loop2])
+wprime = getget(filesWRF(loop), 'W', anomaly = anomalw, count=[0,0,0,1], offset=[0,0,0,loop2])
+supermask1 = fltarr(nx,ny,nz)
+supermask2 = fltarr(nx,ny,nz)
+k_out_histo = 8
+k_out_hist = [1,10,25,50,70,85]
+nbtest=n_elements(k_out_hist)
+b=0
+FOR k=0,nz-1 DO BEGIN
+        mask1=fltarr(nx*ny)
+        mask2=fltarr(nx*ny)
+        anomalqtrac1(*,*,k) = zqtrac1(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac1(*,*,k)),1),1)/ float(nx) / float(ny)
+        sigmazqtrac1(k) = STDDEV(REFORM(zqtrac1(*,*,k)))
+	IF (k ne 0) THEN BEGIN
+	        subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
+		sigmazminqtrac1(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac1(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
+	ENDIF ELSE BEGIN
+		sigmazminqtrac1(k) = sigmazqtrac1(k)
+	ENDELSE
+	print, sigmazqtrac1(k),sigmazminqtrac1(k)
+        plumeIndex1 =  WHERE((anomalqtrac1(*,*,k) GT scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) AND ((anomalw(k)+wprime(*,*,k)) GT 0.))
+        anomalqtrac2(*,*,k) = zqtrac2(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac2(*,*,k)),1),1)/ float(nx) / float(ny)
+        sigmazqtrac2(k) = STDDEV(REFORM(zqtrac2(*,*,k)))
+        IF (k ne 0) THEN BEGIN
+                subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
+                sigmazminqtrac2(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac2(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
+	ENDIF ELSE BEGIN
+                sigmazminqtrac2(k) = sigmazqtrac2(k)
+        ENDELSE
+        plumeIndex2 =  WHERE((anomalqtrac2(*,*,k) GT scale*MAX([sigmazqtrac2(k),sigmazminqtrac2(k)])) AND ((anomalw(k)+wprime(*,*,k)) GT 0.))
+        IF(plumeIndex1(0) NE -1 ) THEN BEGIN
+        mask1(plumeIndex1) = 1.
+        ENDIF ELSE BEGIN
+        mask1(*)=0.
+        ENDELSE
+        IF(plumeIndex2(0) NE -1 ) THEN BEGIN
+        mask2(plumeIndex2) = 1.
+        ENDIF ELSE BEGIN
+        mask2(*)=0.
+        ENDELSE
+        mask1 = reform(mask1,[nx,ny])
+        supermask1(*,*,k) = mask1(*,*)
+        mask2 = reform(mask2,[nx,ny])
+        supermask2(*,*,k) = mask2(*,*)
+;	IF (k eq k_out_histo) THEN BEGIN
+;		plume1_out = plumeIndex1
+;		plume2_out = plumeIndex2
+;	ENDIF	
+
+	IF (k eq k_out_hist(0)) THEN BEGIN
+		c1=plumeIndex1
+		c2=plumeIndex2
+	ENDIF
+        IF (k eq k_out_hist(1)) THEN BEGIN
+                d1=plumeIndex1
+                d2=plumeIndex2
+        ENDIF
+        IF (k eq k_out_hist(2)) THEN BEGIN
+                e1=plumeIndex1
+                e2=plumeIndex2
+        ENDIF
+        IF (k eq k_out_hist(3)) THEN BEGIN
+                f1=plumeIndex1
+                f2=plumeIndex2
+        ENDIF
+        IF (k eq k_out_hist(4)) THEN BEGIN
+                g1=plumeIndex1
+                g2=plumeIndex2
+        ENDIF
+        IF (k eq k_out_hist(5)) THEN BEGIN
+                h1=plumeIndex1
+                h2=plumeIndex2
+        ENDIF
+ENDFOR
+
+IF (Histo eq 'false') THEN BEGIN
+IVOLUME, supermask1
+IVOLUME, supermask2
+ENDIF ELSE BEGIN
+
+; -------------------------------------------------------------------------------
+; THIS IS THE ULTRA-GORE UN-ESTHETIC UGLY-AS-HELL LOOP FOR CONCENTRATION PLOTTING
+; but well, this is just because idl cannot handle arrays as well as I would like
+; -------------------------------------------------------------------------------
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Distrib.ps'
+PSOPEN, THICK=100, CHARSIZE=60, FILE = filename, FONT = 5, TFONT = 5,XPLOTS=2,YPLOTS=3,MARGIN=2000 
+
+FOR n=0, nbtest-1 DO BEGIN
+
+CASE n OF
+	0:BEGIN
+		plume1_out=c1 & plume2_out=c2
+	END
+        1:BEGIN
+                plume1_out=d1 & plume2_out=d2
+        END
+        2:BEGIN
+                plume1_out=e1 & plume2_out=e2
+        END
+        3:BEGIN
+                plume1_out=f1 & plume2_out=f2
+        END
+        4:BEGIN
+                plume1_out=g1 & plume2_out=g2
+        END
+        5:BEGIN
+                plume1_out=h1 & plume2_out=h2
+        END
+ENDCASE
+ 
+ToBin1 = reform(zqtrac1(*,*,k_out_hist(n)),[nx*ny,1])
+ToBin2 = reform(zqtrac2(*,*,k_out_hist(n)),[nx*ny,1])
+svmin1=min(ToBin1) & svmin2=min(ToBin2)
+svmax1=max(ToBin1) & svmax2=max(ToBin2)
+NBINS=100
+ds1=(svmax1-svmin1+1.)/(NBINS-1) & ds2=(svmax2-svmin2+1.)/(NBINS-1)
+Xaxis1 = svmin1+((svmax1-svmin1)/(NBINS-1))*indgen(NBINS)
+Xaxis2 = svmin2+((svmax2-svmin2)/(NBINS-1))*indgen(NBINS)
+Bin1=HISTOGRAM(ToBin1,nbins=NBINS)
+Bin2=INTERPOL(HISTOGRAM(ToBin2,nbins=NBINS),Xaxis2,Xaxis1,/SPLINE)
+
+what_I_plot = [[Bin1],[Bin2]]
+labels=['LES tracer 1 conc. distrib.','LES tracer 2 conc. distrib.']
+
+title_user = TestCase+SubCase+' LES tracer 1&2 concentration distribution at '+string(altitudes_LES(k_out_hist(n)))+'m AGL'
+IF (n lt 3) THEN BEGIN
+	POS, XPOS=1, YPOS=uint(n+1)
+ENDIF ELSE BEGIN
+	POS, XPOS=2, YPOS=uint(n+1)-3
+ENDELSE
+MAP
+CS, SCALE=28
+GSET, XMIN=0, XMAX=20, YMIN=0, YMAX=300, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=Xaxis1, Y=what_I_plot, /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 4, XTITLE='Trac concentration (kg/kg)', YSTEP=50, YTITLE='Counts',NDECS=1
+
+ToBin1 = reform(zqtrac1(*,*,k_out_hist(n)),[nx*ny,1])
+ToBin2 = reform(zqtrac2(*,*,k_out_hist(n)),[nx*ny,1])
+ToBin1 = ToBin1(plume1_out)
+ToBin2 = ToBin2(plume2_out)
+svmin1=min(ToBin1) & svmin2=min(ToBin2)
+svmax1=max(ToBin1) & svmax2=max(ToBin2)
+NBINS=50
+ds1=(svmax1-svmin1+1.)/(NBINS-1) & ds2=(svmax2-svmin2+1.)/(NBINS-1)
+Xaxis1 = svmin1+((svmax1-svmin1)/(NBINS-1))*indgen(NBINS)
+Xaxis2 = svmin2+((svmax2-svmin2)/(NBINS-1))*indgen(NBINS)
+Bin1=HISTOGRAM(ToBin1,nbins=NBINS)
+Bin2=HISTOGRAM(ToBin2,nbins=NBINS)
+oplot,  Xaxis1, Bin1, psym=4
+oplot,  Xaxis2, Bin2, psym=5
+
+ENDFOR
+
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+ENDELSE
+
+ENDIF ELSE BEGIN
+
+; =========================================================================
+; =========================================================================
+IF (got_updrafts EQ 'true') THEN BEGIN
+
+print, '........ ALPHA'
+
+alpha_interlay_gcm = make_array(nZmx)
+FOR k=0, nZmx-2 DO BEGIN
+        alpha_interlay_gcm(k) = (alpha_gcm_lev(k,lt_plotindex_gcm)+alpha_gcm_lev(k+1,lt_plotindex_gcm))/2.
+ENDFOR
+alpha_interlay_gcm(nZmx-1)=0.
+
+smoothed_alpha1_les = make_array(nz)
+smoothed_alpha2_les = make_array(nz)
+smoothed_beta1_les = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_alpha1_les = smoothed_alpha1_les + REFORM(alpha1out(*,lt_plotindex_les+t))
+        smoothed_alpha2_les = smoothed_alpha2_les + REFORM(alpha2out(*,lt_plotindex_les+t))
+        smoothed_beta1_les = smoothed_beta1_les + REFORM(beta1out(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_alpha1_les = smoothed_alpha1_les/nstot
+smoothed_alpha2_les = smoothed_alpha2_les/nstot
+smoothed_beta1_les = smoothed_beta1_les/nstot
+
+ENDIF
+; =========================================================================
+
+; *** Temperatures ***
+
+if (f_offset eq 'false') then begin
+print, '........ TEMPERATURES'
+
+xmin = 190
+xmax = 250
+if (TestCase eq 'Case_Z') then begin
+xmin = 170
+xmax = 250
+endif
+if (TestCase eq 'Case_C') then begin
+xmin = 180
+xmax = 240
+endif
+
+
+what_I_plot = [[reform(temp_gcm(*,lt_plotindex_gcm_ini))],[reform(temp_gcm(*,lt_plotindex_gcm0))],[reform(temp_gcm(*,lt_plotindex_gcm))],[reform(temp_gcm(*,lt_plotindex_gcm2))],[reform(temp_gcm(*,lt_plotindex_gcm3))],[reform(temp_gcm(*,lt_plotindex_gcm4))]]
+labels=['TH temp 1d, lt='+string(lt_plot_ini),'TH temp 1d, lt='+string(lt_plot0),'TH temp 1d, lt='+string(lt_plot),'TH temp 1d, lt='+string(lt_plot2),'TH temp 1d, lt='+string(lt_plot3),'TH temp 1d, lt='+string(lt_plot4)]
+title_user = TestCase+SubCase+LayerCase+' Temperatures Comparison'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Temperature.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=12, TITLE=title_user
+cols=INDGEN(6)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Temperature (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+oplot, temp_les(*,lt_plotindex_les_ini), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les0), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les2), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les3), altitudes_LES/1000., psym=4
+oplot, temp_les(*,lt_plotindex_les4), altitudes_LES/1000., psym=4
+
+if(overplot_convadj EQ 'true') then begin
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj0), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj2), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj3), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj4), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
+endif
+
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+endif
+
+; *** Pressions ***
+
+print, '........ PRESSURES'
+
+;what_I_plot = make_array(nZmx)
+;labels=['TH P 1d, lt='+string(lt_plot)]
+;title_user = TestCase+SubCase+' Pressure Comparisons'
+;filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Pressure.ps'
+;PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+;CS, SCALE=28
+;GSET, XMIN=600, XMAX=900, YMIN=0, YMAX=0.5, TITLE=title_user
+;cols=INDGEN(1)+2
+;GPLOT, X=pplay(*,lt_plotindex_gcm), Y=-alog(pplay(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+;AXES, XSTEP = 25, XTITLE='Log P', YSTEP=0.1, YTITLE='Altitude (km)',NDECS=1
+;
+;oplot, pt(*,lt_plotindex_les),-alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;
+;PSCLOSE, /NOVIEW
+;
+;spawn, 'ps2png '+filename
+
+what_I_plot = make_array(nZmx)
+labels=['TH P 1d, lt='+string(lt_plot)]
+title_user = TestCase+SubCase+LayerCase+' Pressure Comparisons'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Pressure.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=400, XMAX=900, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=pplay(*,lt_plotindex_gcm), Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 25, XTITLE='Pression (Pa)', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+oplot, pt(*,lt_plotindex_les),altitudes_LES/1000., psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; *** Temperatures potentielles ***
+if(full eq 'true') then begin
+
+xmin = 210
+xmax = 230
+if (TestCase eq 'Case_C') then begin
+xmin = 225
+xmax = 255
+endif
+if (TestCase eq 'Case_I') then begin
+xmin = 195
+xmax = 250
+endif
+if (TestCase eq 'Case_Z') then begin
+xmin = 230
+xmax = 290
+endif
+if (TestCase eq 'ExtremeCase') then begin
+xmin = 225
+xmax = 255
+endif
+if (TestCase eq 'Exomars') then begin
+xmin = 225
+xmax = 255
+endif
+
+if (f_offset eq 'false') then begin
+
+print, '........ POTENTIAL TEMPERATURES'
+;what_I_plot = [[reform(teta_gcm(*,lt_plotindex_gcm_ini))],[reform(teta_gcm(*,lt_plotindex_gcm0))],[reform(teta_gcm(*,lt_plotindex_gcm))],[reform(teta_gcm(*,lt_plotindex_gcm2))],[reform(teta_gcm(*,lt_plotindex_gcm3))],[reform(teta_gcm(*,lt_plotindex_gcm4))]]
+what_I_plot = [[reform(teta_gcm(*,lt_plotindex_gcm))],[reform(teta_gcm(*,lt_plotindex_gcm2))],[reform(teta_gcm(*,lt_plotindex_gcm3))]]
+labels=['TH teta 1d, lt='+string(lt_plot),'TH teta 1d, lt='+string(lt_plot2),'TH teta 1d, lt='+string(lt_plot3)]
+title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=0.6, TITLE=title_user
+cols=INDGEN(3)+2
+GPLOT, X=what_I_plot, Y=-alog(pplay(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.2, YTITLE='-Log(P/P0) ',NDECS=1
+
+;oplot, teta_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4,SYMSIZE=0.5, thick=0.5
+;oplot, teta_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4,SYMSIZE=0.5, thick=0.5
+oplot, teta_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4,SYMSIZE=0.5, thick=0.5
+oplot, teta_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4,SYMSIZE=0.5, thick=0.5
+oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4,SYMSIZE=0.5, thick=0.5
+;oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4,SYMSIZE=0.5, thick=0.5
+if(overplot_convadj EQ 'true') then begin
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj0), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj0)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj2), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj2)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj3), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj3)/pGround), thick=0.1,color=8,linestyle=3
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj4), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj4)/pGround), thick=0.1,color=8,linestyle=3
+endif
+;oplot, teta_gcm_0(*), -alog(pplay(*,lt_plotindex_gcm)/pGround), thick=0.5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+xmin = 210
+xmax = 225
+
+if (TestCase eq 'Case_C') then begin
+xmin = 230
+xmax = 255
+endif
+
+if (TestCase eq 'ExtremeCase') then begin
+xmin = 225
+xmax = 255
+endif
+
+;xmin = 280
+;xmax = 300
+what_I_plot = [[tsurf_gcm(lt_plotindex_gcm),reform(teta_gcm(*,lt_plotindex_gcm))],[tsurf_gcm(lt_plotindex_gcm2),reform(teta_gcm(*,lt_plotindex_gcm2))]]
+labels=['TH teta 1d, lt='+string(lt_plot),'TH teta 1d, lt='+string(lt_plot2)]
+title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta_zoom.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=0.05, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=[0.,-alog(pplay(*,lt_plotindex_gcm)/pGround)], /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.005, YTITLE='-Log(P/P0) ',NDECS=1
+
+;oplot, teta_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;oplot, teta_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+if(overplot_convadj EQ 'true') then begin
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj0), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj0)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj)/pGround), thick=0.1,color=8,linestyle=3
+oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj2), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj2)/pGround), thick=0.1,color=8,linestyle=3
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj3), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj3)/pGround), thick=0.1,color=8,linestyle=3
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj4), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj4)/pGround), thick=0.1,color=8,linestyle=3
+endif
+;oplot, teta_gcm_0(*), -alog(pplay(*,lt_plotindex_gcm)/pGround)
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+xmin = 225
+xmax = 270
+;xmin = 280
+;xmax = 300
+if (TestCase eq 'Case_C') then begin
+xmin = 215
+xmax = 240
+endif
+
+what_I_plot = [[tsurf_gcm(lt_plotindex_gcm),reform(temp_gcm(*,lt_plotindex_gcm))],[tsurf_gcm(lt_plotindex_gcm2),reform(temp_gcm(*,lt_plotindex_gcm2))]]
+ymax=0.05
+ystep=0.005
+print, 'tsurf gcm :',tsurf_gcm(lt_plotindex_gcm)
+
+if (TestCase eq 'Exomars') then begin
+xmin = 235
+;xmax = 255
+xmax=295
+what_I_plot = [[tsurf_gcm(lt_plotindex_gcm),reform(temp_gcm(*,lt_plotindex_gcm))],[10.*tsurf_gcm(lt_plotindex_gcm2),10.*reform(temp_gcm(*,lt_plotindex_gcm2))]]
+;what_I_plot = 5.*what_I_plot
+;ymax=0.027
+ymax=0.003
+ystep=0.0005
+endif
+
+
+
+labels=['TH T 1d, lt='+string(lt_plot),'TH T 1d, lt='+string(lt_plot2)]
+title_user = TestCase+SubCase+LayerCase+' T comparisons'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_T_zoom.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=ymax, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=[0.,-alog(pplay(*,lt_plotindex_gcm)/pGround)], /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Temperature (K)', YSTEP=ystep, YTITLE='-Log(P/P0) ',NDECS=4
+
+;oplot, temp_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;oplot, temp_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+
+oplot, [tsurf_gcm(lt_plotindex_gcm),temp_les(*,lt_plotindex_les)], [0.,-alog(pt(*,lt_plotindex_les)/pGround)], psym=4
+oplot, temp_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), thick=0.1
+;oplot, temp_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;oplot, temp_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+
+;oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+;oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+if(overplot_convadj EQ 'true') then begin
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj0), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj0)/pGround), thick=0.1,color=8,linestyle=3
+
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj)/pGround), thick=0.1,color=8,psym=2
+oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj)/pGround), thick=0.1,color=8,linestyle=3
+;oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj2), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj2)/pGround), thick=0.1,color=8,linestyle=3
+
+
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj3), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj3)/pGround), thick=0.1,color=8,linestyle=3
+;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj4), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj4)/pGround), thick=0.1,color=8,linestyle=3
+endif
+;oplot, teta_gcm_0(*), -alog(pplay(*,lt_plotindex_gcm)/pGround)
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+endif
+
+if (plot_3d eq 'true') then begin
+what_I_plot = [[reform(teta_gcm(*,lt_plotindex_gcm_ini))],[reform(teta_gcm(*,lt_plotindex_gcm0))],[reform(teta_gcm(*,lt_plotindex_gcm))],[reform(teta_gcm(*,lt_plotindex_gcm2))],[reform(teta_gcm(*,lt_plotindex_gcm3))],[reform(teta_gcm(*,lt_plotindex_gcm4))]]
+labels=['TH teta 1d, lt='+string(lt_plot_ini),'TH teta 1d, lt='+string(lt_plot0),'TH teta 1d, lt='+string(lt_plot),'TH teta 1d, lt='+string(lt_plot2),'TH teta 1d, lt='+string(lt_plot3),'TH teta 1d, lt='+string(lt_plot4)]
+title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=1.4, TITLE=title_user
+cols=INDGEN(6)+2
+GPLOT, X=what_I_plot, Y=-alog(pplay_3d(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.2, YTITLE='-Log(P/P0) ',NDECS=1
+
+oplot, teta_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+endif
+
+endif else begin
+
+print, '........ POTENTIAL TEMPERATURES'
+
+what_I_plot = reform(teta_gcm(*,lt_plotindex_gcm))
+labels=['TH teta 1d, lt='+string(lt_plot)]
+title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=210, XMAX=240, YMIN=0, YMAX=2, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=-alog(pplay(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.2, YTITLE='-Log(P/P0) ',NDECS=1
+
+oplot, teta_les(*,lt_plotindex_les),-alog(pt(*,lt_plotindex_les)/pGround), psym=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+endelse
+
+print, '........ SURFACE TEMPERATURES'
+
+
+;getcdf, file=les_path+'/wrfout_d01_9999-01-01_tsurf_gcmsoil.nc', charvar='TSURF', invar=tsurf_les_tmp
+;tsurf_les=make_array(nttot)
+;FOR l=0,nttot-1 DO BEGIN
+;        tsurf_les(l)=TOTAL(TOTAL(tsurf_les_tmp(*,*,l),1),1)/float(n_elements(reform(tsurf_les_tmp(*,0,0)))) /float(n_elements(reform(tsurf_les_tmp(0,*,0))))
+;ENDFOR
+;tsurf_les_tmp=0.
+
+what_I_plot = tsurf_gcm
+labels=['TH 1d tsurf']
+title_user = TestCase+SubCase+LayerCase+' Surface temperatures (recomputed from T and P)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_tsurf.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=150, YMAX=320, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=localtime_gcm, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=5., YTITLE='Surface temperature',NDECS=1
+
+;oplot, localtime, tsurf, psym=4,thick=0.3  ;tsurf les with les soil
+;oplot, localtime, tsurf_les, psym=4,thick=0.3  ;tsurf les with gcm soil
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+if (got_swdownz eq 'true') then begin
+
+print, '........ DOWNWARD SOLAR FLUX AT SURFACE'
+print, '.. and LW FLUX AT SURFACE'
+
+localtime=localtime-history_interval_s/3700.
+
+;getcdf, file=les_path+'/wrfout_d01_9999-01-01_swdownz.nc', charvar='SWDOWNZ', invar=swdownz_les_tmp
+getcdf, file=file1, charvar='fluxsurf_sw', invar=swdownz_gcm
+;swdownz_les=make_array(nttot)
+;FOR l=0,nttot-1 DO BEGIN
+;	swdownz_les(l)=TOTAL(TOTAL(swdownz_les_tmp(*,*,l),1),1)/float(nx) /float(ny)
+;ENDFOR
+;swdownz_les_tmp=0.
+
+swdownz_les=temporary(swdownz)
+swdownz_les_Int=INTERPOL(swdownz_les,localtime,localtime_gcm)
+swdownz_gcm_Int=INTERPOL(swdownz_gcm,localtime_gcm,localtime,/QUADRATIC)
+
+what_I_plot = swdownz_gcm-swdownz_les_Int
+labels=['TH1D SW flux - LES SW flux']
+title_user = TestCase+SubCase+LayerCase+' Difference in Solar Fluxes at surface'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_diffswdownz.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=-20, YMAX=20, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=localtime_gcm, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=2., YTITLE='Solar Flux (W.m-2)',NDECS=1
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+what_I_plot = swdownz_les
+labels=['LES SW flux']
+title_user = TestCase+SubCase+LayerCase+' Solar Fluxes at surface'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_swdownz.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=0, YMAX=500, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=localtime, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=50., YTITLE='Solar Flux (W.m-2)',NDECS=1
+
+oplot, localtime_gcm, swdownz_gcm, psym=1,thick=0.2
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+;getcdf, file=les_path+'/wrfout_d01_9999-01-01_lwdownz.nc', charvar='LWDOWNZ', invar=lwdownz_les_tmp
+getcdf, file=file1, charvar='fluxsurf_lw', invar=lwdownz_gcm
+;lwdownz_les=make_array(nttot)
+;FOR l=0,nttot-1 DO BEGIN
+;        lwdownz_les(l)=TOTAL(TOTAL(lwdownz_les_tmp(*,*,l),1),1)/float(nx) /float(ny)
+;ENDFOR
+;lwdownz_les_tmp=0.
+
+lwdownz_les=temporary(lwdownz)
+
+what_I_plot = lwdownz_les
+labels=['LES LW downward flux']
+title_user = TestCase+SubCase+LayerCase+' LW downward fluxes at surface'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_lwdownz.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=-50, YMAX=50, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=localtime, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=10., YTITLE='LW downward surface flux (W.m-2)',NDECS=1
+
+oplot, localtime_gcm, lwdownz_gcm, psym=1,thick=0.2
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+
+
+
+;getcdf, file=les_path+'/wrfout_d01_9999-01-01_flxgrd.nc', charvar='FLXGRD', invar=fluxgrd_les_tmp
+;getcdf, file=les_path+'/wrfout_d01_9999-01-01_flxgrd_gcmsoil.nc', charvar='FLXGRD', invar=fluxgrd_les_tmp
+getcdf, file=file1, charvar='fluxgrd', invar=fluxgrd_gcm
+;fluxgrd_les=make_array(nttot)
+;FOR l=0,nttot-1 DO BEGIN
+;        fluxgrd_les(l)=TOTAL(TOTAL(fluxgrd_les_tmp(*,*,l),1),1)/float(n_elements(reform(fluxgrd_les_tmp(*,0,0)))) /float(n_elements(reform(fluxgrd_les_tmp(0,*,0))))
+;ENDFOR
+;fluxgrd_les_tmp=0.
+
+fluxgrd_les=temporary(flxgrd)
+
+what_I_plot = fluxgrd_les
+labels=['LES ground flux']
+title_user = TestCase+SubCase+LayerCase+' Ground flux at surface'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fluxgrd.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=-70, YMAX=40, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=localtime, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=10., YTITLE='Ground flux at surface (W.m-2)',NDECS=1
+
+oplot, localtime_gcm, fluxgrd_gcm, psym=1,thick=0.2
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+
+
+
+;getcdf, file=les_path+'/wrfout_d01_9999-01-01_flxrad.nc', charvar='FLXRAD', invar=fluxrad_les_tmp
+;getcdf, file=les_path+'/wrfout_d01_9999-01-01_flxrad_gcmsoil.nc', charvar='FLXRAD', invar=fluxrad_les_tmp
+getcdf, file=file1, charvar='fluxrad', invar=fluxrad_gcm
+;fluxrad_les=make_array(nttot)
+;FOR l=0,nttot-1 DO BEGIN
+;        fluxrad_les(l)=TOTAL(TOTAL(fluxrad_les_tmp(*,*,l),1),1)/float(n_elements(reform(fluxrad_les_tmp(*,0,0)))) /float(n_elements(reform(fluxrad_les_tmp(0,*,0))))
+;ENDFOR
+;fluxrad_les_tmp=0.
+
+fluxrad_les=temporary(flxrad)
+
+what_I_plot = fluxrad_les
+labels=['LES radiation flux at surface']
+title_user = TestCase+SubCase+LayerCase+' Radiation flux at surface'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fluxrad.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=-40, YMAX=80, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=localtime, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=10., YTITLE='Radiation flux at surface (W.m-2)',NDECS=1
+
+oplot, localtime_gcm, fluxrad_gcm, psym=1,thick=0.2
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+localtime=localtime+history_interval_s/3700.
+
+endif
+
+if (got_hfx eq 'true') then begin
+
+print, '........ SENSIBLE HEAT FLUX'
+
+localtime=localtime-history_interval_s/3700.
+;getcdf, file=les_path+'/wrfout_d01_9999-01-01_hfx.nc', charvar='HFX', invar=hfx_les_tmp
+;getcdf, file=les_path+'/wrfout_d01_9999-01-01_hfx_gcmsoil.nc', charvar='HFX', invar=hfx_les_tmp
+
+hfx_les=temporary(hfx)
+
+getcdf, file=file1, charvar='hfx', invar=hfx_gcm
+
+;hfx_les=make_array(nttot)
+;FOR l=0,nttot-1 DO BEGIN
+;        hfx_les(l)=TOTAL(TOTAL(hfx_les_tmp(*,*,l),1),1)/float(n_elements(reform(hfx_les_tmp(*,0,0)))) /float(n_elements(reform(hfx_les_tmp(0,*,0))))
+;ENDFOR
+;hfx_les_tmp=0.
+;hfx_les_Int=INTERPOL(hfx_les,localtime,localtime_gcm)
+;hfx_gcm_Int=INTERPOL(hfx_gcm,localtime_gcm,localtime,/QUADRATIC)
+
+what_I_plot = hfx_les
+labels=['LES sensible heat flux']
+title_user = TestCase+SubCase+LayerCase+' Sensible heat Fluxes at surface'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_hfx.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=-50, YMAX=50, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=localtime, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=10., YTITLE='Sensible heat Flux (W.m-2)',NDECS=1
+
+oplot, localtime_gcm, hfx_gcm, psym=1,thick=0.2
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+if (1 eq 1) then begin
+
+openw, lun, "input_hfx.def", /get_lun
+for l=0, nttot-1 do printf, lun, localtime(l),hfx_les(l),fluxrad_les(l)+fluxgrd_les(l)-hfx_les(l), format='((2x,F5.2)(4x,F8.2)(4x,F8.2))'
+FREE_LUN, lun
+close, lun
+
+endif
+
+
+
+what_I_plot = fluxrad_les+fluxgrd_les-hfx_les
+labels=['LES flux vdifc']
+title_user = TestCase+SubCase+LayerCase+' Flux vdifc at surface'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_vdifc.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=-50, YMAX=50, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=localtime, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=10., YTITLE='Heat Flux (W.m-2)',NDECS=1
+
+oplot, localtime_gcm, fluxrad_gcm+fluxgrd_gcm-hfx_gcm, psym=1,thick=0.2
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+
+
+
+;what_I_plot = [[fluxrad_les-swdownz_les-lwdownz_les],[fluxgrd_les],[hfx_les],[swdownz_les],[lwdownz_les],[fluxrad_les-fluxgrd_les-hfx_les]]
+what_I_plot = [[fluxrad_les],[swdownz_les],[lwdownz_les],[swdownz_les-lwdownz_les]]
+;labels=['lw up','grd','hfx','sw down','lw down','total']
+labels=['rad','sw down','lw down','sw +lw down']
+title_user = TestCase+SubCase+LayerCase+' Fluxes at surface'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_totflux.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=-100, YMAX=100, TITLE=title_user
+cols=INDGEN(4)+2
+GPLOT, X=localtime, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=10., YTITLE='Fluxes at surface (W.m-2)',NDECS=1
+
+;oplot, localtime_gcm, fluxrad_gcm, psym=1,thick=0.2
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+
+
+
+
+
+
+
+
+localtime=localtime+history_interval_s/3700.
+
+
+
+
+
+
+
+
+endif
+
+; ---------------------- *** Vitesses verticales *** -------------------------------
+; ------------ Verification de l'approx terrestre wmax = vmoy dans la couche instable
+
+print, '........ CHECKING wmax = vmoy in unstable layer'
+
+what_I_plot = uv_moy(*,lt_plotindex_les)
+labels=['LES uv_moy']
+title_user = TestCase+SubCase+LayerCase+' LES mean UV comp to max W in plume trac1'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_UV.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0, XMAX=10, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, YSTEP = 1, YTITLE='Altitude (km)', XSTEP=1, XTITLE='Mean horizontal velocity inside domain (m/s)',NDECS=1
+
+oplot, make_array(nz,value=wmax(lt_plotindex_les)), altitudes_LES/1000., psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; ------------ Profil de vitesse
+
+print, '........ VERTICAL VELOCITY'
+
+what_I_plot = make_array(nZmx)
+FOR k=0, nZmx-2 DO BEGIN
+        what_I_plot(k) = 0.5*(zw2_lev(k,lt_plotindex_gcm) + zw2_lev(k+1,lt_plotindex_gcm))
+ENDFOR
+what_I_plot(nZmx-1) = 0.
+
+smoothed_w_mean1_les = make_array(nz)
+smoothed_w_mean2_les = make_array(nz)
+smoothed_w_mean1_down_les = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_w_mean1_les = smoothed_w_mean1_les + REFORM(w_mean1(*,lt_plotindex_les+t))
+        smoothed_w_mean2_les = smoothed_w_mean2_les + REFORM(w_mean2(*,lt_plotindex_les+t))
+	smoothed_w_mean1_down_les = smoothed_w_mean1_down_les + REFORM(w_mean1_down(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_w_mean1_les = smoothed_w_mean1_les/nstot
+smoothed_w_mean2_les = smoothed_w_mean2_les/nstot
+smoothed_w_mean1_down_les = smoothed_w_mean1_down_les/nstot
+
+ratio = make_array(nz)
+FOR k=0, nz-1 DO BEGIN
+	IF(smoothed_w_mean1_les(k) ne 0.) then ratio(k) = smoothed_w_mean1_down_les(k)/smoothed_w_mean1_les(k) else ratio(k)=0.
+ENDFOR
+
+labels=['TH 1d w, lt='+string(lt_plot)]
+title_user = TestCase+SubCase+LayerCase+' Vertical velocity comparisons (inside thermal)'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Wprofile.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-6, XMAX=8, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, YSTEP = 2, YTITLE='Altitude (km)', XSTEP=1, XTITLE='Vertical velocity inside thermal (m/s)',NDECS=1
+
+oplot, smoothed_w_mean1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_w_mean2_les, altitudes_LES/1000., psym=5
+oplot, smoothed_w_mean1_down_les, altitudes_LES/1000., psym=6
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; *** Static stability ***
+
+print, '........ STATIC STABILITY'
+
+dteta_dz_gcm = deriv(altitudes_GCM,reform(teta_gcm(*,lt_plotindex_gcm)))
+dteta_dz_les = deriv(altitudes_LES,reform(teta_les(*,lt_plotindex_les)))
+
+what_I_plot = dteta_dz_gcm
+labels=['TH static stability 1d']
+title_user = TestCase+SubCase+LayerCase+' Static stability comparison'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_dTetadz.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.002, XMAX=0.006, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.0005 , XTITLE='Static stability (K.m-1)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+oplot, dteta_dz_les, altitudes_LES/1000., psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+print,' -----------------------------------------------------------------------------------------------------------------------'
+print,' ***  LES diagnostics of the PLUME *** MUAHAHAHAHAHA'
+print,' V2 with E and D computed for a UDE plume'
+print,' -----------------------------------------------------------------------------------------------------------------------'
+
+print, '........ EXTRACTING DATA'
+
+; --- Reinterpolation of F
+
+fm_therm_gcm_interlay = make_array(nZmx,nTmx)
+
+FOR k=0, nZmx-2 DO BEGIN
+        fm_therm_gcm_interlay(k,*) = (fm_therm_gcm_lev(k,*) + fm_therm_gcm_lev(k+1,*))/2.
+ENDFOR
+fm_therm_gcm_interlay(nZmx-1,*)=0.
+
+; --- Calculation of gcm df/dz using entrainment and detrainments and NOT F
+
+df_dz_gcm = deriv(altitudes_GCM,reform(fm_therm_gcm_interlay(*,lt_plotindex_gcm)))
+; --- Smoothing of the mass flux on a user-defined window
+
+smoothed_fm_trac1_les = make_array(nz)
+smoothed_fm_trac2_les = make_array(nz)
+smoothed_downward_fm_trac1_les = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+	smoothed_fm_trac1_les = smoothed_fm_trac1_les + REFORM(fm_trac1_les(*,lt_plotindex_les+t))
+	smoothed_fm_trac2_les = smoothed_fm_trac2_les + REFORM(fm_trac2_les(*,lt_plotindex_les+t))
+	smoothed_downward_fm_trac1_les = smoothed_downward_fm_trac1_les + REFORM(downward_flux1(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_fm_trac1_les = smoothed_fm_trac1_les/nstot
+smoothed_fm_trac2_les = smoothed_fm_trac2_les/nstot
+smoothed_downward_fm_trac1_les = smoothed_downward_fm_trac1_les/nstot
+
+; --- Calculation of the entrainement rate according to Rio(2010)
+; done in the heavy part at the begining (reeaaaally heavy)
+
+; --- Smoothing of the entrainment on a ~30min window
+
+; term 1
+
+
+smoothed_e_term1_trac1_les = make_array(nz)
+smoothed_e_term1_trac2_les = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_e_term1_trac1_les = smoothed_e_term1_trac1_les + REFORM(e_trac1_les(*,lt_plotindex_les+t))
+        smoothed_e_term1_trac2_les = smoothed_e_term1_trac2_les + REFORM(e_trac2_les(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_e_term1_trac1_les = smoothed_e_term1_trac1_les/nstot
+smoothed_e_term1_trac2_les = smoothed_e_term1_trac2_les/nstot
+
+smoothed_e_rate_term1_trac1_les = make_array(nz)
+smoothed_e_rate_trac2_les = smoothed_e_term1_trac2_les
+
+; it already is an entrainment rate ! KIND OF : it is E/Mc, and Mc is not F !! NOW it is Mc/deltaTeta * dchi/dz
+FOR k=0, nz-1 DO BEGIN
+	IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term1_trac1_les(k) = smoothed_e_term1_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term1_trac1_les(k) =0.
+;        IF (smoothed_fm_trac2_les(k) ne 0.) THEN smoothed_e_rate_trac2_les(k) = smoothed_e_trac2_les(k)/smoothed_fm_trac2_les(k) ELSE smoothed_e_rate_trac2_les(k) =0.
+ENDFOR
+
+; term 2  & 3
+
+
+smoothed_e_term2_trac1_les = make_array(nz)
+smoothed_e_term3_trac1_les = make_array(nz)
+smoothed_e_term1_ude_trac1_les = make_array(nz)
+smoothed_e_term2_ude_trac1_les = make_array(nz)
+smoothed_e_term3_ude_trac1_les = make_array(nz)
+
+FOR t=-ns,ns DO BEGIN
+        smoothed_e_term2_trac1_les = smoothed_e_term2_trac1_les + REFORM(e1_term2(*,lt_plotindex_les+t))
+        smoothed_e_term2_trac1_les = smoothed_e_term2_trac1_les + REFORM(e1_term2(*,lt_plotindex_les+t))
+	smoothed_e_term1_ude_trac1_les = smoothed_e_term1_ude_trac1_les + REFORM(e1_term1_ude(*,lt_plotindex_les+t))
+        smoothed_e_term2_ude_trac1_les = smoothed_e_term2_ude_trac1_les + REFORM(e1_term2_ude(*,lt_plotindex_les+t))
+        smoothed_e_term3_ude_trac1_les = smoothed_e_term3_ude_trac1_les + REFORM(e1_term3_ude(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_e_term2_trac1_les = smoothed_e_term2_trac1_les/nstot
+smoothed_e_term3_trac1_les = smoothed_e_term3_trac1_les/nstot
+smoothed_e_term1_ude_trac1_les = smoothed_e_term1_ude_trac1_les/nstot
+smoothed_e_term2_ude_trac1_les = smoothed_e_term2_ude_trac1_les/nstot
+smoothed_e_term3_ude_trac1_les = smoothed_e_term3_ude_trac1_les/nstot
+
+smoothed_e_rate_term2_trac1_les = make_array(nz)
+smoothed_e_rate_term3_trac1_les = make_array(nz)
+smoothed_e_rate_term1_ude_trac1_les = make_array(nz)
+smoothed_e_rate_term2_ude_trac1_les = make_array(nz)
+smoothed_e_rate_term3_ude_trac1_les = make_array(nz)
+
+FOR k=0, nz-1 DO BEGIN
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term2_trac1_les(k) = smoothed_e_term2_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term2_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term3_trac1_les(k) = smoothed_e_term3_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term3_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term1_ude_trac1_les(k) = smoothed_e_term1_ude_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term1_ude_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term2_ude_trac1_les(k) = smoothed_e_term2_ude_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term2_ude_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term3_ude_trac1_les(k) = smoothed_e_term3_ude_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term3_ude_trac1_les(k) =0.
+
+ENDFOR
+
+; --- Summing...
+
+smoothed_e_rate_trac1_les = smoothed_e_rate_term1_trac1_les + smoothed_e_rate_term2_trac1_les + smoothed_e_rate_term3_trac1_les
+smoothed_e_rate_ude_trac1_les = smoothed_e_rate_term1_ude_trac1_les + smoothed_e_rate_term2_ude_trac1_les + smoothed_e_rate_term3_ude_trac1_les
+
+;print, 'ommiting term3'
+;smoothed_e_rate_trac1_les = smoothed_e_rate_term1_trac1_les + smoothed_e_rate_term2_trac1_les
+
+; --- Smoothing of the detrainment rate
+
+smoothed_d_term1_trac1_les = make_array(nz)
+smoothed_d_term2_trac1_les = make_array(nz)
+smoothed_d_term3_trac1_les = make_array(nz)
+smoothed_d_term1_ude_trac1_les = make_array(nz)
+smoothed_d_term2_ude_trac1_les = make_array(nz)
+smoothed_d_term3_ude_trac1_les = make_array(nz)
+
+FOR t=-ns,ns DO BEGIN
+        smoothed_d_term1_trac1_les = smoothed_d_term1_trac1_les + REFORM(d1_term1(*,lt_plotindex_les+t))
+        smoothed_d_term2_trac1_les = smoothed_d_term2_trac1_les + REFORM(d1_term2(*,lt_plotindex_les+t))
+        smoothed_d_term3_trac1_les = smoothed_d_term3_trac1_les + REFORM(d1_term3(*,lt_plotindex_les+t))
+        smoothed_d_term1_ude_trac1_les = smoothed_d_term1_ude_trac1_les + REFORM(d1_term1_ude(*,lt_plotindex_les+t))
+        smoothed_d_term2_ude_trac1_les = smoothed_d_term2_ude_trac1_les + REFORM(d1_term2_ude(*,lt_plotindex_les+t))
+        smoothed_d_term3_ude_trac1_les = smoothed_d_term3_ude_trac1_les + REFORM(d1_term3_ude(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_d_term1_trac1_les = smoothed_d_term1_trac1_les/nstot
+smoothed_d_term2_trac1_les = smoothed_d_term2_trac1_les/nstot
+smoothed_d_term3_trac1_les = smoothed_d_term3_trac1_les/nstot
+smoothed_d_term1_ude_trac1_les = smoothed_d_term1_ude_trac1_les/nstot
+smoothed_d_term2_ude_trac1_les = smoothed_d_term2_ude_trac1_les/nstot
+smoothed_d_term3_ude_trac1_les = smoothed_d_term3_ude_trac1_les/nstot
+
+smoothed_d_rate_term1_trac1_les = make_array(nz)
+smoothed_d_rate_term2_trac1_les = make_array(nz)
+smoothed_d_rate_term3_trac1_les = make_array(nz)
+smoothed_d_rate_term1_ude_trac1_les = make_array(nz)
+smoothed_d_rate_term2_ude_trac1_les = make_array(nz)
+smoothed_d_rate_term3_ude_trac1_les = make_array(nz)
+
+FOR k=0, nz-1 DO BEGIN
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_term1_trac1_les(k) = smoothed_d_term1_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_term1_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_term2_trac1_les(k) = smoothed_d_term2_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_term2_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_term3_trac1_les(k) = smoothed_d_term3_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_term3_trac1_les(k) =0.
+        IF (smoothed_fm_trac1_les(k) ne 0.) THEN BEGIN
+	smoothed_d_rate_term1_ude_trac1_les(k) = smoothed_d_term1_ude_trac1_les(k)/smoothed_fm_trac1_les(k)
+	smoothed_d_rate_term2_ude_trac1_les(k) = smoothed_d_term2_ude_trac1_les(k)/smoothed_fm_trac1_les(k)
+	smoothed_d_rate_term3_ude_trac1_les(k) = smoothed_d_term3_ude_trac1_les(k)/smoothed_fm_trac1_les(k)
+	ENDIF ELSE BEGIN
+	smoothed_d_rate_term1_ude_trac1_les(k)=0.
+	smoothed_d_rate_term2_ude_trac1_les(k)=0.
+	smoothed_d_rate_term3_ude_trac1_les(k)=0.
+	ENDELSE
+ENDFOR
+
+; --- Summing...
+
+full_d_rate_ude = d1_term1_ude + d1_term2_ude + d1_term3_ude
+
+smoothed_d_rate_trac1_les = smoothed_d_rate_term1_trac1_les+smoothed_d_rate_term2_trac1_les+smoothed_d_rate_term3_trac1_les
+smoothed_d_rate_ude_trac1_les = smoothed_d_rate_term1_ude_trac1_les+smoothed_d_rate_term2_ude_trac1_les+smoothed_d_rate_term3_ude_trac1_les
+;print, 'ommiting term3'
+;smoothed_d_rate_trac1_les = smoothed_d_rate_term1_trac1_les+smoothed_d_rate_term2_trac1_les
+
+; --- PLOTTING : BUOYANCY TERM
+
+smoothed_buoyancy_trac1_les = make_array(nz)
+smoothed_buoyancy_ude_trac1_les = make_array(nz)
+smoothed_buoyancy_trac2_les = make_array(nz)
+smoothed_buoyancy_downdraft1_les_ude = make_array(nz)
+
+FOR t=-ns,ns DO BEGIN
+        smoothed_buoyancy_trac1_les = smoothed_buoyancy_trac1_les + REFORM(buoyancy1_les(*,lt_plotindex_les+t))
+	smoothed_buoyancy_ude_trac1_les = smoothed_buoyancy_ude_trac1_les + REFORM(grav*(tplume1moy(*,lt_plotindex_les+t)/tenv1moy_ude(*,lt_plotindex_les+t)-1.))
+        smoothed_buoyancy_trac2_les = smoothed_buoyancy_trac2_les + REFORM(buoyancy2_les(*,lt_plotindex_les+t))
+	smoothed_buoyancy_downdraft1_les_ude = smoothed_buoyancy_downdraft1_les_ude + REFORM(grav*(tdown1moy(*,lt_plotindex_les+t)/tenv1moy_ude(*,lt_plotindex_les+t)-1.))
+ENDFOR
+
+smoothed_buoyancy_trac1_les = smoothed_buoyancy_trac1_les/nstot
+smoothed_buoyancy_ude_trac1_les = smoothed_buoyancy_ude_trac1_les/nstot
+smoothed_buoyancy_trac2_les = smoothed_buoyancy_trac2_les/nstot
+smoothed_buoyancy_downdraft1_les_ude = smoothed_buoyancy_downdraft1_les_ude/nstot
+
+print, '........ BUOYANCY'
+
+what_I_plot = [[buoyancy_gcm(*,lt_plotindex_gcm)],[buoyancy_est_gcm(*,lt_plotindex_gcm)]]
+labels=['TH buoyancy term','TH estimated buoyancy in plume']
+title_user = TestCase+SubCase+LayerCase+' UDE plume buoyancy'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_B.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.06, XMAX=0.06, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.01 , XTITLE='N.m-1', YSTEP=1, YTITLE=' Altitude (km)',NDECS=3
+
+;oplot, smoothed_buoyancy_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_buoyancy_trac2_les, altitudes_LES/1000., psym=5
+print, smoothed_buoyancy_ude_trac1_les
+oplot, smoothed_buoyancy_ude_trac1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_buoyancy_downdraft1_les_ude, altitudes_LES/1000., psym=7
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; --- PLOTTING : MASS FLUX 
+
+print, '........ MASS FLUX'
+
+f_gcm = fm_therm_gcm_interlay(*,lt_plotindex_gcm)
+what_I_plot = f_gcm
+labels=['TH mass flux']
+title_user = TestCase+SubCase+LayerCase+' mass flux comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_f.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.008, XMAX=0.008, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.002 , XTITLE='Kg.m-2.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+oplot, smoothed_fm_trac1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_fm_trac2_les, altitudes_LES/1000., psym=5
+oplot, smoothed_downward_fm_trac1_les, altitudes_LES/1000., psym=6
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; --- PLOTTING : MASS FLUX DERIVATIVE
+
+print, '........ MASS FLUX DERIVATIVE'
+
+
+B_w2_trac1 = make_array(nz)
+
+FOR k=0, nz-1 DO BEGIN
+        IF (smoothed_e_rate_trac1_les(k) ne 0.) THEN B_w2_trac1(k) = smoothed_buoyancy_ude_trac1_les(k)/(smoothed_w_mean1_les(k))^2 ELSE B_w2_trac1(k)=0.
+;       IF (smoothed_e_rate_trac2_les(k) ne 0.) THEN B_w2_trac2(k) = smoothed_buoyancy_trac2_les(k)/(smoothed_w_mean2_les(k))^2 ELSE B_w2_trac2(k)=0.
+ENDFOR
+
+df_dz_les1 = deriv(altitudes_LES,reform(smoothed_fm_trac1_les))
+df_dz_les2 = deriv(altitudes_LES,reform(smoothed_fm_trac2_les))
+df_dz_param = make_array(nz)
+df_dz_param2 = make_array(nz)
+
+;dlow=0.0013   ;baseline from continuity equation
+dlow=0.0003 ; svn baseline
+;dlow=0.0005
+dcoeff=-0.3
+;dcoeff=-0.4
+
+;aaa1=2.5
+;bbb1=0.0015
+;Ae1=0.045
+;Be1=0.6
+
+aaa1=1.60226
+bbb1=0.0006
+Ae1=0.0454
+Be1=0.57
+
+FOR k=0, nz-1 DO BEGIN
+	IF (2.5*B_w2_trac1(k) GE 0.) THEN BEGIN
+	        IF ((aaa1*B_w2_trac1(k)-bbb1) GE 0.) THEN BEGIN
+;		df_dz_param(k)=smoothed_fm_trac1_les(k)*(Ae1*(aaa1*B_w2_trac1(k)-bbb1)^(Be1) - 0.06*(aaa1*B_w2_trac1(k))^(0.75))
+		df_dz_param2(k)=smoothed_fm_trac1_les(k)*(Ae1*(aaa1*B_w2_trac1(k)-bbb1)^(Be1) - MAX([(dcoeff*B_w2_trac1(k) + dlow),0.]))
+		ENDIF ELSE BEGIN
+;		df_dz_param(k)=smoothed_fm_trac1_les(k)*(-0.06*(aaa1*B_w2_trac1(k))^(0.75))
+                df_dz_param2(k)=smoothed_fm_trac1_les(k)*(-MAX([(dcoeff*B_w2_trac1(k) + dlow),0.]))
+		ENDELSE
+	ENDIF ELSE BEGIN
+;        df_dz_param(k)=smoothed_fm_trac1_les(k)*(-0.06*(-aaa1*B_w2_trac1(k))^(0.75))
+	df_dz_param2(k)=smoothed_fm_trac1_les(k)*(-MAX([(dcoeff*B_w2_trac1(k) + dlow),0.]))
+	ENDELSE
+ENDFOR
+
+what_I_plot = df_dz_gcm
+labels=['TH mass flux vertical derivative']
+title_user = TestCase+SubCase+LayerCase+' mass flux vertical derivative comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_dfdz.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.00002, XMAX=0.00002, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.000005 , XTITLE='Kg.m-3.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=6
+oplot, df_dz_les1, altitudes_LES/1000., psym=4
+;oplot, df_dz_les2, altitudes_LES/1000., psym=5
+oplot, df_dz_param, altitudes_LES/1000., psym=6, color=5
+oplot, df_dz_param2, altitudes_LES/1000., psym=6, color=6
+;print, "fm*(e-d)"
+;print, smoothed_fm_trac1_les*(0.045*(2.5*B_w2_trac1-0.0015)^(0.6) - 0.06*(-2.5*B_w2_trac1)^(0.75))
+;print, smoothed_fm_trac1_les
+print, B_w2_trac1
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : ENTRAINMENT RATE e = E/f 
+
+print, '........ ENTRAINMENT RATE'
+
+e_gcm = make_array(nZmx)
+
+FOR k=0, nZmx-1 DO BEGIN
+	IF (fm_therm_gcm_interlay(k,lt_plotindex_gcm) ne 0.) THEN BEGIN
+		e_gcm(k) = zdz_entr_therm_gcm(k,lt_plotindex_gcm)/(approx_zdz_gcm(k)*fm_therm_gcm_interlay(k,lt_plotindex_gcm))
+	ENDIF ELSE BEGIN
+		e_gcm(k) = 0.
+	ENDELSE
+ENDFOR
+
+
+what_I_plot = e_gcm
+labels=['TH entrainment rate']
+title_user = TestCase+SubCase+LayerCase+' UDE entrainment rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.003, XMAX=0.003, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.0006 , XTITLE='entrainment rate m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+oplot, smoothed_e_rate_ude_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_e_rate_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_e_rate_trac2_les, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+print, '........ EXTENDED ENTRAINMENT RATE'
+
+;what_I_plot = [[smoothed_e_rate_term1_trac1_les],[smoothed_e_rate_term2_trac1_les],[smoothed_e_rate_term3_trac1_les],[smoothed_e_rate_trac1_les]]
+what_I_plot = [[smoothed_e_rate_term1_ude_trac1_les],[smoothed_e_rate_term2_ude_trac1_les],[smoothed_e_rate_term3_ude_trac1_les],[smoothed_e_rate_ude_trac1_les]]
+labels=['LES base entrainment rate','LES term2 e rate','LES term3 e rate','LES total e rate']
+title_user = TestCase+SubCase+LayerCase+' UDE entrainment rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e_terms.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.01, XMAX=0.01, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.005 , XTITLE='entrainment rate m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=3
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+; --- PLOTTING : EXTENDED DETRAINMENT RATE 
+
+print, '........ EXTENDED DETRAINMENT RATE'
+
+what_I_plot = [[smoothed_d_rate_term1_ude_trac1_les],[smoothed_d_rate_term2_ude_trac1_les],[smoothed_d_rate_term3_ude_trac1_les],[smoothed_d_rate_ude_trac1_les]]
+labels=['LES term 1 detrainment rate','LES term2 d rate','LES term3 d rate','LES Total d rate']
+title_user = TestCase+SubCase+LayerCase+' UDE detrainment rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d_terms.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.01, XMAX=0.01, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.002 , XTITLE='detrainment rate m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : DETRAINMENT RATE d = D/f
+
+print, '........ DETRAINMENT RATE'
+
+;smoothed_d_rate_trac2_les = make_array(nz)
+;
+;FOR k=0, nz-1 DO BEGIN
+;        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_trac1_les(k) = smoothed_e_rate_trac1_les(k) - df_dz_les1(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_trac1_les(k) =0.
+;        IF (smoothed_fm_trac2_les(k) ne 0.) THEN smoothed_d_rate_trac2_les(k) = smoothed_e_rate_trac2_les(k) - df_dz_les2(k)/smoothed_fm_trac2_les(k) ELSE smoothed_d_rate_trac2_les(k) =0.
+;ENDFOR
+;
+d_gcm = make_array(nZmx)
+FOR k=0, nZmx-1 DO BEGIN
+        IF (fm_therm_gcm_interlay(k,lt_plotindex_gcm) ne 0.) THEN BEGIN
+                d_gcm(k) = zdz_detr_therm_gcm(k,lt_plotindex_gcm)/(approx_zdz_gcm(k)*fm_therm_gcm_interlay(k,lt_plotindex_gcm))
+        ENDIF ELSE BEGIN
+                d_gcm(k) = 0.
+        ENDELSE
+ENDFOR
+
+what_I_plot = d_gcm
+labels=['TH detrainment rate']
+title_user = TestCase+SubCase+LayerCase+' UDE detrainment rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=0.03, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.005 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=2
+
+oplot, smoothed_d_rate_ude_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_d_rate_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_d_rate_trac2_les, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : FRACTION COVERAGE
+
+print, '........ EXTENDED ALPHA'
+
+what_I_plot = alpha_interlay_gcm
+labels=['TH alpha']
+title_user = TestCase+SubCase+LayerCase+' fraction coverage comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_alpha.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=1., YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.1 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+oplot, smoothed_alpha1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_alpha2_les, altitudes_LES/1000., psym=5
+oplot, smoothed_beta1_les, altitudes_LES/1000., psym=6
+
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : THEORETICAL ENTRAINMENT RATE FROM LES DATA 
+
+print, '........ PARAMETRIZED RATES'
+
+approx_zdz_les = make_array(nz)
+
+approx_zdz_les(0)=altitudes_LES(1)
+FOR k=1, nz-2 DO BEGIN
+	approx_zdz_les(k) = altitudes_LES(k+1) - altitudes_LES(k)
+ENDFOR
+approx_zdz_les(nz-1)=approx_zdz_les(nz-2)
+
+
+theoretical_e_trac1_les = make_array(nz)
+theoretical_e_trac2_les = make_array(nz)
+
+
+FOR k=0, nz-1 DO BEGIN
+        theoretical_e_trac1_les(k) = MAX([0.,(betalpha/(1.+betalpha))*((afact*smoothed_buoyancy_trac1_les(k)/((smoothed_w_mean1_les(k))^2.)) - fact_epsilon)])
+        theoretical_e_trac2_les(k) = MAX([0.,(betalpha/(1.+betalpha))*((afact*smoothed_buoyancy_trac2_les(k)/((smoothed_w_mean2_les(k))^2.)) - fact_epsilon)])
+ENDFOR
+
+
+what_I_plot = [[theoretical_e_trac1_les],[theoretical_e_trac2_les]]
+labels=['LES TH theo e rate trac1','LES TH theo e rate trac2']
+title_user = TestCase+SubCase+LayerCase+' comp. theor. entr. rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e_theoretical.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.015, XMAX=0.03, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.003 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=3
+
+oplot, smoothed_e_rate_trac1_les, altitudes_LES/1000., psym=4
+oplot, smoothed_e_rate_trac2_les, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : THEORETICAL DETRAINMENT RATE FROM LES DATA
+; ZDZ STUFF REMOVED
+
+print, '........ PARAMETRIZED DETRAINMENT'
+
+theoretical_d_trac1_les = make_array(nz)
+theoretical_d_trac2_les = make_array(nz)
+
+FOR k=0, nz-1 DO BEGIN
+	theoretical_d_trac1_les(k) = MAX([detr_min,-afact*(betalpha/(1.+betalpha))*(smoothed_buoyancy_trac1_les(k)/((smoothed_w_mean1_les(k))^2.))])
+	theoretical_d_trac2_les(k) = MAX([detr_min,-afact*(betalpha/(1.+betalpha))*(smoothed_buoyancy_trac2_les(k)/((smoothed_w_mean2_les(k))^2.))])
+ENDFOR
+
+what_I_plot = [[theoretical_d_trac1_les],[theoretical_d_trac2_les]]
+labels=['LES TH theo d rate trac1','LES TH theo d rate trac2']
+title_user = TestCase+SubCase+LayerCase+' comp. theor. detr. rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d_theoretical.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.1, XMAX=0.1, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.01 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=2
+
+oplot, smoothed_d_rate_trac1_les, altitudes_LES/1000., psym=4
+;oplot, smoothed_d_rate_trac2_les, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : THEORETICAL E-D  RATE FROM LES DATA
+
+print, '........ PARAMETRIZED MASS FLUX DERIVATIVE'
+
+theoretical_dfdz_f_trac1_les = make_array(nz)
+theoretical_dfdz_f_trac2_les = make_array(nz)
+
+theoretical_dfdz_f_trac1_les = theoretical_e_trac1_les - theoretical_d_trac1_les
+theoretical_dfdz_f_trac2_les = theoretical_e_trac2_les - theoretical_d_trac2_les
+
+df_dz_f_les1 = make_array(nz)
+df_dz_f_les2 = make_array(nz)
+
+FOR k=0, nz-1 DO BEGIN
+	IF (smoothed_fm_trac1_les(k) ne 0.) THEN df_dz_f_les1(k) = df_dz_les1(k)/smoothed_fm_trac1_les(k) ELSE df_dz_f_les1(k)=0.
+        IF (smoothed_fm_trac2_les(k) ne 0.) THEN df_dz_f_les2(k) = df_dz_les2(k)/smoothed_fm_trac2_les(k) ELSE df_dz_f_les2(k)=0.
+ENDFOR
+
+what_I_plot = [[theoretical_dfdz_f_trac1_les],[theoretical_dfdz_f_trac2_les]]
+labels=['LES TH theo 1/f df/dz trac1','LES TH theo 1/f df/dz trac2']
+title_user = TestCase+SubCase+LayerCase+' comp. theor. entr. - detr. rate comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_dfdzf_theoretical.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.02, XMAX=0.02, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.01 , XTITLE='entr - detr (rates) m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+oplot, df_dz_f_les1, altitudes_LES/1000., psym=4
+oplot, df_dz_f_les2, altitudes_LES/1000., psym=5
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : e versus B/w2
+
+print, '........ EXTENDED TURBULENCE'
+
+buoyancy1_les_ude = grav*(tplume1moy/tenv1moy_ude -1.)
+;Gamma_full = buoyancy1_les_ude + Gamma_1 + Gamma_2 + Gamma_3
+Gamma_full = buoyancy1_les + Gamma_1 + Gamma_2 + Gamma_3
+;Gamma_full = buoyancy1_les + Gamma_1
+
+time_indices = [[lt_plotindex_les0],[lt_plotindex_les0a],[lt_plotindex_les],[lt_plotindex_lesa],[lt_plotindex_les2],[lt_plotindex_les2a],[lt_plotindex_les3]]
+ctime = [[lt_plot0],[lt_plot0a],[lt_plot],[lt_plota],[lt_plot2],[lt_plot2a],[lt_plot3]]
+
+openw, lun, "fit_ab_simple_thermiques_"+TestCase+SubCase+les_special, /get_lun
+printf, lun, "    a1     ", "     b1     ","     LT"
+FREE_LUN, lun
+close, lun
+
+openw, lun, "fit_ab_double_thermiques_"+TestCase+SubCase+les_special, /get_lun
+printf, lun, "    a1a     ", "     b1a     ", "      a1b     ", "     b1b     ","     LT"
+FREE_LUN, lun
+close, lun
+
+FOR ttt=0, n_elements(time_indices)-1 DO BEGIN
+
+smooth_t,input=Gamma_full,nz=nz,ndt=6,t0=time_indices(ttt),output=sm_Gamma_full
+smooth_t,input=buoyancy1_les,nz=nz,ndt=6,t0=time_indices(ttt),output=sm_buoyancy1_les
+smooth_t,input=Gamma_1,nz=nz,ndt=6,t0=time_indices(ttt),output=sm_Gamma_1
+smooth_t,input=Gamma_2,nz=nz,ndt=6,t0=time_indices(ttt),output=sm_Gamma_2
+smooth_t,input=Gamma_3,nz=nz,ndt=6,t0=time_indices(ttt),output=sm_Gamma_3
+smooth_t,input=w_mean1,nz=nz,ndt=6,t0=time_indices(ttt),output=sm_w_mean1
+smooth_t,input=full_d_rate_ude,nz=nz,ndt=6,t0=time_indices(ttt),output=sm_full_d_rate_ude
+
+www = where(w_mean1(*,time_indices(ttt))^2 ne 0.)
+nw=n_elements(www)
+
+Y=make_array(nw-4)
+X=make_array(nw-4)
+FOR zz=0, nw-5 DO BEGIN
+;        Y(zz) = Gamma_full(www(zz+2),lt_plotindex_les)/w_mean1(www(zz+2),lt_plotindex_les)^2
+;        X(zz) = buoyancy1_les(www(zz+2),lt_plotindex_les)/w_mean1(www(zz+2),lt_plotindex_les)^2
+
+; Approche Rio et al (2010)
+        Y(zz) = sm_Gamma_full(www(zz+2))/sm_w_mean1(www(zz+2))^2
+        X(zz) = sm_buoyancy1_les(www(zz+2))/sm_w_mean1(www(zz+2))^2
+
+; Approche Gregory et al (2001)
+;        Y(zz) = sm_Gamma_full(www(zz+2))/(sm_full_d_rate_ude(www(zz+2))*sm_w_mean1(www(zz+2))^2)
+;        X(zz) = sm_buoyancy1_les(www(zz+2))/(sm_full_d_rate_ude(www(zz+2))*sm_w_mean1(www(zz+2))^2)
+ENDFOR
+
+A = [2.5,-0.0015]
+
+err_gamma=make_array(nw-4,value=0.001)
+FOR zz=floor(nw/4.), nw-5 DO BEGIN
+        err_gamma(zz)=0.1
+ENDFOR
+
+coefs = lmfit(X,Y,A,/DOUBLE,function_name = 'myfunct', itmax = 500, measure_error = err_gamma)
+
+B = [2.5,-0.0015]
+
+err_gamma=make_array(nw-4,value=0.1)
+FOR zz=floor(nw/4.), floor(nw*3./4.-5) DO BEGIN
+        err_gamma(zz)=0.001
+ENDFOR
+
+coefs = lmfit(X,Y,B,/DOUBLE,function_name = 'myfunct', itmax = 500, measure_error = err_gamma)
+
+C = [1.5,-0.0010]
+
+err_gamma=make_array(nw-4,value=0.001)
+FOR zz=floor(nw*3./4.-5), nw-5 DO BEGIN
+        err_gamma(zz)=0.1
+ENDFOR
+
+coefs = lmfit(X,Y,C,/DOUBLE,function_name = 'myfunct', itmax = 1000, measure_error = err_gamma)
+
+openw, lun, 'fit_ab_simple_thermiques_'+TestCase+SubCase+les_special, /append
+printf, lun, C[0],C[1],ctime(ttt), format='((2x,F6.3)(4x,F9.6)(4x,I0))'
+close, lun
+
+openw, lun, 'fit_ab_double_thermiques_'+TestCase+SubCase+les_special, /append
+printf, lun, A[0],A[1],B[0],B[1],ctime(ttt), format='((2x,F6.3)(4x,F9.6)(4x,F6.3)(4x,F9.6)(4x,I0))'
+close, lun
+
+
+print, '~~~~~> LT: '+string(ctime(ttt))+' <~~~~~~~~~'
+print, 'suggested coefs for fit, a,b in alim layer:'
+print, A
+print, 'suggested coefs for fit, a,b above alim layer:'
+print, B
+print, 'suggested coefs for uniform fit, a,b:'
+print, C
+
+;what_I_plot = [[Gamma_full(*,lt_plotindex_les)],[buoyancy1_les_ude(*,lt_plotindex_les)],[Gamma_1(*,lt_plotindex_les)],[Gamma_2(*,lt_plotindex_les)],[Gamma_3(*,lt_plotindex_les)]]
+
+;what_I_plot = [[Gamma_full(*,lt_plotindex_les)],[buoyancy1_les(*,lt_plotindex_les)],[Gamma_1(*,lt_plotindex_les)],[Gamma_2(*,lt_plotindex_les)],[Gamma_3(*,lt_plotindex_les)]]
+
+what_I_plot = [[sm_Gamma_full(*)],[sm_buoyancy1_les(*)],[sm_Gamma_1(*)],[sm_Gamma_2(*)],[sm_Gamma_3(*)]]
+labels=['Tot','B','G1','G2','G3']
+title_user = TestCase+SubCase+LayerCase+' UDE turbulence term, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Gamma'+string(ctime(ttt),format='(I0)')+'.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.12, XMAX=0.12, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(5)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.03 , XTITLE='Gamma term m.s-2', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+
+oplot, -0.0015*w_mean1(*,lt_plotindex_les)^2, altitudes_LES/1000., psym=5, thick=0.05
+;oplot, 2.5*buoyancy1_les_ude(*,lt_plotindex_les), altitudes_LES/1000., psym=5, thick=0.05
+;oplot, 2.5*buoyancy1_les_ude(*,lt_plotindex_les)-0.0015*w_mean1(*,lt_plotindex_les)^2, altitudes_LES/1000., psym=4, thick=0.3
+;oplot, 2.5*buoyancy1_les(*,lt_plotindex_les), altitudes_LES/1000., psym=5, thick=0.05
+;oplot, 2.*buoyancy1_les(*,lt_plotindex_les)-0.0012*w_mean1(*,lt_plotindex_les)^2, altitudes_LES/1000., psym=4, thick=0.3
+oplot, 2.5*buoyancy1_les(*,lt_plotindex_les)-0.0015*w_mean1(*,lt_plotindex_les)^2, altitudes_LES/1000., psym=4, thick=0.3
+;oplot, A[0]*buoyancy1_les(*,lt_plotindex_les)+A[1]*w_mean1(*,lt_plotindex_les)^2, altitudes_LES/1000., thick=0.3
+;oplot, B[0]*buoyancy1_les(*,lt_plotindex_les)+B[1]*w_mean1(*,lt_plotindex_les)^2, altitudes_LES/1000., thick=0.3
+
+; Rio et al 2010 :
+oplot, A[0]*sm_buoyancy1_les(*)+A[1]*sm_w_mean1(*)^2, altitudes_LES/1000., thick=0.3
+oplot, B[0]*sm_buoyancy1_les(*)+B[1]*sm_w_mean1(*)^2, altitudes_LES/1000., thick=0.3
+oplot, C[0]*sm_buoyancy1_les(*)+C[1]*sm_w_mean1(*)^2, altitudes_LES/1000., thick=0.3, linestyle=2
+
+; Gregory et al 2001 :
+;oplot, A[0]*sm_buoyancy1_les(*)+A[1]*sm_full_d_rate_ude(*)*sm_w_mean1(*)^2, altitudes_LES/1000., thick=0.3
+;oplot, B[0]*sm_buoyancy1_les(*)+B[1]*sm_full_d_rate_ude(*)*sm_w_mean1(*)^2, altitudes_LES/1000., thick=0.3
+;oplot, C[0]*sm_buoyancy1_les(*)+C[1]*sm_full_d_rate_ude(*)*sm_w_mean1(*)^2, altitudes_LES/1000., thick=0.3, linestyle=2
+
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+ENDFOR
+
+print, ' ~~ comparing fit approaches :'
+
+a1_simple=[1.848,1.723,1.455,1.280,1.993,1.789,1.582,1.050]
+b1_simple=[-0.000842,-0.000511,-0.000251,-0.000329,-0.001473,-0.001081,-0.000129,-0.000453]
+a1a_double=[1.820,1.716,1.454,1.274,1.918,1.767,1.568,1.029]
+b1a_double=[0.000015,-0.000331,-0.000202,-0.000158, 0.001490,-0.000450, 0.000330, 0.000500]
+a1b_double=[3.145,2.067,1.222,1.792,4.506,3.071,2.581,0.679]
+b1b_double=[-0.001913,-0.000716,-0.000227,-0.000519,-0.005111,-0.001961,-0.000667,-0.000788]
+
+a1_simple=[1.993,1.870,1.789,1.811,1.582,1.565,1.050,1.607,1.494,1.415,1.508,1.523,1.267,1.266,2.008,1.840,1.683,1.732,1.676,1.577,1.348,1.849,1.933,1.757,1.767,1.659,1.608,1.529,1.992,1.918,1.748,1.737,1.605,1.384,0.083,1.848,1.745,1.723,1.598,1.455,1.473,1.280]
+
+b1_simple=[-0.001473,-0.001211,-0.001081,-0.000492,-0.000129,-0.000343,-0.000453,-0.001194,-0.000856,-0.000386,-0.000072,-0.000187,-0.000292,-0.000806,-0.001287,-0.000947,-0.000587,-0.000326,-0.000759,-0.000560, 0.000108,-0.001072,-0.001034,-0.000792,-0.000685,-0.000468,-0.000724,-0.000208,-0.000995,-0.000851,-0.000374,-0.000493,-0.000140,-0.000291,-0.000450,-0.000842,-0.000569,-0.000511,-0.000496,-0.000251,-0.000276,-0.000329]
+
+print, 'simple approach'
+print, 'mean a1 and mean b1'
+print, MEAN(a1_simple),MEAN(b1_simple)
+print, 'sigma'
+print, STDDEV(a1_simple),STDDEV(b1_simple)
+
+print, 'double approach'
+print, 'mean a1a,b1a,a1b,b1b'
+print, MEAN(a1a_double),MEAN(b1a_double),MEAN(a1b_double),MEAN(b1b_double)
+print, 'sigma'
+print, STDDEV(a1a_double),STDDEV(b1a_double),STDDEV(a1b_double),STDDEV(b1b_double)
+
+;aa1=2.5 & bb1=0.0015
+aa1=MEAN(a1_simple) & bb1=abs(MEAN(b1_simple))
+
+
+print, '........ BUOYANCY AND VERTICAL VELOCITY ENTRAINMENT RATE DEPENDENCY'
+
+B_w2_trac2 = make_array(nz)
+
+dwdz_trac1 = deriv(altitudes_LES,smoothed_w_mean1_les)
+;dwdz_trac2 = deriv(altitudes_LES,smoothed_w_mean2_les)
+full_dwdz_trac1 = make_array(nz,nttot)
+full_dadz_trac1 = make_array(nz,nttot)
+FOR l=0, nttot -1 DO BEGIN
+	full_dwdz_trac1(*,l) = deriv(altitudes_LES,w_mean1(*,l))
+	full_dadz_trac1(*,l) = deriv(altitudes_LES,alpha1out(*,l))
+ENDFOR
+;alpha = 0.
+
+;FOR zzz=0.,30 DO BEGIN
+
+;alpha = zzz/10.
+;
+;FOR k=0, nz-1 DO BEGIN
+;        IF (smoothed_e_rate_trac1_les(k) ne 0. and smoothed_w_mean1_les(k) ne 0.) THEN B_w2_trac1(k) = 0.5*(smoothed_buoyancy_trac1_les(k)/(smoothed_w_mean1_les(k))^2 - alpha*(1./smoothed_w_mean1_les(k))*dwdz_trac1(k)) ELSE B_w2_trac1(k)=0.
+;        IF (smoothed_e_rate_trac2_les(k) ne 0. and smoothed_w_mean2_les(k) ne 0.) THEN B_w2_trac2(k) = 0.5*(smoothed_buoyancy_trac2_les(k)/(smoothed_w_mean2_les(k))^2 - alpha*(1./smoothed_w_mean2_les(k))*dwdz_trac2(k)) ELSE B_w2_trac2(k)=0.
+;ENDFOR
+
+;print, smoothed_buoyancy_trac1_les(*)/(smoothed_w_mean1_les(*))^2
+;print, (1./smoothed_w_mean1_les(*))*dwdz_trac1(*)
+
+full_e1 = make_array(nz,nttot)
+full_bw2 = make_array(nz,nttot)
+FOR k=0, nz-1 DO BEGIN
+FOR l=0, nttot-1 DO BEGIN
+	if(fm_trac1_les(k,l) ne 0.) then full_e1(k,l)=(e1_term1_ude(k,l)+e1_term2_ude(k,l)+e1_term3_ude(k,l))/fm_trac1_les(k,l) else full_e1(k,l)=0.
+;        if(fm_trac1_les(k,l) ne 0.) then full_e1(k,l)=(e_trac1_les(k,l)+e1_term2(k,l)+e1_term3(k,l))/fm_trac1_les(k,l) else full_e1(k,l)=0.
+        if(w_mean1(k,l) ne 0.) then full_bw2(k,l)=grav*(tplume1moy(k,l)/tenv1moy_ude(k,l) -1.)/(w_mean1(k,l)^2) else full_bw2(k,l)=0.
+;        if(w_mean1(k,l) ne 0.) then full_bw2(k,l)=grav*(tplume1moy(k,l)/tenv1moy(k,l) -1.)/(w_mean1(k,l)^2) else full_bw2(k,l)=0.
+
+;        if(w_mean1(k,l) ne 0.) then full_bw2(k,l)=0.5*(alpha*buoyancy1_les(k,l)/(w_mean1(k,l)^2) - full_dwdz_trac1(k,l)/w_mean1(k,l)) else full_bw2(k,l)=0.
+ENDFOR
+ENDFOR
+
+;~~~~~~~~~~~~~~~ fit
+
+lt_plotindex_les3=fix(lt_plotindex_les3(0))
+lt_plotindex_les0=fix(lt_plotindex_les0(0))
+
+offset_fits=0
+IF (TestCase eq 'Case_Z') THEN BEGIN
+offset_fits =-10
+ENDIF
+
+nttotfit = lt_plotindex_les3+offset_fits - lt_plotindex_les0
+
+Gamma_w2=make_array(nz,nttotfit,value=0.)
+
+FOR ttt=0,nttotfit-1 DO BEGIN
+        www = where(w_mean1(*,ttt+lt_plotindex_les0) ne 0.)
+        if (www(0) eq -1 ) then print, 'AIE AIE AIE!'
+	Gamma_w2(www,ttt)=aa1*buoyancy1_les(www,ttt+lt_plotindex_les0)/(w_mean1(www,ttt+lt_plotindex_les0))^2 - bb1
+ENDFOR
+
+D_out=make_array(2,nttotfit)
+;D_out=make_array(3,nttotfit)
+
+print, 'begining fits :'
+print, lt_plotindex_les0, nttotfit, lt_plotindex_les3+offset_fits
+
+FOR ttt=0,nttotfit-1 DO BEGIN
+www = where(Gamma_w2(*,ttt) gt 0.)
+eee = where(full_e1(*,ttt+lt_plotindex_les0) gt 0.)
+nw = n_elements(www)
+nee = n_elements(eee)
+if (nw gt nee) then begin
+Y = make_array(nee)
+X = make_array(nee)
+smooth_t,input=full_e1(eee,*),nz=nee,ndt=6,t0=ttt+lt_plotindex_les0,output=Y
+Y = reform(full_e1(eee,ttt+lt_plotindex_les0))
+X = reform(Gamma_w2(eee,ttt))
+endif else begin
+Y = make_array(nw)
+X = make_array(nw)
+smooth_t,input=full_e1(www,*),nz=nw,ndt=6,t0=ttt+lt_plotindex_les0,output=Y
+Y = reform(full_e1(www,ttt+lt_plotindex_les0))
+X = reform(Gamma_w2(www,ttt))
+endelse
+D = [0.08,0.6]
+;D = [0.08,0.6,0.1]
+coefs = lmfit(X,Y,D,/DOUBLE,function_name = 'myfunct2', itmax = 500)
+;coefs = lmfit(X,Y,D,/DOUBLE,function_name = 'myfunct3', itmax = 500)
+D_out(*,ttt)=D
+ENDFOR
+
+openw, lun, "fit_power_epsilon_AB_thermiques_"+TestCase+SubCase+les_special, /get_lun
+printf, lun, "   Ae    ","    Be"
+close, lun
+
+openw, lun, "fit_power_epsilon_AB_thermiques_"+TestCase+SubCase+les_special, /append
+for l=0, nttotfit-1 do printf, lun, D_out(0,l),D_out(1,l), format='((2x,F8.6)(4x,F8.6))'
+FREE_LUN, lun
+close, lun
+
+print, 'fits complete, output in fit_power_epsilon_AB_thermiques_'+TestCase+SubCase+les_special
+
+print, 'power approach'
+print, 'mean Ae and mean Be'
+print, MEAN(D_out(0,*)),MEAN(D_out(1,*))
+print, 'sigma'
+print, STDDEV(D_out(0,*)),STDDEV(D_out(1,*))
+
+;what_I_plot = smoothed_e_rate_ude_trac1_les
+what_I_plot = smoothed_e_rate_trac1_les
+labels=['e_rate trac1']
+title_user = TestCase+SubCase+LayerCase+' LES UDE entrainment rate dep with B/w2, average over '+taverage+' mn,' 
+;filename = TestCase+SubCase+LayerCase+string(alpha,format='(F3.1)')+'Gcm_Les_Comp_e_Bw2.ps'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e_Bw2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=0.2, YMIN=0., YMAX=0.1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, Y=what_I_plot, X=B_w2_trac1, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30, SYM=5, /NOLINES
+AXES, XSTEP = 0.05 , XTITLE='B/w2', YSTEP=0.05, YTITLE='Entrainement rate m-1',NDECS=4
+
+;oplot, smoothed_e_rate_trac2_les, B_w2_trac2, psym=5
+FOR l=lt_plotindex_les0, lt_plotindex_les3-1 DO BEGIN
+	oplot, full_bw2(*,l),full_e1(*,l),thick=0.05,psym=1
+ENDFOR
+;mean_full_e1 = make_array(nz) & mean_full_bw2 = make_array(nz)
+;FOR k=0, nz-1 DO BEGIN
+;	mean_full_e1(k) = MEAN(reform(full_e1(k,*)))
+;	mean_full_bw2(k) = MEAN(reform(full_bw2(k,*)))
+;ENDFOR
+;oplot, mean_full_e1, mean_full_bw2, thick=0.3, psym = 2,color=5
+;oplot, theoretical_e_trac1_les, B_w2_trac1,psym=2,thick=0.8,color=7
+oplot,B_w2_trac1,(B_w2_trac1)/2.2222 + 0.0005,thick=0.3,color=7
+;oplot, 0.0118*(B_w2_trac1/0.043)^(1./1.65),B_w2_trac1,thick=0.3,color=7
+FOR l=lt_plotindex_les0, lt_plotindex_les3+offset_fits-1 DO BEGIN
+;oplot, full_bw2(*,l),0.012*(full_bw2(*,l)/0.048)^(1./1.60),thick=0.1,color=7,psym=1
+
+;oplot, full_bw2(*,l),0.04*(2.5*full_bw2(*,l))^(0.5)-0.0015,thick=0.1,color=7,psym=1
+;oplot, full_bw2(*,l),0.045*(aa1*full_bw2(*,l)-bb1)^(0.6),thick=0.1,color=7,psym=1     ;entrainment formulation,baseline for a=2.5 & b=0.0015
+
+;oplot, full_bw2(*,l),0.06*(aa1*full_bw2(*,l)-bb1)^(0.6),thick=0.1,color=7,psym=1
+oplot, full_bw2(*,l),0.06*(aa1*full_bw2(*,l))^(0.75),thick=0.1,color=6,psym=1     ;detrainment formulation
+
+oplot, full_bw2(*,l),MEAN(D_out(0,*))*(aa1*full_bw2(*,l)-bb1)^(MEAN(D_out(1,*))),thick=0.1,color=7,psym=1
+
+
+ENDFOR
+beta1=0.15
+
+;FOR l=0, nttot-1 DO BEGIN
+;;oplot, full_bw2(*,l),beta1*(2.5*full_bw2(*,l) - 0.0015)/(1.+beta1*(1.-w_mean1_env(*,l)/w_mean1(*,l))),thick=0.1,color=5,psym=1
+;oplot, full_bw2(*,l),beta1*(2.5*full_bw2(*,l) - 0.0015)/(1.+beta1),thick=0.1,color=5,psym=1    ; earth formulation
+;ENDFOR
+
+;oplot, alog((B_w2_trac1 - 0.000942361)/0.0444855) - 3.85453, B_w2_trac1, thick=0.3,color=7
+
+;print, alog((B_w2_trac1)/0.0444855) - 3.85453
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+;ENDFOR
+
+what_I_plot = full_bw2(*,lt_plotindex_les)
+labels=['B/w2']
+title_user = TestCase+SubCase+LayerCase+' LES UDE B/w2, average over '+taverage+' mn,'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Bw2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.01, XMAX=0.01, YMIN=0., YMAX=6., TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.002 , XTITLE='B/w2 term in LES UDE', YSTEP=0.5, YTITLE='Altitude (km)',NDECS=4
+
+;FOR l=0, nttot-1 DO BEGIN
+;        oplot, full_bw2(*,l),altitudes_LES/1000.,thick=0.05,psym=1
+;ENDFOR
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+print, '........ BUOYANCY AND VERTICAL VELOCITY DETRAINMENT RATE DEPENDENCY'
+
+full_d1 = make_array(nz,nttot)
+full_dSiebesma = make_array(nz,nttot)
+
+
+FOR k=0, nz-1 DO BEGIN
+FOR l=0, nttot-1 DO BEGIN
+        if(fm_trac1_les(k,l) ne 0.) then full_d1(k,l)=(d1_term1_ude(k,l)+d1_term2_ude(k,l)+d1_term3_ude(k,l))/fm_trac1_les(k,l) else full_d1(k,l)=-0.
+;        if(fm_trac1_les(k,l) ne 0.) then full_d1(k,l)=(d1_term1(k,l)+d1_term2(k,l)+d1_term3(k,l))/fm_trac1_les(k,l) else full_d1(k,l)=-0.
+        if(w_mean1(k,l) ne 0.) then full_dSiebesma(k,l)=0.75*0.5*buoyancy1_les(k,l)/(w_mean1(k,l)^2) -1.5*full_dwdz_trac1(k,l)/w_mean1(k,l) - full_dadz_trac1(k,l)/alpha1out(k,l) else full_dSiebesma(k,l)=-0.
+ENDFOR
+ENDFOR
+
+;what_I_plot = smoothed_d_rate_ude_trac1_les
+what_I_plot = smoothed_d_rate_trac1_les
+labels=['d_rate trac1']
+title_user = TestCase+SubCase+LayerCase+' LES UDE detrainment rate dep with B/w2, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d_Bw2.ps'
+;filename = TestCase+SubCase+LayerCase+string(alpha,format='(F3.1)')+'Gcm_Les_Comp_d_Bw2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.1, XMAX=0.1, YMIN=0., YMAX=0.1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, Y=what_I_plot, X=full_bw2(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30, SYM=5, /NOLINES
+AXES, XSTEP = 0.05 , XTITLE='B/w2', YSTEP=0.05, YTITLE='Detrainment rate',NDECS=4
+
+FOR l=0, nttot-1 DO BEGIN
+        oplot, full_bw2(*,l),full_d1(*,l),thick=0.05,psym=1
+ENDFOR
+;oplot, theoretical_d_trac1_les, full_bw2(*,lt_plotindex_les),psym=2,thick=0.8,color=7
+;oplot,B_w2_trac1/2.7 + 0.0002,B_w2_trac1,thick=0.3,color=7
+oplot,B_w2_trac1,B_w2_trac1/2.222 + 0.0002,thick=0.3,color=7
+FOR l=0, nttot-1 DO BEGIN
+oplot, full_bw2(*,l),0.06*(2.5*full_bw2(*,l))^(0.75),thick=0.1,color=7,psym=1   ;detrainment formulation
+;oplot, full_bw2(*,l),0.045*(2.5*full_bw2(*,l)-0.0015)^(0.6),thick=0.1,color=6,psym=1   ;entrainment formulation
+ENDFOR
+FOR l=0, nttot-1 DO BEGIN
+oplot, full_bw2(*,l),0.06*(-2.5*full_bw2(*,l))^(0.75),thick=0.1,color=7,psym=1   ;detrainment formulation
+ENDFOR
+;a1=3.
+
+;FOR l=0, nttot-1 DO BEGIN
+;oplot, full_bw2(*,l),a1*(beta1/(1.+beta1))*full_bw2(*,l),thick=0.1,color=5,psym=1   ;earth formulation
+;ENDFOR
+
+;oplot, 0.0118*(B_w2_trac1/0.043)^(1./1.65),B_w2_trac1,thick=0.3,color=6
+oplot, B_w2_trac1,0.0105*(B_w2_trac1/0.048)^(1./1.7),thick=0.3,color=6
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+print, 'Detrainment : new approach '
+
+full_d1_v2 = make_array(nz,nttot)
+df_dz_les_full = make_array(nz,nttot)
+da_dt_les_full = make_array(nz,nttot)
+
+FOR k=0, nz-1 DO BEGIN
+        da_dt_les_full(k,*) = deriv(localtime,reform(alpha1out(k,*)))/3700.
+ENDFOR
+
+FOR l=0, nttot-1 DO BEGIN
+        df_dz_les_full(*,l) = deriv(altitudes_LES,reform(fm_trac1_les(*,l)))
+	FOR k=0, nz-1 DO BEGIN
+        	if(fm_trac1_les(k,l) ne 0.) then full_d1_v2(k,l)=full_e1(k,l) - df_dz_les_full(k,l)/fm_trac1_les(k,l) -(rho(k,l)/fm_trac1_les(k,l))*da_dt_les_full(k,l) else full_d1_v2(k,l)=0.
+;                if(fm_trac1_les(k,l) ne 0.) then full_d1_v2(k,l)=full_e1(k,l) - df_dz_les_full(k,l)/fm_trac1_les(k,l) else full_d1_v2(k,l)=0.
+	ENDFOR
+ENDFOR
+
+
+;; ~~~~~~~~~~~~~~~~~~~~ DETRAINMENT FIT
+
+;lt_plotindex_les3=fix(lt_plotindex_les3(0))
+;lt_plotindex_les0=fix(lt_plotindex_les0(0))
+
+offset_fits=0
+IF (TestCase eq 'Case_Z') THEN BEGIN
+offset_fits =-10
+ENDIF
+
+nttotfit = lt_plotindex_les3+offset_fits - lt_plotindex_les0
+
+B_w2_fits=make_array(nz,nttotfit,value=0.)
+
+FOR ttt=0,nttotfit-1 DO BEGIN
+        www = where(w_mean1(*,ttt+lt_plotindex_les0) ne 0.)
+        if (www(0) eq -1 ) then print, 'AIE AIE AIE!'
+;        B_w2_fits(www,ttt)=aa1*buoyancy1_les(www,ttt+lt_plotindex_les0)/(w_mean1(www,ttt+lt_plotindex_les0))^2
+         B_w2_fits(www,ttt)=buoyancy1_les(www,ttt+lt_plotindex_les0)/(w_mean1(www,ttt+lt_plotindex_les0))^2
+ENDFOR
+
+E_out=make_array(2,nttotfit)
+print, 'detrainment: begining fits :'
+print, lt_plotindex_les0, nttotfit, lt_plotindex_les3+offset_fits
+
+FOR ttt=0,nttotfit-1 DO BEGIN
+eee = where((full_d1_v2(*,ttt+lt_plotindex_les0) gt 0.) and (abs(B_w2_fits(*,ttt)) gt 0.001))
+nee = n_elements(eee)
+
+eee=eee(4:nee-1)
+nee = n_elements(eee)
+
+Y = make_array(nee)
+X = make_array(nee)
+
+smooth_t,input=full_d1_v2(eee,*),nz=nee,ndt=6,t0=ttt+lt_plotindex_les0,output=Y
+
+;Y = reform(full_d1_v2(eee,ttt+lt_plotindex_les0))
+X = reform(B_w2_fits(eee,ttt))
+
+E = [-0.38,0.0005]
+coefs = lmfit(X,Y,E,/DOUBLE,function_name = 'myfunct', itmax = 1000)
+E_out(*,ttt)=E
+ENDFOR
+
+openw, lun, "fit_lin_delta_AB_thermiques_"+TestCase+SubCase+les_special, /get_lun
+printf, lun, "   Ad    ","    Bd"
+close, lun
+
+openw, lun, "fit_lin_delta_AB_thermiques_"+TestCase+SubCase+les_special, /append
+for l=0, nttotfit-1 do printf, lun, E_out(0,l),E_out(1,l), format='((2x,F9.6)(4x,F9.6))'
+FREE_LUN, lun
+close, lun
+
+print, 'fits complete, output in fit_lin_delta_AB_thermiques_'+TestCase+SubCase+les_special
+
+print, 'delta: lin approach'
+print, 'mean Ad and mean Bd'
+print, MEAN(E_out(0,*)),MEAN(E_out(1,*))
+print, 'sigma'
+print, STDDEV(E_out(0,*)),STDDEV(E_out(1,*))
+
+;~~~~~~~~~~~
+
+
+;what_I_plot = smoothed_d_rate_ude_trac1_les
+what_I_plot = full_d1_v2(*,lt_plotindex_les)
+labels=['d_rate trac1']
+title_user = TestCase+SubCase+LayerCase+' LES UDE detrainment rate dep with B/w2, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d2_Bw2.ps'
+;filename = TestCase+SubCase+LayerCase+string(alpha,format='(F3.1)')+'Gcm_Les_Comp_d_Bw2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.1, XMAX=0.1, YMIN=0., YMAX=0.1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, Y=what_I_plot, X=full_bw2(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30, SYM=5, /NOLINES
+AXES, XSTEP = 0.01 , XTITLE='B/w2', YSTEP=0.01, YTITLE='Detrainment rate',NDECS=2
+
+FOR l=lt_plotindex_les0, lt_plotindex_les3+offset_fits-1 DO BEGIN
+        oplot, full_bw2(*,l),full_d1_v2(*,l),thick=0.05,psym=1
+ENDFOR
+;oplot, theoretical_d_trac1_les, full_bw2(*,lt_plotindex_les),psym=2,thick=0.8,color=7
+;oplot,B_w2_trac1/2.7 + 0.0002,B_w2_trac1,thick=0.3,color=7
+oplot,B_w2_trac1,B_w2_trac1/2.222 + 0.0002,thick=0.3,color=7
+FOR l=lt_plotindex_les0, lt_plotindex_les3+offset_fits-1 DO BEGIN
+
+oplot, full_bw2(*,l), MEAN(E_out(0,*))*full_bw2(*,l)+MEAN(E_out(1,*)),thick=0.1,color=7,psym=1    ;new detrainment formulation
+
+oplot, full_bw2(*,l), -0.45*full_bw2(*,l)+0.0005,thick=0.1,color=8,psym=1    ;new detrainment formulation
+
+;oplot, full_bw2(*,l),0.06*(2.5*full_bw2(*,l))^(0.75),thick=0.1,color=7,psym=1   ;detrainment formulation (classical)
+;oplot, full_bw2(*,l),0.045*(2.5*full_bw2(*,l)-0.0015)^(0.6),thick=0.1,color=6,psym=1   ;entrainment formulation
+ENDFOR
+;FOR l=0, nttot-1 DO BEGIN
+;oplot, full_bw2(*,l),0.06*(-2.5*full_bw2(*,l))^(0.75),thick=0.1,color=7,psym=1   ;detrainment formulation
+;ENDFOR
+;a1=3.
+
+;FOR l=0, nttot-1 DO BEGIN
+;oplot, full_bw2(*,l),a1*(beta1/(1.+beta1))*full_bw2(*,l),thick=0.1,color=5,psym=1   ;earth formulation
+;ENDFOR
+
+;oplot, 0.0118*(B_w2_trac1/0.043)^(1./1.65),B_w2_trac1,thick=0.3,color=6
+oplot, B_w2_trac1,0.0105*(B_w2_trac1/0.048)^(1./1.7),thick=0.3,color=6
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+
+;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mass flux derivative fits
+
+
+;offset_fits=0
+;IF (TestCase eq 'Case_Z') THEN BEGIN
+;offset_fits =-10
+;ENDIF
+
+;nttotfit = lt_plotindex_les3+offset_fits - lt_plotindex_les0
+
+full_d1_fits=make_array(nz,nttotfit,value=0.)
+
+
+full_1_f_dfdz = make_array(nz,nttot)
+
+FOR l=0, nttot-1 DO BEGIN
+FOR k=0,nz-1 DO BEGIN
+       IF (fm_trac1_les(k,l) GT 0.) THEN full_1_f_dfdz(k,l)=df_dz_les_full(k,l)/fm_trac1_les(k,l) ELSE full_1_f_dfdz(k,l)=0.
+ENDFOR
+ENDFOR	
+
+e_from_fit = make_array(nz,nttotfit)
+FOR l=0, nttotfit-1 DO BEGIN
+FOR k=0,nz-1 DO BEGIN
+	e_from_fit(k,l) = MEAN(D_out(0,*))*(MAX([0.,aa1*full_bw2(k,l+lt_plotindex_les0)-bb1]))^(MEAN(D_out(1,*)))
+ENDFOR
+ENDFOR
+
+
+FOR ttt=0,nttotfit-1 DO BEGIN
+        www = where(e_from_fit(*,ttt) gt full_1_f_dfdz(*,ttt+lt_plotindex_les0) )
+        if (www(0) eq -1 ) then print, 'AIE AIE AIE!'
+        full_d1_fits(www,ttt)=e_from_fit(www,ttt) - full_1_f_dfdz(www,ttt+lt_plotindex_les0)
+ENDFOR
+
+F_out=make_array(3,nttotfit)
+print, 'mass flux derivative: begining fits :'
+print, lt_plotindex_les0, nttotfit, lt_plotindex_les3+offset_fits
+
+FOR ttt=0,nttotfit-1 DO BEGIN
+;FOR ttt=3,nttotfit-4 DO BEGIN
+
+eee = where((full_d1_fits(*,ttt) gt 0.) and (altitudes_LES(*) gt 500.) and (B_w2_fits(*,ttt) gt 0.))
+fff = where((full_d1_fits(*,ttt) gt 0.) and (altitudes_LES(*) gt 500.) and (B_w2_fits(*,ttt) lt 0.))
+nee = n_elements(eee)
+nff = n_elements(fff)
+
+;eee=eee(floor(nee/4.):nee-1)
+;nee = n_elements(eee)
+
+Y1 = make_array(nee)
+X1 = make_array(nee)
+
+Y2 = make_array(nff)
+X2 = make_array(nff)
+
+;smooth_t,input=full_d1_v2(eee,*),nz=nee,ndt=6,t0=ttt+lt_plotindex_les0,output=Y
+
+Y1 = reform(full_d1_fits(eee,ttt))
+X1 = reform(B_w2_fits(eee,ttt))
+
+
+Y2 = reform(full_d1_fits(fff,ttt))
+X2 = reform(B_w2_fits(fff,ttt))
+
+;smooth_t,input=full_d1_fits(eee,*),nz=nee,ndt=4,t0=ttt,output=Y
+;smooth_t,input=B_w2_fits(eee,*),nz=nee,ndt=4,t0=ttt,output=X
+
+;F = [-0.38,0.0001]
+F = -0.5
+coefs = lmfit(X2,Y2,F,/DOUBLE,function_name = 'myfunct4', itmax = 1000)
+
+F_out(0,ttt)=MEAN(reform(Y1))
+;F_out(1:2,ttt)=F
+F_out(1,ttt)=F
+
+ENDFOR
+
+;openw, lun, "fit_lin_delta_on_f_AB_thermiques_"+TestCase+SubCase+les_special, /get_lun
+;printf, lun, "   Ada    ","    Ad    ","    Bd"
+;close, lun
+;
+;openw, lun, "fit_lin_delta_on_f_AB_thermiques_"+TestCase+SubCase+les_special, /append
+;for l=0, nttotfit-1 do printf, lun, F_out(0,l),F_out(1,l),F_out(2,l), format='((2x,F9.6)(4x,F9.6)(4x,F9.6))'
+;FREE_LUN, lun
+;close, lun
+
+openw, lun, "fit_lin_delta_on_f_AB_thermiques_"+TestCase+SubCase+les_special, /get_lun
+printf, lun, "   Ad    ","    Bd"
+close, lun
+
+openw, lun, "fit_lin_delta_on_f_AB_thermiques_"+TestCase+SubCase+les_special, /append
+for l=0, nttotfit-1 do printf, lun, F_out(0,l),F_out(1,l), format='((2x,F9.6)(4x,F9.6))'
+FREE_LUN, lun
+close, lun
+
+
+print, 'delta:lin approach'
+print, 'mean Ada and mean Ad, Bd'
+print, MEAN(F_out(0,*)),MEAN(F_out(1,*)) ;,MEAN(F_out(2,*))
+print, 'sigma'
+print, STDDEV(F_out(0,*)),STDDEV(F_out(1,*)) ;,STDDEV(F_out(2,*))
+
+what_I_plot = full_1_f_dfdz(*,lt_plotindex_les)
+labels=['TH mass flux vertical derivative']
+title_user = TestCase+SubCase+LayerCase+' mass flux vertical derivative comparison, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_1_f_dfdz.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.02, XMAX=0.02, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.005 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=6
+
+df_dz_from_param = make_array(nz)
+;FOR k=0, nz-1 DO BEGIN
+;	df_dz_from_param(k) = MEAN(D_out(0,*))*(MAX([0.,aa1*full_bw2(k,lt_plotindex_les)-bb1]))^(MEAN(D_out(1,*))) - MEAN(F_out(0,*))*full_bw2(k,lt_plotindex_les)+MEAN(F_out(1,*))
+;ENDFOR
+FOR k=0, nz-1 DO BEGIN
+       IF (full_bw2(k,lt_plotindex_les) gt 0.) THEN BEGIN
+       df_dz_from_param(k) = MEAN(D_out(0,*))*(MAX([0.,aa1*full_bw2(k,lt_plotindex_les)-bb1]))^(MEAN(D_out(1,*))) - MEAN(F_out(0,*))
+       ENDIF ELSE BEGIN
+;       df_dz_from_param(k) = MEAN(D_out(0,*))*(MAX([0.,aa1*full_bw2(k,lt_plotindex_les)-bb1]))^(MEAN(D_out(1,*))) - (MEAN(F_out(1,*))*full_bw2(k,lt_plotindex_les)+MEAN(F_out(2,*)))
+       df_dz_from_param(k) = MEAN(D_out(0,*))*(MAX([0.,aa1*full_bw2(k,lt_plotindex_les)-bb1]))^(MEAN(D_out(1,*))) - (MEAN(F_out(1,*))*full_bw2(k,lt_plotindex_les))
+       ENDELSE
+ENDFOR
+
+oplot, df_dz_from_param, altitudes_LES/1000., psym=5
+;oplot, df_dz_les1/smoothed_fm_trac1_les, altitudes_LES/1000., psym=4
+;oplot, df_dz_les2, altitudes_LES/1000., psym=5
+;oplot, df_dz_param, altitudes_LES/1000., psym=6, color=5
+;oplot, df_dz_param2, altitudes_LES/1000., psym=6, color=6
+;print, "fm*(e-d)"
+;print, smoothed_fm_trac1_les*(0.045*(2.5*B_w2_trac1-0.0015)^(0.6) - 0.06*(-2.5*B_w2_trac1)^(0.75))
+;print, smoothed_fm_trac1_les
+;print, B_w2_trac1
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+
+
+print, '........ BUOYANCY AND VERTICAL VELOCITY VERTICAL VELOCITY DERIVATIVE DEPENDANCY'
+
+full_dw2_w2 = make_array(nz,nttot)
+w2_mean1 = make_array(nz,nttot)
+dw2_dz = make_array(nz,nttot)
+w2_param = make_array(nz,nttot)
+FOR l=0, nttot-1 DO BEGIN
+	w2_mean1(*,l) = w_mean1(*,l)^2.
+	dw2_dz(*,l) = deriv(altitudes_LES,w2_mean1(*,l))
+ENDFOR
+FOR k=0, nz-1 DO BEGIN
+FOR l=0, nttot-1 DO BEGIN
+       if(w2_mean1(k,l) ne 0.) then begin 
+;       if(full_bw2(k,l) ge 0.) then full_dw2_w2(k,l) = 0.5*dw2_dz(k,l)/w2_mean1(k,l) + (1.-w_mean1_env_ude(k,l)/w_mean1(k,l))*0.012*(full_bw2(k,l)/0.048)^(1./1.6) else full_dw2_w2(k,l)=0.5*dw2_dz(k,l)/w2_mean1(k,l)
+;       if(full_bw2(k,l) ge 0.) then full_dw2_w2(k,l) = 0.5*dw2_dz(k,l)/w2_mean1(k,l) + (1.-w_mean1_env(k,l)/w_mean1(k,l))*0.009*(full_bw2(k,l)/0.048)^(1./1.9) else full_dw2_w2(k,l)=0.5*dw2_dz(k,l)/w2_mean1(k,l)
+        full_dw2_w2(k,l) = 0.5*dw2_dz(k,l)/w2_mean1(k,l); + (1.-w_mean1_env_ude(k,l)/w_mean1(k,l))*full_e1(k,l)
+       endif else begin 
+              full_dw2_w2(k,l)= 0.
+       endelse
+
+       if(w2_mean1(k,l) ne 0.) then begin
+;       if(full_bw2(k,l) ge 0.) then w2_param(k,l) = full_bw2(k,l)/6. - (0.014*(full_bw2(k,l)/0.05)^(1./1.35))/2. else w2_param(k,l) = full_bw2(k,l)/6. - full_d1(k,l)/2. 
+        w2_param(k,l) = 2.5*full_bw2(k,l) - 0.0015
+       endif else begin
+       w2_param(k,l)=0.
+       endelse
+;       if(w2_mean1(k,l) ne 0.) then w2_param(k,l) = full_bw2(k,l) else w2_param(k,l)=0.
+ENDFOR
+ENDFOR
+
+what_I_plot = full_dw2_w2(*,lt_plotindex_les)
+
+labels=['0.5*(dw2/dz)/w2']
+title_user = TestCase+SubCase+LayerCase+' LES w2 equation vs B/w2, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_w2_Bw2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, YMIN=-0.1, YMAX=0.1, XMIN=-0.1, XMAX=0.1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT,Y=what_I_plot, X=w2_param(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30, SYM=5, /NOLINES
+AXES, XSTEP = 0.1 , XTITLE='aB/w2 - b', YSTEP=0.1, YTITLE='0.5*(dw2/dz)/w2 + E/fm',NDECS=4
+
+FOR l=0, nttot-1 DO BEGIN
+        oplot, w2_param(*,l), full_dw2_w2(*,l),thick=0.05,psym=1
+ENDFOR
+oplot, w2_param(*,lt_plotindex_les),w2_param(*,lt_plotindex_les),thick=0.05,color=7
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; --- PLOTTING : 0.5*dwu2/dz
+print, '........ ///////////// starting local thermal model ///////////'
+
+print, ' -> alimentation'
+a_star = make_array(nz, value=0.)
+f_star = make_array(nz, value=0.)
+f_star(0) = 1.
+teta_est = make_array(nz, value=0.)
+teta_p = make_array(nz, value=0.)
+zw2 = make_array(nz,value=0.)
+w_est = make_array(nz,value=0.)
+entr_star = make_array(nz,value=0.)
+detr_star = make_array(nz,value=0.)
+zbuoy_est = make_array(nz,value=0.)
+zbuoy = make_array(nz,value=0.)
+a_star_tot = 0.
+
+zw2(1)= 0.4*0.3811552*2*grav*(teta_les(0,lt_plotindex_les)/teta_les(1,lt_plotindex_les) -1.)*approx_zdz_les(0)
+w_est(1) = zw2(1)
+FOR k=0, nz-2 DO BEGIN
+        if ((teta_les(k,lt_plotindex_les) GT (teta_les(k+1,lt_plotindex_les) +0.1)) AND (teta_les(0,lt_plotindex_les) GE teta_les(k,lt_plotindex_les))) then begin
+	a_star(k) = MAX([(teta_les(k,lt_plotindex_les)-teta_les(k+1,lt_plotindex_les)),0.])*sqrt(altitudes_LES(k))
+	a_star_tot = a_star_tot + a_star(k)
+        lalim = k+1.
+        endif
+ENDFOR
+FOR k=0, nz-1 DO BEGIN
+        a_star(k) = a_star(k)/a_star_tot
+ENDFOR
+print, 'alimentation :'
+;print, a_star
+f_star(0)=0.
+f_star(1) = a_star(0)
+teta_p(0) = teta_les(0,lt_plotindex_les)
+teta_est(0) = teta_les(0,lt_plotindex_les)
+print, ' -> plume'
+FOR k=1, nz-2 DO BEGIN
+	if (k LT lalim) then begin
+		teta_est(k) = (f_star(k)*teta_p(k-1)+a_star(k)*0.25*(teta_les(k,lt_plotindex_les) + teta_p(k-1)))/(f_star(k) + a_star(k))
+	endif else begin
+		teta_est(k) = teta_p(k-1)
+	endelse
+	zbuoy_est(k) = grav*(teta_est(k)/teta_les(k,lt_plotindex_les) -1.)
+	zw2fact=fact_epsilon*2.*approx_zdz_les(k)/(1.+betalpha)
+	zdw2=afact*zbuoy_est(k)/fact_epsilon
+;        w_est(k+1) = MAX([0.0001,exp(-zw2fact)*(w_est(k)-zdw2)+zdw2])
+        w_est(k+1) = MAX([0.0001,w_est(k)*(1.-2.*approx_zdz_les(k)*0.5)+2.*1.*approx_zdz_les(k)*zbuoy_est(k)])
+	if (w_est(k+1) lt 0.) then begin
+                w_est(k+1)=zw2(k)
+        endif
+	if (w_est(k+1) gt 0.001) then begin
+		entr_star(k)=f_star(k)*approx_zdz_les(k)*(betalpha/(1.+betalpha))*MAX([0.,afact*zbuoy_est(k)/w_est(k+1)])
+		detr_star(k)=f_star(k)*approx_zdz_les(k)*MAX([detr_min,-afact*(betalpha/(1.+betalpha))*zbuoy_est(k)/w_est(k+1)])
+	endif
+        if (k lt lalim) then begin
+          a_star(k)=max([a_star(k),entr_star(k)])
+          entr_star(k)=0.
+        endif
+	if (w_est(k+1) gt 0.001) then begin
+	f_star(k+1)=f_star(k)+a_star(k)+entr_star(k)-detr_star(k)
+	if (k lt lalim) then begin
+	teta_p(k)=(f_star(k)*teta_p(k-1)+(a_star(k)+entr_star(k))*0.5*(teta_p(k-1) + teta_les(k,lt_plotindex_les)))/(f_star(k+1)+detr_star(k))
+	endif else begin
+	teta_p(k)=(f_star(k)*teta_p(k-1)+(a_star(k)+entr_star(k))*teta_les(k,lt_plotindex_les))/(f_star(k+1)+detr_star(k))
+	endelse
+	zbuoy(k) = grav*(teta_p(k)/teta_les(k,lt_plotindex_les) -1.)
+        zw2fact=fact_epsilon*2.*approx_zdz_les(k)/(1.+betalpha)
+        zdw2=afact*zbuoy(k)/fact_epsilon
+;        zw2(k+1) = MAX([0.0001,exp(-zw2fact)*(zw2(k)-zdw2)+zdw2])
+        zw2(k+1) = MAX([0.0001,zw2(k)*(1.-2.*approx_zdz_les(k)*0.5)+2.*1.*approx_zdz_les(k)*zbuoy_est(k)])
+	endif
+ENDFOR
+print, ' -> done'
+
+print, '........ CHECKING VERTICAL VELOCITY FORMULATION'
+what_I_plot = make_array(nz,value=0.)
+what_I_overplot = make_array(nz,value=0.)
+FOR k=0, nz-2 DO BEGIN
+        what_I_plot(k) = 0.5*(sqrt(zw2(k)) + sqrt(zw2(k+1)))
+ENDFOR
+FOR k=0, nZmx-2 DO BEGIN
+        what_I_overplot(k) = 0.5*(zw2_lev(k,lt_plotindex_gcm) + zw2_lev(k+1,lt_plotindex_gcm))
+ENDFOR
+labels=['zw2 in les calc as in TH']
+title_user = TestCase+SubCase+LayerCase+' LES vertical velocity formulation check'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_w2_check.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=8., YMIN=0., YMAX=7, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1 , XTITLE='w2 in LES from TH calc m/s', YSTEP=1., YTITLE='Altitude (km)',NDECS=3
+
+oplot, w_mean1(*,lt_plotindex_les), altitudes_LES/1000.
+oplot, what_I_overplot, altitudes_GCM/1000.,psym =4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+print, '........ CHECKING TETA ESTIMATIONS FORMULATION'
+
+what_I_plot = [[teta_est],[teta_p],[tplume1moy(*,lt_plotindex_les)]]
+labels=['LES estimated teta','LES teta plume calc as in TH','LES teta plume']
+title_user = TestCase+SubCase+LayerCase+' LES estimated teta formulation check'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_teta_check.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=214., XMAX=220., YMIN=0., YMAX=7, TITLE=title_user
+cols=INDGEN(3)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1 , XTITLE='Teta plume and Est in LES from TH calc K', YSTEP=1., YTITLE='Altitude (km)',NDECS=3
+
+oplot, teta_gcm(*,lt_plotindex_gcm)*(buoyancy_gcm(*,lt_plotindex_gcm)/grav +1.), altitudes_GCM/1000.
+oplot, teta_gcm(*,lt_plotindex_gcm)*(buoyancy_est_gcm(*,lt_plotindex_gcm)/grav +1.), altitudes_GCM/1000.
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+print, '........ CHECKING MASS FLUX FORMULATION'
+
+what_I_plot = [[f_star/MAX(f_star)],[smoothed_fm_trac1_les(*,lt_plotindex_les)/MAX(smoothed_fm_trac1_les(*,lt_plotindex_les))]]
+labels=['LES normalized f_star ','LES normalized updraft mass flux']
+title_user = TestCase+SubCase+LayerCase+' LES normalized f_star formulation check'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fm_check.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0., XMAX=1., YMIN=0., YMAX=7, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.1 , XTITLE='f*/max(f*) in LES from TH calc', YSTEP=1., YTITLE='Altitude (km)',NDECS=3
+
+oplot,fm_therm_gcm_interlay(*,lt_plotindex_gcm)/MAX(fm_therm_gcm_interlay(*,lt_plotindex_gcm)), altitudes_GCM/1000.,psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; COMPUTING THE CONTINUITY EQUATION IN THE QUASI-BOUSSINESQ APPROX
+
+da_dt = make_array(nz,n_elements(localtime))
+smoothed_da_dt = make_array(nz)
+FOR k=0, nz-1 DO BEGIN
+	da_dt(k,*) = deriv(localtime,reform(alpha1out(k,*)))/3700.
+ENDFOR
+FOR t=-ns,ns DO BEGIN
+        smoothed_da_dt = smoothed_da_dt + REFORM(da_dt(*,lt_plotindex_les+t))
+ENDFOR
+smoothed_da_dt = smoothed_da_dt/nstot
+
+smoothed_rho = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_rho = smoothed_rho + REFORM(rho(*,lt_plotindex_les+t))
+ENDFOR
+smoothed_rho = smoothed_rho/nstot
+
+;continuity1 = smoothed_rho*smoothed_da_dt + df_dz_les1 - smoothed_e_rate_ude_trac1_les*smoothed_fm_trac1_les + smoothed_d_rate_ude_trac1_les*smoothed_fm_trac1_les
+continuity1 = smoothed_rho*smoothed_da_dt + df_dz_les1 - smoothed_e_rate_trac1_les*smoothed_fm_trac1_les + smoothed_d_rate_trac1_les*smoothed_fm_trac1_les
+
+print, '........ CONTINUITY CHECK'
+
+;what_I_plot = [[continuity1],[smoothed_rho*smoothed_da_dt],[df_dz_les1],[-smoothed_e_rate_ude_trac1_les*smoothed_fm_trac1_les],[smoothed_d_rate_ude_trac1_les*smoothed_fm_trac1_les]]
+what_I_plot = [[continuity1],[smoothed_rho*smoothed_da_dt],[df_dz_les1],[-smoothed_e_rate_trac1_les*smoothed_fm_trac1_les],[smoothed_d_rate_trac1_les*smoothed_fm_trac1_les]]
+labels=['total continuity','rho*da/dt','df/dz','-E','D']
+title_user = TestCase+SubCase+LayerCase+' LES UDE continuity check, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_continuity.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.0001, XMAX=0.0001, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(5)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30 
+AXES, XSTEP = 0.00001 , XTITLE='kg.m-2.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; COMPUTING THE E-D TERM FROM THE CONTINUITY EQUATION
+
+eminusd1=make_array(nz)
+FOR k=0, nz-1 DO BEGIN
+	IF(smoothed_fm_trac1_les(k) ne 0.) THEN eminusd1(k) = (smoothed_rho(k)*smoothed_da_dt(k) - df_dz_les1(k))/smoothed_fm_trac1_les(k) ELSE eminusd1(k)=0.
+ENDFOR
+what_I_plot = eminusd1
+labels=['e-d']
+title_user = TestCase+SubCase+LayerCase+' LES e-d, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_EminusD.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-0.002, XMAX=0.002, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.0005 , XTITLE='kg.m-2.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; COMPUTING THE TURBULENT FLUX DECOMPOSITION IN PASSIVE ENV AND ACTIVE PLUME
+; TO CHECK CONSISTENCY
+
+print, '........ CHECKING CONSISTENCY OF UPDRAFT/ENV DECOMPOSITION'
+
+smoothed_hf1_term1 = make_array(nz)
+smoothed_hf1_term2 = make_array(nz)
+smoothed_hf1_term3 = make_array(nz)
+smoothed_wt = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+	smoothed_hf1_term1 = smoothed_hf1_term1 + REFORM(hf1_term1(*,lt_plotindex_les+t))
+	smoothed_hf1_term2 = smoothed_hf1_term2 + REFORM(hf1_term2(*,lt_plotindex_les+t))
+	smoothed_hf1_term3 = smoothed_hf1_term3 + REFORM(hf1_term3(*,lt_plotindex_les+t))
+	smoothed_wt = smoothed_wt + REFORM(wt(*,lt_plotindex_les+t))
+ENDFOR
+smoothed_hf1_term1 = smoothed_hf1_term1/nstot
+smoothed_hf1_term2 = smoothed_hf1_term2/nstot
+smoothed_hf1_term3 = smoothed_hf1_term3/nstot
+smoothed_wt = smoothed_wt/nstot
+
+what_I_plot = [[smoothed_hf1_term1],[smoothed_hf1_term2],[smoothed_hf1_term3],[smoothed_hf1_term1+smoothed_hf1_term2+smoothed_hf1_term3]]
+labels=['within plume turbulence','within env. turbulence','organized turbulence','TOTAL']
+title_user = TestCase+SubCase+LayerCase+' LES turbulence decomposition check, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_turbu.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=1.5, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.5 , XTITLE='m.K/s', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+oplot, smoothed_wt, altitudes_LES/1000.,psym=3
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+
+; COMPUTING THE TURBULENT FLUX DECOMPOSITION IN PASSIVE ENV ,ACTIVE PLUME and ACTIVE DOWNDRAFT
+; TO CHECK CONSISTENCY
+
+print, '........ CHECKING CONSISTENCY OF UPDRAFT/DOWNDRAFT/ENV DECOMPOSITION'
+
+smoothed_hf1_ude_term1 = make_array(nz)
+smoothed_hf1_ude_term2 = make_array(nz)
+smoothed_hf1_ude_term3 = make_array(nz)
+smoothed_hf1_ude_term4 = make_array(nz)
+FOR t=-ns,ns DO BEGIN
+        smoothed_hf1_ude_term1 = smoothed_hf1_ude_term1 + REFORM(hf1_ude_term1(*,lt_plotindex_les+t))
+        smoothed_hf1_ude_term2 = smoothed_hf1_ude_term2 + REFORM(hf1_ude_term2(*,lt_plotindex_les+t))
+        smoothed_hf1_ude_term3 = smoothed_hf1_ude_term3 + REFORM(hf1_ude_term3(*,lt_plotindex_les+t))
+        smoothed_hf1_ude_term4 = smoothed_hf1_ude_term4 + REFORM(hf1_ude_term4(*,lt_plotindex_les+t))
+ENDFOR
+smoothed_hf1_ude_term1 = smoothed_hf1_ude_term1/nstot
+smoothed_hf1_ude_term2 = smoothed_hf1_ude_term2/nstot
+smoothed_hf1_ude_term3 = smoothed_hf1_ude_term3/nstot
+smoothed_hf1_ude_term4 = smoothed_hf1_ude_term4/nstot
+
+what_I_plot = [[smoothed_hf1_ude_term1],[smoothed_hf1_ude_term2],[smoothed_hf1_ude_term3],[smoothed_hf1_ude_term4],[smoothed_hf1_ude_term1+smoothed_hf1_ude_term2+smoothed_hf1_ude_term3+smoothed_hf1_ude_term4]]
+labels=['within plume turbulence','within downdraft turbulence','within env. turbulence','organized turbulence','TOTAL']
+title_user = TestCase+SubCase+LayerCase+' LES UDE turbulence decomposition check, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_turbu_ude.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=1.5, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(5)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.25 , XTITLE='m.K/s', YSTEP=0.5, YTITLE='Altitude (km)',NDECS=3
+oplot, smoothed_wt, altitudes_LES/1000.,psym=3
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+print, '........ UDE TRANSPORT : Q'
+
+what_I_plot = [[wq(*,lt_plotindex_les)],[wq_updraft(*,lt_plotindex_les)],[wq_downdraft(*,lt_plotindex_les)]]
+
+labels=['total turbulent transport','within updraft turbulent transport','within downdraft turbulent transport']
+title_user = TestCase+SubCase+LayerCase+' LES UDE turbulence Q transport, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Qturbu_ude.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=1.5, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(3)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.25 , XTITLE='m.K/s', YSTEP=0.5, YTITLE='Altitude (km)',NDECS=3
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+
+
+; CHECK CONSISTENCY OF We = W and THETA e = THETA approximation
+
+print, '........ CHECKING CONSISTENCY OF env variable (w_e,theta_e) = mean variable (w_overbar,theta_overbar)'
+print, 'as well as mean(w) = 0, in the UDE decomposition'
+
+smoothed_delta_theta_ude = make_array(nz)
+smoothed_delta_w_ude = make_array(nz)
+smoothed_w_mean1_full = make_array(nz)
+
+FOR t=-ns,ns DO BEGIN
+        smoothed_delta_theta_ude = smoothed_delta_theta_ude + REFORM(w_mean1_env_ude(*,lt_plotindex_les+t)-w_mean1_full(*,lt_plotindex_les+t))
+        smoothed_delta_w_ude = smoothed_delta_w_ude + REFORM(tenv1moy_ude(*,lt_plotindex_les+t)-tmoy_full(*,lt_plotindex_les+t))
+        smoothed_w_mean1_full = smoothed_w_mean1_full + REFORM(w_mean1_full(*,lt_plotindex_les+t))
+ENDFOR
+
+smoothed_delta_theta_ude = smoothed_delta_theta_ude/nstot
+smoothed_delta_w_ude = smoothed_delta_w_ude/nstot
+smoothed_w_mean1_full = smoothed_w_mean1_full/nstot
+
+what_I_plot = [[smoothed_delta_theta_ude],[smoothed_delta_w_ude],[smoothed_w_mean1_full]]
+labels=['theta env_ude - theta moy','w env_ude - w moy','mean w over domain (*,*,k)']
+title_user = TestCase+SubCase+LayerCase+' LES UDE env/mean approximation check, average over '+taverage+' mn'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_approx_ude.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-2, XMAX=2, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(3)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.5 , XTITLE='(m/s) and (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; GETTING SOME INSIGHT ON PLUME'S INSIDE TEMPERATURES
+
+print, '........ STRUCTURE POTENTIAL TEMPERATURES'
+xmin = 210
+xmax = 220
+if (TestCase eq 'Case_Z') then begin
+xmin = 260
+xmax = 270
+endif
+ztva = teta_gcm*(buoyancy_gcm/grav +1.)
+ztva_est = teta_gcm*(buoyancy_est_gcm/grav +1.)
+what_I_plot = [[tplume1moy(*,lt_plotindex_les)],[tenv1moy(*,lt_plotindex_les)],[teta_les(*,lt_plotindex_les)]]
+labels=['Teta updraft','Teta env ','Teta moy']
+title_user = TestCase+SubCase+LayerCase+' LES Teta in the structures, no average'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fullTeta.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(3)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1 , XTITLE='Potential Temperature (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+oplot, ztva(*,lt_plotindex_gcm), altitudes_GCM/1000., thick=0.3
+oplot, ztva_est(*,lt_plotindex_gcm), altitudes_GCM/1000., thick=0.3
+oplot, teta_gcm(*,lt_plotindex_gcm), altitudes_GCM/1000., thick=0.3
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+
+print, '........ UDE STRUCTURE POTENTIAL TEMPERATURES'
+
+what_I_plot = [[tplume1moy(*,lt_plotindex_les)],[tdown1moy(*,lt_plotindex_les)],[tenv1moy_ude(*,lt_plotindex_les)],[teta_les(*,lt_plotindex_les)]]
+labels=['Teta updraft','Teta downdraft','Teta env (UDE)','Teta moy']
+title_user = TestCase+SubCase+LayerCase+' LES UDE Teta in the structures, no average'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fullTeta_ude.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=210, XMAX=220, YMIN=0, YMAX=6, TITLE=title_user
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1 , XTITLE='Potential Temperature (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; -----------------------------------------------------------------------------------------------------------------------
+; End of PLUME diagnostics
+; -----------------------------------------------------------------------------------------------------------------------
+
+; *** TKE ***
+
+print, '........ TKE'
+
+what_I_plot = reform(tke_gcm(*,lt_plotindex_gcm))
+labels=['TH tke 1d']
+title_user = TestCase+SubCase+LayerCase+' TKE comparison'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_tke.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=8, YMIN=0, YMAX=10, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='Turbulent kinetic energy (kg.m-3)', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+oplot, tke_les(*,lt_plotindex_les), altitudes_LES/1000., psym=4
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; *** HEAT FLUX ***
+
+print, '........ BL TOP'
+
+dteta_dz_les_full=make_array(nz,nttot)
+
+FOR l=0, nttot-1 DO BEGIN
+	dteta_dz_les_full(*,l)= deriv(altitudes_LES,reform(teta_les(*,l)))
+ENDFOR
+
+altindex=make_array(nttot,value=0)
+altboundary=make_array(nttot)
+
+altindex2=make_array(nttot,value=0)
+altboundary2=make_array(nttot)
+
+print, nttot
+FOR l=0, nttot-1 DO BEGIN
+ 
+        if (n_elements(where(wt(*,l) eq min(wt(*,l)))) eq 1) then begin
+	altindex(l)=where(wt(*,l) eq min(wt(*,l)))
+        endif
+        if (altindex(l) ne -1) then altboundary(l)=altitudes_LES(altindex(l))/1000.
+        if (l ne 0) then begin
+            if ((altboundary(l) gt 1.5*altboundary(l-1)) and (localtime(l) gt 10.)) then altboundary(l)=altboundary(l-1)
+        endif
+
+        if (n_elements(where(dteta_dz_les_full(*,l) eq max(dteta_dz_les_full(*,l)))) eq 1) then begin
+        altindex2(l)=where(dteta_dz_les_full(*,l) eq max(dteta_dz_les_full(*,l)))
+        endif
+        if (altindex2(l) ne -1) then altboundary2(l)=altitudes_LES(altindex2(l))/1000.
+
+ENDFOR
+FOR l=1, nttot-2 DO BEGIN
+     if (localtime(l) gt 10.) then begin
+     if ((altboundary2(l) gt 1.5*altboundary2(l-1)) and (altboundary2(l+1) lt 1.5*altboundary2(l-1))) then altboundary2(l)=(altboundary2(l-1)+altboundary2(l+1))/2.
+     if (altboundary2(l) gt 1.5*altboundary2(l-1)) then altboundary2(l)=altboundary2(l-1)
+     endif
+     if (localtime(l) gt 10.) then begin
+     if ((altindex2(l) gt 1.5*altindex2(l-1)) and (altindex2(l+1) lt 1.5*altindex2(l-1))) then altindex2(l)=(altindex2(l-1)+altindex2(l+1))/2.
+     if (altindex2(l) gt 1.5*altindex2(l-1)) then altindex2(l)=altindex2(l-1)
+     endif
+
+ENDFOR
+
+
+altboundary2 = SMOOTH(altboundary2,5,/EDGE_TRUNCATE)
+altboundary2 = SMOOTH(altboundary2,10,/EDGE_TRUNCATE)
+altindex2 = SMOOTH(altindex2,5,/EDGE_TRUNCATE)
+altindex2 = SMOOTH(altindex2,10,/EDGE_TRUNCATE)
+
+FOR l=0, nttot-1 DO BEGIN
+     if (localtime(l) gt 16.) then altboundary2(l)=0.
+     if ((localtime(l) lt 9.) or (localtime(l) gt 16.)) then altindex2(l)=0.
+ENDFOR
+
+what_I_plot = [[altboundary],[altboundary2]]
+
+labels=['LES Boundary Layer top from Heat flux minimum','LES Boundary Layer top grom Teta gradient']
+
+title_user = TestCase+SubCase+LayerCase+' LES boundary layer top'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Zi.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=0, YMAX=9, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=localtime, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time LES', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+;oplot,localtime_gcm,zi_gcm/1000.,thick=0.4,color=5
+oplot,localtime_gcm,altitudes_GCM(lmax_gcm)/1000.,thick=0.4,color=6
+
+
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+what_I_plot = [[altindex],[altindex2]]
+labels=['LES Boundary Layer top from Heat flux minimum','LES Boundary Layer top grom Teta gradient']
+title_user = TestCase+SubCase+LayerCase+' LES boundary layer top'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Ziindex.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=6, XMAX=18, YMIN=0, YMAX=400, TITLE=title_user
+cols=INDGEN(2)+2
+GPLOT, X=localtime, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='local time LES', YSTEP=10, YTITLE='Altitude (km)',NDECS=1
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+if (1 eq 1) then begin
+
+openw, lun, "input_zipbl", /get_lun
+for l=0, nttot-1 do printf, lun, altindex2(l),localtime(l), format='((2x,I0)(4x,F8.2))'
+FREE_LUN, lun
+close, lun
+
+endif
+
+print, '........ HEAT FLUX'
+
+lay_heatFlux_up = make_array(nZmx,nTmx)
+lay_heatFlux_down = make_array(nZmx,nTmx)
+
+FOR k=1, nZmx-1 DO BEGIN
+	lay_heatFlux_up(k,*) = 0.5*(heatFlux_up(k,*) + heatFlux_up(k-1,*))
+	lay_heatFlux_down(k,*) = 0.5*(heatFlux_down(k,*) + heatFlux_down(k-1,*))
+ENDFOR
+lay_heatFlux_up(0,*)=0.5*(heatFlux_up(0,*))
+lay_heatFlux_down(0,*)=0.5*(heatFlux_down(0,*))
+zkh_gcm_int = make_array(nZmx)
+
+FOR k=0, nZmx-2 DO BEGIN
+	zkh_gcm_int(k) = 0.5*(zkh(k,lt_plotindex_gcm) + zkh(k+1,lt_plotindex_gcm))
+ENDFOR
+MY_gcm = -zkh_gcm_int*(deriv(altitudes_GCM,reform(zh(*,lt_plotindex_gcm)))); - 0.025*max(lay_heatFlux_up(*,lt_plotindex_gcm)))
+
+
+;what_I_plot = [[lay_heatFlux_up(*,lt_plotindex_gcm)],[MY_gcm],[lay_heatFlux_up(*,lt_plotindex_gcm)+MY_gcm]]
+what_I_plot = [[lay_heatFlux_up(*,lt_plotindex_gcm)],[MY_gcm],[lay_heatFlux_down(*,lt_plotindex_gcm)],[lay_heatFlux_down(*,lt_plotindex_gcm)+lay_heatFlux_up(*,lt_plotindex_gcm)+MY_gcm]]
+
+;labels=['TH updraft heat flux','Mellor and Yamada gcm heat flux','Total']
+labels=['TH updraft heat flux','Mellor and Yamada gcm heat flux','TH downdraft heat flux','Total']
+
+title_user = TestCase+SubCase+LayerCase+' TH vertical heat flux'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_WT.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-2, XMAX=3, YMIN=0, YMAX=10, TITLE=title_user
+;cols=INDGEN(3)+2
+cols=INDGEN(4)+2
+GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='vertical turbulent heat flux', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+;hf1_ude_term4 = alpha1out*(w_mean1 - w_mean1_full)*(tplume1moy - tmoy_full) + beta1out*(w_mean1_down - w_mean1_full)*(tdown1moy - tmoy_full) + (1.- (alpha1out+beta1out))*(w_mean1_env_ude - w_mean1_full)*(tenv1moy_ude - tmoy_full)
+
+oplot, alpha1out(*,lt_plotindex_les)*(w_mean1(*,lt_plotindex_les) - w_mean1_full(*,lt_plotindex_les))*(tplume1moy(*,lt_plotindex_les) - tmoy_full(*,lt_plotindex_les)), altitudes_LES/1000., color=2
+
+oplot, beta1out(*,lt_plotindex_les)*(w_mean1_down(*,lt_plotindex_les) - w_mean1_full(*,lt_plotindex_les))*(tdown1moy(*,lt_plotindex_les) - tmoy_full(*,lt_plotindex_les)), altitudes_LES/1000.,color=6
+
+oplot, smoothed_hf1_ude_term4, altitudes_LES/1000., color = 5
+
+;oplot, smoothed_hf1_term1, altitudes_LES/1000.,thick=0.1,LINESTYLE = 5
+;oplot, smoothed_hf1_term2, altitudes_LES/1000.,color=2,thick=0.1,LINESTYLE = 5
+;oplot, smoothed_hf1_term3, altitudes_LES/1000.,color=8,thick=0.1,LINESTYLE = 5
+
+oplot, wt(*,lt_plotindex_les), altitudes_LES/1000. 
+
+;oplot, smoothed_hf1_term3(*,lt_plotindex_les), altitudes_LES/1000., psym=7
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+; *** TRACERS ***
+
+print, '........ TRACER FLUX'
+
+if (got_tracer_flux eq 'true') then begin
+
+what_I_plot = [[alpha1out(*,lt_plotindex_les)*wq_updraft(*,lt_plotindex_les)],[beta1out(*,lt_plotindex_les)*wq_downdraft(*,lt_plotindex_les)],[(1.-alpha1out(*,lt_plotindex_les)-beta1out(*,lt_plotindex_les))*wq_env_ude(*,lt_plotindex_les)],[alpha1out(*,lt_plotindex_les)*w_mean1(*,lt_plotindex_les)*(q_mean_up(*,lt_plotindex_les) - q_mean(*,lt_plotindex_les))+beta1out(*,lt_plotindex_les)*w_mean1_down(*,lt_plotindex_les)*(q_mean_down(*,lt_plotindex_les) - q_mean(*,lt_plotindex_les))],[wq(*,lt_plotindex_les)]]
+
+;labels=['TH updraft heat flux','Mellor and Yamada gcm heat flux','Total']
+labels=['LES updraft tracer flux','LES downdraft tracer flux','LES env tracer flux','LES organized structures tracer flux','Total']
+
+title_user = TestCase+SubCase+LayerCase+' LES vertical tracer flux'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_WQ.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=4, YMIN=0, YMAX=5, TITLE=title_user
+;cols=INDGEN(3)+2
+cols=INDGEN(5)+2
+GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 1, XTITLE='vertical turbulent tracer flux', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
+
+oplot, alpha1out(*,lt_plotindex_les)*w_mean1(*,lt_plotindex_les)*(q_mean_up(*,lt_plotindex_les) - q_mean(*,lt_plotindex_les)), altitudes_LES/1000., color=2,psym=2,thick=0.5
+oplot, beta1out(*,lt_plotindex_les)*w_mean1_down(*,lt_plotindex_les)*(q_mean_down(*,lt_plotindex_les) - q_mean(*,lt_plotindex_les)), altitudes_LES/1000., color=3,psym=2,thick=0.5
+
+
+;oplot, alpha1out(*,lt_plotindex_les)*(w_mean1(*,lt_plotindex_les) - w_mean1_full(*,lt_plotindex_les))*(tplume1moy(*,lt_plotindex_les) - tmoy_full(*,lt_plotindex_les)), altitudes_LES/1000., color=2
+
+;oplot, beta1out(*,lt_plotindex_les)*(w_mean1_down(*,lt_plotindex_les) - w_mean1_full(*,lt_plotindex_les))*(tdown1moy(*,lt_plotindex_les) - tmoy_full(*,lt_plotindex_les)), altitudes_LES/1000.,color=6
+
+;oplot, smoothed_hf1_ude_term4, altitudes_LES/1000., color = 5
+
+;oplot, smoothed_hf1_term1, altitudes_LES/1000.,thick=0.1,LINESTYLE = 5
+;oplot, smoothed_hf1_term2, altitudes_LES/1000.,color=2,thick=0.1,LINESTYLE = 5
+;oplot, smoothed_hf1_term3, altitudes_LES/1000.,color=8,thick=0.1,LINESTYLE = 5
+
+;oplot, wt(*,lt_plotindex_les), altitudes_LES/1000.
+
+;oplot, smoothed_hf1_term3(*,lt_plotindex_les), altitudes_LES/1000., psym=7
+
+PSCLOSE, /NOVIEW
+
+spawn, 'ps2png '+filename
+
+endif
+
+print, '........ TRACER PLOTS DEACTIVATED'
+
+; trying stuff 
+
+buoyancy_downdraft = grav*(tdown1moy/tenv1moy_ude-1.)
+lmix = make_array(nttot,value=-1.)
+altitudes_rel_LES = make_array(nz,nttot)
+FOR l=0, nttot-1 DO BEGIN
+;	kmax = where(w_mean1(*,l) eq max(w_mean1(*,l)))
+;	if (kmax(0) ne -1) then lmix(l) = altitudes_LES(kmax(0)) else lmix(l) = -1.
+;FOR k=nz-2, 1,-1 DO BEGIN
+;	if ((buoyancy_downdraft(k,l) gt 0.) and (buoyancy_downdraft(k-1,l) lt 0.)) then lmix(l) = 0.5*(altitudes_LES(k)+altitudes_LES(k+1))
+;ENDFOR
+FOR k=nz-2, 1,-1 DO BEGIN
+	if (tdown1moy(k,l) eq 0.) then lmix(l) = altitudes_LES(k)
+ENDFOR
+ENDFOR
+
+FOR l=0, nttot-1 DO BEGIN
+FOR k=0, nz-1 DO BEGIN
+	altitudes_rel_LES(k,l) = altitudes_LES(k)/lmix(l)
+ENDFOR
+ENDFOR
+
+print, '........ Teta down / Teta up in UDE'
+
+stuff2=tdown1moy/tenv1moy_ude
+
+what_I_plot = stuff2(*,lt_plotindex_les)
+labels=['Teta d/Teta env 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuff2.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0.992, XMAX=1.004, YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.002, XTITLE='Teta d/ Teta env', YSTEP=0.2, YTITLE='Altitude/zi ',NDECS=3
+
+FOR i=0,nttot-1 DO BEGIN
+	if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+;oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.075)/187.931 + 0.9977, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, (altitudes_rel_LES(*,lt_plotindex_les))/19.231 + 0.9938, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.075)/187.931 + 0.9982, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.60)/(-1333) + 1.00025, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+print, '........ Teta down / Teta up in UDE'
+
+stuff2=tdown1moy/tplume1moy
+
+what_I_plot = stuff2(*,lt_plotindex_les)
+labels=['Teta d/Teta u 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuff2.5.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=0.95, XMAX=1.1, YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.01, XTITLE='Teta d/ Teta u', YSTEP=0.2, YTITLE='Altitude/zi ',NDECS=3
+
+FOR i=0,nttot-1 DO BEGIN
+        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+;oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.075)/187.931 + 0.9977, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, (altitudes_rel_LES(*,lt_plotindex_les))/19.231 + 0.9938, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.60)/(-1333) + 1.00025, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+print, '........ B down / B up in UDE'
+
+stuff2 = (tdown1moy/tenv1moy_ude -1.)/(tplume1moy/tenv1moy_ude -1.)
+what_I_plot = stuff2(*,lt_plotindex_les)
+labels=['B down/B up 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff Bd/Bu'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuffBuBd.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-1, XMAX=1., YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.1, XTITLE='B down/ B up', YSTEP=0.1, YTITLE='Altitude/zi ',NDECS=1
+
+FOR i=0,nttot-1 DO BEGIN
+        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+;oplot, ((altitudes_rel_LES(*,lt_plotindex_les)-0.06)/0.839841)^2 - 0.3, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, ((altitudes_rel_LES(*,lt_plotindex_les)-0.06)/1.16847)^2 - 0.3, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.7)/1., altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, (altitudes_rel_LES(*,lt_plotindex_les))/0.08333333-1., altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+oplot, sqrt(altitudes_rel_LES(*,lt_plotindex_les)/0.122449)-1., altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+print, '........ F down / F up in UDE'
+
+stuff2 = downward_flux1/fm_trac1_les
+what_I_plot = stuff2(*,lt_plotindex_les)
+labels=['f down/f up 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff f down/f up'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stufffufd.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-8, XMAX=0.5, YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 0.5, XTITLE='f down/ f up', YSTEP=0.1, YTITLE='Altitude/zi ',NDECS=1
+
+FOR i=0,nttot-1 DO BEGIN
+        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.0149259)/0.00333)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.02)/0.006)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+
+print, '........ dFdz down / dzFdz up in UDE'
+stuff3=make_array(nz,nttot)
+FOR l=0, nttot-1 DO BEGIN
+	stuff3(*,l) = deriv(altitudes_LES,downward_flux1(*,l))/deriv(altitudes_LES,fm_trac1_les(*,l))
+ENDFOR
+what_I_plot = stuff3(*,lt_plotindex_les)
+labels=['dfdz down/dfdz up 12h']
+title_user = TestCase+SubCase+LayerCase+' TH trying stuff f down/f up'
+filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuffdfudfd.ps'
+PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+CS, SCALE=28
+GSET, XMIN=-30, XMAX=30, YMIN=0, YMAX=1, TITLE=title_user
+cols=INDGEN(1)+2
+GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+AXES, XSTEP = 5, XTITLE='dfdz down/ dfdz up', YSTEP=0.1, YTITLE='Altitude/zi ',NDECS=1
+
+FOR i=0,nttot-1 DO BEGIN
+        if(lmix(i) ne -1) then oplot, stuff3(*,i), altitudes_rel_LES(*,i), thick=0.1
+ENDFOR
+;oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.0149259)/0.00333)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+;oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.02)/0.006)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
+PSCLOSE, /NOVIEW
+spawn, 'ps2png '+filename
+;
+;what_I_plot = [[ar_col],[co2_col],[tke_col]] 
+;labels=['Ar deviation','Co2 deviation','TKE deviation']
+;title_user = TestCase+SubCase+' TH 1d tracer conservation'
+;filename = TestCase+SubCase+'Gcm_Les_Comp_tracer.ps'
+;PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
+;CS, SCALE=28
+;GSET, XMIN=localtime_gcm(0), XMAX=localtime_gcm(nTmx-1), YMIN=0, YMAX=2, TITLE=title_user
+;cols=INDGEN(3)+2
+;GPLOT, X=localtime_gcm, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
+;AXES, XSTEP = 2, XTITLE='Local time (h)', YSTEP=0.1, YTITLE='Tracer integrated column mass deviation from origin (%)',NDECS=1
+;
+;PSCLOSE, /NOVIEW
+;
+;spawn, 'ps2png '+filename
+;
+;title_user = TestCase+SubCase+' TH argon propagation from first layer'
+;PS_START, file = TestCase+SubCase+'Gcm_Les_Comp_Argon.ps'
+;
+;what_I_plot = transpose(ar(0:6,*))
+;
+;maxfield_init = 0.05
+;minfield_init = 0
+;pal=33
+;lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+;lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+;
+;section, $
+;        what_I_plot, $                          ; 2D field
+;        localtime_gcm, $                                ; horizontal coordinate
+;        altitudes_gcm(0:6), $                                ; altitude coordinate
+;        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+;        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+;;       minspace=minspace, $                    ; minimum value of space window (=0: calculate)
+;;       maxspace=maxspace, $                    ; maximum value of space window (=0: calculate)
+;;       overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+;;       overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+;;       overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+;;       colors=colors, $                        ; number of colors/levels (32 is default)
+;        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+;        title_axis=['Martian hour (h)','Height above ground (m)'], $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+;        ct=pal, $                               ; color table (33-rainbow is default)
+;;       topo=topography, $
+;        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;PS_END, /PNG
+;
+;INTERVAL_VOLUME, supermask1, 0.5, 1.,verts, conn
+;conn = TETRA_SURFACE(verts, conn)  
+;oRain = OBJ_NEW('IDLgrPolygon', verts, POLYGONS=conn, $  
+;   COLOR=[255,255,255], SHADING=1)  
+;XOBJVIEW, oRain, BACKGROUND=[150,200,255]
+
+;INTERVAL_VOLUME, supermask2, 0.5, 1.5,verts, conn
+;conn = TETRA_SURFACE(verts, conn)
+;oRain = OBJ_NEW('IDLgrPolygon', verts, POLYGONS=conn, $
+;   COLOR=[255,255,255], SHADING=1)
+;XOBJVIEW, oRain, BACKGROUND=[150,200,255]
+
+ENDELSE
+
+print, ''
+print, '........ ALL DONE'
+print, ''
+
+END
Index: trunk/UTIL/IDLplot/SPEC/LES/article_qjrms.inc
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/article_qjrms.inc	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/article_qjrms.inc	(revision 1185)
@@ -0,0 +1,67 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+saveplot        = './COMP_REAL_50m_145_145_201_12km/'
+setting         = 'REAL_50m_145_145_201_12km/'
+;cases          = ['case_A', 'case_B', 'case_C', 'case_I']
+;cases          = ['case_A', 'case_B', 'case_C', 'case_HIGH']
+cases          = ['case_A', 'case_B', 'case_C', 'case_I', 'case_HIGH']
+;cases          = ['case_A', 'case_B', 'case_C', 'case_I']
+paths           = setting + cases
+tttitle         = ['[case a]  T!Ds,max!N=284 K   h= -3.9  km' $
+                  ,'[case b]  T!Ds,max!N=280 K   h= -3.5  km' $
+                  ,'[case c]  T!Ds,max!N=279 K   h=+2.4 km' $
+                  ,'[case i]   T!Ds,max!N=279 K   h= -0.5  km' $
+                  ,'[case z]  T!Ds,max!N=268 K   h=+8.4 km' ]
+tttitles        = ['[a]  T!Ds,m!N=284 K   h= -3.9  km' $
+                  ,'[b]  T!Ds,m!N=280 K   h= -3.5  km' $
+                  ,'[c]  T!Ds,m!N=279 K   h=+2.4 km' $
+                  ,'[i]   T!Ds,m!N=279 K   h= -0.5  km' $
+                  ,'[z]  T!Ds,m!N=268 K   h=+8.4 km' ]
+shorttt         = ['a','b','c','i','z' ]
+
+
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        ;saveplot        = './COMP_case_C/'
+        ;setting        = [       $
+        ;;                'REAL_100m_145_145_201_15km/', $
+        ;;                'REAL_100m_101_101_201_15km/', $
+        ;;                'REAL_100m_101_101_151_15km/', $
+        ;;                'REAL_100m_73_73_201_15km/', $
+        ;;                'REAL_100m_73_73_151_15km/', $
+        ;;                      'REAL_100m_45_45_71_10km/', $
+        ;;                'REAL_100m_145_145_201_20km/', $
+        ;;                'REAL_100m_45_45_71_10km/', $
+        ;;                'REAL_100m_45_45_71_10km/', $
+        ;;;                'REAL_50m_201_201_201_12km/', $
+        ;;;                'REAL_50m_241_241_201_12km/', $
+        ;;'REAL_50m_181_181_201_12km/', $
+        ;;      'REAL_50m_145_145_251_10km/', $
+        ;;              'REAL_100m_145_145_101_12km/', $
+        ;;              'REAL_100m_241_241_151_15km/', $
+        ;'REAL_100m_181_181_201_15km/', $
+        ;                'REAL_50m_145_145_201_12km/'      $       ;;ref 
+        ;               ]
+        ;cases          = 'case_C'
+        ;paths           = setting + cases
+        ;;paths = [ paths, '/home/spiga/data/current3/']
+        ;tttitle = paths
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; pour les calculs des lois de similitude
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;saveplot        = './'
+;setting         = 'REAL_50m_145_145_201_12km/'
+;cases           = ['case_A', 'case_B', 'case_C', 'case_I']
+;;;cases           = ['case_C', 'case_B']
+;;cases           = ['case_B', 'case_C', 'case_HIGH']
+;cases           = ['case_A', 'case_B', 'case_C', 'case_I','case_HIGH']
+;paths           = setting + cases
+;;;paths = [ paths, './GUSEV/']
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;saveplot        = './'
+;paths = [ 'REAL_50m_145_145_201_12km/case_A', '/home/spiga/data/current3/']
+
+;;tttitle = paths
+
Index: trunk/UTIL/IDLplot/SPEC/LES/coeffhf
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/coeffhf	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/coeffhf	(revision 1185)
@@ -0,0 +1,30 @@
+;
+; @coeffhf
+;
+
+
+ye, r, t
+
+yeyeye = where(t le 0.3) & r0 = r[yeyeye] & t0 = t[yeyeye]
+
+rerr = replicate(1.e-10,n_elements(r0))
+start = [mean(r0), max(r0)-min(r0), (max(t0)-min(t0))*mean(r0)]
+expr = 'FONC1(X, P)'
+result = MPFITEXPR(expr,t0,r0,rerr,start)
+
+;plot, r, t, psym=5, yrange=[0,0.6] & oplot, fonc1(t, result), t
+
+yeyeye = where((t gt 0.3) and (t le 1.0)) & r0 = r[yeyeye] & t0 = t[yeyeye]
+;ye = LINFIT(t0,r0) & oplot, ye(1) * t + ye(0), t
+
+       ;;
+       ;; verif
+       ;;
+       ;lim=0.30 & zelim=(-3.85/alog(lim)+0.07*alog(lim))*exp(-4.61*lim)
+       ;up=1. & & zeup= - 1.55 * up + 1.27
+       ;slope = (zelim - zeup) / (lim - up) & ord = zeup - slope * up
+       ;t1 = findgen(101.)*lim/100. & param1 = (-3.85/alog(t1)+0.07*alog(t1))*exp(-4.61*t1)
+       ;t2 = lim + findgen(101.)*(1.0 - lim)/100. & param2 = slope * t2 + ord
+       ;plot, param1, t1, yrange=[0.,1.], xrange=[-0.5,1.] & oplot, param2, t2 & oplot, r, t, psym=5
+
+
Index: trunk/UTIL/IDLplot/SPEC/LES/coeffw
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/coeffw	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/coeffw	(revision 1185)
@@ -0,0 +1,20 @@
+;;#
+;;# @coeffw
+;;#
+
+ye2, r, t
+
+;;1.2
+yeyeye = where(t le 1.5) & r0 = r[yeyeye] & t0 = t[yeyeye]
+
+;;r0 = r & t0 = t
+
+rerr = replicate(1.e-10,n_elements(r0))
+start = [mean(r0), max(r0)-min(r0), (max(t0)-min(t0))*mean(r0)]
+start = [2.53,0.73,0]
+expr = 'FONC2(X, P)'
+result = MPFITEXPR(expr,t0,r0,rerr,start)
+
+plot, r, t, psym=5, yrange=[0,1.5] & oplot, fonc2(t, result), t
+;oplot, fonc2(t, [2.53,0.73,0.]), t
+
Index: trunk/UTIL/IDLplot/SPEC/LES/comp_hfx.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/comp_hfx.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/comp_hfx.pro	(revision 1185)
@@ -0,0 +1,10 @@
+restore, filename='case_B/addturb.dat'
+caseb=ustarm
+restore, filename='case_C/addturb.dat'
+casec=ustarm
+restore, filename='case_HIGH/addturb.dat'
+casez=ustarm
+plot, localtime, caseb
+oplot, localtime, casec, linestyle=2
+oplot, localtime, casez, linestyle=3
+
Index: trunk/UTIL/IDLplot/SPEC/LES/comp_ustarmax.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/comp_ustarmax.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/comp_ustarmax.pro	(revision 1185)
@@ -0,0 +1,45 @@
+
+PS_Start, FILENAME='ustarmax.ps'
+!P.Charsize = 1.2
+
+
+
+history_interval_s = 400.
+history_interval_s = 100.
+smoothampl=3700/history_interval_s
+smoothampl=0.  ;; no smooth
+;smoothampl=20.
+
+lev=1
+
+
+;restore, filename='REAL_50m_145_145_201_12km/case_A/addturb.dat'
+;ustarmaxye = SMOOTH(TEMPORARY(ustarmax), [smoothampl], /EDGE_TRUNCATE)
+;ustarmye = SMOOTH(TEMPORARY(ustarm), [smoothampl], /EDGE_TRUNCATE)
+;plot, localtime, ustarmaxye, yrange=[0.0,1.0], xtickinterval=1., ytickinterval=0.1, ytitle='m/s', xtitle='Local time (h)'
+;oplot, localtime, ustarmye
+
+restore, filename='REAL_50m_145_145_201_12km/case_B/addturb.dat'
+ustarmaxye = SMOOTH(TEMPORARY(ustarmax), [smoothampl], /EDGE_TRUNCATE)
+ustarmye = SMOOTH(TEMPORARY(ustarm), [smoothampl], /EDGE_TRUNCATE)
+plot, localtime, ustarmaxye, yrange=[0.0,1.2], xtickinterval=1., ytickinterval=0.1, ytitle='m/s', xtitle='Local time (h)'
+oplot, localtime, ustarmye
+
+restore, filename='REAL_50m_145_145_201_12km/case_C/addturb.dat'
+ustarmaxye = SMOOTH(TEMPORARY(ustarmax), [smoothampl], /EDGE_TRUNCATE)
+ustarmye = SMOOTH(TEMPORARY(ustarm), [smoothampl], /EDGE_TRUNCATE)
+oplot, localtime, ustarmaxye, linestyle=2
+oplot, localtime, ustarmye, linestyle=2
+
+;restore, filename='REAL_50m_145_145_201_12km/case_I/addturb.dat'
+;ustarmaxye = SMOOTH(TEMPORARY(ustarmax), [smoothampl], /EDGE_TRUNCATE)
+;oplot, localtime, ustarmaxye, linestyle=3
+
+;restore, filename='REAL_50m_145_145_201_12km/case_HIGH/addturb.dat'
+;ustarmaxye = SMOOTH(TEMPORARY(ustarmax), [smoothampl], /EDGE_TRUNCATE)
+;oplot, localtime, ustarmaxye, linestyle=4
+
+
+
+
+PS_END, /PNG
Index: trunk/UTIL/IDLplot/SPEC/LES/comp_velo.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/comp_velo.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/comp_velo.pro	(revision 1185)
@@ -0,0 +1,57 @@
+
+
+PS_Start, FILENAME='velmax.ps'
+!P.Charsize = 1.2
+
+
+history_interval_s = 400.
+history_interval_s = 100.
+smoothampl=3700/history_interval_s
+;smoothampl=0.  ;; no smooth
+;smoothampl=20.
+smoothampl=5.
+
+lev=1
+;lev=0 qu'il faut faire ???
+
+
+@report_tasi.inc
+
+
+
+
+;restore, filename='REAL_50m_145_145_201_12km/case_A/addturb.dat'
+restore, filename=saveplot+cases(0)+'/addturb.dat'
+restore, filename=saveplot+cases(0)+'/getturb.dat'
+print, h(lev)
+velmaxye = reform(velmax(lev,*))
+velmaxye = SMOOTH(TEMPORARY(velmaxye), [smoothampl], /EDGE_TRUNCATE)
+plot, localtime, velmaxye, $
+xrange=[8.,17.], xtickinterval=1., ytickinterval=2.0, $
+yrange=[0.,14.], ytitle='Horizontal velocity (m s!U-1!N)', xtitle='Local time (h)'
+
+;restore, filename='REAL_50m_145_145_201_12km/case_B/addturb.dat'
+restore, filename=saveplot+cases(1)+'/addturb.dat'
+restore, filename=saveplot+cases(1)+'/getturb.dat'
+print, h(lev)
+velmaxye = reform(velmax(lev,*))
+velmaxye = SMOOTH(TEMPORARY(velmaxye), [smoothampl], /EDGE_TRUNCATE)
+oplot, localtime, velmaxye, linestyle=1
+
+;restore, filename='REAL_50m_145_145_201_12km/case_C/addturb.dat'
+restore, filename=saveplot+cases(2)+'/addturb.dat'
+restore, filename=saveplot+cases(2)+'/getturb.dat'
+print, h(lev)
+velmaxye = reform(velmax(lev,*))
+velmaxye = SMOOTH(TEMPORARY(velmaxye), [smoothampl], /EDGE_TRUNCATE)
+oplot, localtime, velmaxye, linestyle=2
+
+;restore, filename='REAL_50m_145_145_201_12km/case_I/addturb.dat'
+restore, filename=saveplot+cases(3)+'/addturb.dat'
+restore, filename=saveplot+cases(3)+'/getturb.dat'
+print, h(lev)
+velmaxye = reform(velmax(lev,*))
+velmaxye = SMOOTH(TEMPORARY(velmaxye), [smoothampl], /EDGE_TRUNCATE)
+oplot, localtime, velmaxye, linestyle=3
+
+PS_END, /PNG
Index: trunk/UTIL/IDLplot/SPEC/LES/compturb.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/compturb.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/compturb.pro	(revision 1185)
@@ -0,0 +1,939 @@
+pro compturb
+saveps='true' & p0=610. & t0=220. & r_cp=1/4.4 & grav=3.72 & R=192.
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; grep frames_per_outfile */*/namelist.input
+history_interval_s = 100.
+smoothampl=3700/history_interval_s
+;smoothampl=10.
+;smoothampl=20.
+;smoothampl=4.
+smoothampl=0.
+smoothampl=5.
+;;;;;;;
+;
+; ATTENTION IL FAUT CHANGER LES VARIABLES A DEUX ENDROITS
+;
+;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;
+;;; SET HERE WHAT YOU WANT TO COMPARE
+;;;
+;@article_qjrms.inc
+@report_tasi.inc
+;;;
+;;;
+;;;
+
+
+;;;
+;;; TWEAKS
+;;;
+;SPAWN, 'cp compturb.pro '+saveplot
+;SPAWN, 'gqview '+saveplot+' &'
+;goto, quick
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; pour article, decommenter ici et commenter l'appel au deuxieme fichier
+;;;com
+;;!p.multi = [0,2,1]
+;
+;        path = paths(0) & print, path 
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;;;
+;;; COEFFICIENT POUR LOIS DE SIMILITUDE
+;;;
+;;@coeffhf
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zefield       =  a_wt_bot 
+;zey           =  a_h
+;set_name      =  saveplot+'comp_A_HFLUX.ps'
+;set_title     =  "Similarity: vert. eddy heat flux on Mars"
+;set_titlex    =  "Dimensionless vertical heat flux <w'T'>/<w'T'>!Dmax!N"
+;set_titley    =  'Dimensionless height z/z!Di!N'
+;set_subtitle  =  ''
+;set_xrange    =  [-0.5,1.]
+;set_yrange    =  [0.,1.5]
+;set_tickx     =  0.25
+;set_ticky     =  0.1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zesim = 1 - 1.2 * a_h
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;localtimes = localtime[where( (localtime ge 11) and (localtime le 16) )]
+;;;localtimes = localtime[where( (localtime ge 13) and (localtime le 16) )]
+;;;localtimes = localtime[where( (localtime ge 12) and (localtime le 15) )]
+;;localtimes = localtime[where( (localtime ge 13) and (localtime le 15) )]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;!P.Charsize = 1.2
+;user_lt=localtimes[0] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;plot, zefield(*,nntt), zey(*,nntt), xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, psym=3;, /ISOTROPIC;, POS=[0.12, 0.22, 0.42, 1.0] ;color=0, linestyle=altlin
+;for ll = 1, n_elements(localtimes)-1 do begin
+;  user_lt=localtimes[ll] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;  if (nntt ne -1) then oplot, zefield(*,nntt), zey(*,nntt), psym=3 ;linestyle=altlin
+;endfor
+;;wherex = set_xrange(0)
+;;wherey = set_yrange(1)
+;;dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/20. & xyouts, wherex + dddx, wherey, path
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zecolor = 0. & loadct, 33
+;for i=1, n_elements(paths)-1 do begin
+;;        zecolor = 50. + zecolor
+;zecolor = 0. & loadct, 0
+;        path = paths(i) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        zefield = a_wt_bot
+;        zey = a_h
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        for ll = 0, n_elements(localtimes)-1 do begin
+;          user_lt=localtimes[ll] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;          if (nntt ne -1) then oplot, zefield(*,nntt), zey(*,nntt), psym=3, color=zecolor
+;        endfor
+;        ;xyouts, wherex + dddx, wherey - float(i)*dddy, path, color=zecolor
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;endfor
+;loadct, 0
+;;oplot, [0.,0.], set_yrange, linestyle=0, color=0
+;	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;	;ye, ryeah, tyeah & oplot, ryeah, tyeah, linestyle=0, color=255, /NOCLIP
+;	;oplot, set_xrange, [0.,0.], linestyle=0, color=0
+;	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_End, /PNG
+;;com
+;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;	path = paths(0) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;;;
+;;; COEFFICIENT POUR LOIS DE SIMILITUDE
+;;;
+;;@coeffw
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zefield       =  a_vel_bot 
+;zey           =  a_h  
+;set_name      =  saveplot+'comp_A_VEL.ps'
+;set_title     =  "Similarity: vert. vel. variance on Mars"
+;set_titlex    =  "Dimensionless vert. vel. variance <w'!U2!N>/w!D*!N!U2!N"
+;set_titley    =  'Dimensionless height z/z!Di!N'
+;set_subtitle  =  ''
+;set_xrange    =  [0.,1.2]
+;set_yrange    =  [0.,1.5]
+;set_tickx     =  0.25 ;0.1
+;set_ticky     =  0.1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zesim = 1.8 * a_h^(2./3.) * ( 1. - 0.8 * a_h )^2
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;localtimes = localtime[where( (localtime ge 11) and (localtime le 16) )]
+;;localtimes = localtime[where( (localtime ge 13) and (localtime le 15) )]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;com
+;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;!P.Charsize = 1.2
+;user_lt=localtimes[0] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;plot, zefield(*,nntt), zey(*,nntt), xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, psym=3;, /ISOTROPIC;, POS=[0.62, 0.22, 0.92, 1.0] ;color=0, linestyle=altlin
+;for ll = 1, n_elements(localtimes)-1 do begin
+;  user_lt=localtimes[ll] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;  if (nntt ne -1) then oplot, zefield(*,nntt), zey(*,nntt), psym=3 ;linestyle=altlin
+;endfor
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zecolor = 0. & loadct, 33
+;for i=1, n_elements(paths)-1 do begin
+;zecolor = 0. & loadct, 0
+;;	zecolor = 50. + zecolor
+;	path = paths(i) & print, path
+;	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;	file = path+'/compturb.dat' & restore, filename=file
+;	file = path+'/getturb.dat'  & restore, filename=file
+;	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;	zefield = a_vel_bot 
+;	zey = a_h
+;	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;	for ll = 0, n_elements(localtimes)-1 do begin
+;	  user_lt=localtimes[ll] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;	  if (nntt ne -1) then oplot, zefield(*,nntt), zey(*,nntt), psym=3, color=zecolor
+;	endfor
+;	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;endfor
+;loadct, 0
+;	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;	;ye2, ryeah, tyeah & oplot, ryeah, tyeah, linestyle=0, color=255, /NOCLIP
+;	;oplot, set_xrange, [0.,0.], linestyle=0, color=0
+;	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_End, /PNG
+;
+;;;com
+;;stop
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;        path = paths(0) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zefield       =  localtime
+;zey           =  SMOOTH(w_star_bot, [smoothampl], /EDGE_TRUNCATE)
+;set_name      =  saveplot+'comp_W_STAR.ps'
+;set_title     =  '';"Free convection velocity scale W!D*!N (m.s!U-1!N)"
+;set_titlex    =  'Local Time (h)'
+;set_titley    =  'Free convection velocity scale (m s!U-1!N)'
+;set_subtitle  =  ''
+;set_xrange    =  [08.,17.]
+;set_yrange    =  [00.,06.]
+;set_tickx     =  1.0
+;set_ticky     =  0.5
+;wherex	      =  8.5;11.0
+;wherey	      =  5.5;1.75
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;fixfix = where((w_star_bot le 0.) and (localtime ge 15.)) & if (fixfix(0) ne -1) then zey(fixfix(0):n_elements(zey)-1) = !Values.F_NAN
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;!P.Charsize = 1.2
+;altlin=0
+;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/20. & xyouts, wherex + 2.*dddx, wherey, tttitle(0);path
+;        plots,  wherex + 2.*dddx/1.1,  wherey
+;        plots,  wherex + 2.*dddx/20.,  wherey, linestyle=altlin, /continue
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zecolor = 0. & loadct, 33
+;for i=1, n_elements(paths)-1 do begin
+;        ;zecolor = float(255)/n_elements(paths) + zecolor
+;	zecolor = 0
+;        path = paths(i) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        zefield = localtime
+;        zey = SMOOTH(w_star_bot, [smoothampl], /EDGE_TRUNCATE);w_star_bot
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;	fixfix = where((w_star_bot le 0.) and (localtime ge 15.)) & if (fixfix(0) ne -1) then zey(fixfix(0):n_elements(zey)-1) = !Values.F_NAN
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        oplot, zefield, zey, color=zecolor, linestyle=altlin+i
+;        xyouts, wherex + 2.*dddx,      wherey - float(i)*dddy, tttitle(i), color=zecolor
+;        plots,  wherex + 2.*dddx/1.1,  wherey - float(i)*dddy
+;        plots,  wherex + 2.*dddx/20.,  wherey - float(i)*dddy, linestyle=altlin+i, /continue
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;endfor
+;loadct, 0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_End, /PNG
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+        path = paths(0) & print, path
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        file = path+'/compturb.dat' & restore, filename=file
+        file = path+'/getturb.dat'  & restore, filename=file
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  localtime
+zey           =  SMOOTH(pbl_height, [smoothampl], /EDGE_TRUNCATE)
+set_name      =  saveplot+'comp_HEIGHT.ps'
+set_title     =  '';"Boundary layer height z!Di!N (km)"; [definition : static stability > 1.5 K.m!U-1!N] "
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Boundary layer height (km)'
+set_subtitle  =  ''
+set_xrange    =  [08.,18.]
+set_yrange    =  [00.,08.] ;[00.,07.]
+set_tickx     =  1. 
+set_ticky     =  1.
+wherex        =  09.;13.25 ;12.75
+wherey        =  06.5;2.5 ;2.0
+;	set_xrange    =  [13.5,18.] & set_yrange    =  [06.4,08.0] & set_tickx     =  0.5 & set_ticky     =  0.2 
+;       wherex=15.30
+;       wherey=06.90
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+altlin=0
+plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/20. & xyouts, wherex + 2.*dddx, wherey, tttitle(0)
+        plots,  wherex + 2.*dddx/1.1,  wherey
+        plots,  wherex + 2.*dddx/20.,  wherey, linestyle=altlin, /continue
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;w = where((localtime ge 17.) and (localtime le 17.5)) & if (w(0) ne -1) then print, 'BL height 17:00-17:30 : ', mean(pbl_height[w])
+w = where((localtime ge 14.) and (localtime le 14.5)) & if (w(0) ne -1) then print, 'BL height 14:00-14:30 : ', mean(pbl_height[w])
+;print, max(SMOOTH(tke, [0,37], /EDGE_TRUNCATE))
+;print, max(SMOOTH(wmax, [0,37], /EDGE_TRUNCATE))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zecolor = 0. & loadct, 33
+for i=1, n_elements(paths)-1 do begin
+        ;zecolor = float(255)/n_elements(paths) + zecolor
+	zecolor=0
+        path = paths(i) & print, path
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        file = path+'/compturb.dat' & restore, filename=file
+        file = path+'/getturb.dat'  & restore, filename=file
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        zefield = localtime
+        zey = SMOOTH(pbl_height, [smoothampl], /EDGE_TRUNCATE);pbl_height 
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        oplot, zefield, zey, color=zecolor, linestyle=altlin+i
+        xyouts, wherex + 2.*dddx,      wherey - float(i)*dddy, tttitle(i), color=zecolor
+        plots,  wherex + 2.*dddx/1.1,  wherey - float(i)*dddy
+        plots,  wherex + 2.*dddx/20.,  wherey - float(i)*dddy, linestyle=altlin+i, /continue
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	;w = where((localtime ge 17.) and (localtime le 17.5)) & if (w(0) ne -1) then print, 'BL height 17:00-17:30 : ', mean(pbl_height[w])
+        w = where((localtime ge 14.) and (localtime le 14.5)) & if (w(0) ne -1) then print, 'BL height 14:00-14:30 : ', mean(pbl_height[w])
+	;print, max(SMOOTH(tke, [0,37], /EDGE_TRUNCATE))
+	;print, max(SMOOTH(wmax, [0,37], /EDGE_TRUNCATE))
+endfor
+loadct, 0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_End, /PNG
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;        path = paths(0) & print, path
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        file = path+'/compturb.dat' & restore, filename=file
+;;        file = path+'/getturb.dat'  & restore, filename=file
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  localtime
+;;zey           =  smooth(DERIV(localtime, smooth(pbl_height,smoothampl,/EDGE_TRUNCATE)),smoothampl,/EDGE_TRUNCATE)  
+;;set_name      =  saveplot+'comp_dHEIGHT.ps'
+;;set_title     =  "Boundary layer height growth dz!Di!N/dt (km/hour)"
+;;set_titlex    =  'Local Time (h)'
+;;set_titley    =  'Boundary layer height growth (km/hour)'
+;;set_subtitle  =  ''
+;;set_xrange    =  [9.,18.]
+;;set_yrange    =  [-0.4,1.6] 
+;;set_tickx     =  1.
+;;set_ticky     =  0.2
+;;wherex        =  10.30
+;;wherey        =  0.1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;altlin = 0
+;;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;;dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/20. & xyouts, wherex + 2.*dddx, wherey, path
+;;        plots,  wherex + 2.*dddx/1.1,  wherey
+;;        plots,  wherex + 2.*dddx/20.,  wherey, linestyle=altlin, /continue
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;zecolor = 0. & loadct, 33
+;;for i=1, n_elements(paths)-1 do begin
+;;        ;zecolor = float(255)/n_elements(paths) + zecolor
+;;	zecolor = 0
+;;        path = paths(i) & print, path
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        file = path+'/compturb.dat' & restore, filename=file
+;;        file = path+'/getturb.dat'  & restore, filename=file
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        zefield = localtime
+;;        zey = smooth(DERIV(localtime, smooth(pbl_height,smoothampl,/EDGE_TRUNCATE)),smoothampl,/EDGE_TRUNCATE) 
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        oplot, zefield, zey, color=zecolor, linestyle=altlin+i
+;;        xyouts, wherex + 2.*dddx,      wherey - float(i)*dddy, path, color=zecolor
+;;        plots,  wherex + 2.*dddx/1.1,  wherey - float(i)*dddy
+;;        plots,  wherex + 2.*dddx/20.,  wherey - float(i)*dddy, linestyle=altlin+i, /continue
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;endfor
+;;loadct, 0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_End, /PNG
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;        path = paths(0) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zefield       =  localtime
+;zey           =  SMOOTH(wmaxmax, [smoothampl], /EDGE_TRUNCATE)
+;zey2          =  SMOOTH(wminmin, [smoothampl], /EDGE_TRUNCATE)
+;set_name      =  saveplot+'comp_WMAX.ps'
+;set_title     =  '';"Maximum and minimum vertical velocity (m.s!U-1!N)"
+;set_titlex    =  'Local Time (h)'
+;set_titley    =  'Maximum and minimum vertical velocity (m s!U-1!N)'
+;set_subtitle  =  ''
+;;set_xrange    =  [09.0,18.0]
+;set_yrange    =  [-12.0,18.0];[-15.0,20.0]
+;set_tickx     =  1.
+;set_ticky     =  2.
+;wherex        =  8.5;11.00
+;wherey        =  16.5;5.5
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;!P.Charsize = 1.2
+;altlin = 0
+;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;oplot, zefield, zey2, color=0, linestyle=altlin
+;dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/20. & xyouts, wherex + 2.*dddx, wherey, tttitle(0)
+;        plots,  wherex + 2.*dddx/1.1,  wherey
+;        plots,  wherex + 2.*dddx/20.,  wherey, linestyle=altlin, /continue
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zecolor = 0. & loadct, 33
+;for i=1, n_elements(paths)-1 do begin
+;        ;zecolor = float(255)/n_elements(paths) + zecolor
+;        zecolor = 0.
+;        path = paths(i) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        zefield = localtime
+;        zey = SMOOTH(wmaxmax, [smoothampl], /EDGE_TRUNCATE)
+;	zey2 = SMOOTH(wminmin, [smoothampl], /EDGE_TRUNCATE) 
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        oplot, zefield, zey, color=zecolor, linestyle=altlin+i
+;        oplot, zefield, zey2, color=zecolor, linestyle=altlin+i
+;        xyouts, wherex + 2.*dddx,      wherey - float(i)*dddy, tttitle(i), color=zecolor
+;        plots,  wherex + 2.*dddx/1.1,  wherey - float(i)*dddy
+;        plots,  wherex + 2.*dddx/20.,  wherey - float(i)*dddy, linestyle=altlin+i, /continue
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;endfor
+;loadct, 0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_End, /PNG
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;        path = paths(0) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zefield       =  localtime
+;zey           =  SMOOTH(tkemax, [smoothampl], /EDGE_TRUNCATE);hfbotmax
+;set_name      =  saveplot+'comp_TKE.ps'
+;set_title     =  '';"Maximum turbulent kinetic energy (m!U2!N.s!U-2!N)" ; 0.5[<u'!U2!N>+<v'!U2!N>+<w'!U2!N>]!Dmax!N (m!U2!N.s!U-2!N)"
+;set_titlex    =  'Local Time (h)'
+;set_titley    =  'Maximum turbulent kinetic energy (m!U2!N s!U-2!N)'
+;set_subtitle  =  ''
+;;set_xrange    =  [09.0,18.0]
+;set_yrange    =  [00.0,18.0];[00.0,26.0]
+;set_tickx     =  1.
+;set_ticky     =  2.
+;wherex        =  8.5;11.70
+;wherey        =  16.;5.4
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;!P.Charsize = 1.2
+;altlin = 0
+;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/25. & xyouts, wherex + 2.*dddx, wherey, tttitles(0)
+;        plots,  wherex + 2.*dddx/1.1,  wherey
+;        plots,  wherex + 2.*dddx/20.,  wherey, linestyle=altlin, /continue
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zecolor = 0. & loadct, 33
+;for i=1, n_elements(paths)-1 do begin
+;        ;zecolor = float(255)/n_elements(paths) + zecolor
+;        zecolor = 0.
+;        path = paths(i) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        zefield = localtime
+;        zey = SMOOTH(tkemax, [smoothampl], /EDGE_TRUNCATE);hfbotmax 
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        oplot, zefield, zey, color=zecolor, linestyle=altlin+i
+;        xyouts, wherex + 2.*dddx,      wherey - float(i)*dddy, tttitles(i), color=zecolor
+;        plots,  wherex + 2.*dddx/1.1,  wherey - float(i)*dddy
+;        plots,  wherex + 2.*dddx/20.,  wherey - float(i)*dddy, linestyle=altlin+i, /continue
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;endfor
+;loadct, 0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_End, /PNG
+;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;        path = paths(0) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zefield       =  localtime
+;zey           =  SMOOTH(hfbotmax, [smoothampl], /EDGE_TRUNCATE);hfbotmax
+;set_name      =  saveplot+'comp_HFBOT.ps'
+;set_title     =  '';"Maximum heat flux <w'T'>!Dmax!N (K.m.s!U-1!N)"
+;set_titlex    =  'Local Time (h)'
+;set_titley    =  'Maximum vertical eddy heat flux (K m s!U-1!N)'
+;set_subtitle  =  ''
+;;set_xrange    =  [09.0,18.0]
+;set_yrange    =  [00.0,02.0];[00.0,02.8]
+;set_tickx     =  1.
+;set_ticky     =  0.2
+;wherex        =  8.5;10.30
+;wherey        =  1.8;0.7
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_Start, FILENAME=set_name 
+;!P.Charsize = 1.2
+;altlin = 0
+;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/20. & xyouts, wherex + 2.*dddx, wherey, tttitle(0)
+;        plots,  wherex + 2.*dddx/1.1,  wherey
+;        plots,  wherex + 2.*dddx/20.,  wherey, linestyle=altlin, /continue
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zecolor = 0. & loadct, 33
+;for i=1, n_elements(paths)-1 do begin
+;        ;zecolor = float(255)/n_elements(paths) + zecolor
+;	zecolor = 0.
+;        path = paths(i) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/getturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        zefield = localtime
+;        zey = SMOOTH(hfbotmax, [smoothampl], /EDGE_TRUNCATE);hfbotmax 
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        oplot, zefield, zey, color=zecolor, linestyle=altlin+i
+;        xyouts, wherex + 2.*dddx,      wherey - float(i)*dddy, tttitle(i), color=zecolor
+;        plots,  wherex + 2.*dddx/1.1,  wherey - float(i)*dddy
+;        plots,  wherex + 2.*dddx/20.,  wherey - float(i)*dddy, linestyle=altlin+i, /continue
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;endfor
+;loadct, 0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_End, /PNG 
+;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;        path = paths(0) & print, path
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        file = path+'/compturb.dat' & restore, filename=file
+;;        file = path+'/getturb.dat'  & restore, filename=file
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  localtime
+;;zey           =  t_bot;SMOOTH(t_bot, [smoothampl], /EDGE_TRUNCATE);tt_top
+;;zey	      =  SMOOTH(DERIV(localtime, SMOOTH(t_bot,smoothampl/2.,/EDGE_TRUNCATE)),smoothampl,/EDGE_TRUNCATE)
+;;;zey           =  SMOOTH(DERIV(localtime, SMOOTH(t_bot/((p0 / p_bot)^r_cp),smoothampl/2.,/EDGE_TRUNCATE)),smoothampl,/EDGE_TRUNCATE)
+;;set_name      =  saveplot+'comp_TdtBOT.ps';saveplot+'comp_TBOT.ps'
+;;set_title     =  "Potential temperature time derivative dT!Db!N/dt (K.hour!U-1!N)"
+;;set_titlex    =  'Local Time (h)'
+;;set_titley    =  'Potential temperature time derivative (K.hour!U-1!N)'
+;;set_subtitle  =  ''
+;;set_xrange    =  [ 09., 18.] 
+;;set_yrange    =  [-01., 06.] 
+;;set_tickx     =  1.
+;;set_ticky     =  1. 
+;;wherex        =  13.25 
+;;wherey        =  5.5
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;altlin = 0
+;;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;;dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/20. & xyouts, wherex + 2.*dddx, wherey, tttitle(0)
+;;        plots,  wherex + 2.*dddx/1.1,  wherey
+;;        plots,  wherex + 2.*dddx/20.,  wherey, linestyle=altlin, /continue
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;zecolor = 0. & loadct, 33
+;;for i=1, n_elements(paths)-1 do begin
+;;        ;zecolor = float(255)/n_elements(paths) + zecolor
+;;        zecolor = 0.
+;;        path = paths(i) & print, path
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        file = path+'/compturb.dat' & restore, filename=file
+;;        file = path+'/getturb.dat'  & restore, filename=file
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        zefield = localtime
+;;        zey = t_bot;SMOOTH(t_bot, [smoothampl], /EDGE_TRUNCATE);tt_top 
+;;		;zey = DERIV(localtime, t_bot)
+;;		zey = SMOOTH(DERIV(localtime, SMOOTH(t_bot,smoothampl/2.,/EDGE_TRUNCATE)),smoothampl,/EDGE_TRUNCATE)
+;;		;zey = SMOOTH(DERIV(localtime, SMOOTH(t_bot/((p0 / p_bot)^r_cp),smoothampl/2.,/EDGE_TRUNCATE)),smoothampl,/EDGE_TRUNCATE)
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        oplot, zefield, zey, color=zecolor, linestyle=altlin+i
+;;        xyouts, wherex + 2.*dddx,      wherey - float(i)*dddy, tttitle(i), color=zecolor
+;;        plots,  wherex + 2.*dddx/1.1,  wherey - float(i)*dddy
+;;        plots,  wherex + 2.*dddx/20.,  wherey - float(i)*dddy, linestyle=altlin+i, /continue
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;endfor
+;;loadct, 0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;oplot, set_xrange, [0,0], linestyle=2
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_End, /PNG
+;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;        path = paths(0) & print, path
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        file = path+'/compturb.dat' & restore, filename=file
+;;        file = path+'/getturb.dat'  & restore, filename=file
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  localtime
+;;zey           =  SMOOTH(tt_top, [smoothampl], /EDGE_TRUNCATE);tt_top
+;;set_name      =  saveplot+'comp_TTOP.ps'
+;;set_title     =  "Temperature at the top of the boundary layer (K)"
+;;set_titlex    =  'Local Time (h)'
+;;set_titley    =  'Temperature at the top of the boundary layer (K)'
+;;set_subtitle  =  ''
+;;set_xrange    =  [09.,18.]
+;;set_yrange    =  [195.,225.]
+;;set_tickx     =  1.
+;;set_ticky     =  5.
+;;wherex        =  13.00
+;;wherey        =  223.5
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;altlin = 0
+;;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;;dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/20. & xyouts, wherex + 2.*dddx, wherey, path
+;;        plots,  wherex + 2.*dddx/1.1,  wherey
+;;        plots,  wherex + 2.*dddx/20.,  wherey, linestyle=altlin, /continue
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;zecolor = 0. & loadct, 33
+;;for i=1, n_elements(paths)-1 do begin
+;;        ;zecolor = float(255)/n_elements(paths) + zecolor
+;;	zecolor = 0.
+;;        path = paths(i) & print, path
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        file = path+'/compturb.dat' & restore, filename=file
+;;        file = path+'/getturb.dat'  & restore, filename=file
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        zefield = localtime
+;;        zey = SMOOTH(tt_top, [smoothampl], /EDGE_TRUNCATE);tt_top 
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;        oplot, zefield, zey, color=zecolor, linestyle=altlin+i
+;;        xyouts, wherex + 2.*dddx,      wherey - float(i)*dddy, path, color=zecolor
+;;        plots,  wherex + 2.*dddx/1.1,  wherey - float(i)*dddy
+;;        plots,  wherex + 2.*dddx/20.,  wherey - float(i)*dddy, linestyle=altlin+i, /continue
+;;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;endfor
+;;loadct, 0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_End, /PNG
+;
+;
+;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;
+;lev = 4
+;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;
+;
+;        path = paths(0) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/addturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zefield       =  localtime
+;zey 	      =  SMOOTH(reform(velmax(lev,*)), [smoothampl], /EDGE_TRUNCATE)
+;set_name      =  saveplot+'comp_VELMAX.ps'
+;set_title     =  '';"Maximum horizontal velocity "+string(h(lev)*1000.,'(I0)')+"m above ground (m.s!U-1!N)"
+;set_titlex    =  'Local Time (h)'
+;set_titley    =  "Maximum horizontal velocity "+string(h(lev)*1000.,'(I0)')+"m above ground (m s!U-1!N)"
+;set_subtitle  =  ''
+;;set_xrange    =  [09.0,18.0]
+;set_yrange    =  [00.0,14.0]
+;set_tickx     =  1.
+;set_ticky     =  2.
+;wherex        =  8.5;10.30
+;wherey        =  12.;0.7
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;print, h(lev)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_Start, FILENAME=set_name 
+;!P.Charsize = 1.2
+;altlin = 0
+;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;dddx = (set_xrange(1) - set_xrange(0))/20. & dddy = (set_yrange(1) - set_yrange(0))/20. & xyouts, wherex + 2.*dddx, wherey, tttitle(0)
+;        plots,  wherex + 2.*dddx/1.1,  wherey
+;        plots,  wherex + 2.*dddx/20.,  wherey, linestyle=altlin, /continue
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zecolor = 0. & loadct, 33
+;for i=1, n_elements(paths)-1 do begin
+;        ;zecolor = float(255)/n_elements(paths) + zecolor
+;        zecolor = 0.
+;        path = paths(i) & print, path
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        file = path+'/compturb.dat' & restore, filename=file
+;        file = path+'/addturb.dat'  & restore, filename=file
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        zefield = localtime
+;	zey = SMOOTH(reform(velmax(lev,*)), [smoothampl], /EDGE_TRUNCATE)
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;        oplot, zefield, zey, color=zecolor, linestyle=altlin+i
+;        xyouts, wherex + 2.*dddx,      wherey - float(i)*dddy, tttitle(i), color=zecolor
+;        plots,  wherex + 2.*dddx/1.1,  wherey - float(i)*dddy
+;        plots,  wherex + 2.*dddx/20.,  wherey - float(i)*dddy, linestyle=altlin+i, /continue
+;        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;endfor
+;loadct, 0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_End, /PNG
+
+
+
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+goto, no_therm
+quick:
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+cp = R / r_cp
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+x  = fltarr(n_elements(paths)) & y  = fltarr(n_elements(paths))
+x2 = fltarr(n_elements(paths)) & y2 = fltarr(n_elements(paths))
+for i=0, n_elements(paths)-1 do begin
+	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	path = paths(i) & print, path
+        file = path+'/compturb.dat' & restore, filename=file
+        file = path+'/getturb.dat'  & restore, filename=file
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	yeye = 17. 
+	;yeye = 15.
+        ;yeye = 13.
+        ;yeye = 09.
+	w = where(localtime eq yeye) ;& print, w
+
+
+        	;yeye = 08. 
+        	;w2 = where(localtime eq yeye) ;& print, w
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	x(i) = (p0 / p_bot[w])^r_cp
+	y(i) = t_bot[w];-t_bot[w2] & print, y(i)
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	y2(i) = z_top[w]
+	;y2(i) = pbl_height[w]
+	x2(i) = t_bot[w]
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;w2 = where( abs(h-0.01) eq min(abs(h-0.01)) )
+;w2(0)=0
+;w2 = where( abs(h-0.1) eq min(abs(h-0.1)) )
+;w2 = where( abs(h-1.5) eq min(abs(h-1.5)) )
+;w2 = where( abs(h-1.) eq min(abs(h-1.)) )
+;print, w2(0), w(0)
+;x(i) = (p0 / pt[w2(0),w(0)])^r_cp
+;y(i) = t[w2(0),w(0)]
+;print, h[w2]
+;stop
+
+;ye=smooth(DERIV(localtime, smooth(t_bot,smoothampl,/EDGE_TRUNCATE)),smoothampl,/EDGE_TRUNCATE)
+;ye=DERIV(localtime, t_bot)
+;w3 = where(localtime eq 13.) ;;11. flat!
+;y(i) = ye[w3]
+
+endfor
+print, x2
+print, y2
+fit  = LINFIT(x ,y )
+print, fit
+fit2 = LINFIT(x2,y2)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+file='./data_hinson' & header='' & nlines_header=0 & ncol = 7
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+nlines = FILE_LINES(file)-nlines_header & data=FLTARR(ncol,nlines)
+OPENR, lun, file, /GET_LUN & READF, lun, data & CLOSE, lun & FREE_LUN, lun
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+alt = reform(data(5,*)) - reform(data(3,*))		;; altitude
+xdata = (exp(alt/10.))^r_cp				;; p/p0 with assumed scale height
+ydata = reform(data(6,*))				;; potential temperature
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ydata2 = reform(data(5,*));reform(data(3,*));reform(data(5,*))  				;; altitude of the top of the boundary layer zt
+xdata2 = reform(data(6,*))	                        ;; potential temperature
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+data = 0.
+fitdata  = LINFIT(xdata ,ydata )
+fitdata2 = LINFIT(xdata2,ydata2)
+;fitdata2 = POLY_FIT(xdata2,ydata2,2)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+set_name      =  saveplot+'comp_EXN.ps'
+set_title     =  ""
+set_titlex    =  'Base Exner function P!U-1!N=(p!D0!N/p!Db!N)!UR/cp!N'
+set_titley    =  'Base potential temperature T!Db!N (K)'
+set_subtitle  =  ''
+set_xrange    =  [0.90,1.25]
+set_yrange    =  [210.,265.]
+;set_xrange    =  [0.90,1.10]
+;set_yrange    =  [210.,250.]
+	;set_xrange    =  [0.80,1.20]
+	;set_yrange    =  [2.,5.]
+        ;set_xrange    =  [0.80,1.20]
+        ;set_yrange    =  [180.,230.]
+set_tickx     =  0.05
+set_ticky     =  5.
+wherex	      =  1.00
+wherey        =  220.	
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+altlin=0
+dddy = (set_yrange(1) - set_yrange(0))/20.
+dddx = (set_xrange(1) - set_xrange(0))/20.
+
+!p.multi=[0,2,1]
+
+set_title='LES results. T!Db!N = '+string(fit(1), '(F5.1)')+' P!U-1!N + '+string(fit(0), '(F5.1)')
+                plot, $
+set_xrange, fit[1]*set_xrange + fit[0], linestyle=0, $
+                xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, $
+                ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, $
+                 title=set_title, subtitle=set_subtitle, color=0
+for i=0, n_elements(paths)-1 do xyouts, x(i), y(i), shorttt(i)
+;		xyouts, $
+;wherex, wherey, 'squares : data. T!Db!N = '+string(fitdata(1), '(F6.2)')+' P!U-1!N + '+string(fitdata(0), '(F6.2)')
+;                xyouts, $
+;wherex, wherey-dddy, 'triangles : LES. T!Db!N = '+string(fit(1), '(F6.2)')+' P!U-1!N + '+string(fit(0), '(F6.2)')
+
+set_title='RO data. T!Db!N = '+string(fitdata(1), '(F5.1)')+' P!U-1!N + '+string(fitdata(0), '(F5.1)')
+                plot, $
+set_xrange, fitdata[1]*set_xrange + fitdata[0], $
+                xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, $
+                ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, $
+                 title=set_title, subtitle=set_subtitle, color=0, linestyle=1
+                oplot, $
+xdata, ydata, psym=6
+;                oplot, $
+;x, y, psym=5
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_End, /PNG
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+fit 	= fit2
+x	= x2
+y	= y2
+fitdata	= fitdata2
+xdata 	= xdata2 
+ydata 	= ydata2  
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+set_name      =  saveplot+'comp_ZTOP.ps'
+set_title     =  "Absolute altitude of the BL top z!Dt!N (km)"
+set_titlex    =  'Base potential temperature T!Db!N (K)'
+set_titley    =  'Absolute altitude of the BL top (km)'
+set_subtitle  =  ''
+set_xrange    =  [150.,280.] ;[200.,265.]
+set_yrange    =  [-8.,25.]   ;[-4.,20.]
+set_tickx     =  10.
+set_ticky     =  2.
+wherex        =  205.
+wherey        =  17.0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+altlin=0
+dddy = (set_yrange(1) - set_yrange(0))/20.
+dddx = (set_xrange(1) - set_xrange(0))/20.
+;yeye = set_xrange[0] + (set_xrange[1]-set_xrange[0])*findgen(100.)/99.
+                plot, $
+set_xrange, fitdata[1]*set_xrange + fitdata[0], $
+;yeye, fitdata[2]*yeye^2 + fitdata[1]*yeye + fitdata[0], $
+                xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, $
+                ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, $
+                 title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+                oplot, $
+xdata, ydata, psym=6
+                oplot, $
+x, y, psym=5
+                oplot, $
+set_xrange, fit[1]*set_xrange + fit[0], linestyle=1
+                xyouts, $
+wherex, wherey, 'squares : data.  z!Dt!N  =  ('+strtrim(string(fitdata(1)),1)+')  T!Db!N + ('+strtrim(string(fitdata(0)),1)+')'
+                xyouts, $
+wherex, wherey-dddy, 'triangles : model. z!Dt!N  =  ('+strtrim(string(fit(1)),1)+')  T!Db!N + ('+strtrim(string(fit(0)),1)+')'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_End, /PNG
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+no_therm:
+
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/extract_turb
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/extract_turb	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/extract_turb	(revision 1185)
@@ -0,0 +1,24 @@
+#! /bin/bash
+
+
+ycoord=20
+
+
+#echo coord
+#ncrcat -O -v HGT,XLAT,XLONG 	-d Time,0,0,1 		     ../wrfout*   coord.nc
+
+#echo v
+#ncrcat -O -v V     -d south_north_stag,${ycoord},${ycoord},1 ./wrfout*   v${ycoord}.nc
+
+#echo u
+#ncrcat -O -v U     -d south_north,${ycoord},${ycoord},1      ./wrfout*   u${ycoord}.nc
+#echo w
+#ncrcat -O -v W     -d south_north,${ycoord},${ycoord},1      ./wrfout*   w${ycoord}.nc
+#echo p
+#ncrcat -O -v PTOT  -d south_north,${ycoord},${ycoord},1      ./wrfout*   p${ycoord}.nc
+#echo ph
+#ncrcat -O -v PHTOT -d south_north,${ycoord},${ycoord},1      ./wrfout*  ph${ycoord}.nc
+echo t
+ncrcat -O -v T     -d south_north,${ycoord},${ycoord},1      ./wrfout*   t${ycoord}.nc
+
+
Index: trunk/UTIL/IDLplot/SPEC/LES/extract_turb2
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/extract_turb2	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/extract_turb2	(revision 1185)
@@ -0,0 +1,24 @@
+#! /bin/bash
+
+
+#ycoord=20
+#ycoord=30
+
+#echo coord
+#ncrcat -O -v HGT,XLAT,XLONG 	-d Time,0,0,1 		     ../wrfout*   coord.nc
+
+echo v
+#ncrcat -O -v V     ./wrfout*   v${ycoord}.nc
+
+echo u
+#ncrcat -O -v U     ./wrfout*   u${ycoord}.nc
+echo w
+#ncrcat -O -v W     ./wrfout*   w${ycoord}.nc
+echo p
+ncrcat -O -v PTOT  ./wrfout*   p${ycoord}.nc
+echo ph
+ncrcat -O -v PHTOT ./wrfout*  ph${ycoord}.nc
+echo t
+ncrcat -O -v T     ./wrfout*   t${ycoord}.nc
+
+
Index: trunk/UTIL/IDLplot/SPEC/LES/fonc2.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/fonc2.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/fonc2.pro	(revision 1185)
@@ -0,0 +1,11 @@
+function fonc2, x, p
+
+y = p(0) * x^(2./3.) * ( 1. - p(1) * x + p(2) )^2
+ 
+y = p(0) * x^(2./3.) * ( p(2) - p(1) * x )^2
+
+y = p(0) * x^(2./3.) * ( 1. - p(1) * x )^2
+
+
+return, y
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/generate_datafile.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/generate_datafile.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/generate_datafile.pro	(revision 1185)
@@ -0,0 +1,85 @@
+;pro try
+
+
+restore, filename='getturb.dat'
+
+;;wt, tke, ztke, h, ht, t, p, pt, stst, localtime, xtke, ytke, wmax, wmin, depressions, psmin, filename='getturb.dat'
+
+
+nz = n_elements(wt(*,0))
+nt = n_elements(wt(0,*))
+
+;
+; nz: colonnes
+; nt: lignes
+;
+
+openw, lun, 'LES_MERIDIANI_vert_levels.txt', /GET_LUN
+printf, lun, h, format='(F12.6)'
+close, lun
+free_lun, lun
+
+openw, lun, 'LES_MERIDIANI_local_times.txt', /GET_LUN
+printf, lun, localtime, format='(F12.6)'
+close, lun
+free_lun, lun
+
+openw, lun, 'LES_MERIDIANI_TKE.txt', /GET_LUN
+printf, lun, tke, format='('+string(nz,'(I0)')+'F12.6)'
+close, lun
+free_lun, lun
+
+openw, lun, 'LES_MERIDIANI_xTKE.txt', /GET_LUN
+printf, lun, xtke, format='('+string(nz,'(I0)')+'F12.6)'
+close, lun
+free_lun, lun
+
+openw, lun, 'LES_MERIDIANI_yTKE.txt', /GET_LUN
+printf, lun, ytke, format='('+string(nz,'(I0)')+'F12.6)'
+close, lun
+free_lun, lun
+
+openw, lun, 'LES_MERIDIANI_zTKE.txt', /GET_LUN
+printf, lun, ztke, format='('+string(nz,'(I0)')+'F12.6)'
+close, lun
+free_lun, lun
+
+openw, lun, 'LES_MERIDIANI_Wmax.txt', /GET_LUN
+printf, lun, wmax, format='('+string(nz,'(I0)')+'F12.6)'
+close, lun
+free_lun, lun
+
+openw, lun, 'LES_MERIDIANI_Wmin.txt', /GET_LUN
+printf, lun, wmin, format='('+string(nz,'(I0)')+'F12.6)'
+close, lun
+free_lun, lun
+
+openw, lun, 'LES_MERIDIANI_Tpot.txt', /GET_LUN
+printf, lun, t, format='('+string(nz,'(I0)')+'F12.6)'
+close, lun
+free_lun, lun
+
+restore, filename='addturb.dat'
+openw, lun, 'LES_MERIDIANI_VELmax.txt', /GET_LUN
+printf, lun, VELMAX, format='('+string(nz,'(I0)')+'F12.6)'
+close, lun
+free_lun, lun
+
+
+
+;yeye = fltarr(nz,nt)
+;openr, lun, 'LES_MERIDIANI_Tpot.txt', /GET_LUN
+;readf, lun, yeye
+;close, lun
+;free_lun, lun
+;contour, transpose(yeye), nlevels=20
+
+yeye2 = fltarr(nz,nt)
+openr, lun, 'LES_MERIDIANI_TKE.txt', /GET_LUN
+readf, lun, yeye2
+close, lun
+free_lun, lun
+contour, transpose(yeye2), nlevels=20
+
+
+;end
Index: trunk/UTIL/IDLplot/SPEC/LES/getcdf.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/getcdf.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/getcdf.pro	(revision 1185)
@@ -0,0 +1,15 @@
+pro getcdf, $
+	file=file, $
+	charvar=charvar, $
+	invar=invar	
+
+T = SYSTIME(1)
+
+cdfid = ncdf_open(file)
+varid=ncdf_varid(cdfid,charvar)
+ncdf_varget, cdfid, varid, invar
+
+print, 'got '+charvar+' in '+file+' within ', SYSTIME(1) - T, ' seconds'
+
+
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/getget.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/getget.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/getget.pro	(revision 1185)
@@ -0,0 +1,1 @@
+link ../getget.pro
Index: trunk/UTIL/IDLplot/SPEC/LES/getget2d.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/getget2d.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/getget2d.pro	(revision 1185)
@@ -0,0 +1,121 @@
+function getget2d, name, charvar, count=count, offset=offset, stride=stride, coordmean=coordmean, anomaly=anomaly
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; name: char
+; charvar: char
+; count: 4 elements array   ; The dimensions of the sub-image
+; offset: 4 elements array  ; A variable that contains the offset for the sub-image
+; stride: 4 elements array  ; Create a variable to be used as a value for the STRIDE keyword
+; coordmean: 1 to 4 elements array (dimension 1 is 1)
+; anomaly: a non-null element that would be filled with mean
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+nosave = 1  ;; comment to get an IDL data file
+notime = 1  ;; comment to get mention of time taken
+if (n_elements(notime) eq 0) then timetime = SYSTIME(1)
+
+;
+; MINIMAL ARGUMENTS
+;
+if (n_elements(name) eq 0) then stop
+if (n_elements(charvar) eq 0) then stop
+
+;
+; IDL DATA DIRECTORY
+;
+name_idl = charvar+name+'.idl'
+  if (n_elements(coordmean) ne 0) then begin
+    nc = n_elements(coordmean)
+    for i=0,nc-1 do begin
+     name_idl = string(coordmean(i),'(I0)')+name_idl   
+    endfor
+  endif
+name_idl = './idl_dat/'+name_idl
+
+;
+; TEST IF FILE EXISTS
+;
+openr,unit,name_idl,/get_lun,error=err
+
+;
+; IF IDL FILE EXISTS, THAT IS RATHER SIMPLE
+;
+IF (err EQ 0) THEN BEGIN
+
+   print, 'read from file'
+   free_lun,unit
+   restore, filename=name_idl
+
+;
+; IF IDL FILE DOES NOT EXIST, WELL, READ NETCDF
+;
+ENDIF ELSE BEGIN
+
+  ;
+  ; check save directory
+  ;
+  if (n_elements(nosave) eq 0) then SPAWN, 'mkdir -p idl_dat'  
+
+  ;
+  ; open file
+  ;
+  id=ncdf_open(name) 
+
+  ;
+  ; get dimensions
+  ;
+  var = intarr(3)
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), toto, titi & var(0) = titi
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), toto, titi & var(1) = titi 
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, titi & var(2) = titi 
+  ;print, var
+
+  ;
+  ; define default data windows
+  ;
+  if (n_elements(offset) le 3) then offset=[0,0,0]
+  if (n_elements(stride) le 3) then stride=[1,1,1]
+  if (n_elements(count) le 3) then count=intarr(3)
+  w = where(count eq 0) & if (w(0) ne -1) then count[w] = var[w] / stride[w]
+
+  ;
+  ; read variable
+  ;
+  varid=ncdf_varid(id,charvar) ;& print, 'get '+charvar 
+  if (n_elements(notime) eq 0) then timetime = SYSTIME(1) ;& help, /memory
+  ncdf_varget, id, varid, invar, count=count, offset=offset, stride=stride & if (n_elements(notime) eq 0) then print, SYSTIME(1) - timetime, ' s' ;& help, /memory
+  ncdf_close, id
+
+  ;
+  ; OPTIONAL: ANOMALY (value is returned in the keyword)
+  ; 
+  if (n_elements(anomaly) ne 0) then begin
+    anomaly=TOTAL(TOTAL(invar,1),1)/float(var[0])/float(var[1])
+    for i=0,var[0]-1 do for j=0,var[1]-1 do invar(i,j,*) = TEMPORARY(invar(i,j,*)) - anomaly  ; coute cher
+  endif
+
+  ;
+  ; OPTIONAL: MEAN 
+  ;
+  if (n_elements(coordmean) ne 0) then begin
+  for i=0,nc-1 do begin
+   print, 'mean over dimension '+string(coordmean(i),'(I0)')+' - '+string(var(coordmean(i)),'(I0)')+' elements'
+   invar=total(TEMPORARY(invar),coordmean(i))/var(coordmean(i))
+  endfor
+  endif
+
+  ;
+  ; SAVE
+  ;
+  if (n_elements(nosave) eq 0) then save, invar, filename=name_idl
+
+ENDELSE
+
+if (n_elements(notime) eq 0) then print, SYSTIME(1) - timetime, ' s'
+
+;
+; RETURN FIELD
+;
+return, invar
+
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/getturb.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/getturb.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/getturb.pro	(revision 1185)
@@ -0,0 +1,1002 @@
+pro getturb, saveps=saveps, noplot=noplot
+
+;----------------------------------
+; USE: getturb
+;      getturb, saveps='false'     
+;----------------------------------
+
+history_interval_s = 400.
+history_interval_s = 100.
+smoothampl=3700/history_interval_s
+;smoothampl=0.  ;; no smooth
+;smoothampl=10.
+smoothampl=2.
+;smoothampl=5.
+
+;;
+;; constantes
+;;
+p0=610. & t0=220. & r_cp=1.0/4.4 & grav=3.72 & R=192.
+;p0=610. & t0=220. & r_cp=1.0/3.9 & grav = 3.72 & R=191.
+;print, 'ATTENTION ATTENTION R/cp !!!!', r_cp 
+
+; INTERCOMP INTERCOMP
+r_cp = 192./770.
+
+;
+; graphics definition
+;
+if (n_elements(saveps) eq 0) then saveps='true'
+if (n_elements(noplot) eq 0) then noplot='false'
+if (saveps eq 'false') then begin
+   ;!p.multi=[0,3,2] 
+   !P.CHARSIZE=2.
+   WINDOW, /PIXMAP & WDELETE & DEVICE,BYPASS_TRANSLATION=0,DECOMPOSED=0,RETAIN=2
+endif else begin
+   ;PREF_SET, 'IDL_PATH', '/home/spiga/Save/SOURCES/IDL/fsc_psconfig:<IDL_DEFAULT>', /COMMIT
+   ;PREF_SET, 'IDL_PATH', '/home/spiga/SVN/trunk/mesoscale/PLOT/MINIMAL:<IDL_DEFAULT>', /COMMIT
+   PREF_SET, 'IDL_PATH', '/home/spiga/MODELES/MESOSCALE_DEV/PLOT/MINIMAL:<IDL_DEFAULT>', /COMMIT
+endelse
+
+;
+; retrieve fields
+;
+openr,unit,'getturb.dat',/get_lun,error=err
+IF (err ne 0) THEN BEGIN
+
+;
+; input files
+;
+OPENR, 22, 'input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+OPENR, 23, 'input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+
+;
+; get fields
+;
+domain='d01' & filesWRF = FindFile('wrfout_'+domain+'_????-??-??_??:??:??') & nf=n_elements(filesWRF)
+
+
+; get dimensions
+;
+id=ncdf_open(filesWRF(0))
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), toto, nx & NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), toto, ny
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'bottom_top'   ), toto, nz & NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, nt
+NCDF_CLOSE, id 
+id=ncdf_open(filesWRF(nf-1))  ;; for interrupted runs
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, ntlast
+NCDF_CLOSE, id
+
+;
+; prepare loop
+;
+;nloop1 = nf-1 & nloop2 = nt & yeye = 0 
+yeye = 0 & nttot = (nf-1)*nt + ntlast
+
+localtime = lctu + history_interval_s*findgen(nttot)/3700.
+
+wt  = fltarr(nz,nttot) & tke = fltarr(nz,nttot) & ztke = fltarr(nz,nttot) & t = fltarr(nz,nttot)
+p = fltarr(nz) & ph = fltarr(nz) & pht = fltarr(nz,nttot) & pt = fltarr(nz,nttot) & stst = fltarr(nz,nttot)
+xtke = fltarr(nz,nttot) & ytke = fltarr(nz,nttot) & wmax = fltarr(nz,nttot) & wmin = fltarr(nz,nttot)
+depressions = fltarr(nttot) & psmin = fltarr(nttot)
+
+;
+; loop loop
+;
+for loop  = 0, nf-1 do begin
+                                          timetime = SYSTIME(1)
+  if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
+
+for loop2 = 0, nloop2-1 do begin
+
+   anomalt = 1. & anomalu = 1. & anomalv = 1.
+	;print, loop, loop2
+
+   ; ------------
+   ; t' = t - <t>
+   ; ------------
+ tprime = getget(filesWRF(loop), 'T', anomaly=anomalt, count=[0,0,0,1], offset=[0,0,0,loop2])  ;; t' = t - <t>
+ t(*,yeye) = t0 + TEMPORARY(anomalt)
+   ; ------
+   ; w' = w   
+   ; ------
+ wprime = getget(filesWRF(loop), 'W', count=[0,0,0,1], offset=[0,0,0,loop2])     
+ 	for toto = 0, nz-1 do begin
+ 		wmax(toto,yeye) = max(reform(wprime(*,*,toto,0)),min=tutu) & wmin(toto,yeye) = tutu 
+ 	endfor
+;   ; ------
+;   ; u' = u and v' = v   (car PAS de background wind !)
+;   ; ------
+; uprime = getget(filesWRF(loop), 'U', count=[0,0,0,1], offset=[0,0,0,loop2])
+; vprime = getget(filesWRF(loop), 'V', count=[0,0,0,1], offset=[0,0,0,loop2])
+   ; --------------------------------------------------------
+   ; tke = 0.5 ( <u'^2> + <v'^2> + <w'^2> ) ; u' = u ; v' = v  
+   ; --------------------------------------------------------
+   ; ztke is 0.5 * <w'^2>/2 or 0.5 * sigma_w^2 
+ ztke(*,yeye) = 0.5 * TOTAL(TOTAL(wprime^2,1),1) / float(nx) / float(ny)
+ xtke(*,yeye) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'U', anomaly=anomalu, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
+ ytke(*,yeye) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'V', anomaly=anomalv, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
+; xtke(*,yeye) = 0.5 * TOTAL(TOTAL(uprime^2,1),1) / float(nx) / float(ny)
+; ytke(*,yeye) = 0.5 * TOTAL(TOTAL(vprime^2,1),1) / float(nx) / float(ny)
+  tke(*,yeye) = xtke(*,yeye) + $
+                ytke(*,yeye) + $
+                ztke(*,yeye)
+   ; ------
+   ; <w't'>
+   ; ------
+ wt(*,yeye)  = TOTAL(TOTAL(TEMPORARY(tprime)  * TEMPORARY(wprime),1),1) / float(nx) / float(ny)  
+   ; ------
+   ; p & ph
+   ; ------
+ ;if (loop + loop2 eq 0) then nloopbeware = nloop2-1 else nloopbeware = nloop2  ; 1ere valeur vaut 0
+ nttotbeware = nttot-1 ; 1ere valeur vaut 0
+ pht(*,yeye) = TOTAL(TOTAL(getget(filesWRF(loop), 'PHTOT',  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny) / 1000. / 3.72
+ pt(*,yeye)  = TOTAL(TOTAL(getget(filesWRF(loop), 'PTOT' ,  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny)
+ ph = TEMPORARY(ph) + pht(*,yeye) / nttotbeware ;/ nloopbeware / nloop1
+ p  = TEMPORARY(p ) + pt(*,yeye) / nttot ;/ nloop2 / nloop1
+   ; ----------------
+   ; static stability
+   ; ----------------
+ stst(*,yeye) = DERIV( reform(pht(*,yeye)) - hgtu/1000. , reform(t(*,yeye)) * ( reform(pt(*,yeye)) /p0 )^r_cp ) + 1000.*grav / (R / r_cp)  ;; 4.9 dans Hinson
+   ; ----------------
+   ; surface pressure
+   ; ----------------
+ !QUIET=1
+ ;psfc = getget(filesWRF(loop), 'PSFC', anomaly=1, count=[0,0,0,1], offset=[0,0,0,loop2])   ;; plus rapide que autre routine! pas grave avertissement
+ psfc = getget(filesWRF(loop), 'PSFC', count=[0,0,0,1], offset=[0,0,0,loop2])
+ !QUIET=0
+; psfc = getget2d(filesWRF(loop), 'PSFC', anomaly=1, count=[0,0,1], offset=[0,0,loop2]) 
+ psmin(yeye) = min(psfc) ;& print, psmin(yeye)
+ w = where(TEMPORARY(psfc) lt -0.5) ;& print, n_elements(w)
+ if (w(0) ne -1) then depressions(yeye) = 1000. * n_elements(w) / float(nx) / float(ny) else depressions(yeye) = 0.
+   ; ----------
+   ; loop count
+   ; ----------
+ yeye = TEMPORARY(yeye) + 1 ;& print, yeye & print, SYSTIME(1) - timetime, ' s'  
+
+endfor
+                                          print, 'file '+string(loop+1,'(I0)'), SYSTIME(1) - timetime, ' s'
+endfor
+h  = TEMPORARY(ph)  - hgtu/1000.  ;; altitude above ground
+ht = TEMPORARY(pht) - hgtu/1000.  
+;
+; save
+;
+save, wt, tke, ztke, h, ht, t, p, pt, stst, localtime, xtke, ytke, wmax, wmin, depressions, psmin, filename='getturb.dat'
+nz = n_elements(h)
+nnn = n_elements(tke(0,*))
+
+ENDIF ELSE BEGIN
+
+print, 'OK, file is here'
+restore, filename='getturb.dat'
+nz = n_elements(h)
+nnn = n_elements(tke(0,*))
+
+OPENR, 23, 'input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+
+;@include_ustar.pro
+;@include_hfx.pro
+;@include_w.pro
+;@include_tprime.pro
+
+ENDELSE
+
+;
+; pbl height
+;
+pbl_height = fltarr(nnn) & hfsurf = fltarr(nnn) & w_star = fltarr(nnn) & hfbot = fltarr(nnn) & w_star_bot = fltarr(nnn) & hfbotmax = fltarr(nnn)
+a_vel = fltarr(nz,nnn) & a_h = fltarr(nz,nnn) & a_wt = fltarr(nz,nnn) & a_vel_bot = fltarr(nz,nnn) & a_wt_bot = fltarr(nz,nnn)
+tt_top = fltarr(nnn) & z_top = fltarr(nnn) & t_bot = fltarr(nnn) & p_bot = fltarr(nnn)
+tt_bot = fltarr(nnn)
+wmaxmax = fltarr(nnn)
+wminmin = fltarr(nnn)
+tkemax = fltarr(nnn)
+
+for i=1, nnn-1 do begin    ;; ne pas traiter l'init 
+
+	  ;
+	  ; pbl height
+	  ;
+          z_in = reform(ht(*,i)) 
+          profile_in = reform(stst(*,i))   ;; wt pas suffisamment regulier
+          resol = 1000  ;200 un peu juste
+         	  ;********************************************************************
+	          ; ---- numerical recipes in C - section 3.3 ----
+	          ;
+	          ; Calculate interpolating cubic spline 
+	                yspline = SPL_INIT(z_in,profile_in)
+	          ; Define the X values P at which we desire interpolated Y values
+	                xspline=min(z_in)+findgen(floor(max(z_in))*resol)/resol
+	          ; Calculate the interpolated Y values
+	                result=spl_interp(z_in,profile_in,yspline,xspline)
+	          ;********************************************************************
+	  w = where( (result ge 1.5) and (xspline gt 0.01) ) ;0.3) )   ;0.1 suffit si HR
+	  ;if ( localtime(i) gt 16. ) then w = where( (result ge 1.5) and (xspline gt 2.) )
+
+	if ( localtime(i) gt 15. ) then w = where( (result ge 1.5) and (xspline gt 1.) )  
+
+	;;;; special tau = 5.
+	;if ( localtime(i) ge 13. ) then w = where( (result ge 1.5) and (xspline gt 0.35) )
+	;if ( localtime(i) ge 16.05 ) then w = [0]
+
+	  pbl_height(i) = xspline(w(0)) ;& print, 'PBL height - mean profile', pbl_height(i)
+	  z_top(i) = xspline(w(0)) + hgtu/1000.
+
+          ;
+          ; temperature @ pbl height
+          ;
+          z_in = reform(ht(*,i))
+          profile_in = reform(t(*,i))   
+	  ;profile_in = reform(t(*,i))*(reform(pt(*,i))/p0)^r_cp
+	  profile_in2 = reform(pt(*,i))
+          resol = 1000  ;200 un peu juste
+                  ;********************************************************************
+                  ; ---- numerical recipes in C - section 3.3 ----
+                  ;
+                  ; Calculate interpolating cubic spline 
+                        yspline = SPL_INIT(z_in,profile_in)
+			yspline2 = SPL_INIT(z_in,profile_in2)
+                  ; Define the X values P at which we desire interpolated Y values
+                        xspline=min(z_in)+findgen(floor(max(z_in))*resol)/resol
+                  ; Calculate the interpolated Y values
+                        result=spl_interp(z_in,profile_in,yspline,xspline)
+			result2=spl_interp(z_in,profile_in2,yspline2,xspline)
+                  ;********************************************************************
+          w = where( abs(xspline-pbl_height(i)) eq min(abs(xspline-pbl_height(i))) ) & tt_top(i) = result[w(0)]*(result2[w(0)]/p0)^r_cp ;& print, z_top(i), t_top(i)
+	  hhh = 1000. / 1000. ;100. / 1000.
+	  w = where( abs(xspline-hhh) eq min(abs(xspline-hhh)) ) & t_bot(i) = result[w(0)] & p_bot(i) = result2[w(0)] ;& print, p_bot(i), t_bot(i)
+	  tt_bot(i) = result[w(0)]*(result2[w(0)]/p0)^r_cp
+
+	  ;
+          ; heat flux at the "surface" 
+	  ;
+	  hfsurf(i) = wt(1,i)           ;; attention vaut 0 a la hauteur 0
+
+          ;
+          ; heat flux at the bottom of mixed layer = top of radiative layer
+          ;
+          z_in = reform(ht(*,i)) 
+          profile_in = reform(wt(*,i))   ;; wt pas suffisamment regulier
+          resol = 1000  ;200 un peu juste
+                  ;********************************************************************
+                  ; ---- numerical recipes in C - section 3.3 ----
+                  ;
+                  ; Calculate interpolating cubic spline 
+                        yspline = SPL_INIT(z_in,profile_in)
+                  ; Define the X values P at which we desire interpolated Y values
+                        xspline=min(z_in)+findgen(floor(max(z_in))*resol)/resol
+                  ; Calculate the interpolated Y values
+                        result=spl_interp(z_in,profile_in,yspline,xspline)
+                  ;********************************************************************
+	  hhh = 300./1000. & yeah=where(abs(xspline-hhh) eq (min(abs(xspline-hhh)))) & nnzz=yeah(0) & hfbot(i)=result(nnzz)  ;; 300m semble OK, 500m super
+	  w=where(xspline lt 1.5) & result=result[w] & xspline=xspline[w] & yeah=where(result eq max(result)) & nnzz=yeah(0) & hfbotmax(i)=result(nnzz)  
+	  ;print, 'surf, 300m, max   ', hfsurf(i), hfbot(i), hfbotmax(i) ;& plot, result, xspline
+
+result = reform(wmax(*,i)) & yeah=where(result eq max(result)) & nnzz=yeah(0) & wmaxmax(i)=result(nnzz)
+result = reform(wmin(*,i)) & yeah=where(result eq min(result)) & nnzz=yeah(0) & wminmin(i)=result(nnzz)
+result = reform(tke(*,i))  & yeah=where(result eq max(result)) & nnzz=yeah(0) & tkemax(i )=result(nnzz)
+
+	  ;
+	  ; free convection velocity scale
+	  ;
+;	  w_star_bot(i) = ( 1000.* grav * pbl_height(i) * hfbot(i) / t(0,i) ) ^ (1./3.)   
+          w_star_bot(i) = ( 1000.* grav * pbl_height(i) * hfbotmax(i) / t(0,i) ) ^ (1./3.)
+          w_star(i) 	= ( 1000.* grav * pbl_height(i) * hfsurf(i) / t(0,i) ) ^ (1./3.)     
+
+	  ;
+	  ; dimensional quantities
+   	  ;
+	  a_vel(*,i) 		= reform( 2.*ztke(*,i) / w_star(i)^2 )
+          a_vel_bot(*,i) 	= reform( 2.*ztke(*,i) / w_star_bot(i)^2 )
+	  a_h(*,i) 	= reform( ht(*,i) / pbl_height(i) )
+	  a_wt(*,i) 	= reform( wt(*,i) / hfsurf(i) )		;reform( wt(*,i) / w_star(i) )
+	  a_wt_bot(*,i) = reform( wt(*,i) / hfbotmax(i) )	;reform( wt(*,i) / w_star_bot(i) )
+
+endfor
+	  ;
+	  ; free convection time scale
+	  ;
+	  fcts = 1000. * pbl_height / w_star / 3700.
+	  ;
+	  ; mixed layer temperature scale
+	  ;
+ 	  mlts = hfsurf / w_star 
+
+;pbl_height 	= SMOOTH(TEMPORARY(pbl_height), [smoothampl], /EDGE_TRUNCATE)
+;hfsurf 	= SMOOTH(TEMPORARY(hfsurf), 	[smoothampl], /EDGE_TRUNCATE)
+;w_star 	= SMOOTH(TEMPORARY(w_star), 	[smoothampl], /EDGE_TRUNCATE)
+;hfbot 		= SMOOTH(TEMPORARY(hfbot), 	[smoothampl], /EDGE_TRUNCATE)
+;w_star_bot 	= SMOOTH(TEMPORARY(w_star_bot), [smoothampl], /EDGE_TRUNCATE)
+;hfbotmax 	= SMOOTH(TEMPORARY(hfbotmax), 	[smoothampl], /EDGE_TRUNCATE)
+;a_vel 		= SMOOTH(TEMPORARY(a_vel), 	[0,smoothampl], /EDGE_TRUNCATE)
+;a_h 		= SMOOTH(TEMPORARY(a_h), 	[0,smoothampl], /EDGE_TRUNCATE)
+;a_wt 		= SMOOTH(TEMPORARY(a_wt), 	[0,smoothampl], /EDGE_TRUNCATE)
+;a_vel_bot 	= SMOOTH(TEMPORARY(a_vel_bot), 	[0,smoothampl], /EDGE_TRUNCATE)
+;a_wt_bot 	= SMOOTH(TEMPORARY(a_wt_bot), 	[0,smoothampl], /EDGE_TRUNCATE)
+;tt_top		= SMOOTH(TEMPORARY(tt_top), 	[smoothampl], /EDGE_TRUNCATE)
+;z_top          = SMOOTH(TEMPORARY(z_top),   	[smoothampl], /EDGE_TRUNCATE)
+;t_bot          = SMOOTH(TEMPORARY(t_bot),   	[smoothampl], /EDGE_TRUNCATE)
+;p_bot          = SMOOTH(TEMPORARY(p_bot),   	[smoothampl], /EDGE_TRUNCATE)
+
+;
+; save for comparison sake
+;
+save, pbl_height, hfbot, hfsurf, w_star, w_star_bot, a_vel_bot, a_vel, a_h, a_wt_bot, a_wt, fcts, mlts, hfbotmax, tt_top, z_top, t_bot, p_bot, tt_bot, wmaxmax, wminmin, tkemax, filename='compturb.dat'
+if (noplot ne 'false') then stop
+
+;
+; smooth smooth
+;
+wt  = SMOOTH(TEMPORARY(wt),  [0,smoothampl], /EDGE_TRUNCATE)
+tke = SMOOTH(TEMPORARY(tke), [0,smoothampl], /EDGE_TRUNCATE)
+ztke = SMOOTH(TEMPORARY(ztke), [0,smoothampl], /EDGE_TRUNCATE)
+xtke = SMOOTH(TEMPORARY(xtke), [0,smoothampl], /EDGE_TRUNCATE)
+ytke = SMOOTH(TEMPORARY(ytke), [0,smoothampl], /EDGE_TRUNCATE)
+wmax = SMOOTH(TEMPORARY(wmax), [0,smoothampl], /EDGE_TRUNCATE)
+wmin = SMOOTH(TEMPORARY(wmin), [0,smoothampl], /EDGE_TRUNCATE)
+depressions = SMOOTH(TEMPORARY(depressions), [smoothampl], /EDGE_TRUNCATE)
+psmin = SMOOTH(TEMPORARY(psmin), [smoothampl], /EDGE_TRUNCATE)
+
+
+;*******************;
+;*******************;
+; PLOTS PLOTS PLOTS ;
+;*******************;
+;*******************;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  a_vel_bot 
+;;zey           =  a_h  
+;;set_name      =  'A_VEL.ps'
+;;set_title     =  "Scaled vertical velocity variance (m.s!U-1!N)"
+;;set_titlex    =  'Scaled vertical velocity variance (m.s!U-1!N)'
+;;set_titley    =  'Scaled height (km)'
+;;set_subtitle  =  ''
+;;set_xrange    =  [0.,1.2]
+;;set_yrange    =  [0.,1.2]
+;;set_tickx     =  0.1
+;;set_ticky     =  0.1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zesim = 1.8 * a_h^(2./3.) * ( 1. - 0.8 * a_h )^2
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;localtimes = localtime[where( (localtime ge 11) and (localtime le 16) )]
+;;;localtimes = localtime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;altlin=0
+;;user_lt=localtimes[0] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;;plot, zefield(*,nntt), zey(*,nntt), xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin, /ISOTROPIC
+;;for ll = 1, n_elements(localtimes)-1 do begin
+;;  user_lt=localtimes[ll] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;;  if (nntt ne -1) then oplot, zefield(*,nntt), zey(*,nntt), linestyle=altlin
+;;endfor
+;;loadct, 33 & oplot, zesim, zey, psym=5, color=255 & loadct, 0 
+;;if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  localtime
+zey           =  pbl_height
+set_name      =  'HEIGHT.ps'
+set_title     =  'Boundary layer height (km)'
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Boundary layer height (km)'
+set_subtitle  =  '' ;'Criterion is : static stability > 1.5 K.m!U-1!N'
+set_xrange    =  [7.,19.] ;[11.,17.] ;[8.,17.]
+set_yrange    =  [0.,9.]
+set_tickx     =  1.
+set_ticky     =  1.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;oplot, zefield, zey, psym=5
+if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  localtime
+;;zey           =  w_star_bot
+;;set_name      =  'W_STAR.ps'
+;;set_title     =  "Free convection velocity scale (m.s!U-1!N)"
+;;set_titlex    =  'Local Time (h)'
+;;set_titley    =  'Free convection velocity scale (m.s!U-1!N)'
+;;set_subtitle  =  ''
+;;set_xrange    =  [8.,18.]
+;;set_yrange    =  [0.,6.]
+;;set_tickx     =  1.
+;;set_ticky     =  0.5
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;;;oplot, zefield, zey, psym=5
+;;if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  localtime
+;;zey           =  hfbot
+;;zey2	      =  hfsurf	
+;;zey3          =  hfbotmax
+;;set_name      =  'HFBOT.ps'
+;;set_title     =  "Heat flux at the top of the radiative layer (K.m.s!U-1!N)"
+;;set_titlex    =  'Local Time (h)'
+;;set_titley    =  'Heat flux at the top of the radiative layer (K.m.s!U-1!N)'
+;;set_subtitle  =  ''
+;;set_xrange    =  [8.,18.]
+;;set_yrange    =  [0.,2.5]
+;;set_tickx     =  1.
+;;set_ticky     =  0.5
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;;oplot, zefield, zey2, linestyle=1
+;;oplot, zefield, zey3, linestyle=2
+;;if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  transpose(tke) 
+zex           =  localtime 
+zey           =  h
+set_name      =  'TKE.ps'
+set_title     =  "Turbulent Kinetic Energy (m!U2!N.s!U-2!N)" ;0.5[<u'!U2!N>+<v'!U2!N>+<w'!U2!N>]
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Altitude above surface (km)'
+set_subtitle  =  '' ;'Mean over the simulation domain'
+set_xrange    =  [7.,19.] ;[8.,17.]
+set_yrange    =  [0.,9.]  ;; [0.,200.]
+set_tickx     =  1.
+set_ticky     =  1. ;; 50.
+minval        =  0.
+maxval        =  20.
+nlev          =  maxval-minval
+pal           =  22
+rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+;; 0. levels
+lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+;;; 1. background
+loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0 
+  ;; 2. color field
+  loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b) 
+              contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;; 3. contour field
+loadct, 0 & contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (lev LT 0.0)
+;; 4. choose output
+if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  2.*transpose(ztke)
+;;set_title     =  "Vertical wind variance (m!U2!N.s!U-2!N)"
+;;minval        =  -6.
+;;maxval        =  12.
+;;pal           =  0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  transpose(ztke)
+zex           =  localtime
+zey           =  h
+set_name      =  'zTKE.ps'
+set_title     =  "Vertical Turbulent Kinetic Energy (m!U2!N.s!U-2!N)" ;0.5[<w'!U2!N>]
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Altitude above surface (km)'
+set_subtitle  =  '' ;'Mean over the simulation domain'
+set_xrange    =  [7.,19.]
+set_yrange    =  [0.,9.]
+set_tickx     =  1.
+set_ticky     =  1.
+minval        =  0.
+maxval        =  8.
+nlev          =  maxval-minval
+pal           =  22
+rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+;; 0. levels
+lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+;;; 1. background
+loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+;; 2. color field
+loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+            contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;; 3. contour field
+loadct, 0 & contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (lev LT 0.0)
+;; 4. choose output
+if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;restore, filename='addturb.dat'
+;;modvar = SMOOTH(TEMPORARY(modvar),  [0,smoothampl], /EDGE_TRUNCATE)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  transpose(modvar)
+;;zex           =  localtime
+;;zey           =  h
+;;set_name      =  'modvar.ps'
+;;set_title     =  "Horizontal wind speed variance (m!U2!N.s!U-2!N)"
+;;set_titlex    =  'Local Time (h)'
+;;set_titley    =  'Altitude above surface (km)'
+;;set_subtitle  =  '' ;'Mean over the simulation domain'
+;;set_xrange    =  [7.,17.]
+;;set_yrange    =  [0.,7.]
+;;set_tickx     =  1.
+;;set_ticky     =  1.
+;;minval        =  0.
+;;maxval        =  10.
+;;nlev          =  maxval-minval
+;;pal           =  22
+;;rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;;; 0. levels
+;;lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+;;;;; 1. background
+;;loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+;;;; 2. color field
+;;loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+;;            contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;;;; 3. contour field
+;;loadct, 0 & contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (lev LT 0.0)
+;;;; 4. choose output
+;;if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  transpose(wt)
+zex           =  localtime
+zey           =  h
+set_name      =  'HF.ps'
+set_title     =  "Turbulent Heat Flux (K.m.s!U-1!N)"  ;"Vertical Eddy Heat Flux <w'T'>" ;<w'!7h!3'>
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Altitude above surface (km)'
+set_subtitle  =  '' ;'Mean over the simulation domain'
+set_xrange    =  [7.,19.]
+set_yrange    =  [0.,9.]  ;; [0.,200.]
+set_tickx     =  1.
+set_ticky     =  1. ;; 50.
+minval        =  -1.5 ;-2.
+maxval        =  2.5  ;2.
+nlev          =  floor(maxval-minval)*10
+pal           =  33  
+rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;minval        =  -0.8
+;maxval        =  1.2
+;pal           =  0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+;; 0. levels
+lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+;;; 1. background
+loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+;; 2. color field
+loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+            ;;;--------------------------------------------------------------------------------------------------------------------------------
+            ;;; WHITE ZONE - 1. get location of interval in the CT - 2. change the CT to have a white zone
+            ulim=0.09 & dlim=-0.09 & w=where(lev le dlim) & n1=w[n_elements(w)-1] & w=where(lev ge ulim) & n2=w[0] & yy=BYTSCL(lev) & nd=yy[n1] & nu=yy[n2]-5
+            nu = nd + (nu-nd)/2  ;; otherwise the interval is too large (because we removed 0)
+            TVLCT, r, g, b, /Get & r[nd:nu]=255 & g[nd:nu]=255 & b[nd:nu]=255 & TVLCT, r, g, b
+            ;;;--------------------------------------------------------------------------------------------------------------------------------
+            contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;; 3. contour field
+loadct, 0 & contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (lev LT 0.0)
+;; 4. choose output
+if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;restore, filename='tpot_profB'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  t
+;;zey           =  ht 
+;;set_name      =  'T.ps'
+;;set_title     =  "Potential Temperature (K)"
+;;set_titlex    =  'Potential Temperature (K)'
+;;set_titley    =  'Altitude above surface (km)'
+;;set_subtitle  =  '' ;'Mean over the simulation domain'
+;;set_xrange    =  [190.,230.] ;[min(t),max(t)]
+;;set_yrange    =  [0.,7.]
+;;set_tickx     =  5.
+;;set_ticky     =  1.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;localtimes = [9,10,11,12,13,14,15,16,17,18]
+;;localtimes = [7,9,11,13,15,17]
+;;;localtimes = [17.0,17.1,17.2,17.3,17.4,17.5,17.6,17.7,17.8,17.9,18.0]
+;;;localtimes = [15.0]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;;altlin=0 & loadct, 0
+;;altlin=1 & loadct, 0
+;;user_lt=localtimes[0] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;;plot, zefield(*,nntt), zey(*,nntt), xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;;;plot, zefield(*,nntt), les_column, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;;for ll = 1, n_elements(localtimes)-1 do begin
+;;  CASE altlin OF
+;;  0: altlin=1
+;;  1: altlin=0
+;;  ENDCASE  
+;;  user_lt=localtimes[ll] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;;  if (nntt ne -1) then oplot, zefield(*,nntt), zey(*,nntt), linestyle=altlin
+;;;  if (nntt ne -1) then oplot, zefield(*,nntt), les_column, linestyle=altlin
+;;endfor
+;;;oplot, ro_tpot, ro_column, psym=7
+;;;xyouts, 192.0, 0.25, '09:00'
+;;;xyouts, 205.5, 0.25, '11:00'
+;;;xyouts, 214.5, 0.25, '13:00'
+;;;xyouts, 219.5, 0.25, '17:00'
+;;;xyouts, 220.5, 2.30, '17:00 [RO]'
+;;if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  stst
+;;zey           =  ht 
+;;set_name      =  'STST.ps'
+;;set_title     =  "Static stability (K.m!U-1!N)"
+;;set_titlex    =  'Static stability (K.m!U-1!N)'
+;;set_titley    =  'Altitude above surface (km)'
+;;set_subtitle  =  'Mean over the simulation domain'
+;;set_xrange    =  [-5.,5.]
+;;set_yrange    =  [0.,7.]
+;;set_tickx     =  1.
+;;set_ticky     =  1.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;localtimes = [9,11,13,15,17]
+;;localtimes = [12,13,14,15,16]
+;;;localtimes = [17.0,17.1,17.2,17.3,17.4,17.5,17.6,17.7,17.8,17.9,18.0]
+;;;localtimes = [15.0]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;altlin=0 & loadct, 0
+;;user_lt=localtimes[0] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;;plot, zefield(*,nntt), zey(*,nntt), xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;;oplot, zefield(*,nntt), zey(*,nntt), psym=5
+;;for ll = 1, n_elements(localtimes)-1 do begin
+;;  CASE altlin OF
+;;  0: altlin=1 
+;;  1: altlin=0
+;;  ENDCASE
+;;  user_lt=localtimes[ll] & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt)))) & nntt = yeah(0)
+;;  if (nntt ne -1) then oplot, zefield(*,nntt), zey(*,nntt), linestyle=altlin
+;;  if (nntt ne -1) then oplot, zefield(*,nntt), zey(*,nntt), psym=5
+;;endfor
+;;oplot, 0.*zefield(*,nntt) + 1.5, zey(*,nntt), linestyle=2  
+;;if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;
+;
+;if (n_elements(xtke) eq 0) then stop
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;zefield       =  2.*transpose(xtke)
+;;;minval        =  -4
+;;;maxval        =  8. ;12.
+;;;pal           =  0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zex           =  localtime
+;;zey           =  h
+;;set_name      =  'xTKE.ps'
+;;set_title     =  "Horizontal Turbulent Kinetic Energy (m!U2!N.s!U-2!N)" ;0.5[<u'!U2!N>]
+;;set_titlex    =  'Local Time (h)'
+;;set_titley    =  'Altitude above surface (km)'
+;;set_subtitle  =  '';'Mean over the simulation domain'
+;;set_xrange    =  [8.,17.]
+;;set_yrange    =  [0.,7.] 
+;;set_tickx     =  1.
+;;set_ticky     =  1.
+;;minval        =  0.
+;;maxval        =  8. 
+;;nlev          =  maxval-minval
+;;pal           =  22
+;;rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;;; 0. levels
+;;lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+;;;;; 1. background
+;;loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+;;;; 2. color field
+;;loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+;;            contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;;;; 3. contour field
+;;loadct, 0 & contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (lev LT 0.0)
+;;;; 4. choose output
+;;if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zefield       =  transpose(ytke) + transpose(xtke)
+;zex           =  localtime
+;zey           =  h
+;set_name      =  'hTKE.ps'
+;set_title     =  "Horizontal Turbulent Kinetic Energy (m!U2!N.s!U-2!N)" ;0.5[<v'!U2!N>]
+;set_titlex    =  'Local Time (h)'
+;set_titley    =  'Altitude above surface (km)'
+;set_subtitle  =  '' ;'Mean over the simulation domain'
+;set_xrange    =  [8.,17.]
+;set_yrange    =  [0.,1.] ;[0.,7.] ;; [0.,200.]
+;set_tickx     =  1.
+;set_ticky     =  0.1 ;1. ;50.
+;minval        =  0.
+;maxval        =  12. ;10.
+;nlev          =  maxval-minval
+;pal           =  22
+;rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;!P.Charsize = 1.2
+;;; 0. levels
+;lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+;;;; 1. background
+;loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+;;; 2. color field
+;loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+;            contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;;; 3. contour field
+;loadct, 0 & contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (lev LT 0.0)
+;;; 4. choose output
+;if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+if (n_elements(wmax) eq 0) then stop
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  transpose(wmax)
+zex           =  localtime
+zey           =  h
+set_name      =  'Wmax.ps'
+set_title     =  "Maximum updraft speed (m.s!U-1!N)"
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Altitude above surface (km)'
+set_subtitle  =  ''
+set_xrange    =  [11.,17.] ;[8.,18.]
+set_yrange    =  [0.,8.] ;[0.,8.]
+set_tickx     =  1.
+set_ticky     =  1.
+minval        =  0.
+maxval        =  18. ;16. ;15.;14.;13.
+nlev          =  maxval-minval
+pal           =  22
+rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+;; 0. levels
+lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+levhalf = minval + (maxval-minval)*findgen((nlev/2)+1)/float(nlev/2) & if (minval ne 0.) then levhalf = levhalf[where(levhalf ne 0.)]
+;;; 1. background
+loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+  ;; 2. color field
+  loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+              contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;; 3. contour field
+loadct, 0 & contour, zefield, zex, zey, levels=levhalf, c_labels=findgen(n_elements(levhalf))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (levhalf LT 0.0)
+;; 4. choose output
+if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  abs(transpose(wmin))
+zex           =  localtime
+zey           =  h
+set_name      =  'Wmin.ps'
+set_title     =  "Maximum downdraft speed (m.s!U-1!N)"
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Altitude above surface (km)'
+set_subtitle  =  ''
+set_xrange    =  [11.,17.] ;[8.,18.]
+set_yrange    =  [0.,8.]
+set_tickx     =  1.
+set_ticky     =  1.
+minval        =  0.
+maxval        =  10.;12.
+nlev          =  maxval-minval
+pal           =  22
+rrr           =  'no' ;'yes'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+;; 0. levels
+lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+levhalf = minval + (maxval-minval)*findgen((nlev/2)+1)/float(nlev/2) & if (minval ne 0.) then levhalf = levhalf[where(levhalf ne 0.)]
+;;; 1. background
+loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+;; 2. color field
+loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+            contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;; 3. contour field
+loadct, 0 & contour, zefield, zex, zey, levels=levhalf, c_labels=findgen(n_elements(levhalf))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (levhalf LT 0.0)
+;; 4. choose output
+if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+restore, filename='addturb.dat'
+velmax = SMOOTH(TEMPORARY(velmax),  [0,smoothampl], /EDGE_TRUNCATE)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  transpose(velmax)
+zex           =  localtime
+zey           =  h
+set_name      =  'velmax.ps'
+set_title     =  "Maximum horizontal wind speed (m.s!U-1!N)"
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Altitude above surface (km)'
+set_subtitle  =  '' ;'Mean over the simulation domain'
+set_xrange    =  [07.,19.] ;[8.,17.]
+set_yrange    =  [0.,4.]
+set_tickx     =  1.
+set_ticky     =  1.
+minval        =  0.
+maxval        =  30. ;12.
+nlev          =  maxval-minval
+pal           =  22
+rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+;; 0. levels 
+lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+;;; 1. background
+loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+;;; 2. color field
+loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+            contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;; 3. contour field
+loadct, 0 & contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (lev LT 0.0)
+;; 4. choose output
+if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;zefield       =  localtime
+;;zey           =  depressions 
+;;set_name      =  'DEPR.ps'
+;;set_title     =  "Percentage of depressions in the domain"
+;;set_titlex    =  'Local Time (h)'
+;;set_titley    =  'Percentage'
+;;set_subtitle  =  ''
+;;set_xrange    =  [8.,18.]
+;;set_yrange    =  [0.,3.]
+;;set_tickx     =  1.
+;;set_ticky     =  1.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;if (saveps eq 'true') then PS_Start, FILENAME=set_name
+;;!P.Charsize = 1.2
+;;plot, zefield, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, linestyle=altlin
+;;oplot, zefield, zey, psym=5
+;;	oplot, localtime, abs(psmin), linestyle=1
+;;if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+stop
+
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+goto, no_staticstab
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then begin
+  device, /close
+  set_plot, 'ps' & device, filename='plot/staticstab.ps'
+endif
+
+user_lt=17. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+
+   ;;; recompute height @ given local time 
+   caca=heightp+hgtu/1000.
+   height=reform(ph(*,0,*,*))
+   height=total(height,1)/n_elements(height(*,0,0))
+   height=reform(height)
+   height=reform(height(*,yeah(0)))
+   height=height/1000./3.72
+   heightp=height(0:n_elements(height(*))-2) 
+   print, 'new minus old', heightp - caca
+   ;;; recompute height @ given local time 
+
+        press=reform(p(*,0,*,*))
+        press=total(press,1)/n_elements(press(*,0,0))
+        press=reform(press)
+        press=reform(press(*,yeah(0)))
+        press=press(0:n_elements(press(*))-2)
+
+staticstab = DERIV( heightp , reform(what_I_plot5(*,yeah(0))) ) + 1000.*3.72/844.6  ;; 4.9 dans Hinson
+   staticstab = staticstab(0:n_elements(staticstab)-5)
+   heightp = heightp(0:n_elements(heightp)-5)
+
+plot, $
+        staticstab, $
+        heightp,$
+        xtitle='Static stability (K/km)',$
+        xrange=[-1.,5.], $
+        xtickinterval=0.5, $
+        ytitle='Altitude above surface (km)', $
+        yrange=[min(heightp),max(heightp)], $
+        ytickinterval=1., $
+        title="LMD LES Static stability @ LT 17h (K/km)", $
+        subtitle='zonal average at lat. '+latwrite
+oplot, $
+        staticstab, $
+        heightp,$
+        psym=5
+oplot, $
+       findgen(n_elements(heightp))*0. + 1.,$
+       heightp,$
+       linestyle=2
+oplot, $
+       findgen(n_elements(heightp))*0. + 2.,$
+       heightp,$
+       linestyle=2
+
+;;;;;;;;;;
+w = where((staticstab gt 1.5) and ((heightp- hgtu/1000.) gt 1.))
+t_top_plus = what_I_plot5(w(0),yeah(0))
+z_top_plus = heightp(w(0))
+p_top_plus = press(w(0))
+t_top_moins = what_I_plot5(w(0)-1,yeah(0))
+z_top_moins = heightp(w(0)-1)
+p_top_moins = press(w(0)-1)
+pbl_depth = (z_top_plus*alog(p_top_plus) + z_top_moins*alog(p_top_moins))/(alog(p_top_plus) + alog(p_top_moins)) - hgtu/1000.
+xyouts, 3., 1.5 + (max(heightp) + min(heightp)) / 3., 'Ls = '+string(lsu,'(F5.1)')+'!Uo!N', CHARSIZE=1
+xyouts, 3., 1. + (max(heightp) + min(heightp)) / 3., 'Lat = '+string(latu,'(F5.1)')+'!Uo!N', CHARSIZE=1
+xyouts, 3., 0.5 + (max(heightp) + min(heightp)) / 3., 'LonE = '+string(lonu,'(F6.1)')+'!Uo!N', CHARSIZE=1
+xyouts, 3., (max(heightp) + min(heightp)) / 3., 'T!Dt!N = '+string(t_top_plus,'(I0)')+'/'+string(t_top_moins,'(I0)')+' K ', CHARSIZE=1
+xyouts, 3., -0.5 + (max(heightp) + min(heightp)) / 3., 'p!Dt!N = '+string(p_top_plus,'(I0)')+'/'+string(p_top_moins,'(I0)')+' Pa', CHARSIZE=1
+xyouts, 3., -1. + (max(heightp) + min(heightp)) / 3., 'z!Dt!N = '+string(z_top_plus,'(F4.1)')+'/'+string(z_top_moins,'(F4.1)')+' km', CHARSIZE=1
+xyouts, 3., -1.5 + (max(heightp) + min(heightp)) / 3., 'z!Ds!N = '+string(hgtu/1000.,'(F4.1)')+' km', CHARSIZE=1
+xyouts, 3., -2. + (max(heightp) + min(heightp)) / 3., 'D = '+string(pbl_depth,'(F4.1)')+' km', CHARSIZE=1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+no_staticstab:
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then begin
+  device, /close
+endif
+stop
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+user_lt=13.
+yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+
+user_h=0.1
+walt=where(abs(heightp-user_h) eq (min(abs(heightp-user_h))))
+
+;mapfield=reform(t[*,*,walt(0),w(0)])
+;help, mapfield
+;contour, mapfield
+
+section=reform(w[*,0,*,yeah(0)])
+
+section=reform(w[*,0,*,160])
+
+lev=[-12.,-8.,-4.,4.,8.,12.]
+lev=[-5.,-4.,-3.,-2.,-1.,1.,2.,3.,4.,5.]
+contour, $
+	section, $
+	(lon(*,0)-lon(0,0))*59., $
+	heightp, $
+	levels=lev , $
+	C_LINESTYLE = (lev LT 0.0)
+
+device, /close
+
+end
+
Index: trunk/UTIL/IDLplot/SPEC/LES/include_hfx.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/include_hfx.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/include_hfx.pro	(revision 1185)
@@ -0,0 +1,32 @@
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        OPENR, 22, 'input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+        OPENR, 23, 'input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+        domain='d01' & filesWRF = FindFile('wrfout_'+domain+'_????-??-??_??:??:??') & nf=n_elements(filesWRF)
+        id=ncdf_open(filesWRF(0))
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), toto, nx & NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), toto, ny
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'bottom_top'   ), toto, nz & NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, nt
+                NCDF_CLOSE, id
+        id=ncdf_open(filesWRF(nf-1))  ;; for interrupted runs
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, ntlast
+                NCDF_CLOSE, id
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        yeye = 0 & nttot = (nf-1)*nt + ntlast & localtime = lctu + history_interval_s*findgen(nttot)/3700.
+        velmax = fltarr(nz,nttot) & velmin = fltarr(nz,nttot)
+        ustarm = fltarr(nttot) & ustarmax = fltarr(nttot)
+        for loop  = 0, nf-1 do begin
+                                                  timetime = SYSTIME(1)
+          if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
+        for loop2 = 0, nloop2-1 do begin
+!QUIET=1
+ustar = getget(filesWRF(loop), 'HFX', count=[0,0,0,1], offset=[0,0,0,loop2])
+ustarmax(yeye) = max(reform(ustar(*,*,0,0)))
+ustarm(yeye) = reform(TOTAL(TOTAL(TEMPORARY(ustar),1),1) / float(nx) / float(ny))
+print, ustarm(yeye), ustarmax(yeye)
+!QUIET=0
+        yeye = TEMPORARY(yeye) + 1
+        endfor
+        endfor
+        save, ustarm, localtime, filename='addturb.dat' ;; pour l'instant ecrase systematiquement
+        stop
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Index: trunk/UTIL/IDLplot/SPEC/LES/include_tprime.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/include_tprime.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/include_tprime.pro	(revision 1185)
@@ -0,0 +1,116 @@
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        OPENR, 22, 'input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+        OPENR, 23, 'input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+        domain='d01' & filesWRF = FindFile('wrfout_'+domain+'_????-??-??_??:??:??') & nf=n_elements(filesWRF)
+        id=ncdf_open(filesWRF(0))
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), toto, nx & NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), toto, ny
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'bottom_top'   ), toto, nz & NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, nt
+                NCDF_CLOSE, id
+        id=ncdf_open(filesWRF(nf-1))  ;; for interrupted runs
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, ntlast
+                NCDF_CLOSE, id
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        yeye = 0 & nttot = (nf-1)*nt + ntlast & localtime = lctu + history_interval_s*findgen(nttot)/3700.
+        std_tprime = fltarr(nz,nttot) 
+        field = fltarr(nz,nttot)
+        anomalt = 1.
+        for loop  = 0, nf-1 do begin
+                                                  timetime = SYSTIME(1)
+          print, loop
+          if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
+        for loop2 = 0, nloop2-1 do begin
+!QUIET=1
+
+ ;;;; TEMPPOT
+ ;tprime = getget(filesWRF(loop), 'T', anomaly=anomalt, count=[0,0,0,1], offset=[0,0,0,loop2])   ;; t' = t - <t>
+ ;;;; TEMP (K)
+ tempk = reform ( ( t0 + getget(filesWRF(loop), 'T', count=[0,0,0,1], offset=[0,0,0,loop2]) ) * ( getget(filesWRF(loop), 'PTOT', count=[0,0,0,1], offset=[0,0,0,loop2]) / p0 )^r_cp )
+ meanmean = reform(TOTAL(TOTAL(tempk,1),1) / float(nx) / float(ny))
+ for i=0,n_elements(tempk(*,0,0,0))-1 do for j=0,n_elements(tempk(0,*,0,0))-1 do tempk(i,j,*) = tempk(i,j,*) - meanmean
+ tprime = TEMPORARY(tempk)^2
+ 
+ std_tprime(*, yeye) = sqrt ( reform(TOTAL(TOTAL(TEMPORARY(tprime),1),1) / float(nx) / float(ny)) )
+ ;print, std_tprime(*, yeye)
+ ;print, yeye
+
+!QUIET=0
+        yeye = TEMPORARY(yeye) + 1
+        endfor
+        endfor
+        ;save, std_tprime, localtime, filename='addturb.dat' ;; pour l'instant ecrase systematiquement
+        ;stop
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  transpose(std_tprime)
+zex           =  localtime
+zey           =  h
+set_name      =  'std_tprime.ps'
+set_title     =  "Temperature standard deviation (K)" ;"Maximum updraft speed (m.s!U-1!N)"
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Altitude above surface (km)'
+set_subtitle  =  ''
+set_xrange    =  [8.,18.]
+set_yrange    =  [0.,7.]
+set_tickx     =  1.
+set_ticky     =  1.
+minval        =  0.
+maxval        =  2. ;15.;14.;13.
+nlev          =  10 ;(maxval-minval)*10.
+pal           =  22
+rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+;; 0. levels
+lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+;;; 1. background
+loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+  ;; 2. color field
+  loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+              contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;; 3. contour field
+loadct, 0 & contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (lev LT 0.0)
+;; 4. choose output
+if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+zefield       =  transpose(std_tprime)
+zex           =  localtime
+zey           =  h
+set_name      =  'std_tprime_ns.ps'
+set_title     =  "Temperature standard deviation (K)" ;"Maximum updraft speed (m.s!U-1!N)"
+set_titlex    =  'Local Time (h)'
+set_titley    =  'Altitude above surface (km)'
+set_subtitle  =  ''
+set_xrange    =  [8.,18.]
+set_yrange    =  [0.,1.]
+set_tickx     =  1.
+set_ticky     =  1.
+minval        =  0.
+maxval        =  2. ;15.;14.;13.
+nlev          =  10 ;(maxval-minval)*10.
+pal           =  22
+rrr           =  'no'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then PS_Start, FILENAME=set_name
+!P.Charsize = 1.2
+;; 0. levels
+lev = minval + (maxval-minval)*findgen(nlev+1)/float(nlev) & if (minval ne 0.) then lev = lev[where(lev ne 0.)]
+;;; 1. background
+loadct, 0 & contour, /NODATA, zefield, zex, zey, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0
+  ;; 2. color field
+  loadct, pal & if (rrr eq 'yes') then TVLCT, r, g, b, /Get & if (rrr eq 'yes') then TVLCT, Reverse(r), Reverse(g), Reverse(b)
+              contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /overplot, /cell_fill
+;; 3. contour field
+loadct, 0 & contour, zefield, zex, zey, levels=lev, c_labels=findgen(n_elements(lev))*0.+1., /noerase, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle, color=0, C_LINESTYLE = (lev LT 0.0)
+;; 4. choose output
+if (saveps eq 'true') then PS_End, /PNG
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+
+stop
Index: trunk/UTIL/IDLplot/SPEC/LES/include_ustar.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/include_ustar.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/include_ustar.pro	(revision 1185)
@@ -0,0 +1,42 @@
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        OPENR, 22, 'input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+        OPENR, 23, 'input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+        domain='d01' & filesWRF = FindFile('wrfout_'+domain+'_????-??-??_??:??:??') & nf=n_elements(filesWRF)
+        id=ncdf_open(filesWRF(0))
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), toto, nx & NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), toto, ny
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'bottom_top'   ), toto, nz & NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, nt
+                NCDF_CLOSE, id
+        id=ncdf_open(filesWRF(nf-1))  ;; for interrupted runs
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, ntlast
+                NCDF_CLOSE, id
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        yeye = 0 & nttot = (nf-1)*nt + ntlast & localtime = lctu + history_interval_s*findgen(nttot)/3700.
+        velmax = fltarr(nz,nttot) & velmin = fltarr(nz,nttot)
+        ustarm = fltarr(nttot) & ustarmax = fltarr(nttot)
+        for loop  = 0, nf-1 do begin
+                                                  timetime = SYSTIME(1)
+          if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
+        for loop2 = 0, nloop2-1 do begin
+                 uprime = getget(filesWRF(loop), 'U', count=[0,0,0,1], offset=[0,0,0,loop2])
+                 vprime = getget(filesWRF(loop), 'V', count=[0,0,0,1], offset=[0,0,0,loop2])
+;
+; autre methode... ustar² = sqrt(<u'w'>s²+<v'w'>s²)
+;
+!QUIET=1
+ustar = getget(filesWRF(loop), 'USTM', count=[0,0,0,1], offset=[0,0,0,loop2])
+ustarmax(yeye) = max(reform(ustar(*,*,0,0)))
+ustarm(yeye) = reform(TOTAL(TOTAL(TEMPORARY(ustar),1),1) / float(nx) / float(ny))
+print, ustarm(yeye), ustarmax(yeye)
+!QUIET=0
+                 veltot = sqrt(uprime^2+vprime^2) ;; attention si background wind
+                        for toto = 0, nz-1 do begin
+                               velmax(toto,yeye) = max(reform(veltot(*,*,toto,0)))
+                               ;print, velmax(toto,yeye)
+                        endfor
+        yeye = TEMPORARY(yeye) + 1
+        endfor
+        endfor
+        save, ustarm, ustarmax, velmax, localtime, filename='addturb.dat' ;; pour l'instant ecrase systematiquement
+        stop
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Index: trunk/UTIL/IDLplot/SPEC/LES/include_w.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/include_w.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/include_w.pro	(revision 1185)
@@ -0,0 +1,40 @@
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        OPENR, 22, 'input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+        OPENR, 23, 'input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+        domain='d01' & filesWRF = FindFile('wrfout_'+domain+'_????-??-??_??:??:??') & nf=n_elements(filesWRF)
+        id=ncdf_open(filesWRF(0))
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), toto, nx & NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), toto, ny
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'bottom_top'   ), toto, nz & NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, nt
+                NCDF_CLOSE, id
+        id=ncdf_open(filesWRF(nf-1))  ;; for interrupted runs
+                NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, ntlast
+                NCDF_CLOSE, id
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+        yeye = 0 & nttot = (nf-1)*nt + ntlast & localtime = lctu + history_interval_s*findgen(nttot)/3700.
+        for loop  = 0, nf-1 do begin
+                                                  timetime = SYSTIME(1)
+          if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
+        for loop2 = 0, nloop2-1 do begin
+                 ;wprime = getget(filesWRF(loop), 'W', count=[0,0,0,1], offset=[0,0,0,loop2])
+
+;if (localtime(yeye) eq 11.) then begin
+if (localtime(yeye) eq 14.) then begin
+wprime = getget(filesWRF(loop), 'W', count=[0,0,0,1], offset=[0,0,0,loop2])
+print, 'save !! ', localtime(yeye)
+save, wprime, h, filename='savew'
+stop
+uprime = getget(filesWRF(loop), 'U', count=[0,0,0,1], offset=[0,0,0,loop2])
+vprime = getget(filesWRF(loop), 'V', count=[0,0,0,1], offset=[0,0,0,loop2])
+help, uprime
+help, vprime
+veltot = sqrt(uprime^2+vprime^2)
+print, 'save !! ', localtime(yeye)
+save, veltot, h, filename='saveu'
+stop
+endif
+
+        yeye = TEMPORARY(yeye) + 1
+        endfor
+        endfor
+        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Index: trunk/UTIL/IDLplot/SPEC/LES/pause.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/pause.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/pause.pro	(revision 1185)
@@ -0,0 +1,76 @@
+pro pause,up=up,xcrs=xcrs,ycrs=ycrs,on_screen=on_screen
+;+
+; routine:        pause
+;
+; useage:         pause
+;                 pause,up=up,xcrs=xcrs,ycrs=ycrs,on_screen=on_screen
+;
+; input:          none
+;
+; keyword input:  
+;   up
+;     if set, don't return until a upward button transition is
+;     detected.  This is useful when pause is used between plots which
+;     draw quickly.  Setting this keyword ensures that no plots are
+;     skipped but also requires that each new plot be accompanied by a
+;     downward and upward button transition.  The default is to skip
+;     to the next plot as long a mouse button is pressed down.
+;
+;
+; xcrs,ycrs
+;     pixel location to put cursor while waiting
+;
+; on_screen
+;     if set, don't pause if cursor not in plot window
+;
+; output:         none
+;
+; PURPOSE:
+;     Momentarily stop execution until a mouse key is pressed.  While
+;     in the paused state the cursor is changed to what looks like an
+;     arrow pointing down on a button.  When any of the mouse buttons
+;     are pressed the cursor returns to its original form and
+;     execution continues.
+;     
+;     PAUSE will only interrupt execution if the output device is 'X'
+;     and plot system variable !p.multi(0) eq 0.  The first condition
+;     disables PAUSE when output is directed to a postscript file.
+;     The second condition ensures that pauses occur only just before
+;     the screen is erased for a new plot.
+;     
+;     NOTE: After PAUSE returns to the calling program different
+;     actions can be performed depending on whether the left, middle
+;     or right mouse button was pressed.  Just test on the !err system
+;     variable: !err=1 => left !err=2 => middle !err=4 => right.
+;
+; COMMON BLOCKS: pause_blk
+;                       
+; EXAMPLE:        
+;
+;x=findgen(201)/10.-10. 
+;for a=-2.,2.,.1 do begin & plot,x,1/(x^2*10.^a+1),tit=string(a) & pause & end
+;
+;for a=-2.,2.,.1 do begin & plot,x,1/(x^2*10.^a+1),tit=string(a) &$
+;   pause,/u & end
+;
+;  author:  Paul Ricchiazzi                            22sep92
+;           Institute for Computational Earth System Science
+;           University of California, Santa Barbara
+;-
+
+
+if !d.name eq 'X' and !p.multi(0) eq 0 then begin
+  cursor,xw,yw,/nowait,/device
+  
+  if xw eq -1 then begin
+    if keyword_set(on_screen) then return
+    if n_elements(xcrs) eq 0 then xcrs=.9*!d.x_vsize 
+    if n_elements(ycrs) eq 0 then ycrs=.9*!d.y_vsize 
+    tvcrs,xcrs,ycrs
+  endif
+  device,cursor_standard=16
+  cursor,xdum,ydum,/wait,/device
+  if keyword_set(up) then cursor,xdum,ydum,/up,/device
+  device,cursor_standard=30
+endif
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/ps_start.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/ps_start.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/ps_start.pro	(revision 1185)
@@ -0,0 +1,254 @@
+;+
+; NAME:
+;   PS_START/PS_END
+;
+; PURPOSE:
+;
+;    The purpose of PS_START and PS_END is to make it easy to set-up
+;    for and close a PostScript file. The programs work in close conjunction
+;    with PSCONFIG, another program from the Coyote Library.
+;
+;    If ImageMagick  (http://www.imagemagick.org/script/index.php) is installed 
+;    on your computer, you can easily convert PostScript output to JPEG, PNG, and TIFF
+;    image output. (See the keywords to PS_END.)
+;
+; AUTHOR:
+;
+;   FANNING SOFTWARE CONSULTING
+;   David Fanning, Ph.D.
+;   1645 Sheely Drive
+;   Fort Collins, CO 80526 USA
+;   Phone: 970-221-0438
+;   E-mail: davidf@dfanning.com
+;   Coyote's Guide to IDL Programming: http://www.dfanning.com/
+;
+; CATEGORY:
+;
+;       Graphics, File Output, PostScript
+;
+; CALLING SEQUENCE:
+;
+;       PS_START
+;       Various graphics commands here...
+;       PS_END
+;
+; KEYWORD PARAMETERS FOR PS_START:
+;
+;       GUI:          The default behavior is to use PSCONFIG to configure the
+;                     PostScript device silently. If you wish to allow the user
+;                     to interatively configure the PostScript device, set this
+;                     keyword.
+;
+;       SCALE_FACTOR: Set this to the PostScript scale factor. By default: 1.
+;
+;       Any keyword supported by PSCONFIG can be used to configure the PostScript device.
+;       Common keywords would include FILENAME, XSIZE, YSIZE, XOFFSET, YOFFSET, etc. See
+;       the PSCONFIG documentation for details.
+;
+; KEYWORD PARAMETERS FOR PS_END:
+;
+;      All keywords for PS_END require that ImageMagick is installed on your computer
+;      and is configured correctly. Image conversion is done by spawning a "convert" 
+;      command to ImageMagick.
+;
+;       JPEG:         Set this keyword to convert the PostScript output file to a JPEG image.
+;       PNG:          Set this keyword to convert the PostScript output file to a PNG image.
+;       TIFF:         Set this keyword to convert the PostScript output file to a TIFF image.
+;
+; COMMON BLOCKS:
+;
+;       _$FSC_PS_START_   Contains the PS_STRUCT structure for communication between
+;                         PS_START and PS_END.
+;
+; SIDE EFFECTS:
+;
+;       When PS_START is called, the current graphics device is set to "PS" (the PostScript 
+;       device). When PS_END is called the current graphics device is returned to the device
+;       in effect when PS_START was called.
+;
+; RESTRICTIONS:
+;
+;       Requires numerous programs from the Coyote Library. To convert PostScript files
+;       to PNG, JPEG, and TIFF files requires ImageMagick be installed on your
+;       computer and configured correctly. You can download Coyote Library programs here:
+;
+;             http://www.dfanning.com/programs/coyoteprograms.zip
+;
+;       ImageMagick can be found here:
+;
+;              http://www.imagemagick.org/script/index.php
+;
+; EXAMPLE:
+;
+;       To create a line plot in a PostScript file named lineplot.ps and
+;       also create a PNG file named lineplot.png for display in a browser,
+;       type these commands.
+;
+;       PS_Start, FILENAME='lineplot.ps'
+;       Plot, Findgen(11), COLOR=FSC_Color('navy'), /NODATA, XTITLE='Time', YTITLE='Signal'
+;       OPlot, Findgen(11), COLOR=FSC_Color('indian red')
+;       OPlot, Findgen(11), COLOR=FSC_Color('olive'), PSYM=2
+;       PS_End, /PNG
+;
+; NOTES:
+;
+;       You can easily configure any modifications you like for your PostScript output
+;       by setting fields in the plot and axis system variables (!P, !X, !Y, and !Z).
+;       The modifications currently made by default in this program are these:
+;
+;          !P.Charsize = 1.5
+;          !P.Thick = 2
+;          !X.Thick = 2
+;          !Y.Thick = 2
+;          !Z.Thick = 2
+;          !P.Symsize = 1.25
+;          !P.Font = 1
+;
+; MODIFICATION HISTORY:
+;
+;       Written by: David W. Fanning, 20 May 2008.
+;-
+;
+;###########################################################################
+;
+; LICENSE
+;
+; This software is OSI Certified Open Source Software.
+; OSI Certified is a certification mark of the Open Source Initiative.
+;
+; Copyright 2008 Fanning Software Consulting.
+;
+; This software is provided "as-is", without any express or
+; implied warranty. In no event will the authors be held liable
+; for any damages arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any
+; purpose, including commercial applications, and to alter it and
+; redistribute it freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must
+;    not claim you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation
+;    would be appreciated, but is not required.
+;
+; 2. Altered source versions must be plainly marked as such, and must
+;    not be misrepresented as being the original software.
+;
+; 3. This notice may not be removed or altered from any source distribution.
+;
+; For more information on Open Source Software, visit the Open Source
+; web site: http://www.opensource.org.
+;
+;###########################################################################
+PRO FSC_PS_SETUP__DEFINE
+
+    struct = { FSC_PS_SETUP, $
+               currentDevice: "", $
+               setup: 0, $
+               convert: "", $
+               filename: "", $
+               p: !P, $
+               x: !X, $
+               y: !Y, $
+               z: !Z $
+              }
+            
+END ;---------------------------------------------------------------
+
+
+
+PRO PS_END, JPEG=jpeg, PNG=png, TIFF=tiff
+
+   COMMON _$FSC_PS_START_, ps_struct
+   
+   ON_ERROR, 2 ; Return to caller.
+   
+   ; Close the PostScript file, if this is PostScript device.
+   IF !D.Name EQ 'PS' THEN Device, /CLOSE_FILE
+   
+   ; Need to convert with ImageMagick?
+   IF Keyword_Set(png) THEN ps_struct.convert = 'PNG'
+   IF Keyword_Set(jpeg) THEN ps_struct.convert = 'JPEG'
+   IF Keyword_Set(tiff) THEN ps_struct.convert = 'TIFF'
+   IF ps_struct.convert NE "" THEN BEGIN
+
+        basename = FSC_Base_Filename(ps_struct.filename, DIRECTORY=theDir, EXTENSION=theExtension)
+        CASE 1 OF
+            ps_struct.convert EQ 'PNG':  outfilename = Filepath(ROOT_DIR=theDir, basename + '.png')
+            ps_struct.convert EQ 'JPEG': outfilename = Filepath(ROOT_DIR=theDir, basename + '.jpg')
+            ps_struct.convert EQ 'TIFF': outfilename = Filepath(ROOT_DIR=theDir, basename + '.tif')
+        ENDCASE
+        IF N_Elements(outfilename) NE "" THEN BEGIN
+;            cmd = 'convert -density 300 ' + ps_struct.filename + ' -resize 25% ' + outfilename
+            cmd = 'convert -density 300 +antialias ' + ps_struct.filename + ' -resize 50% ' + outfilename
+cmd = cmd + ' ; convert '+ ps_struct.filename + ' ' + Filepath(ROOT_DIR=theDir, basename + '.eps')
+            SPAWN, cmd
+        ENDIF
+        
+   ENDIF
+   
+   ; Clean up.
+   Set_Plot, ps_struct.currentDevice
+   !P = ps_struct.p
+   !X = ps_struct.x
+   !Y = ps_struct.y
+   !Z = ps_struct.z
+   ps_struct.setup = 0
+   ps_struct.currentDevice = ""
+   ps_struct.filename = ""
+   ps_struct.convert = ""
+
+END ;---------------------------------------------------------------
+
+
+
+PRO PS_START, SCALE_FACTOR=scale_factor, GUI=gui, _EXTRA=extra
+
+   COMMON _$FSC_PS_START_, ps_struct
+   
+   ; Define the PS structure.
+   IF N_Elements(ps_struct) EQ 0 THEN ps_struct = {FSC_PS_SETUP}
+   
+   ; If the setup flag is on, then we have to close the previous
+   ; start command before we can continue.
+   IF ps_struct.setup EQ 1 THEN PS_END
+   
+   ; Save current setup information in the PS_STRUCT structure.
+   ps_struct.setup = 1
+   ps_struct.currentDevice = !D.Name
+   ps_struct.p = !P
+   ps_struct.x = !X
+   ps_struct.y = !Y
+   ps_struct.z = !Z
+   
+   ; Change any parameters you feel like changing.
+   !P.Charsize = 1.75
+   !P.Thick = 2
+   !X.Thick = 2
+   !Y.Thick = 2
+   !Z.Thick = 2
+   !P.Symsize = 1.25
+   !P.Font = 1
+   Device, Set_Font='Helvetica', /TT_FONT
+
+   ; Configure the PostScript Device
+   cancelled = 0
+   sizes = PSWindow(_Extra=extra)
+   keywords = PSConfig(_Extra=extra, INCHES=sizes.inches, XSIZE=sizes.xsize, YSIZE=sizes.ysize, $
+      XOFFSET=sizes.xoffset, YOFFSET=sizes.yoffset, Cancel=cancelled, NOGUI=(1-Keyword_Set(gui)))
+   IF cancelled THEN BEGIN
+        PS_END
+        RETURN
+   ENDIF
+   Set_Plot, 'PS'
+   Device, _EXTRA=keywords
+   
+   ; What about scale factor?
+   IF N_Elements(scale_factor) NE 0 THEN $
+        DEVICE, SCALE_FACTOR=scale_factor ELSE $
+        DEVICE, SCALE_FACTOR=1
+   
+   ; Store filename.
+   ps_struct.filename = keywords.filename
+   
+END
Index: trunk/UTIL/IDLplot/SPEC/LES/report_tasi.inc
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/report_tasi.inc	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/report_tasi.inc	(revision 1185)
@@ -0,0 +1,19 @@
+
+saveplot        = './'
+cases          = ['baseline', 'hill', 'little_hill', 'realistic_extreme']
+paths           = cases
+tttitle         = cases
+tttitles        = tttitle
+shorttt         = tttitle
+
+
+;saveplot        = './'
+;cases          = ['MERIDIANI_tau050', 'MERIDIANI_tau100', 'MERIDIANI_tau200', 'MERIDIANI_tau500']
+;paths           = cases
+;tttitle         = ['tau = 0.5' $
+;                  ,'tau = 1.0' $
+;                  ,'tau = 2.0' $
+;                  ,'tau = 5.0' $
+;                  ]
+;tttitles        = tttitle
+;shorttt         = tttitle
Index: trunk/UTIL/IDLplot/SPEC/LES/report_tasi_winds.inc
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/report_tasi_winds.inc	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/report_tasi_winds.inc	(revision 1185)
@@ -0,0 +1,20 @@
+saveplot        = './'
+cases           = ['../MERIDIANI_tau100' $
+                  , '../MERIDIANI_tau100_wind10' $
+                  , '../MERIDIANI_tau100_wind20' $
+;                  , '../MERIDIANI_tau500' $
+;                  , '../MERIDIANI_tau500_wind20' $
+                  , '../MERIDIANI_tau050' $
+                  , '../MERIDIANI_tau100_extreme' $
+                  ]
+paths           = cases
+tttitle         = ['tau = 1' $
+                  ,'tau = 1, wind = 10 m s!U-1!N' $
+                  ,'tau = 1, wind = 20 m s!U-1!N' $
+;                  ,'tau = 5, wind = 0 m s!U-1!N' $
+;                  ,'tau = 5, wind = 20 m s!U-1!N' $
+                  ,'tau = 0.5' $
+                  ,'tau = 1, extreme soil' $
+                  ]
+tttitles        = tttitle
+shorttt         = tttitle
Index: trunk/UTIL/IDLplot/SPEC/LES/scr
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/scr	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/scr	(revision 1185)
@@ -0,0 +1,32 @@
+#! /bin/bash
+
+## use: scr U V W
+## les fichiers deja crees ne sont pas recrees
+
+## IDL remplit la memoire et devient plus lent...
+
+mean='1'
+mean='[1,2]'
+
+count='[1,1,0,0]'
+offset='[20,20,0,0]'
+
+count='0'
+offset='0'
+
+\rm log 2> /dev/null
+touch log
+
+for fich in $(ls wrfout*) ; do
+ for param in "$@" ; do
+
+  echo $param $fich
+  unset limits 
+#  echo "ye = getget('"${fich}"', '"${param}"',coordmean="$mean") & DELVAR, ye & exit" | /distrib/local/rsi/idl_6.1/bin/idl >> log 2>> log
+  echo "ye = getget('"${fich}"', '"${param}"',count="$count",offset="$offset") & DELVAR, ye & exit" | /distrib/local/rsi/idl_6.1/bin/idl >> log 2>> log
+
+ done 
+done
+
+
+
Index: trunk/UTIL/IDLplot/SPEC/LES/scridl
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/scridl	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/scridl	(revision 1185)
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+\rm getturb.dat 2> /dev/null
+echo "getturb & exit" | /opt/idl-6.4/idl/bin/idl > logidl 2> logidl_err &
+
Index: trunk/UTIL/IDLplot/SPEC/LES/similarity.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/similarity.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/similarity.pro	(revision 1185)
@@ -0,0 +1,64 @@
+pro similarity
+
+!p.multi = [0,2,1]
+
+
+lim=0.30 & zelim=(-3.85/alog(lim)+0.07*alog(lim))*exp(-4.61*lim)
+up=1. & & zeup= - 1.55 * up + 1.27
+slope = (zelim - zeup) / (lim - up) & ord = zeup - slope * up
+t1 = findgen(1001.)*lim/1000. & param1 = (-3.85/alog(t1)+0.07*alog(t1))*exp(-4.61*t1)
+t2 = lim + findgen(1001.)*(1.0 - lim)/1000. & param2 = slope * t2 + ord
+;;print, slope, ' slope'
+;;print, ord, ' ord'
+;;      -1.51562 slope      1.23562 ord
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+set_title     =  "Similarity functions: vertical eddy heat flux"
+set_titlex    =  "Dimensionless vertical heat flux <w'T'>/<w'T'>!Dmax!N"
+set_titley    =  'Dimensionless height z/z!Di!N'
+set_subtitle  =  ''
+set_xrange    =  [-0.5,1.]
+set_yrange    =  [0.0,1.0]
+set_tickx     =  0.25
+set_ticky     =  0.1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;zesim = 1 - 1.2 * a_h
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+PS_Start, FILENAME='similarity.ps'
+!P.Charsize = 1.2
+plot, param1, t1, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle;, /ISOTROPIC
+oplot, param2, t2
+oplot, [0.,0.], set_yrange, linestyle=1
+oplot, 1 - 1.2 * t1, t1, linestyle=2
+oplot, 1 - 1.2 * t2, t2, linestyle=2
+xyouts, 0.6, 0.47, 'MARS'
+xyouts, 0.25, 0.3, 'EARTH'
+;PS_End, /PNG
+
+
+t1 = findgen(2001.)*1./2000.
+param1 = 2.05 * t1^(2./3.) * ( 1. - 0.64 * t1 )^2
+param2 = 1.80 * t1^(2./3.) * ( 1. - 0.80 * t1 )^2
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+set_title     =  "Similarity functions: vert. vel. variance"
+set_titlex    =  "Dimensionless vert. vel. variance <w'!U2!N>/w!D*!N!U2!N"
+set_titley    =  'Dimensionless height z/z!Di!N'
+set_subtitle  =  ''
+set_xrange    =  [0.,1.]
+set_yrange    =  [0.0,1.0]
+set_tickx     =  0.25
+set_ticky     =  0.1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;PS_Start, FILENAME='similarity.ps'
+!P.Charsize = 1.2
+plot, param1, t1, xtitle=set_titlex, xrange=set_xrange, xtickinterval=set_tickx, ytitle=set_titley, yrange=set_yrange, ytickinterval=set_ticky, title=set_title, subtitle=set_subtitle;, /ISOTROPIC
+oplot, param2, t1, linestyle=2
+xyouts, 0.2, 0.3, 'EARTH'
+xyouts, 0.67, 0.4, 'MARS'
+PS_End, /PNG
+
+
+
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/test.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/test.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/test.pro	(revision 1185)
@@ -0,0 +1,123 @@
+pro test
+
+
+getcdf, $
+;        file='./wrfout_d01_9999-01-01_05:08:21', $
+        file='./wrfout_d01_9999-01-01_06:10:00', $
+;        file='./wrfout_d01_9999-01-01_07:11:40', $
+        charvar='W', $
+        invar=w
+w1 = max ( w, DIMENSION=3 )
+wm1 = min ( TEMPORARY(w), DIMENSION=3 )
+
+;getcdf, $
+;        file='./wrfout_d01_9999-01-01_06:10:00', $
+;        charvar='W', $
+;        invar=w
+;w2 = max ( w, DIMENSION=3 )
+;wm2 = min ( TEMPORARY(w), DIMENSION=3 )
+;
+;getcdf, $
+;        file='./wrfout_d01_9999-01-01_07:11:40', $
+;        charvar='W', $
+;        invar=w
+;w3 = max ( w, DIMENSION=3 )
+;wm3 = min ( TEMPORARY(w), DIMENSION=3 )
+;
+;getcdf, $
+;        file='./wrfout_d01_9999-01-01_04:06:40', $
+;        charvar='W', $
+;        invar=w
+;w4 = max ( w, DIMENSION=3 )
+;wm4 = min ( TEMPORARY(w), DIMENSION=3 )
+
+getcdf, $
+        file='./wrfout_d01_9999-01-01_06:10:00', $
+        charvar='PSFC', $
+        invar=psfc
+
+gros=50 ;20;5;10
+;gros=5 ;; pour le cas hill
+var1 = psfc[ where( w1  gt 10.) ]
+var2 = psfc
+var3 = psfc[ where( wm1  lt -5.)  ]
+;var4 = psfc[ where( w1  gt 13.) ] ;; bien mais deja montre avec courbes max
+r1 = ( float(histogram(floor(var1*gros))) ) ;/ n_elements(var1) * 100.
+r2 = ( float(histogram(floor(var2*gros))) ) ;/ n_elements(var2) * 100. 
+r3 = ( float(histogram(floor(var3*gros))) ) ;/ n_elements(var3) * 100.
+r1 = 100. * r1 / max(r1)
+r2 = 100. * r2 / max(r2)
+r3 = 100. * r3 / max(r3)
+t1 = min(var1) + findgen(n_elements(r1))/gros
+t2 = min(var2) + findgen(n_elements(r2))/gros
+t3 = min(var3) + findgen(n_elements(r3))/gros
+PS_START, file='stats_w.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+!p.psym = 10 
+plot, t2, r2, xrange=[min(t2)+(max(t2)-min(t2))/2., max(t2)], xtickinterval=1, xtitle='Surface pressure (Pa)', ytitle='Relative quantity (ratio to max value in %)';, yrange=[0,4]
+oplot, t3, r3, psym=2
+oplot, t1, r1, psym=5
+PS_END, /PNG
+
+getcdf, $
+        file='./wrfout_d01_9999-01-01_00:00:00', $
+        charvar='PSFC', $
+        invar=psfc
+
+xx=findgen(n_elements(psfc(*,0,0)))*50.
+yy=findgen(n_elements(psfc(0,*,0)))*50. 
+
+PS_START, file='psfc.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+levu=[685.,687.,689.,691.,693.,695.,697.,699.,701.,703.,705.,707.,709.,711.,713.,715.,717.,719.]
+
+psfc(0,0,1)=684.
+psfc(0,1,1)=718.
+
+loadct, 4
+contour, reform(psfc(*,*,1)), xx, yy, /cell_fill, nlevels=60, xtitle='x dimension (m)', ytitle='y dimension (m)', /isotropic, max_value=718., min_value=684.
+contour, reform(psfc(*,*,1)), xx, yy, lev=levu, c_labels=findgen(n_elements(levu))*0+1, /overplot
+PS_END, /PNG
+
+stop
+
+
+;m = max(psfc)
+;psfc = -11000. * alog ( psfc / m )
+
+PS_START, file='stats_w.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+plot, psfc, w1, psym=3, title='Maximum of vertical wind amplitude along the vertical (between LT 11 and 15)', xtitle='Surface pressure (Pa)', ytitle='Maximum vertical wind (m s!U-1!N)', yrange=[5.,20.], xrange=[685.,720.]
+oplot, psfc, w2, psym=3
+oplot, psfc, w3, psym=3
+oplot, psfc, w4, psym=3
+PS_END, /PNG
+
+PS_START, file='stats_w2.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+plot, psfc, wm1, psym=3, title='Maximum of vertical wind amplitude along the vertical (between LT 11 and 15)', xtitle='Surface pressure (Pa)', ytitle='Maximum vertical wind (m s!U-1!N)', yrange=[-12.,-4.], xrange=[685.,720.]
+oplot, psfc, wm2, psym=3
+oplot, psfc, wm3, psym=3
+oplot, psfc, wm4, psym=3
+
+PS_END, /PNG
+
+
+
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/tsurf.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/tsurf.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/tsurf.pro	(revision 1185)
@@ -0,0 +1,28 @@
+
+domain='d01' & filesWRF = FindFile('wrfout_'+domain+'_????-??-??_??:??:??') & nf=n_elements(filesWRF)
+id=ncdf_open(filesWRF(0))
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), toto, nx & NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), toto, ny
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, nt
+NCDF_CLOSE, id 
+id=ncdf_open(filesWRF(nf-1))  ;; for interrupted runs
+NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, ntlast
+NCDF_CLOSE, id
+yeye = 0 & nttot = (nf-1)*nt + ntlast
+
+history_interval_s = 100.
+OPENR, 22, 'input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+
+localtime = lctu + history_interval_s*findgen(nttot)/3700.
+
+
+cdfid = ncdf_open('surf.nc')
+varid=ncdf_varid(cdfid,'TSURF')
+ncdf_varget, cdfid, varid, tsurf
+
+;print, tsurf(20,20,*)
+
+yeyey = reform(tsurf(20,20,*))
+
+w = where(yeyey eq max(yeyey))
+print, localtime[w]
+
Index: trunk/UTIL/IDLplot/SPEC/LES/turb_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/turb_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/turb_inc.pro	(revision 1185)
@@ -0,0 +1,44 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(F4.1)'
+colors        = 128
+;colors	      = 16	
+minfield_init = -8.
+maxfield_init =  12. 
+pal = 33
+	;
+	;minfield_init = -2.
+	;maxfield_init =  2.
+	;
+;minfield_init = 0.;0.1
+;maxfield_init =  1.;1.1
+;;pal           =  22;33  
+;minfield_init =  0.
+;maxfield_init =  10. 
+;pal           =  22  
+;title_user    = ''
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+flag_cb = 'true'
+windowx = [0.,20.] 
+windowy = [0.,20.] 
+intervalx = 2. 
+intervaly = 2. 
+	windowx = [0.,9.]
+	windowy = [0.,9.]
+	intervalx = 1.
+	intervaly = 1.
+;;
+        windowx = [0.,8.]
+        windowy = [6.,14.]
+        intervalx = 1.0
+        intervaly = 1.0
+;;
+title_axis = ['x-axis (km)','y-axis (km)']
+poscb = 0.70
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex = 20 
+stride = 1
Index: trunk/UTIL/IDLplot/SPEC/LES/turb_inc.pro.new
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/turb_inc.pro.new	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/turb_inc.pro.new	(revision 1185)
@@ -0,0 +1,23 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(F6.2)'
+colors        = 64
+pal = 0 ;33 ;22 ;33
+minfield_init = 818.0 ;-1.5
+maxfield_init = 819.5 ;1.5
+ndiv = 6
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+flag_cb = 'true'
+windowx = [0.,3600.] 
+windowy = [0.,3600.] 
+intervalx = 600. 
+intervaly = 600. 
+title_axis = ['x-axis (m)','y-axis (m)']
+poscb = 0.72
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex = 20 
+stride = 1
Index: trunk/UTIL/IDLplot/SPEC/LES/turb_period.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/turb_period.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/turb_period.pro	(revision 1185)
@@ -0,0 +1,142 @@
+pro turb_period
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+SPAWN, '\rm param_plot.idl ; cp turb_inc.pro param_plot.idl'
+;
+;
+;
+altiuser=0.5
+start_lt = 8
+zefile='turbh_period'
+;
+;
+;
+filefile = "/home/aymeric/Work/submitted/mars_journal/LMD_MM_MARS_ustar_LEScaseC.nc"
+filefile = "/home/aymeric/extract.nc"
+getcdf, file=filefile, charvar="USTM", invar=zevar
+getcdf, file=filefile, charvar="U", invar=zeu
+getcdf, file=filefile, charvar="V", invar=zev
+getcdf, file=filefile, charvar="W", invar=zew
+getcdf, file=filefile, charvar="PSFC", invar=zevar
+
+        nx = n_elements(zevar(*,0))
+        ny = n_elements(zevar(0,*))
+        ;lon = findgen(nx) / 10.
+        ;lat = findgen(ny) / 10.
+	lon = findgen(2*nx+1) / 10.
+	lat = findgen(2*ny+1) / 10.
+
+alpha=1
+nstart=195
+nend=215
+nstride=1
+	;nstart=1
+	;nend=n_elements(zevar(0,0,*))-1
+	;nstride=10
+for nt=nstart,nend,nstride do begin
+print, nt
+;
+;
+;
+  PS_Start, filename=zefile+string(1000+alpha,'(I0)')+'.ps'
+  print, zefile+'.ps'
+  ;!p.multi=[0,3,2]
+  ;!P.Charsize = 0.6
+	!P.Charsize = 1.2
+	!p.charthick = 2.0
+	!p.thick = 2.0
+	!x.thick = 2.0
+	!y.thick = 2.0
+;;
+;;
+;;
+;restore, filename='../LES/MERIDIANI_tau100/savew'
+;;restore, filename='../LES/MERIDIANI_tau100_wind10/savew'
+;;restore, filename='../LES/MERIDIANI_tau100_wind20/savew'
+;;;restore, filename='saveu'
+;indind=where(abs(h - altiuser) eq min(abs(h - altiuser)))
+;print, h(indind)
+;;
+;;
+;;
+;;what_I_plot = reform(wprime(*,*,indind))
+;what_I_plot = wprime(*,*,indind)
+;;what_I_plot = veltot(*,*,indind)
+;;contour, wprime(*,*,indind), nlevels=30
+;lon = findgen(n_elements(wprime(*,0,0))) / 10.
+;lat = findgen(n_elements(wprime(0,*,0))) / 10.
+;nx = n_elements(wprime(*,0,0))
+;ny = n_elements(wprime(0,*,0))
+
+	;;;
+	what_I_plot = reform(zevar(*,*,nt))
+        overvector_x = reform(zeu(0:nx-1,*,0,nt))	
+	overvector_y = reform(zev(*,0:ny-1,0,nt))
+	what_I_plot = reform(zew(*,*,0,nt))
+	;what_I_plot = reform(zevar(*,*,nt)) - mean(reform(zevar(*,*,nt)))
+	;;;
+
+what_I_plot_period = fltarr(2*nx+1,2*ny+1)
+what_I_plot_period(0:nx-1   ,0:ny-1   ) = what_I_plot(0:nx-1,0:ny-1)
+what_I_plot_period(nx:2*nx-1,0:ny-1   ) = what_I_plot(0:nx-1,0:ny-1)
+what_I_plot_period(0:nx-1   ,ny:2*ny-1) = what_I_plot(0:nx-1,0:ny-1)
+what_I_plot_period(nx:2*nx-1,ny:2*ny-1) = what_I_plot(0:nx-1,0:ny-1)
+what_I_plot_period(2*nx,*) = what_I_plot_period(0,*)
+what_I_plot_period(*,2*ny) = what_I_plot_period(*,0)
+what_I_plot = TEMPORARY(what_I_plot_period)
+
+overvector_x_period = fltarr(2*nx+1,2*ny+1)
+overvector_x_period(0:nx-1   ,0:ny-1   ) = overvector_x(0:nx-1,0:ny-1)
+overvector_x_period(nx:2*nx-1,0:ny-1   ) = overvector_x(0:nx-1,0:ny-1)
+overvector_x_period(0:nx-1   ,ny:2*ny-1) = overvector_x(0:nx-1,0:ny-1)
+overvector_x_period(nx:2*nx-1,ny:2*ny-1) = overvector_x(0:nx-1,0:ny-1)
+overvector_x_period(2*nx,*) = overvector_x_period(0,*)
+overvector_x_period(*,2*ny) = overvector_x_period(*,0)
+overvector_x = TEMPORARY(overvector_x_period)
+
+overvector_y_period = fltarr(2*nx+1,2*ny+1)
+overvector_y_period(0:nx-1   ,0:ny-1   ) = overvector_y(0:nx-1,0:ny-1)
+overvector_y_period(nx:2*nx-1,0:ny-1   ) = overvector_y(0:nx-1,0:ny-1)
+overvector_y_period(0:nx-1   ,ny:2*ny-1) = overvector_y(0:nx-1,0:ny-1)
+overvector_y_period(nx:2*nx-1,ny:2*ny-1) = overvector_y(0:nx-1,0:ny-1)
+overvector_y_period(2*nx,*) = overvector_y_period(0,*)
+overvector_y_period(*,2*ny) = overvector_y_period(*,0)
+overvector_y = TEMPORARY(overvector_y_period)
+
+
+print, 'plot !!!!'
+;
+;
+;
+	;localtime_h = start_lt + 100*nt/3700  ;; division euclidienne
+	;localtime_m = float(100*nt mod 3700)/3700.
+	;localtime_m = 60.*localtime_m
+	;title_user=string(localtime_h,'(I0)')+'h'+string(localtime_m,'(I0)')
+title_user='local time = '+string(start_lt + 100.*float(nt)/3700.,'(F5.2)')
+print, title_user
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+;        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;
+;
+PS_End, /PNG
+alpha=alpha+1
+endfor
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/turb_period_psfc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/turb_period_psfc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/turb_period_psfc.pro	(revision 1185)
@@ -0,0 +1,161 @@
+pro turb_period
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+SPAWN, '\rm param_plot.idl ; cp turb_inc.pro param_plot.idl'
+;;
+;;
+;;
+;altiuser=0.5
+start_lt = 9. ;8
+zefile='psfc' ;'turbh_period'
+overvector_x = 0
+overvector_y = 0
+freq_out = 50. ;100.
+dx = 10.
+;
+;
+;
+filefile = "/home/aymeric/Work/submitted/mars_journal/LMD_MM_MARS_ustar_LEScaseC.nc"
+filefile = "/home/aymeric/extract.nc"
+filefile = "/home/aslmd/bigLES10m/psfc.nc"
+;getcdf, file=filefile, charvar="USTM", invar=zevar
+;getcdf, file=filefile, charvar="U", invar=zeu
+;getcdf, file=filefile, charvar="V", invar=zev
+;getcdf, file=filefile, charvar="W", invar=zew
+getcdf, file=filefile, charvar="PSFC", invar=zevar
+
+        nx = n_elements(zevar(*,0,0))
+        ny = n_elements(zevar(0,*,0))
+        ntot = n_elements(zevar(0,0,*))
+        ;lon = findgen(nx) / 10.
+        ;lat = findgen(ny) / 10.
+	;;lon = findgen(2*nx+1) / 10.
+	;;lat = findgen(2*ny+1) / 10.
+        lon = findgen(2*nx+1) * dx ;/ 1000.
+        lat = findgen(2*ny+1) * dx ;/ 1000.
+    lon = findgen(nx) * dx ;/ 1000.
+    lat = findgen(ny) * dx ;/ 1000.
+
+
+alpha=1
+;nstart=195
+;nend=198
+;;nend=215
+;nstride=1
+	;nstart=1
+	;nend=n_elements(zevar(0,0,*))-1
+	;nstride=10
+nstart=0
+nend=n_elements(zevar(0,0,*))-1
+nstride=1
+for nt=nstart,nend,nstride do begin
+print, nt
+;
+;
+;
+  PS_Start, filename=zefile+string(1000+alpha,'(I0)')+'.ps'
+  print, zefile+'.ps'
+  ;!p.multi=[0,3,2]
+  ;!P.Charsize = 0.6
+	!P.Charsize = 1.2
+	!p.charthick = 2.0
+	!p.thick = 2.0
+	!x.thick = 2.0
+	!y.thick = 2.0
+;;
+;;
+;;
+;restore, filename='../LES/MERIDIANI_tau100/savew'
+;;restore, filename='../LES/MERIDIANI_tau100_wind10/savew'
+;;restore, filename='../LES/MERIDIANI_tau100_wind20/savew'
+;;;restore, filename='saveu'
+;indind=where(abs(h - altiuser) eq min(abs(h - altiuser)))
+;print, h(indind)
+;;
+;;
+;;
+;;what_I_plot = reform(wprime(*,*,indind))
+;what_I_plot = wprime(*,*,indind)
+;;what_I_plot = veltot(*,*,indind)
+;;contour, wprime(*,*,indind), nlevels=30
+;lon = findgen(n_elements(wprime(*,0,0))) / 10.
+;lat = findgen(n_elements(wprime(0,*,0))) / 10.
+;nx = n_elements(wprime(*,0,0))
+;ny = n_elements(wprime(0,*,0))
+
+	;;;
+	what_I_plot = reform(zevar(*,*,nt))
+        ;overvector_x = reform(zeu(0:nx-1,*,0,nt))	
+	;overvector_y = reform(zev(*,0:ny-1,0,nt))
+	;what_I_plot = reform(zew(*,*,0,nt))
+	;what_I_plot = reform(zevar(*,*,nt)) - mean(reform(zevar(*,*,nt)))
+	;;;
+
+;;;;
+;;;; DUPLIQUER LES DOMAINES
+;;;;
+
+;what_I_plot_period = fltarr(2*nx+1,2*ny+1)
+;what_I_plot_period(0:nx-1   ,0:ny-1   ) = what_I_plot(0:nx-1,0:ny-1)
+;what_I_plot_period(nx:2*nx-1,0:ny-1   ) = what_I_plot(0:nx-1,0:ny-1)
+;what_I_plot_period(0:nx-1   ,ny:2*ny-1) = what_I_plot(0:nx-1,0:ny-1)
+;what_I_plot_period(nx:2*nx-1,ny:2*ny-1) = what_I_plot(0:nx-1,0:ny-1)
+;what_I_plot_period(2*nx,*) = what_I_plot_period(0,*)
+;what_I_plot_period(*,2*ny) = what_I_plot_period(*,0)
+;what_I_plot = TEMPORARY(what_I_plot_period)
+
+;overvector_x_period = fltarr(2*nx+1,2*ny+1)
+;overvector_x_period(0:nx-1   ,0:ny-1   ) = overvector_x(0:nx-1,0:ny-1)
+;overvector_x_period(nx:2*nx-1,0:ny-1   ) = overvector_x(0:nx-1,0:ny-1)
+;overvector_x_period(0:nx-1   ,ny:2*ny-1) = overvector_x(0:nx-1,0:ny-1)
+;overvector_x_period(nx:2*nx-1,ny:2*ny-1) = overvector_x(0:nx-1,0:ny-1)
+;overvector_x_period(2*nx,*) = overvector_x_period(0,*)
+;overvector_x_period(*,2*ny) = overvector_x_period(*,0)
+;overvector_x = TEMPORARY(overvector_x_period)
+
+;overvector_y_period = fltarr(2*nx+1,2*ny+1)
+;overvector_y_period(0:nx-1   ,0:ny-1   ) = overvector_y(0:nx-1,0:ny-1)
+;overvector_y_period(nx:2*nx-1,0:ny-1   ) = overvector_y(0:nx-1,0:ny-1)
+;overvector_y_period(0:nx-1   ,ny:2*ny-1) = overvector_y(0:nx-1,0:ny-1)
+;overvector_y_period(nx:2*nx-1,ny:2*ny-1) = overvector_y(0:nx-1,0:ny-1)
+;overvector_y_period(2*nx,*) = overvector_y_period(0,*)
+;overvector_y_period(*,2*ny) = overvector_y_period(*,0)
+;overvector_y = TEMPORARY(overvector_y_period)
+
+
+print, 'plot !!!!'
+;
+;
+;
+	;localtime_h = start_lt + 100*nt/3700  ;; division euclidienne
+	;localtime_m = float(100*nt mod 3700)/3700.
+	;localtime_m = 60.*localtime_m
+	;title_user=string(localtime_h,'(I0)')+'h'+string(localtime_m,'(I0)')
+title_user='Surface pressure (Pa) / Local time = '+string(start_lt + freq_out*float(nt)/3700.,'(F6.3)')
+print, title_user
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+;        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;
+;
+PS_End, /PNG
+alpha=alpha+1
+endfor
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/turb_section_period.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/turb_section_period.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/turb_section_period.pro	(revision 1185)
@@ -0,0 +1,53 @@
+pro turb_section_period
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+SPAWN, '\rm param_plot.idl ; cp turb_section_period_inc.pro param_plot.idl'
+;
+;
+;
+filefile = "./MERIDIANI_tau050_wind10_section_plume.nc"
+getcdf, file=filefile, charvar="W", invar=zew
+getcdf, file=filefile, charvar="PHTOT", invar=zevar
+zew   = reform(zew)
+zevar = reform(zevar)
+
+        nx = n_elements(zevar(*,0))
+        nz = n_elements(zevar(0,*))
+
+        xx = findgen(nx) * 100. / 1000.
+        zz = reform(zevar(0,*)) / 3.72 / 1000. + ( 1473.35 / 1000. )
+
+	zew = zew[*,0:nz-2]
+	zz = zz[0:nz-2]
+
+
+	PS_Start, filename='sectionLES.ps'
+        !P.Charsize = 1.2
+        !p.charthick = 2.0
+        !p.thick = 2.0
+        !x.thick = 2.0
+        !y.thick = 2.0
+
+	what_I_plot = zew
+	lon = xx
+	lat = zz
+
+	map_latlon, $
+	        what_I_plot, $                          ; 2D field
+	        lon, $                                  ; 1D latitude OR 2D
+	        lat, $                                  ; 1D longitude OR 2D
+	        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+	        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+	        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+	        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+	        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+	        ct=pal, $                               ; color table (33-rainbow is default)
+	        colors=colors, $                        ; number of colors/levels (32 is default)
+	        title=title_user, $                     ; title of the plot ('' is default)
+	        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/turb_section_period_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/turb_section_period_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/turb_section_period_inc.pro	(revision 1185)
@@ -0,0 +1,22 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(I0)'
+colors	      = 64 ;32	
+minfield_init = -8.
+maxfield_init = 12. 
+pal = 33 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+flag_cb = 'true'
+windowx = [0.,9.] 
+windowy = [0.,12.] 
+intervalx = 1. 
+intervaly = 1. 
+title_axis = ['Horizontal coordinate (km)','Altitude above surface (km)']
+title_user = 'Vertical wind (m s!U-1!N) in Meridiani LES'
+subtitle_user = 'DOD = 0.5 / BW = 10 m s!U-1!N'
+poscb = 0.55
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Index: trunk/UTIL/IDLplot/SPEC/LES/turbulence.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/turbulence.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/turbulence.pro	(revision 1185)
@@ -0,0 +1,549 @@
+pro turbulence
+
+;;----------------------------------------------------
+;;----------------------------------------------------
+;;----------------------------------------------------
+
+
+retrieve='true'
+;retrieve='false'
+
+
+
+;; CALCUL DE LA MOYENNE
+;; 18 pas assez 74 trop
+meansmooth=37
+;meansmooth=18
+;meansmooth=74
+
+;; CALCUL DE LA MOYENNE DES FLUX
+;smoothampl=74
+;smoothampl=2
+;smoothampl=10
+;smoothampl=18
+smoothampl=meansmooth
+
+saveps='false'
+;saveps='true'
+
+yu=20
+
+;;----------------------------------------------------
+;;----------------------------------------------------
+;;----------------------------------------------------
+
+
+p0=610. & t0=220. & r_cp=1/4.4 & grav=3.72 & R=192.
+
+;
+; graphics definition
+;
+if (saveps eq 'false') then begin
+   !p.multi=[0,3,2]
+   !P.CHARSIZE=2.
+endif else begin
+   !p.charthick = 2.0
+   !p.thick = 3.0
+   !x.thick = 2.0
+   !y.thick = 2.0
+endelse
+
+;
+; input files
+;
+OPENR, 22, 'input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+OPENR, 23, 'input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+print, lonu, latu, lsu, lctu, hgtu, tsurfu
+
+
+;
+; retrieve
+;
+if (retrieve eq 'true') then begin
+
+
+;
+; get fields
+;
+getcdf, file='u'+string(yu,'(I0)')+'.nc', charvar='U', invar=u
+getcdf, file='v'+string(yu,'(I0)')+'.nc', charvar='V', invar=v
+getcdf, file='t'+string(yu,'(I0)')+'.nc', charvar='T', invar=t
+getcdf, file='w'+string(yu,'(I0)')+'.nc', charvar='W', invar=w
+getcdf, file='p'+string(yu,'(I0)')+'.nc', charvar='PTOT', invar=p
+	;
+	; no vertical staggering for w
+	;
+	wplus=shift(w,0,0,-1,0)
+	w=(w+wplus)/2.
+	w=w(*,*,0:n_elements(w(0,0,*,0))-2,*)
+
+
+ndim=n_elements(t(*,0,0,0))
+lat=fltarr(ndim,ndim)
+lon=fltarr(ndim,ndim)
+  for i=0,ndim-1 do begin
+  for j=0,ndim-1 do begin
+    lat(i,j)=latu+float(j)*100./59000.
+    lon(i,j)=lonu+float(i)*100./59000.
+  endfor
+  endfor
+what_I_plot=0. & what_I_plot2=0. & what_I_plot3=0. & what_I_plot4=0. & what_I_plot5=0. & what_I_plot6=0.
+maxwhat_I_plot=0. & maxwhat_I_plot2=0. & maxwhat_I_plot3=0.
+minwhat_I_plot=0.
+
+
+;
+; loop on west-east coordinate
+;
+nloop=n_elements(t(*,0,0,0))
+for i=0,nloop-1 do begin
+
+	indp=[i,0]	;;indp=[75,0]
+
+	;
+	; 2D field for plot
+	;
+	t2=reform(t(indp[0],indp[1],*,*))
+t2_save=t0+reform(t(indp[0],indp[1],*,*))
+treal2_save=t2_save*(reform(p(indp[0],indp[1],*,*))/p0)^r_cp
+	u2=reform(u(indp[0],indp[1],*,*))
+	v2=reform(v(indp[0],indp[1],*,*))
+	w2=reform(w(indp[0],indp[1],*,*))
+	nz=n_elements(t2(*,0))
+	nt=n_elements(t2(0,*))
+
+nt=nt-2
+t2=t2[*,0:nt-1]
+u2=u2[*,0:nt-1]
+v2=v2[*,0:nt-1]
+w2=w2[*,0:nt-1]
+
+        	;;
+        	;; local time
+        	;;
+        	;localtime=21.+100.*findgen(nt)/3700.+lon(indp[0],indp[1])/15.-24. 
+                localtime=lctu+100.*findgen(nt)/3700.
+		;;print, localtime
+		
+	;
+	; 1. perturbations
+	;
+	for k=0,nz-1 do begin
+		t2(k,*)=t2(k,*)-SMOOTH(reform(t2(k,*)),meansmooth,/EDGE_TRUNCATE)
+		u2(k,*)=u2(k,*)-SMOOTH(reform(u2(k,*)),meansmooth,/EDGE_TRUNCATE)
+		v2(k,*)=v2(k,*)-SMOOTH(reform(v2(k,*)),meansmooth,/EDGE_TRUNCATE)
+		w2(k,*)=w2(k,*);-SMOOTH(reform(w2(k,*)),meansmooth,/EDGE_TRUNCATE)
+		;treal2_save(k,*)=treal2_save(k,*)-SMOOTH(reform(treal2_save(k,*)),meansmooth,/EDGE_TRUNCATE)
+	endfor
+	;
+	; 2. nonlinear products
+	;
+	vertical_eddy_heat_flux=w2*t2
+	uprime2=u2^2
+	vprime2=v2^2
+	wprime2=w2^2
+	;
+	; 3. Reynolds averaging
+	;
+	for k=0,nz-1 do begin
+		vertical_eddy_heat_flux(k,*)=SMOOTH(reform(vertical_eddy_heat_flux(k,*)),smoothampl,/EDGE_TRUNCATE)
+	        uprime2(k,*)=SMOOTH(reform(uprime2(k,*)),smoothampl,/EDGE_TRUNCATE)
+	        vprime2(k,*)=SMOOTH(reform(vprime2(k,*)),smoothampl,/EDGE_TRUNCATE)
+	        wprime2(k,*)=SMOOTH(reform(wprime2(k,*)),smoothampl,/EDGE_TRUNCATE)
+	endfor
+	tke=0.5*(uprime2+vprime2+wprime2)
+
+
+what_I_plot=what_I_plot+vertical_eddy_heat_flux/nloop
+what_I_plot2=what_I_plot2+tke/nloop
+what_I_plot3=what_I_plot3+wprime2/nloop
+what_I_plot4=what_I_plot4+t2_save/nloop
+what_I_plot5=what_I_plot5+treal2_save/nloop
+if (i eq nloop-1) then  what_I_plot6=t2
+
+;;help, t2
+;;help, treal2_save
+;treal2_save=treal2_save(0:n_elements(t2(*,0))-1,0:n_elements(t2(0,*))-1)
+;if (i eq nloop-1) then  what_I_plot6=treal2_save
+
+yeah=max(vertical_eddy_heat_flux)
+yeah2=max(tke)
+yeah3=max(wprime2)
+yeah4=min(vertical_eddy_heat_flux)
+
+if (yeah gt maxwhat_I_plot) then maxwhat_I_plot=yeah
+if (yeah2 gt maxwhat_I_plot2) then maxwhat_I_plot2=yeah2
+if (yeah3 gt maxwhat_I_plot3) then maxwhat_I_plot3=yeah3
+if (yeah4 lt minwhat_I_plot) then minwhat_I_plot=yeah4
+
+endfor
+
+
+
+
+
+;
+; get model height
+;
+getcdf, file='ph'+string(yu,'(I0)')+'.nc', charvar='PHTOT', invar=ph
+height=reform(ph(*,0,*,*))   
+height=total(height,1)/n_elements(height(*,0,0))
+height=reform(height)
+height=total(height(*,1:nt-1),2)/(nt-1)
+height=height/1000./3.72
+heightp=height(0:n_elements(height(*))-2) 
+	;
+	; altitude above ground
+	;	
+        heightp=heightp-hgtu/1000.
+
+
+;
+; save
+;
+save, what_I_plot, $
+	what_I_plot2, $
+	what_I_plot3, $
+	what_I_plot4, $
+	what_I_plot5, $
+	what_I_plot6, $
+	localtime, $
+	heightp, $
+	lat, $
+	lon, $
+	hgtu, $
+	filename='turbulence.dat' 
+
+endif else begin
+	restore, filename='turbulence.dat'	
+endelse	
+
+help, what_I_plot
+help, localtime
+help, heightp
+
+
+latwrite=string(lat(0,yu),'(F5.1)')
+
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then begin
+  set_plot, 'ps' & device, filename='plot/TKE.ps'
+endif
+
+lev=findgen(15)+1.
+contour, $
+        transpose(what_I_plot2), $
+        localtime, $
+        heightp, $
+        xtitle='Local Time (h)', $
+        xrange=[8.,18.], $
+        xtickinterval=1., $
+        ytitle='Altitude above surface (km)', $
+        yrange=[0.,10.], $
+        ytickinterval=1., $
+        title="Turbulent Kinetic Energy 0.5[<u'!U2!N>+<v'!U2!N>+<w'!U2!N>] (m!U2!N.s!U-2!N)", $
+        levels=lev, $
+        c_labels=findgen(n_elements(lev))*0.+1., $
+	subtitle='zonal average at lat. '+latwrite+' (max value is '+string(maxwhat_I_plot2,'(F4.1)')+' m!U2!N.s!U-2!N)'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then begin
+  device, /close
+  set_plot, 'ps' & device, filename='plot/zTKE.ps'
+endif
+
+lev=findgen(15)+1.
+contour, $
+        0.5*transpose(what_I_plot3), $
+        localtime, $
+        heightp, $
+        xtitle='Local Time (h)', $
+        xrange=[8.,18.], $
+        xtickinterval=1., $
+        ytitle='Altitude above surface (km)', $
+        yrange=[0.,10.], $
+        ytickinterval=1., $
+        title="Vertical TKE 0.5<w'!U2!N> (m!U2!N.s!U-2!N)", $
+        levels=lev, $
+        c_labels=findgen(n_elements(lev))*0.+1., $
+        subtitle='zonal average at lat. '+latwrite+' (max value is '+string(0.5*maxwhat_I_plot3,'(F4.1)')+' m!U2!N.s!U-2!N)'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+
+if (saveps eq 'true') then begin
+  device, /close
+  set_plot, 'ps' & device, filename='plot/HF.ps'
+endif
+
+;lev=[-0.15,-0.05,-0.02,0.05,0.15,0.25,0.35,0.45,0.55,0.65,0.75,0.85,0.95]
+lev = -1. + findgen(20)/10.
+contour, $
+        transpose(what_I_plot), $
+        localtime, $
+        heightp, $ 
+	xtitle='Local Time (h)', $
+	xrange=[8.,18.], $
+	xtickinterval=1., $
+	ytitle='Altitude above surface (km)', $
+	yrange=[0.,10.], $
+	ytickinterval=1., $
+	title="Vertical Eddy Heat Flux <w'!7h!3'> (K.m.s!U-1!N)", $
+	levels=lev, $	
+	C_LINESTYLE = (lev LT 0.0), $
+	c_labels=findgen(n_elements(lev))*0.+1., $
+        subtitle='zonal average at lat. '+latwrite+' (min/max values are '+string(minwhat_I_plot,'(F5.1)')+'/'+string(maxwhat_I_plot,'(F3.1)')+' K.m.s!U-1!N)'
+
+
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+goto, no_pert_temp
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then begin
+  device, /close
+  set_plot, 'ps' & device, filename='plot/pert_temp.ps'
+endif
+
+lev=[-4.,-2.,-1.,-0.5,0.5,1.,2.,4.]
+contour, $
+	transpose(what_I_plot6), $
+        localtime, $
+        heightp, $
+        xtitle='Local Time (h)', $
+        xrange=[13.5,14.], $
+        xtickinterval=0.1, $
+        ytitle='Altitude above surface (km)', $
+        yrange=[0.,0.5], $
+        ytickinterval=0.1, $
+        title="Potential Temperature Perturbation !7h!3' (K)", $
+        levels=lev, $
+;nlevels=20, $
+        C_LINESTYLE = (lev LT 0.0), $
+        c_labels=findgen(n_elements(lev))*0.+1., $
+;/cell_fill, $
+        subtitle='latitude '+latwrite+' longitude '+string(lon(nloop-1,0),'(F6.1)')
+;xyouts, 14.007, heightp(0), '1'
+;xyouts, 14.016, heightp(1), '2'
+;xyouts, 14.007, heightp(2), '3'
+;xyouts, 14.007, heightp(3), '4'
+;xyouts, 14.007, heightp(4), '5'
+;xyouts, 14.007, heightp(5), '6'
+;xyouts, 14.007, heightp(6), '7'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+no_pert_temp:
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+
+
+if (saveps eq 'true') then begin
+  device, /close
+  set_plot, 'ps' & device, filename='plot/temp_pot.ps'
+endif
+
+user_lt=10. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+plot, $
+        what_I_plot4(*,yeah(0)), $
+        heightp,$
+	xtitle='Potential Temperature (K)',$
+;	xrange=[215,240], $
+        xtickinterval=5., $
+        ytitle='Altitude above surface (km)', $
+	yrange=[0.,10.], $
+        ytickinterval=1., $
+	title="Potential Temperature !7h!3 profile (K)", $
+        subtitle='zonal average at lat. '+latwrite
+user_lt=12. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+        oplot, what_I_plot4(*,yeah(0)), heightp, linestyle=1
+user_lt=14. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+        oplot, what_I_plot4(*,yeah(0)), heightp
+user_lt=16. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+        oplot, what_I_plot4(*,yeah(0)), heightp, linestyle=1
+user_lt=18. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+        oplot, what_I_plot4(*,yeah(0)), heightp
+
+;xyouts, 217.3, 0.5, '10:00'
+;xyouts, 225.8, 1.5, '12:00'
+;xyouts, 231.8, 3.0, '14:00'
+;xyouts, 234.8, 0.7, '16:00'
+;xyouts, 232.3, 2.0, '18:00'
+
+
+if (saveps eq 'true') then begin
+  device, /close
+  set_plot, 'ps' & device, filename='plot/temp.ps'
+endif
+
+user_lt=14.+55./60. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+plot, $
+        what_I_plot5(*,yeah(0)), $
+        heightp,$
+        xtitle='Temperature (K)',$
+        xrange=[210,250], $
+        xtickinterval=5., $
+        ytitle='Altitude above surface (km)', $
+        yrange=[0.,2.], $
+        ytickinterval=0.2, $
+        title="LMD LES Near-surface T profile (K)", $
+        subtitle='zonal average at lat. '+latwrite, $
+	linestyle=2	
+user_lt=10.+24./60. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+	oplot, what_I_plot5(*,yeah(0)), heightp
+user_lt=10.+59./60. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+	oplot, what_I_plot5(*,yeah(0)), heightp, linestyle=2
+user_lt=11.+59./60. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+	oplot, what_I_plot5(*,yeah(0)), heightp
+user_lt=15.+22./60. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+	oplot, what_I_plot5(*,yeah(0)), heightp
+user_lt=17.+13./60. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+        oplot, what_I_plot5(*,yeah(0)), heightp, linestyle=2
+
+;xyouts, 221,   0.2,  '10:24'
+;xyouts, 226.5,   0.4,  '10:59'
+;xyouts, 231.8, 0.2,  '11:59'
+;xyouts, 233,   0.8,  '14:55'
+;xyouts, 241,   0.1,  '15:22'
+;xyouts, 236.5, 0.05, '17:13'
+ 
+
+;;
+;xyouts, 250.05, heightp(0), '1'
+;xyouts, 250.45, heightp(1), '2'
+;xyouts, 251.00, heightp(2), '3'
+;xyouts, 250.45, heightp(3), '4'
+;xyouts, 250.45, heightp(4), '5'
+;xyouts, 250.45, heightp(5), '6'
+;xyouts, 250.45, heightp(6), '7'
+;xyouts, 250.45, heightp(7), '8'
+;xyouts, 250.45, heightp(8), '9'
+;xyouts, 250.25, heightp(9), '10'
+;xyouts, 250.25, heightp(10), '11'
+;xyouts, 250.25, heightp(11), '12'
+;xyouts, 250.25, heightp(12), '13'
+;xyouts, 250.25, heightp(13), '14'
+;xyouts, 250.25, heightp(14), '15'
+;xyouts, 250.25, heightp(15), '16'
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;goto, no_staticstab
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then begin
+  device, /close
+  set_plot, 'ps' & device, filename='plot/staticstab.ps'
+endif
+
+user_lt=17. & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+
+   ;;; recompute height @ given local time 
+   caca=heightp+hgtu/1000.
+   height=reform(ph(*,0,*,*))
+   height=total(height,1)/n_elements(height(*,0,0))
+   height=reform(height)
+   height=reform(height(*,yeah(0)))
+   height=height/1000./3.72
+   heightp=height(0:n_elements(height(*))-2) 
+   print, 'new minus old', heightp - caca
+   ;;; recompute height @ given local time 
+
+        press=reform(p(*,0,*,*))
+        press=total(press,1)/n_elements(press(*,0,0))
+        press=reform(press)
+        press=reform(press(*,yeah(0)))
+        press=press(0:n_elements(press(*))-2)
+
+staticstab = DERIV( heightp , reform(what_I_plot5(*,yeah(0))) ) + 1000.*3.72/844.6  ;; 4.9 dans Hinson
+   staticstab = staticstab(0:n_elements(staticstab)-5)
+   heightp = heightp(0:n_elements(heightp)-5)
+
+plot, $
+        staticstab, $
+        heightp,$
+        xtitle='Static stability (K/km)',$
+        xrange=[-1.,5.], $
+        xtickinterval=0.5, $
+        ytitle='Altitude above surface (km)', $
+        yrange=[min(heightp),max(heightp)], $
+        ytickinterval=1., $
+        title="LMD LES Static stability @ LT 17h (K/km)", $
+        subtitle='zonal average at lat. '+latwrite
+oplot, $
+        staticstab, $
+        heightp,$
+        psym=5
+oplot, $
+       findgen(n_elements(heightp))*0. + 1.,$
+       heightp,$
+       linestyle=2
+oplot, $
+       findgen(n_elements(heightp))*0. + 2.,$
+       heightp,$
+       linestyle=2
+
+;;;;;;;;;;
+w = where((staticstab gt 1.5) and ((heightp- hgtu/1000.) gt 1.))
+t_top_plus = what_I_plot5(w(0),yeah(0))
+z_top_plus = heightp(w(0))
+p_top_plus = press(w(0))
+t_top_moins = what_I_plot5(w(0)-1,yeah(0))
+z_top_moins = heightp(w(0)-1)
+p_top_moins = press(w(0)-1)
+pbl_depth = (z_top_plus*alog(p_top_plus) + z_top_moins*alog(p_top_moins))/(alog(p_top_plus) + alog(p_top_moins)) - hgtu/1000.
+xyouts, 3., 1.5 + (max(heightp) + min(heightp)) / 3., 'Ls = '+string(lsu,'(F5.1)')+'!Uo!N', CHARSIZE=1
+xyouts, 3., 1. + (max(heightp) + min(heightp)) / 3., 'Lat = '+string(latu,'(F5.1)')+'!Uo!N', CHARSIZE=1
+xyouts, 3., 0.5 + (max(heightp) + min(heightp)) / 3., 'LonE = '+string(lonu,'(F6.1)')+'!Uo!N', CHARSIZE=1
+xyouts, 3., (max(heightp) + min(heightp)) / 3., 'T!Dt!N = '+string(t_top_plus,'(I0)')+'/'+string(t_top_moins,'(I0)')+' K ', CHARSIZE=1
+xyouts, 3., -0.5 + (max(heightp) + min(heightp)) / 3., 'p!Dt!N = '+string(p_top_plus,'(I0)')+'/'+string(p_top_moins,'(I0)')+' Pa', CHARSIZE=1
+xyouts, 3., -1. + (max(heightp) + min(heightp)) / 3., 'z!Dt!N = '+string(z_top_plus,'(F4.1)')+'/'+string(z_top_moins,'(F4.1)')+' km', CHARSIZE=1
+xyouts, 3., -1.5 + (max(heightp) + min(heightp)) / 3., 'z!Ds!N = '+string(hgtu/1000.,'(F4.1)')+' km', CHARSIZE=1
+xyouts, 3., -2. + (max(heightp) + min(heightp)) / 3., 'D = '+string(pbl_depth,'(F4.1)')+' km', CHARSIZE=1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+no_staticstab:
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+if (saveps eq 'true') then begin
+  device, /close
+endif
+stop
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+user_lt=13.
+yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+
+user_h=0.1
+walt=where(abs(heightp-user_h) eq (min(abs(heightp-user_h))))
+
+;mapfield=reform(t[*,*,walt(0),w(0)])
+;help, mapfield
+;contour, mapfield
+
+section=reform(w[*,0,*,yeah(0)])
+
+section=reform(w[*,0,*,160])
+
+lev=[-12.,-8.,-4.,4.,8.,12.]
+lev=[-5.,-4.,-3.,-2.,-1.,1.,2.,3.,4.,5.]
+contour, $
+	section, $
+	(lon(*,0)-lon(0,0))*59., $
+	heightp, $
+	levels=lev , $
+	C_LINESTYLE = (lev LT 0.0)
+
+device, /close
+
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/turbulence2.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/turbulence2.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/turbulence2.pro	(revision 1185)
@@ -0,0 +1,250 @@
+pro turbulence2
+
+
+retrieve='true'
+
+fast='true'
+;fast='false'
+
+
+p0=610. & t0=220. & r_cp=1/4.4 & grav=3.72 & R=192. & g_cp=1000.*grav/844.6
+;;;;;;;;;;;;;;;;;;;;;;;
+;                     ;
+; HINSON - HINSON !!! ;
+;                     ;
+r_cp = 0.25           ; 
+;g_cp = 4.9           ;
+;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+;
+; input files
+;
+OPENR, 22, 'input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
+OPENR, 23, 'input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
+print, lonu, latu, lsu, lctu, hgtu, tsurfu
+
+;
+; retrieve
+;
+if (retrieve eq 'true') then begin
+
+;
+; get fields and dimensions
+;
+getcdf, file='t.nc', charvar='T', invar=t
+getcdf, file='p.nc', charvar='PTOT', invar=p
+getcdf, file='ph.nc', charvar='PHTOT', invar=ph
+nx=n_elements(t(*,0,0,0))
+ny=n_elements(t(0,*,0,0))
+nz=n_elements(t(0,0,*,0))
+nt=n_elements(t(0,0,0,*))
+   ;;;; pour eviter de detecter des fluctuations plus basses que PBL top ;;;
+     smooth_gridpoint = 2 & smooth_time = 2 & smooth_vert = 2  
+     ;smooth_gridpoint = 0 & smooth_time = 0 & smooth_vert = 0  
+     t = smooth(t,[smooth_gridpoint,smooth_gridpoint,smooth_vert,smooth_time],/EDGE_TRUNCATE)
+     p = smooth(p,[smooth_gridpoint,smooth_gridpoint,smooth_vert,smooth_time],/EDGE_TRUNCATE)
+     ;ph = smooth(ph,[smooth_gridpoint,smooth_gridpoint,smooth_vert,smooth_time],/EDGE_TRUNCATE)
+   ;;;; pour eviter de detecter des fluctuations plus basses que PBL top ;;;
+
+;
+; localtime loop
+;
+localtime = lctu + 100.*findgen(nt)/3700.
+  ;
+  ; radio-occultations
+  ;
+  user_lt=17.0 & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+  user_lt=17.5 & yeah2=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+  ;;
+  ;; PBL growth
+  ;;
+  ;user_lt=14.5 & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+  ;user_lt=18.0 & yeah2=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+  ;
+
+  user_lt=14.0 & yeah=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+  user_lt=14.5 & yeah2=where(abs(localtime-user_lt) eq (min(abs(localtime-user_lt))))
+
+
+
+deb=yeah(0)
+fin=yeah2(0)
+
+;
+; calculate over domain
+;
+pbl_depth_tab=findgen(nx,ny,fin-deb+1)
+nloop = nx*ny
+
+;
+; LOOOOOOP
+;
+for tt=deb,fin do begin
+
+ tprof_mean = 0.
+ heightp_mean = 0.
+ staticstab_mean = 0.
+ nbad = 0
+
+for i=0,nx-1 do begin
+for j=0,ny-1 do begin
+
+ height=reform( ph( i,j,*,tt ) ) / 1000. / grav
+ heightp=height(0:nz-1) ;no stagger
+
+ thprof = t0 + reform( t( i,j,*,tt ) )
+ pprof = reform( p( i,j,*,tt ) )
+ tprof = thprof * ( pprof/p0 )^r_cp
+
+ staticstab = DERIV( heightp , tprof ) + g_cp  
+
+if (fast eq 'true') then begin
+
+; MOINS BON mais PLUS RAPIDE
+tprof_mean = tprof_mean + tprof/nloop
+heightp_mean = heightp_mean + heightp/nloop
+staticstab_mean = staticstab_mean + staticstab/nloop
+
+endif else begin
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+  z_in = heightp
+  profile_in = staticstab
+  resol = 500.  ;200 un peu juste
+  ;********************************************************************
+  ; ---- numerical recipes in C - section 3.3 ----
+  ;
+  ; Calculate interpolating cubic spline 
+        yspline = SPL_INIT(z_in,profile_in)
+  ; Define the X values P at which we desire interpolated Y values
+        xspline=min(z_in)+findgen(floor(max(z_in)-min(z_in))*resol)/resol
+  ; Calculate the interpolated Y values
+        result=spl_interp(z_in,profile_in,yspline,xspline)
+  ;********************************************************************
+  staticstab = result
+  heightp = xspline
+
+  heightp_mean = heightp_mean + heightp/nloop
+  staticstab_mean = staticstab_mean + staticstab/nloop
+    yspline = SPL_INIT(z_in,tprof)
+    tprof = spl_interp(z_in,tprof,yspline,xspline)
+  tprof_mean = tprof_mean + tprof/nloop
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+endelse
+
+lim=3.
+lim=1.5
+w = where( (staticstab ge lim) and (heightp-heightp(0) ge lim) )
+pbl_depth_tab(i,j,tt-deb) = heightp(w(0)) - heightp(0)
+
+   ; garde-fou supplementaire
+   if (heightp(w(0)) - heightp(0) lt 2.) then begin
+     pbl_depth_tab(i,j,tt-deb) = !VALUES.F_NAN
+     ;plot, profile_in, z_in, xrange=[-1.,5.], psym=5, title='bad!' & oplot, staticstab, heightp & oplot, staticstab, findgen(nz)*0. + heightp(w(0)), linestyle=2
+     print, heightp(w) - heightp(0)
+     nbad = nbad+1
+   endif
+
+;plot, profile_in, z_in, xrange=[-1.,5.], psym=5 & oplot, staticstab, heightp & oplot, staticstab, findgen(nz)*0. + heightp(w(0)), linestyle=2 
+;pause
+
+endfor
+;print, i
+endfor
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+  print, '-------------------------------------------------------'
+  print, 'Local Time : ', localtime(tt)
+  print, 'nbad ', nbad
+  print, 'PBL height - min ', min(pbl_depth_tab(*,*,tt-deb))
+  print, 'PBL height - max ', max(pbl_depth_tab(*,*,tt-deb))
+  print, 'PBL height - mean ', mean(pbl_depth_tab(*,*,tt-deb))
+    ;; static stability of mean profile
+    staticstab = DERIV( heightp_mean , tprof_mean ) + g_cp
+
+	  ;z_in = heightp_mean
+	  ;profile_in = staticstab
+	  ;resol = 500  ;200 un peu juste
+	  ;;********************************************************************
+	  ;; ---- numerical recipes in C - section 3.3 ----
+	  ;;
+	  ;; Calculate interpolating cubic spline 
+	  ;      yspline = SPL_INIT(z_in,profile_in)
+	  ;; Define the X values P at which we desire interpolated Y values
+	  ;      xspline=min(z_in)+findgen(floor(max(z_in))*resol)/resol
+	  ;; Calculate the interpolated Y values
+	  ;      result=spl_interp(z_in,profile_in,yspline,xspline)
+	  ;;********************************************************************
+	  ;staticstab = result
+	  ;w = where((staticstab ge 1.5) and (xspline-xspline(0) gt 2.))
+	  ;print, 'PBL height - mean profile', xspline(w(0)) - xspline(0)
+
+    w = where((staticstab ge 1.5) and (heightp_mean-heightp_mean(0) gt 1.5))
+    print, 'PBL height - mean profile', heightp_mean(w(0))-heightp_mean(0)
+    ;; mean static stability
+    w = where((staticstab_mean ge 1.5) and (heightp_mean-heightp_mean(0) gt 1.5))
+    print, 'PBL height - mean static stability', heightp_mean(w(0)) - heightp_mean(0)
+
+   ;plot, staticstab, heightp_mean, xrange=[-1.,5.]
+   ;oplot, staticstab, findgen(nz)*0. + heightp_mean(w(0)), linestyle=2
+   ;oplot, staticstab_mean, heightp_mean
+   ;oplot, staticstab_mean, findgen(nz)*0. + heightp_mean(w(0)), linestyle=2
+   ;pause
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+endfor
+endif
+
+  print, '-------------------------------------------------------'
+  print, 'PBL height - min ', min(pbl_depth_tab(*,*,*))
+  print, 'PBL height - max ', max(pbl_depth_tab(*,*,*))
+  print, 'PBL height - mean ', mean(pbl_depth_tab(*,*,*))
+  print, '-------------------------------------------------------'
+
+stop
+
+!p.charthick = 2.0
+!p.thick = 3.0
+!x.thick = 2.0
+!y.thick = 2.0
+set_plot, 'ps' & device, filename='plot/map.ps', /color
+;map_latlon, reform(pbl_depth_tab(*,*,0))
+
+
+what_I_plot = reform(pbl_depth_tab(*,*,0))
+pal=4
+colors=128
+title_user='PBL depth'
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+;        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+;        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+;        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+;        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+;        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user;, $                     ; title of the plot ('' is default)
+;        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+
+
+
+device, /close
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/update
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/update	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/update	(revision 1185)
@@ -0,0 +1,107 @@
+#! /bin/bash
+
+cd PLAN_100m_145_145_101_12km/case_I/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd PLAN_100m_45_45_71_10km/case_B/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd PLAN_100m_45_45_71_10km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd PLAN_100m_45_45_71_10km/case_I/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_145_145_201_15km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_145_145_201_20km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_45_45_71_10km/case_A/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd REAL_100m_45_45_71_10km/case_B/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd REAL_100m_45_45_71_10km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd REAL_100m_45_45_71_10km/case_C_low_ck/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd REAL_100m_45_45_71_10km/case_C_start10/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd REAL_100m_45_45_71_10km/case_I/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_50m_145_145_201_12km/case_A/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd REAL_50m_145_145_201_12km/case_B/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd REAL_50m_145_145_201_12km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd REAL_50m_145_145_201_12km/case_I/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+cd REAL_50m_145_145_201_12km/case_HIGH/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_50m_201_201_201_12km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_50m_241_241_201_12km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_145_145_101_12km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_73_73_151_15km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_101_101_151_15km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_101_101_201_15km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_73_73_201_15km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_241_241_151_15km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_50m_181_181_201_12km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_50m_145_145_251_10km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_181_181_201_15km/case_C/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
+cd REAL_100m_181_181_201_15km/case_A/
+echo "getturb, noplot='1' & exit" | /opt/idl-6.4/idl/bin/idl #> logidl 2> logidl_err &
+cd ../../
+
Index: trunk/UTIL/IDLplot/SPEC/LES/ye.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/ye.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/ye.pro	(revision 1185)
@@ -0,0 +1,83 @@
+pro ye, r, t
+
+;; paper
+min_lt = 13.
+max_lt = 16.
+
+;min_lt = 12.
+;max_lt = 16.
+
+;min_lt = 13.
+;max_lt = 15.
+
+
+wherefiles='./REAL_50m_145_145_201_12km/'
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_A'+'/compturb.dat'
+restore, filename=wherefiles+'case_A'+'/getturb.dat'
+wspe = where( (localtime ge min_lt) and (localtime le max_lt) )
+nspe = n_elements(wspe)
+r = TOTAL(a_wt_bot[*,wspe],2) 
+t = TOTAL(a_h[*,wspe],2) 
+rtot = [r]
+ttot = [t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_B'+'/compturb.dat'
+restore, filename=wherefiles+'case_B'+'/getturb.dat'
+r = TOTAL(a_wt_bot[*,wspe],2)
+t = TOTAL(a_h[*,wspe],2) 
+rtot = [rtot,r]
+ttot = [ttot,t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_C'+'/compturb.dat'
+restore, filename=wherefiles+'case_C'+'/getturb.dat'
+r = TOTAL(a_wt_bot[*,wspe],2)
+t = TOTAL(a_h[*,wspe],2)
+rtot = [rtot,r]
+ttot = [ttot,t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_I'+'/compturb.dat'
+restore, filename=wherefiles+'case_I'+'/getturb.dat'
+r = TOTAL(a_wt_bot[*,wspe],2)
+t = TOTAL(a_h[*,wspe],2)
+rtot = [rtot,r]
+ttot = [ttot,t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_HIGH'+'/compturb.dat'
+restore, filename=wherefiles+'case_HIGH'+'/getturb.dat'
+r = TOTAL(a_wt_bot[*,wspe],2)
+t = TOTAL(a_h[*,wspe],2)
+rtot = [rtot,r]
+ttot = [ttot,t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+r = r / float(nspe)
+t = t / float(nspe)
+
+sssss = sort(t)
+r = r[sssss]
+t = t[sssss]
+
+;;
+;; OK
+;;
+;lim=0.30 & zelim=(-3.85/alog(lim)+0.07*alog(lim))*exp(-4.61*lim)
+;up=1. & & zeup= - 1.55 * up + 1.27
+;slope = (zelim - zeup) / (lim - up) & ord = zeup - slope * up
+;t1 = findgen(1001.)*lim/1000. & param1 = (-3.85/alog(t1)+0.07*alog(t1))*exp(-4.61*t1)
+;t2 = lim + findgen(1001.)*(1.0 - lim)/1000. & param2 = slope * t2 + ord
+;
+;r = [param1, param2]
+;t = [t1, t2]
+
+
+end
Index: trunk/UTIL/IDLplot/SPEC/LES/ye2.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/LES/ye2.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/LES/ye2.pro	(revision 1185)
@@ -0,0 +1,78 @@
+pro ye2, r, t
+
+;;paper
+min_lt = 12.
+max_lt = 14.
+
+;min_lt = 13.
+;max_lt = 16.
+
+;min_lt = 12.
+;max_lt = 16.
+
+;min_lt = 13.
+;max_lt = 15.
+
+
+wherefiles='./REAL_50m_145_145_201_12km/'
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_A'+'/compturb.dat'
+restore, filename=wherefiles+'case_A'+'/getturb.dat'
+wspe = where( (localtime ge min_lt) and (localtime le max_lt) )
+nspe = n_elements(wspe)
+r = TOTAL(a_vel_bot[*,wspe],2)
+t = TOTAL(a_h[*,wspe],2)
+rtot = [r]
+ttot = [t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_B'+'/compturb.dat'
+restore, filename=wherefiles+'case_B'+'/getturb.dat'
+r = TOTAL(a_vel_bot[*,wspe],2)
+t = TOTAL(a_h[*,wspe],2) 
+rtot = [rtot,r]
+ttot = [ttot,t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_C'+'/compturb.dat'
+restore, filename=wherefiles+'case_C'+'/getturb.dat'
+r = TOTAL(a_vel_bot[*,wspe],2)
+t = TOTAL(a_h[*,wspe],2)
+rtot = [rtot,r]
+ttot = [ttot,t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_I'+'/compturb.dat'
+restore, filename=wherefiles+'case_I'+'/getturb.dat'
+r = TOTAL(a_vel_bot[*,wspe],2)
+t = TOTAL(a_h[*,wspe],2)
+rtot = [rtot,r]
+ttot = [ttot,t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+restore, filename=wherefiles+'case_HIGH'+'/compturb.dat'
+restore, filename=wherefiles+'case_HIGH'+'/getturb.dat'
+r = TOTAL(a_vel_bot[*,wspe],2)
+t = TOTAL(a_h[*,wspe],2)
+rtot = [rtot,r]
+ttot = [ttot,t]
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+r = r / float(nspe)
+t = t / float(nspe)
+
+sssss = sort(t)
+r = r[sssss]
+t = t[sssss]
+
+;t1 = findgen(2001.)*1./2000.
+;param1 = 2.05 * t1^(2./3.) * ( 1. - 0.64 * t1 )^2
+;r = param1
+;t = t1
+
+end
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/MOLA_topo.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/MOLA_topo.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/MOLA_topo.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,126 @@
+;;;;;*************************************** FOLDER
+        folder  = '/donnees/aslmd/MODELES/MESOSCALE/LMD_MM_MARS/mpi_64/WPS/'
+        ;coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'geo_em.d01.nc'
+        ;filename        = folder + 'paleo/geo_em.d01.nc'
+        ini_utc         = 6           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'MOLA_topo'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 99               ;; cf. what user wants (99 pour tous)
+        field1          = 'HGT_M'            ;; comment to trace horizontal velocity
+        ;field2         = 'PTOT'           ;; contour
+        ;no3d           = 'true'
+        overvector_x    = 0               ;; comment out to get rid of vectors
+        overvector_y    = 0               ;; comment out to get rid of vectors
+        fieldscoord     = ['XLONG_M','XLAT_M','HGT_M']
+
+;;;;;*************************************** TWEAK VAR
+        what_I_plot = what_I_plot / 1000.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'MOLA Topography' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.85
+        format          =       '(F4.1)' 
+        colors          =       64 
+        pal             =       15 ;33             ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       -6.0
+        maxfield_init   =       -2.5
+        ndiv            =       7
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 0.05 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        lev             =       -10. + 0.5*findgen(30)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       30.0
+        intervaly       =	05.0
+
+;;;;;*************************************** MAP LIMITS
+	windowx 	= 	[-180.,180.]        
+	windowy 	= 	[70.,90.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM10_mesopaper_tsurf.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM10_mesopaper_tsurf.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM10_mesopaper_tsurf.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,138 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM10_mesopaper/wrfout_d01_2024-06-43_18:00:00_zabg' 
+save_ps 	= 'OM10_mesopaper_tsurf'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 18	;; cf. name of file
+freq		= 2  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt
+        ntime	= ((24 + use_utc - ini_utc) MOD 24)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+        ;pal             =       4
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       150.
+        maxfield_init   =       180.
+	;minfield_init	= 	50.
+	;maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM10_nocstTI_tsurf.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM10_nocstTI_tsurf.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM10_nocstTI_tsurf.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,138 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'nocst_TI/OM10/wrfout_d01_2024-06-43_18z00z00_zabg' 
+save_ps 	= 'OM10_nocstTI_tsurf'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 18	;; cf. name of file
+freq		= 2  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt
+        ntime	= ((24 + use_utc - ini_utc) MOD 24)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Remotely-sounded TI'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+        ;pal             =       4
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       150.
+        maxfield_init   =       180.
+	;minfield_init	= 	50.
+	;maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM20_tsurf.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM20_tsurf.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM20_tsurf.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,138 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM20/wrfout_d01_2024-06-43_18z00z00_zabg' 
+save_ps 	= 'OM20_tsurf'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 18	;; cf. name of file
+freq		= 2  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt
+        ntime	= ((24 + use_utc - ini_utc) MOD 24)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 20km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+        ;pal             =       4
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       150.
+        maxfield_init   =       180.
+	;minfield_init	= 	50.
+	;maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM40_tsurf.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM40_tsurf.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM40_tsurf.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,138 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'nocst_TI/OM40/wrfout_d01_2024-06-37_06_zabg' 
+save_ps 	= 'OM40_tsurf'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt
+        ntime	= ((24 + use_utc - ini_utc) MOD 24)/freq	;; TRUE IDL SUBSCRIPT... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 170!Uo!N  /  dx = 40km [single]  /  Remotely-sounded TI'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+        ;pal             =       4
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       150.
+        maxfield_init   =       180.
+	;minfield_init	= 	50.
+	;maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_app_ti.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_app_ti.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_app_ti.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,141 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_app_ti'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+        a0 = 64.839418 & a1 = 3.1521937 & a2 = 0.0054538848 ;; Ls ~ 173 -- 2AM
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	print, max(what_I_plot), min(what_I_plot)
+	;overvector_x=0
+	;overvector_y=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        ;title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       '';'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.80 ;0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+	pal		=	4
+
+;;;;;*************************************** FILL LIMITS
+        ;minfield_init   =       150.
+        ;maxfield_init   =       180.
+	minfield_init	= 	50.
+	maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_hfx.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_hfx.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_hfx.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,144 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_hfx'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+;field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+field1         = 'HFX'       ;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+	;overvector_x=0
+	;overvector_y=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+what_I_plot = - what_I_plot
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        ;title_user      =       'Surface temperature (K)'
+	title_user	=	'Downward sensible heat flux at the surface (W m!U-2!N)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       0 ;22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        ;minfield_init   =       150.
+        ;maxfield_init   =       180.
+        minfield_init   =       0.
+        maxfield_init   =       30.
+	;minfield_init	= 	50.
+	;maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_lwdownz.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_lwdownz.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_lwdownz.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,145 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_lwdownz'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+;field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+;field1         = 'HFX'       	;; comment to trace horizontal velocity
+field1         = 'LWDOWNZ'      ;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+	;overvector_x=0
+	;overvector_y=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        ;title_user      =       'Surface temperature (K)'
+	;title_user	=	'Upward sensible heat flux at the surface (W m!U-2!N)'
+	title_user	=	'Downward longwave radiative flux at the surface (W m!U-2!N)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       0 ;22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        ;minfield_init   =       150.
+        ;maxfield_init   =       180.
+        minfield_init   =       0.
+        maxfield_init   =       30.
+	;minfield_init	= 	50.
+	;maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_m5_tsurf.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_m5_tsurf.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_m5_tsurf.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,143 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_tsurf'
+filename        = folder + 'OM6_TI85_m5/wrfout_d01_2024-05-03_06:00:00_zabg'
+save_ps         = 'OM6_TI85_m5_tsurf'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+	;overvector_x=0
+	;overvector_y=0
+what_I_plot = what_I_plot + 1.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+	subtitle_user   =       'LT = 02:00am  /  Ls = 120!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.78;0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       150.
+        maxfield_init   =       180.
+	;minfield_init	= 	50.
+	;maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_profile.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_profile.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_profile.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,152 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_profile'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+zex  = 85
+zey  = 139
+zex2 = 85
+zey2 = 160
+alt = [0.,1.]
+alt = [5.,5000.]
+alt = [0.01, 1000.]
+alt = [10., 1000.]
+;;;;;;;;;;
+nlevel          = 0
+;field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+field1         = 'HFX'       ;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+	;overvector_x=0
+	;overvector_y=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+	title_user	=	'' ;'Vertical wind speed (z-component) (m s!U-1!N)'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['Vertical wind velocity (m s!U-1!N)', 'Altitude above the surface (m)']
+        if (mention eq 'two') then title_axis      =      ['Horizontal wind speed (m s!U-1!N)', 'Altitude above the surface (m)']
+        if (mention eq 'three') then title_axis      =      ['Atmospheric temperature (K)', 'Altitude above the surface (m)']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       0 ;22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       -15.
+        maxfield_init   =       2.5
+        if (mention eq 'two') then minfield_init   =       0.001
+        if (mention eq 'two') then maxfield_init   =       40.
+        if (mention eq 'three') then minfield_init   =       160.
+        if (mention eq 'three') then maxfield_init   =       230.
+      
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	;overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.5
+        ;intervaly       =	intervalx
+	intervaly	=	0.1
+        if (mention eq 'two') then intervalx = 5.
+        if (mention eq 'three') then intervalx = 10.
+        
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_tsurf.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_tsurf.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_tsurf.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,139 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_tsurf'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+	;overvector_x=0
+	;overvector_y=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.80;0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       150.
+        maxfield_init   =       180.
+	;minfield_init	= 	50.
+	;maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_winds.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_winds.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/OM6_TI85_winds.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,143 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_winds'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'WAVE'  	;; comment to trace horizontal velocity
+;no3d 		= 'true'
+;overvector_x	= 0		;; comment out to get rid of vectors
+;overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+        ;a0 = 64.839418 & a1 = 3.1521937 & a2 = 0.0054538848 ;; Ls ~ 173 -- 2AM
+	;;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+	;;overvector_x=0
+	;;overvector_y=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        ;title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.80;0.96
+        format          =       '(I0)'
+        format          =       '(F5.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+	;pal		=	4
+	;pal		=	0
+	pal		=	1 ;19; 10 ;2
+
+;;;;;*************************************** FILL LIMITS
+        ;minfield_init   =       150.
+        ;maxfield_init   =       180.
+	minfield_init	= 	-15.
+	maxfield_init	= 	0.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       20.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       5.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_MTOT.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_MTOT.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_MTOT.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,125 @@
+;;;;;*************************************** FOLDER
+        folder  = '/tmp7/aslmd/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'wrfout_d01_2024-05-02_01:00:00'
+        ini_utc         = 1           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'POLAR_newphys_RAC_MTOT'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 99            ;; cf. what user wants (99 pour tous)
+        field1          = 'MTOT'        ;; comment to trace horizontal velocity
+        field2         = 'SWDOWNZ'           ;; contour
+        ;no3d            = 'true'
+        ;overvector_x    = 0               ;; comment out to get rid of vectors
+        ;overvector_y    = 0               ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 1.e6 / 920.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Water vapor column (precip. microns)' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.85
+        format          =       '(I0)' 
+        colors          =       32
+        pal             =       33              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.
+        maxfield_init   =       40.
+        ndiv            =       8
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 0.05 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	;overcontour	=	overcontour/1000.
+        ;lev             =       -10. + 0.5*findgen(80)
+        lev             =       25. + 25. * findgen(20)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       30.0
+        intervaly       =	05.0
+
+;;;;;*************************************** MAP LIMITS
+	windowx 	= 	[-180.,180.]        
+	windowy 	= 	[65.,90.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_QH2Oatm1.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_QH2Oatm1.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_QH2Oatm1.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,124 @@
+;;;;;*************************************** FOLDER
+        folder  = '/tmp7/aslmd/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'wrfout_d01_2024-05-02_01:00:00'
+        ini_utc         = 1           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'POLAR_newphys_RAC_QH2Oatm1'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 99            ;; cf. what user wants (99 pour tous)
+        field1          = 'QH2O'       ;; comment to trace horizontal velocity
+        ;field2         = 'XLAT'           ;; contour
+        ;no3d            = 'true'
+        ;overvector_x    = 0               ;; comment out to get rid of vectors
+        ;overvector_y    = 0               ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        what_I_plot = what_I_plot * 1.e6
+        print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Near-surface water vapor mass mixing ratio (ppm)' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.85
+        format          =       '(I0)' 
+        colors          =       32
+        pal             =       33              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.
+        maxfield_init   =       200.
+        ndiv            =       10
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 0.05 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        lev             =       -10. + 0.5*findgen(80)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       30.0
+        intervaly       =	05.0
+
+;;;;;*************************************** MAP LIMITS
+	windowx 	= 	[-180.,180.]        
+	windowy 	= 	[65.,90.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_QSURFICEneg.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_QSURFICEneg.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_QSURFICEneg.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,125 @@
+;;;;;*************************************** FOLDER
+        folder  = '/tmp7/aslmd/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'wrfout_d01_2024-05-02_01:00:00'
+        ini_utc         = 1           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'POLAR_newphys_RAC_QSURFICEneg'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 24;99               ;; cf. what user wants (99 pour tous)
+        field1          = 'QSURFICE'       ;; comment to trace horizontal velocity
+        ;field2         = 'XLAT'           ;; contour
+        no3d            = 'true'
+        ;overvector_x    = 0               ;; comment out to get rid of vectors
+        ;overvector_y    = 0               ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 0.
+        what_I_plot = abs(what_I_plot * 1.e6 / 920.)
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Hollowed surface water ice (microns)' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.85
+        format          =       '(I0)' 
+        colors          =       32
+        pal             =       33;22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.
+        maxfield_init   =       250.
+        ndiv            =       10
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 0.05 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        lev             =       -10. + 0.5*findgen(80)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       30.0
+        intervaly       =	05.0
+
+;;;;;*************************************** MAP LIMITS
+	windowx 	= 	[-180.,180.]        
+	windowy 	= 	[65.,90.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_QSURFICEpos.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_QSURFICEpos.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_QSURFICEpos.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,125 @@
+;;;;;*************************************** FOLDER
+        folder  = '/tmp7/aslmd/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'wrfout_d01_2024-05-02_01:00:00'
+        ini_utc         = 1           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'POLAR_newphys_RAC_QSURFICEpos'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 24;99               ;; cf. what user wants (99 pour tous)
+        field1          = 'QSURFICE'       ;; comment to trace horizontal velocity
+        ;field2         = 'XLAT'           ;; contour
+        no3d            = 'true'
+        ;overvector_x    = 0               ;; comment out to get rid of vectors
+        ;overvector_y    = 0               ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 0.
+        what_I_plot =  what_I_plot * 1.e6 / 920.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Deposited surface water ice (microns)' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.85
+        format          =       '(I0)' 
+        colors          =       32
+        pal             =       33              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.
+        maxfield_init   =       6.
+        ndiv            =       6
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 0.05 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        lev             =       -10. + 0.5*findgen(80)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       30.0
+        intervaly       =	05.0
+
+;;;;;*************************************** MAP LIMITS
+	windowx 	= 	[-180.,180.]        
+	windowy 	= 	[65.,90.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_TAUTES.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_TAUTES.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/POLAR_newphys_RAC_TAUTES.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,124 @@
+;;;;;*************************************** FOLDER
+        folder  = '/tmp7/aslmd/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'wrfout_d01_2024-05-02_01:00:00'
+        ini_utc         = 1           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'POLAR_newphys_RAC_TAUTES'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 99               ;; cf. what user wants (99 pour tous)
+        field1          = 'TAU_ICE'        ;; comment to trace horizontal velocity
+        ;field2         = 'XLAT'           ;; contour
+        no3d            = 'true'
+        ;overvector_x    = 0               ;; comment out to get rid of vectors
+        ;overvector_y    = 0               ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 0.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Water ice cloud optical depth at 825 cm!U-1!N' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.85
+        format          =       '(F5.2)' 
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.
+        maxfield_init   =       0.55
+        ndiv            =       11
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        lev             =       -10. + 0.5*findgen(80)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       30.0
+        intervaly       =	05.0
+
+;;;;;*************************************** MAP LIMITS
+	windowx 	= 	[-180.,180.]        
+	windowy 	= 	[65.,90.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/SHARAD_topo.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/SHARAD_topo.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/SHARAD_topo.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,129 @@
+;;;;;*************************************** FOLDER
+        folder  = '/donnees/aslmd/MODELES/MESOSCALE/LMD_MM_MARS/mpi_64/WPS/'
+        ;coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'geo_em.d01.nc'
+        ini_utc         = 6           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'MOLA_topo'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 99               ;; cf. what user wants (99 pour tous)
+        field1          = 'HGT_M'            ;; comment to trace horizontal velocity
+        ;field2         = 'PTOT'           ;; contour
+        ;no3d           = 'true'
+        overvector_x    = 0               ;; comment out to get rid of vectors
+        overvector_y    = 0               ;; comment out to get rid of vectors
+        fieldscoord     = ['XLONG_M','XLAT_M','HGT_M']
+
+;;;;;*************************************** TWEAK VAR
+        what_I_plot = what_I_plot / 1000.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'MOLA Topography' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+filename        = folder + 'paleo/geo_em.d01.nc'
+save_ps         = 'SHARAD_topo'
+title_user      = 'SHARAD Paleo-Topography'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.85
+        format          =       '(F4.1)' 
+        colors          =       64 
+        pal             =       15 ;33             ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       -6.0
+        maxfield_init   =       -2.5
+        ndiv            =       7
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 0.05 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        lev             =       -10. + 0.5*findgen(30)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       30.0
+        intervaly       =	05.0
+
+;;;;;*************************************** MAP LIMITS
+	windowx 	= 	[-180.,180.]        
+	windowy 	= 	[70.,90.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/THARSIS_newphys_RAC_TAUTES.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/THARSIS_newphys_RAC_TAUTES.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/THARSIS_newphys_RAC_TAUTES.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,124 @@
+;;;;;*************************************** FOLDER
+        folder  = '/tmp7/aslmd/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	;coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'RACmeso_RACgcm/wrfout_d01_2024-05-03_01:00:00'
+        ini_utc         = 1           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'THARSIS_newphys_RAC_TAUTES'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 14               ;; cf. what user wants (99 pour tous)
+        field1          = 'TAU_ICE'        ;; comment to trace horizontal velocity
+        ;field2         = 'XLAT'           ;; contour
+        no3d            = 'true'
+        ;overvector_x    = 0               ;; comment out to get rid of vectors
+        ;overvector_y    = 0               ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 0.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Water ice cloud optical depth at 825 cm!U-1!N' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.70
+        format          =       '(F5.2)' 
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.
+        maxfield_init   =       0.25
+        ndiv            =       5
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       5.0
+        intervaly       =       intervalx
+
+;;;;;*************************************** MAP LIMITS
+        windowx         =       [-150.,-100.]
+        windowy         =       [-15.,35.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/THARSIS_newphys_bugnoRAC_RACgcm_TAUTES.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/THARSIS_newphys_bugnoRAC_RACgcm_TAUTES.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/THARSIS_newphys_bugnoRAC_RACgcm_TAUTES.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,132 @@
+;;;;;*************************************** FOLDER
+        folder  = '/home/aslmd/MESOWATERCYCLE/'
+        ;coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	;coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'THARSIS_noBUG.171021/wrfout_d01_2024-05-03_01:00:00'
+        ini_utc         = 1           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'THARSIS_newphys_RAC_TAUTES'
+filename        = folder + 'THARSIS_noRAC_noBUG.171041/wrfout_d01_2024-05-03_01:00:00'
+save_ps         = 'THARSIS_newphys_noRAC_TAUTES'
+filename        = folder + 'RACmeso_RACgcm/wrfout_d01_2024-05-03_01:00:00'
+save_ps         = 'THARSIS_newphys_bugRAC_TAUTES'
+filename        = folder + 'noRACmeso_noRACgcm/wrfout_d01_2024-05-03_01:00:00'
+save_ps         = 'THARSIS_newphys_bugnoRAC_TAUTES'
+filename        = folder + 'noRACmeso_RACgcm/wrfout_d01_2024-05-03_01:00:00'
+save_ps         = 'THARSIS_newphys_bugnoRAC_RACgcm_TAUTES'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 14               ;; cf. what user wants (99 pour tous)
+        field1          = 'TAU_ICE'        ;; comment to trace horizontal velocity
+        ;field2         = 'XLAT'           ;; contour
+        no3d            = 'true'
+        overvector_x    = 0               ;; comment out to get rid of vectors
+        overvector_y    = 0               ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 0.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Water ice cloud optical depth at 825 cm!U-1!N' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.70
+        format          =       '(F5.2)' 
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.
+        maxfield_init   =       0.4
+        ndiv            =       8
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       5.0
+        intervaly       =       intervalx
+
+;;;;;*************************************** MAP LIMITS
+        windowx         =       [-150.,-100.]
+        windowy         =       [-15.,35.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/THARSIS_newphys_noRAC_TAUTES.map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/THARSIS_newphys_noRAC_TAUTES.map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/THARSIS_newphys_noRAC_TAUTES.map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,124 @@
+;;;;;*************************************** FOLDER
+        folder  = '/tmp7/aslmd/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	;coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'noRACmeso_noRACgcm/wrfout_d01_2024-05-03_01:00:00'
+        ini_utc         = 1           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'THARSIS_newphys_noRAC_TAUTES'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 14               ;; cf. what user wants (99 pour tous)
+        field1          = 'TAU_ICE'        ;; comment to trace horizontal velocity
+        ;field2         = 'XLAT'           ;; contour
+        no3d            = 'true'
+        ;overvector_x    = 0               ;; comment out to get rid of vectors
+        ;overvector_y    = 0               ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 0.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Water ice cloud optical depth at 825 cm!U-1!N' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.70
+        format          =       '(F5.2)' 
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.10
+        maxfield_init   =       0.65
+        ndiv            =       11
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       5.0
+        intervaly       =       intervalx
+
+;;;;;*************************************** MAP LIMITS
+        windowx         =       [-150.,-100.]
+        windowy         =       [-15.,35.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/map_static_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/map_static_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/map_static_inc.pro	(revision 1185)
@@ -0,0 +1,47 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+filename = '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/OM6_TI85/geo_em.d01.nc'
+save_ps  = 'olympus_slope'
+	field1  = 'THERMAL_INERTIA'  ;; omettre trace pentes
+	save_ps  = 'olympus_ti'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(I0)'
+colors        = 32 ;64 ;128 ;32
+pal           = 6 ;39 ;4 ;33 ;4 ;33 ;4 ;22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+	pal   = 4	
+title_user    = 'Slope angle (deg)'
+	title_user    =  'Apparent nighttime thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+title_axis    = ['East longitude','North latitude']
+poscb=0.80
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+	;what_I_plot = what_I_plot / 1000.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FILL LIMITS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+minfield_init= 0.      
+maxfield_init= 25.    
+	minfield_init= 50.
+	maxfield_init= 250.
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; WINDS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex=20.  	;; default: 20.
+stride=3.       ;; default: 5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; CONTOUR				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+overcontour=overcontour/1000.
+lev=-10. + 2.*findgen(20) 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; AXIS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+intervalx=2.0            
+intervaly=1.0            
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; MAP LIMITS 				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windowx = [-146.,-126.]
+windowy = [11.,27.]
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/map_static_inc.pro.2
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/map_static_inc.pro.2	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/map_static_inc.pro.2	(revision 1185)
@@ -0,0 +1,69 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+filename = '/d5/aslmd/WRF_Mars/EN_COURS/OMG_cstTI/geo_em.d03.nc'
+save_ps  = 'meridiani_ti'
+field1  = 'THERMAL_INERTIA'  ;; omettre trace vitesse horizontale
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(I0)'
+colors        = 32
+pal           =  4 ;33 ;4 ;22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+title_user    = 'Apparent nighttime thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+        title_axis      =       ['East longitude','North latitude']
+poscb=0.96
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FILL LIMITS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;minfield_init= 10.      
+;maxfield_init= 110.    
+minfield_init= 30. ;50.      
+maxfield_init= 230. ;250.    
+minfield_init= 50.      
+maxfield_init= 250.    
+	;minfield_init=1.4
+	;maxfield_init=2.4
+	;what_I_plot = alog(what_I_plot)/alog(10)
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; WINDS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex=20.  	;; default: 20.
+stride=3.       ;; default: 5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; CONTOUR				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+overcontour=overcontour/1000.
+lev=-10. + 0.2*findgen(100) 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; AXIS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+intervalx=0.5            
+intervaly=0.5            
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; MAP LIMITS 				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windowx=[14.0,16.0]        
+windowy=[10.0,12.0]
+
+
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/g95_32_single/WPS/geo_em.d01.nc'
+filename = './geo_em.d01.nc'
+;filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/mpi_64/WPS/geo_em.d01.nc'
+filename = '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/OM6_TI85/geo_em.d01.nc'
+save_ps  = 'OM6_TI85_ti'
+lev = -10. + 2.*findgen(20)
+intervalx = 2.
+intervaly = 1.
+windowx = [-146.,-126.]
+windowy = [10.,28.]
+windowx = [-146.,-128.]
+windowy = [12.,26.]
+windowx         =       [-146.,-126.]        
+windowy         =       [11.,27.]
+
+
+title='Slope angle (deg)'
+format='(I0)'
+pal=16
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro	(revision 1185)
@@ -0,0 +1,124 @@
+;;;;;*************************************** FOLDER
+        folder  = '/tmp7/aslmd/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	coord2d = 'polar'       ;; for polar projection with map_set ;; utiliser use_lt=99
+        filename        = folder + 'wrfout_d01_2024-05-02_01:00:00'
+        ini_utc         = 1           ;; cf. name of file
+        freq            = 1           ;; cf. 1 output per ... hour
+        save_ps         = 'POLAR_newphys_RAC_TAUTES'
+
+;;;;;*************************************** LVL & FLD & TIME
+        nlevel          = 0
+        use_lt          = 99               ;; cf. what user wants (99 pour tous)
+        field1          = 'TAU_ICE'        ;; comment to trace horizontal velocity
+        ;field2         = 'XLAT'           ;; contour
+        no3d            = 'true'
+        ;overvector_x    = 0               ;; comment out to get rid of vectors
+        ;overvector_y    = 0               ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 0.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Water ice cloud optical depth at 825 cm!U-1!N' 
+        title_axis      =       ['East longitude','North latitude']
+        ;subtitle_user   = 'LMD_MM'
+        ;;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+        ;;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+        ;subtitle_user   = subtitle_user + ' / Ls = 120!Uo!N'
+        ;subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.85
+        format          =       '(F5.2)' 
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.
+        maxfield_init   =       0.55
+        ndiv            =       11
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.             ;; DEF: 20.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        lev             =       -10. + 0.5*findgen(80)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       30.0
+        intervaly       =	05.0
+
+;;;;;*************************************** MAP LIMITS
+	windowx 	= 	[-180.,180.]        
+	windowy 	= 	[65.,90.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+;;;;;*************************************** SETTING TIME (do not modify)
+        if (n_elements(windowx) eq 0) then windowx = 0 
+        utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+        use_utc         = use_lt - utc_to_lt
+        zentime         = floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... 
+        if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+        print, zentime, ntime
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro.map
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro.map	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro.map	(revision 1185)
@@ -0,0 +1,142 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_winds'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'WAVE'  	;; comment to trace horizontal velocity
+;no3d 		= 'true'
+;overvector_x	= 0		;; comment out to get rid of vectors
+;overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+        ;a0 = 64.839418 & a1 = 3.1521937 & a2 = 0.0054538848 ;; Ls ~ 173 -- 2AM
+	;;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+	;;overvector_x=0
+	;;overvector_y=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        ;title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+	pal		=	4
+	pal		=	0
+
+;;;;;*************************************** FILL LIMITS
+        ;minfield_init   =       150.
+        ;maxfield_init   =       180.
+	minfield_init	= 	-10.
+	maxfield_init	= 	0.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       20.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       5.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro.oldref
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro.oldref	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro.oldref	(revision 1185)
@@ -0,0 +1,139 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_tsurf'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+nlevel          = 0
+field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+	;overvector_x=0
+	;overvector_y=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+        ;title_user 	= 	'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)' 
+	;title_user    	= 	'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+	;title_user 	= 	'Winds 10m ABG (m s!U-1!N)'
+        title_user      =       'Surface temperature (K)'
+        ;subtitle_user   =       'LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['East longitude','North latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.80;0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       150.
+        maxfield_init   =       180.
+	;minfield_init	= 	50.
+	;maxfield_init	= 	250.
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        ;intervaly       =	intervalx
+	intervaly	=	1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro.profile
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro.profile	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc.pro.profile	(revision 1185)
@@ -0,0 +1,152 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOLDER
+	folder 	= '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/' 
+        coord2d = 'false'	;; for non-regular projections  
+filename 	= folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg' 
+save_ps 	= 'OM6_TI85_profile'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TIME
+ini_utc		= 6	;; cf. name of file
+freq		= 1  	;; cf. 1 output per ... hour
+utc_to_lt       = -9    ;; cf. longitude -- LT = UTC + utc_to_lt 
+	use_lt	= 2	;; cf. what user wants
+	use_utc	= use_lt - utc_to_lt 
+        ntime	= (use_utc - ini_utc)/freq	;; TRUE IDL SUBSCRIPT ... ajouter un modulo... 
+        print, 'CHECK ... ', filename, ntime
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LVL & FLD
+zex  = 85
+zey  = 139
+zex2 = 85
+zey2 = 160
+alt = [0.,1.]
+alt = [5.,5000.]
+alt = [0.01, 1000.]
+alt = [10., 1000.]
+;;;;;;;;;;
+nlevel          = 0
+;field1   	= 'TSURF'  	;; comment to trace horizontal velocity
+field1         = 'HFX'       ;; comment to trace horizontal velocity
+no3d 		= 'true'
+overvector_x	= 0		;; comment out to get rid of vectors
+overvector_y	= 0		;; comment out to get rid of vectors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TWEAK VAR
+	;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+	;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+	;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+	;print, max(what_I_plot), min(what_I_plot)
+	;overvector_x=0
+	;overvector_y=0
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+
+
+;;;;;*************************************** PLOT TITLES
+	title_user	=	'' ;'Vertical wind speed (z-component) (m s!U-1!N)'
+        subtitle_user   =       'LT = 02:00am  /  Ls = 173!Uo!N  /  dx = 6km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+        title_axis      =       ['Vertical wind velocity (m s!U-1!N)', 'Altitude above the surface (m)']
+        if (mention eq 'two') then title_axis      =      ['Horizontal wind speed (m s!U-1!N)', 'Altitude above the surface (m)']
+        if (mention eq 'three') then title_axis      =      ['Atmospheric temperature (K)', 'Altitude above the surface (m)']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       0 ;22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       -15.
+        maxfield_init   =       2.5
+        if (mention eq 'two') then minfield_init   =       0.001
+        if (mention eq 'two') then maxfield_init   =       40.
+        if (mention eq 'three') then minfield_init   =       160.
+        if (mention eq 'three') then maxfield_init   =       230.
+      
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.		;; DEF: 20.
+        windex          =       30.             ;; DEF: 20.
+        ;stride          =       1. 		;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+	;overcontour	=	overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.5
+        ;intervaly       =	intervalx
+	intervaly	=	0.1
+        if (mention eq 'two') then intervalx = 5.
+        if (mention eq 'three') then intervalx = 10.
+        
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+	windowx 	= 	[-146.,-126.]        
+	;windowy 	 =	[10.,28.]
+	;windowx 	 = 	[-146.,-128.]
+        ;windowy         =      [12.,26.]
+	windowy 	= 	[11.,27.]
+
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+;;;;;***************************************
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc_gen.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc_gen.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/defs/map_uvt_inc_gen.pro	(revision 1185)
@@ -0,0 +1,114 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ntime    = 19  ;; le vrai indice IDL 
+nlevel   = 0 ;1 
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d03_2024-01-51_06z00z00_zabg' ;;UTC+1h
+save_ps  = 'meridiani'
+;coord2d  = 'true'
+;field1   = 'TSURF'  ;; omettre trace vitesse horizontale
+no3d = 'true'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(I0)'
+colors        = 128
+pal           =  22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; PLOT TITLES                                ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+title_user = 'Surface temperature (K) and Winds 10m ABG (m s!U-1!N)'
+subtitle_user='LT = 02:00am  /  Ls = 25!Uo!N  /  dx = 2.25km [nest 3]  /  Uniform TI = 65 J m!U-2!N s!U-0.5!N K!U-1!N'        
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FILL LIMITS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+minfield_init= 150.      
+maxfield_init= 180.    
+;minfield_init= 155.
+;maxfield_init= 175.
+missing_value=1.e30
+;lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+;lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; WINDS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex=15.  	;; default: 20.
+stride=2.       ;; default: 5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; CONTOUR				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+overcontour=overcontour/1000.
+lev=-10. + 0.2*findgen(100) 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; AXIS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+intervalx=0.5            
+intervaly=0.5            
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; MAP LIMITS 				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windowx=[14.0,16.0]        
+windowy=[10.0,12.0]
+
+
+;
+; OLYMPUS
+;
+ntime = 8
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d01_2024-06-42_18z00z00_zabg' ;;UTC-9h ;;sorties tt 2h
+save_ps = 'olympus'
+subtitle_user='LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 20km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+windex = 30.
+stride = 2.
+lev = -10. + 2.*findgen(20)
+intervalx = 2.            
+intervaly = 2.            
+windowx = [-146.,-126.]        
+windowy = [10.,28.]
+
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d01_2024-06-43_18:00:00_zabg' ;;mm chose a 10 km
+save_ps = 'olympus10'
+subtitle_user='LT = 03:00am  /  Ls = 173!Uo!N  /  dx = 10km [single]  /  Uniform TI = 85 J m!U-2!N s!U-0.5!N K!U-1!N'
+stride = 3.
+
+;pal           =  4 ;33 ;4 ;22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+;title_user    = 'Wind-induced apparent thermal inertia (J m!U-2!N s!U-0.5!N K!U-1!N)'
+;minfield_init= 30. ;50.
+;maxfield_init= 230. ;250.
+;a0 = 65.052165 & a1 = 3.1228993 & a2 = 0.0053787417 ;; Ls ~ 173
+;;a0 = 64.039300 & a1 = 3.1378104 & a2 = 0.0055369148 ;; Ls ~ 120
+;what_I_plot = - ( alog ( a1 - what_I_plot / a0 ) ) /  a2
+;print, max(what_I_plot), min(what_I_plot)
+;overvector_x=0
+;overvector_y=0
+
+;minfield_init= 0.
+;maxfield_init= 30.
+
+
+;;
+;; % of error due to winds
+;;
+;pal=4;18;0;22
+;minfield_init=-100.
+;maxfield_init=150.
+;;what_I_plot = 100. * (what_I_plot / 60. - 1.)
+;;what_I_plot = 100. * (what_I_plot / 70. - 1.)
+;;what_I_plot = 100. * (what_I_plot / 85. - 1.)
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;;;commenter au dessus
+
+ntime    = 6
+;;filename = '/tmp7/aslmd/results60/wrfout_d01_2024-05-03_06:00:00_zabg'
+;;filename = '/tmp7/aslmd/results70/wrfout_d01_2024-05-03_06:00:00_zabg'
+;;filename = '/tmp7/aslmd/lowres/wrfout_d01_2024-05-01_06:00:00_zabg'
+;filename = '/tmp7/aslmd/wrfout_d01_2024-05-03_06:00:00_zabg'
+;filename = '/tmp7/aslmd/OM6/wrfout_d01_2024-06-43_06:00:00_zabg'
+
+
+windowx = [-146.,-128.]
+windowy = [12.,26.]
+
+;windowx=[-115.,-111.]       ;; grepMAP
+;windowy=[-1.,3.]       ;; grepMAP
+
+title_user = 'Winds 10m ABG (m s!U-1!N)' 
Index: trunk/UTIL/IDLplot/SPEC/MAP/map_static.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/map_static.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/map_static.pro	(revision 1185)
@@ -0,0 +1,84 @@
+pro map_static
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+@map_static_inc.pro
+SPAWN, '\rm param_plot.idl ; cp map_static_inc.pro param_plot.idl'
+if (n_elements(coord2d) eq 0) then coord2d='false'
+;
+;
+;
+  zefile=save_ps
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+;
+;
+;
+if (n_elements(field1) ne 0) then getcdf, file=filename, charvar=field1, invar=cfield1
+getcdf, file=filename, charvar='XLONG_M', invar=longi
+getcdf, file=filename, charvar='XLAT_M', invar=lati
+getcdf, file=filename, charvar='HGT_M', invar=hgt
+getcdf, file=filename, charvar='SLPX', invar=hxwrf
+getcdf, file=filename, charvar='SLPY', invar=hywrf
+
+	hx=hxwrf*1000. & hy=hywrf*1000.
+	;; SLOPE ANGLE vs HORIZONTAL
+	theta=atan(sqrt(hx^2+hy^2)) & theta=180.*theta/!pi ;& theta=round(theta)
+;
+;
+;
+        hgt = smooth(hgt, [2,2], /EDGE_TRUNCATE) ;;; truc
+;
+;
+;
+sp = 5 ;; relaxation width
+nx = n_elements(longi(0,*))
+ny = n_elements(longi(*,0))
+if (n_elements(field1) ne 0) then begin
+	cfield1	= cfield1	(sp:nx-sp-1,sp:ny-sp-1,*,*)
+endif else begin
+	cfield1 = theta         (sp:nx-sp-1,sp:ny-sp-1,*,*)
+endelse
+longi		= longi		(sp:nx-sp-1,sp:ny-sp-1,*)
+lati           	= lati 	        (sp:nx-sp-1,sp:ny-sp-1,*)
+hgt		= hgt		(sp:nx-sp-1,sp:ny-sp-1,*)
+nx = n_elements(longi(0,*))
+ny = n_elements(longi(*,0))
+;
+;
+;
+overcontour = reform(hgt(*,*))
+lon = reform(longi(*,*))
+lat = reform(lati(*,*))
+overvector_x = 0
+overvector_y = 0
+what_I_plot = reform(cfield1(*,*))
+help, what_I_plot, lon, lat
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;
+;
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/MAP/map_uvt.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/MAP/map_uvt.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/MAP/map_uvt.pro	(revision 1185)
@@ -0,0 +1,202 @@
+pro map_uvt
+;
+;
+;
+what_I_plot=0.
+overcontour=0
+no3d='true'
+@map_uvt_inc.pro
+SPAWN, '\rm param_plot.idl ; cp map_uvt_inc.pro param_plot.idl ; cp -f map_uvt_inc.pro '+save_ps+'.map_uvt_inc.pro'
+if (n_elements(coord2d) eq 0) then coord2d='false'
+if (n_elements(overvector_x) eq 0) then overvector_x = 1  ;; initialisation (!! map_uvt_inc.pro utilise dans map_uvt et map_latlon) 
+;
+;
+;
+if (n_elements(field1) ne 0) then getcdf, file=filename, charvar=field1, invar=cfield1
+if (n_elements(field2) ne 0) then getcdf, file=filename, charvar=field2, invar=cfield2
+if ( ( overvector_x ne 0 ) or ( n_elements(field1) eq 0 ) ) then begin
+   u = getget(filename, 'Um', count=[0,0,1,0], offset=[0,0,nlevel,0])
+   v = getget(filename, 'Vm', count=[0,0,1,0], offset=[0,0,nlevel,0])
+   help, u
+endif
+if (n_elements(fieldscoord) eq 0) then begin
+ getcdf, file=filename, charvar='XLONG', invar=longi
+ getcdf, file=filename, charvar='XLAT', invar=lati
+ getcdf, file=filename, charvar='HGT', invar=hgt
+endif else begin
+ print, 'coordinates are ', fieldscoord
+ getcdf, file=filename, charvar=fieldscoord(0), invar=longi
+ getcdf, file=filename, charvar=fieldscoord(1), invar=lati
+ getcdf, file=filename, charvar=fieldscoord(2), invar=hgt
+endelse
+
+;
+;
+;
+sp = 5 ;; relaxation width
+nx = n_elements(longi(0,*))
+ny = n_elements(longi(*,0))
+if (n_elements(field1) ne 0) then begin
+	if (no3d ne 'true') then cfield1 = cfield1 (sp:nx-sp-1,sp:ny-sp-1,*,*) else cfield1 = cfield1 (sp:nx-sp-1,sp:ny-sp-1,*)
+endif
+if (n_elements(field2) ne 0) then begin
+        if (no3d ne 'true') then cfield2 = cfield2 (sp:nx-sp-1,sp:ny-sp-1,*,*) else cfield2 = cfield2 (sp:nx-sp-1,sp:ny-sp-1,*)
+endif
+if ( ( overvector_x ne 0 ) or ( n_elements(field1) eq 0 ) ) then begin
+  u 		= reform (u		(sp:nx-sp-1,sp:ny-sp-1,0,*) )
+  v       	= reform (v       	(sp:nx-sp-1,sp:ny-sp-1,0,*) )
+endif
+longi		= longi		(sp:nx-sp-1,sp:ny-sp-1,*)
+lati          	= lati 	        (sp:nx-sp-1,sp:ny-sp-1,*)
+hgt		= hgt		(sp:nx-sp-1,sp:ny-sp-1,*)
+nx = n_elements(longi(*,0,0))
+ny = n_elements(longi(0,*,0))
+nt = n_elements(longi(0,0,*))
+if ( overvector_x ne 0 ) then begin  
+  overvector_x = u
+  overvector_y = v
+endif
+;
+;
+;
+                if (ntime eq 99) then begin
+                        PRINT, '-- ALL TIME STEPS', nt-1 
+                        ntstart = 0  & ntend = nt-1 
+                endif else begin
+                        PRINT, '-- ONLY TIME STEP ', string(ntime,'(I0)')
+                        ntstart = ntime & ntend = ntime
+                endelse
+                for ntime = ntstart,ntend do begin
+help, u
+;
+;
+;
+  zefile=save_ps+string(100+ntime,'(I0)')
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+;
+;
+;
+lon = reform(longi(*,*,ntime))
+lat = reform(lati(*,*,ntime))
+if (n_elements(field1) eq 0) then begin
+        print, 'field1: horizontal velocity'
+		;;;attention attention overvector_x et overvector_y sont vides
+		;zevel = overvector_x^2 + overvector_y^2  ;; attention il faut que les tableaux soient de la meme taille, OK si uvmet
+        zevel = (reform(u(*,*,ntime)))^2 + (reform(v(*,*,ntime)))^2 ;; attention il faut que les tableaux soient de la meme taille, OK si uvmet
+	what_I_plot = sqrt(zevel)
+endif else begin
+	if (no3d ne 'true') then what_I_plot = reform(cfield1(*,*,nlevel,ntime)) else what_I_plot = reform(cfield1(*,*,ntime))
+        if (n_elements(u) ne 0) then overvector_x = reform(u(*,*,ntime))   ;; ne pas utiliser test overvector_x a cause de la boucle temps
+        if (n_elements(v) ne 0) then overvector_y = reform(v(*,*,ntime))   ;; ne pas utiliser test overvector_y a cause de la boucle temps
+endelse
+if (n_elements(field2) eq 0) then begin
+        print, 'field2: topography'
+        overcontour = reform(hgt(*,*,ntime))
+endif else begin
+        if (no3d ne 'true') then overcontour = reform(cfield2(*,*,nlevel,ntime)) else overcontour = reform(cfield2(*,*,ntime))
+endelse
+;
+;
+;
+if ( coord2d eq 'polar' ) then begin
+   print, 'OK YOU USE MAP_SET with POLAR PROJECTION. VECTORS ARE NOT SUPPORTED. USE polar_uv OR ADAPT THIS SCRIPT.'
+   overvector_x = 0 
+   overvector_y = 0
+   if (n_elements(windowx) ne 0) then begin
+       latmin = windowy(0) & latmax = windowy(1) & lonmin = windowx(0) & lonmax = windowx(1)
+   endif else begin
+       latmin = 65. & latmax = 90. & lonmin = -180. & lonmax = 180.
+   endelse
+   print, 'latmin,lonmin,latmax,lonmax', latmin,lonmin,latmax,lonmax
+   map_set, latmax, 0., /isotropic, /azimuthal, /noborder, limit=[latmin,lonmin,latmax,lonmax], title=title_user, /advance
+endif else begin
+  minlat=min(lat) & maxlat=max(lat) & minlon=min(lon) & maxlon=max(lon)
+  if (coord2d eq 'true') then begin
+        ;;;; CECI EST DESORMAIS FAIT DANS MAP_LATLON  
+	;;npoints=n_elements(lon(*,0)) + n_elements(lon(0,*))  ;; trop de points, mais au moins on ne perd rien 
+	;;TRIANGULATE, lon, lat, tr 
+	;;what_I_plot  = GRIDDATA( lon, lat, what_I_plot,  /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+        ;;if ( overvector_x ne 0 ) then begin
+	;;  overvector_x = GRIDDATA( lon, lat, overvector_x, /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+	;;  overvector_y = GRIDDATA( lon, lat, overvector_y, /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+        ;;endif
+        ;;overcontour  = GRIDDATA( lon, lat, overcontour,  /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+        ;;                if ( overvector_x ne 0 ) then begin
+	;;		  ; sale sale sale
+	;;		  if (minlat lt min(lat(*,0))) then overvector_y=-overvector_y
+	;;		  if (minlon lt min(lon(0,*))) then overvector_x=-overvector_x
+        ;;                endif
+        ;;lon =  minlon + (maxlon - minlon)*findgen(npoints)/float(npoints-1)
+        ;;lat =  minlat + (maxlat - minlat)*findgen(npoints)/float(npoints-1)
+  endif else begin
+	lon = reform(lon(*,0))
+	lat = reform(lat(0,*))
+	;;npoints=n_elements(lon(*,0)) + n_elements(lon(0,*))
+        ;;what_I_plot = REBIN( what_I_plot, npoints, npoints )
+        ;;overvector_x = REBIN( overvector_x, npoints, npoints )
+	;;overvector_y = REBIN( overvector_y, npoints, npoints )
+	;;overcontour = REBIN( overcontour, npoints, npoints )
+        ;;lon =  minlon + (maxlon - minlon)*findgen(npoints)/float(npoints-1)
+        ;;lat =  minlat + (maxlat - minlat)*findgen(npoints)/float(npoints-1)
+		;lon = findgen( n_elements(what_I_plot(*,0)) )
+		;lat = findgen( n_elements(what_I_plot(0,*)) )
+		;print, 'ATTENTION!!!! NOUS SOMMES BIEN D ACCORD QUE VOUS NE CHARGEZ PAS UMET et VMET ??'
+  endelse
+                        ;;;;; trouve dans polar_uv.pro
+			;;if (coord2d eq 'regular') then begin ;; carte avec mercator
+			;;	lon = reform(lon(*,0))
+			;;	lat = reform(lat(0,*))
+			;;endif
+endelse
+help, what_I_plot, lon, lat
+print, 'COLOR PLOT min/max ', min(what_I_plot), max(what_I_plot)
+print, 'CONTOUR PLOT min/max ', min(overcontour), max(overcontour)
+print, 'VECTOR PLOT min/max ', min(overvector_x), min(overvector_y)
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;
+;
+if ( coord2d eq 'polar' ) then begin    ;;; pourrait aller dans map_latlon
+  loadct, 0
+  MAP_GRID, $
+          CHARSIZE = 1., $
+          COLOR    = 0,   $
+          ;lats=-60, $
+          LABEL    = 1,   $   ;; /LABEL or LABEL=2 (one label any 2 grid lines)
+          LATDEL   = intervaly, $   ;;5 10
+          LONDEL   = intervalx, $   ;;15
+          ;LONLAB   = latmin + intervaly/2., $ ;5. + (latmin+latmax)/2., $ ;0.
+          LONLAB   = (latmin+latmax)/2., $
+          LATLAB   = -0.001, $
+          GLINESTYLE = 2, $
+          GLINETHICK = 0.3
+          ;LONALIGN = 0., $
+          ;LATALIGN = 1.
+endif
+;
+;
+;
+PS_End, /PNG
+		endfor
+end
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/OM6_TI85_tsurf_polar_inc_uv.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/OM6_TI85_tsurf_polar_inc_uv.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/OM6_TI85_tsurf_polar_inc_uv.pro	(revision 1185)
@@ -0,0 +1,136 @@
+;;;;;*************************************** FOLDER
+	folder  = '/d5/aslmd/LMD_MM_MARS_SIMUS/OM/'
+        coord2d = 'regular'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	filename        = folder + 'OM6_TI85/wrfout_d01_2024-06-43_06:00:00_zabg'
+	ini_utc         = 6           ;; cf. name of file
+	freq            = 1           ;; cf. 1 output per ... hour
+	save_ps         = 'OM6_TI85_tsurf'
+
+;;;;;*************************************** LVL & FLD & TIME
+	nlevel          = 0 
+	use_lt          = 99 ;12           ;; cf. what user wants (99 pour tous)
+	field1          = 'TSURF'       ;; comment to trace horizontal velocity
+	;field2  	= 'XLAT' 	;; contour
+	no3d            = 'true'
+	;overvector_x    = 0             ;; comment out to get rid of vectors
+	;overvector_y    = 0             ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 0.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user    = 'Horizontal wind (m s!U-1!N) 10m AGL'
+	title_user    = 'Horizontal wind vectors 20m AGL'
+	;title_user    = 'Horizontal wind (m s!U-1!N) 20km AMR'
+	title_user	= 'Surface temperature (K)'
+	subtitle_user   = 'LMD_MM'
+	;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+	subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+	subtitle_user   = subtitle_user + ' / Ls = 173!Uo!N'
+	subtitle_user   = subtitle_user + ' / dx = 6km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        ;flag_cb         =       'false'
+        poscb           =       0.96
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11, 19, 0
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =      0;150.
+        maxfield_init   =      0;180.
+
+        ;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+                ;missing_value=1.e30
+                ;lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+                ;lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+                ;;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       30.            ;; DEF: 20.
+        ;windex          =       20.             ;; DEF: 20.
+        ;stride          =       1.             ;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       5.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+	;lev		=	-10. + 0.5*findgen(50)
+
+;;;;;*************************************** AXIS
+        ;isotropic       =       'true'		;; DEF: 'true'
+        ;intervalx       =       0.5
+        intervalx       =        2.0
+        ;intervaly       =      intervalx
+        intervaly       =       1.0
+
+;;;;;*************************************** MAP LIMITS
+        windowx         =       [-146.,-126.] 
+        windowy         =       [11.,27.] 
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;;;*************************************** SETTING TIME (do not modify)
+	utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+	use_utc 	= use_lt - utc_to_lt
+	zentime   	= floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... ajouter un modulo...
+	if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/hellas_polar_inc_uv.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/hellas_polar_inc_uv.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/hellas_polar_inc_uv.pro	(revision 1185)
@@ -0,0 +1,136 @@
+;;;;;*************************************** FOLDER
+	folder  = '/home/aslmd/ALTIERI/ALTIERI_1HELLAS/'
+        coord2d = 'true'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	filename        = folder + 'wrfout_d01_2024-07-02_06:00:00_zabg'
+	ini_utc         = 6           ;; cf. name of file
+	freq            = 1           ;; cf. 1 output per ... hour
+	save_ps         = 'hellas'
+
+;;;;;*************************************** LVL & FLD & TIME
+	nlevel          = 0 
+	use_lt          = 02. ;-3 ;12 ;14 ;99 ;12           ;; cf. what user wants (99 pour tous, negatif pour indice)
+	;field1          = 'UTSM'        ;; comment to trace horizontal velocity
+	;field2  	= 'XLAT' 	;; contour
+	no3d            = 'true'
+	;overvector_x    = 0             ;; comment out to get rid of vectors
+	;overvector_y    = 0             ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = - what_I_plot 
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user    = 'Horizontal wind (m s!U-1!N) 10m AGL'
+	;title_user    = 'Horizontal wind vectors 20m AGL'
+	;title_user    = 'Horizontal wind (m s!U-1!N) 20km AMR'
+	;title_user	= 'Surface temperature (K)'
+	;title_user	= 'Downward sensible heat flux at the surface (W m!U-2!N)'
+	subtitle_user   = 'LMD_MM'
+	subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+	;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+	subtitle_user   = subtitle_user + ' / Ls = 180!Uo!N'
+	subtitle_user   = subtitle_user + ' / dx = 30km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        ;flag_cb         =       'false'
+        poscb           =       0.80
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11, 19, 0
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =      0.
+        maxfield_init   =      20.
+
+        ;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+                missing_value=1.e30
+                lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+                lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+                ;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       20.            ;; DEF: 20.
+        ;windex          =       20.             ;; DEF: 20.
+        ;stride          =       1.             ;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 0.5*findgen(50)
+        ;lev             =       -10. + 1.*findgen(40)
+	;lev		=	-10. + 0.5*findgen(50)
+
+;;;;;*************************************** AXIS
+        ;;isotropic       =       'true'		;; DEF: 'true'
+        intervalx       =        5.0
+        intervaly       =      intervalx
+
+;;;;;*************************************** MAP LIMITS
+        windowx         =       [ 40., 90.] 
+        windowy         =       [-65.,-25.] 
+
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;;;*************************************** SETTING TIME (do not modify)
+	utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+	use_utc 	= use_lt - utc_to_lt
+	zentime   	= floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... ajouter un modulo...
+	if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+	if (use_lt lt 0) then ntime = -use_lt 
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/lmd_winds_polar_inc_uv.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/lmd_winds_polar_inc_uv.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/lmd_winds_polar_inc_uv.pro	(revision 1185)
@@ -0,0 +1,139 @@
+;;;;;*************************************** FOLDER
+	folder  = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	filename        = folder + 'wrfout_d01_2024-04-27_06:00:00_zabg'
+	ini_utc         = 6           ;; cf. name of file
+	freq            = 1           ;; cf. 1 output per ... hour
+	save_ps         = 'lmd_winds'
+
+;;;;;*************************************** LVL & FLD & TIME
+	nlevel          = 0 
+	use_lt          = 99 ;12           ;; cf. what user wants (99 pour tous)
+	field1          = 'HGT'       ;; comment to trace horizontal velocity
+	;field2  	= 'XLAT' 	;; contour
+	no3d            = 'true'
+	;overvector_x    = 0             ;; comment out to get rid of vectors
+	;overvector_y    = 0             ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 0.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user    = 'Horizontal wind (m s!U-1!N) 10m AGL'
+	title_user    = 'Horizontal wind vectors 20m AGL'
+	;title_user    = 'Horizontal wind (m s!U-1!N) 20km AMR'
+	subtitle_user   = 'LMD_MM'
+	;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+	subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+	subtitle_user   = subtitle_user + ' / Ls = 102!Uo!N'
+	subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'false'
+        poscb           =       0.75 ;0.95
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11, 19, 0
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =      -5000.
+        maxfield_init   =      -2000.
+
+        ;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+                missing_value=1.e30
+                lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+                lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+                ;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       10.            ;; DEF: 20.
+        ;windex          =       20.             ;; DEF: 20.
+        ;stride          =       1.             ;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       5.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        ;lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+	lev		=	-10. + 0.5*findgen(50)
+
+;;;;;*************************************** AXIS
+        ;isotropic       =       'true'		;; DEF: 'true'
+        ;intervalx       =       0.5
+        intervalx       =        20.
+        intervaly       =      intervalx
+        ;intervaly       =       1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+        ;windowx         =       [-42.,-26.]
+        ;windowy         =      	[-34.,-20.]
+	windowx         =       [40.,200.]
+        windowy         =       [40.,200.]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;;;*************************************** SETTING TIME (do not modify)
+	utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+	use_utc 	= use_lt - utc_to_lt
+	zentime   	= floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... ajouter un modulo...
+	if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_hfx_polar_inc_uv.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_hfx_polar_inc_uv.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_hfx_polar_inc_uv.pro	(revision 1185)
@@ -0,0 +1,144 @@
+;;;;;*************************************** FOLDER
+	folder  = '/home/aslmd/POLAR/POLAR_APPERE_highres/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	filename        = folder + 'wrfout_d01_2024-03-04_06:00:00_zabg'
+	ini_utc         = 6           ;; cf. name of file
+	freq            = 1           ;; cf. 1 output per ... hour
+	save_ps         = 'polar_hfx'
+
+;;;;;*************************************** LVL & FLD & TIME
+	nlevel          = 0 
+	use_lt          = -3 ;12 ;14 ;99 ;12           ;; cf. what user wants (99 pour tous, negatif pour indice)
+	field1          = 'HFX'       ;; comment to trace horizontal velocity
+	;field2  	= 'XLAT' 	;; contour
+	no3d            = 'true'
+	;overvector_x    = 0             ;; comment out to get rid of vectors
+	;overvector_y    = 0             ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        what_I_plot = - what_I_plot 
+        print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user    = 'Horizontal wind (m s!U-1!N) 10m AGL'
+	title_user    = 'Horizontal wind vectors 20m AGL'
+	;title_user    = 'Horizontal wind (m s!U-1!N) 20km AMR'
+	;title_user	= 'Surface temperature (K)'
+	title_user	= 'Downward sensible heat flux at the surface (W m!U-2!N)'
+	subtitle_user   = 'LMD_MM'
+	;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+	;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+	subtitle_user   = subtitle_user + ' / Ls = 61!Uo!N'
+	subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        ;flag_cb         =       'false'
+        poscb           =       0.68 ;0.80
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       0              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11, 19, 0
+	pal=33
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =      -5.
+        maxfield_init   =      15.
+
+        ;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+                missing_value=1.e30
+                lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+                lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+                ;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       20.            ;; DEF: 20.
+        ;windex          =       20.             ;; DEF: 20.
+        ;stride          =       1.             ;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+;stride          = 1.
+stride=3.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+       ;lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+	lev		=	-10. + 0.5*findgen(50)
+
+;;;;;*************************************** AXIS
+        ;isotropic       =       'true'		;; DEF: 'true'
+        intervalx       =     10.0
+        intervaly       =     intervalx
+	title_axis      = ['x grid point', 'y grid point']
+
+;;;;;*************************************** MAP LIMITS
+        windowx         =       [50,190] 
+        windowy         =       [40,160] 
+windowx         =       [60,180]
+     ;windowx         =       [060,110]
+     ;windowy         =       [100,150]
+     ;windowx         =       [090,120]
+     ;windowy         =       [050,080]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;;;*************************************** SETTING TIME (do not modify)
+	utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+	use_utc 	= use_lt - utc_to_lt
+	zentime   	= floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... ajouter un modulo...
+	if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+	if (use_lt lt 0) then ntime = -use_lt 
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc.pro	(revision 1185)
@@ -0,0 +1,28 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ntime    = 10
+nlevel   = 0
+filename = './wrfout_d01_2024-07-03_06:00:00_z'
+save_ps  = 'polar'
+cfield1  = 'W'
+cfield2  = 'HGT'
+cfield3 = 'SWDOWNZ'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(F4.1)'
+colors        = 32 ;128
+minfield_init = -2.50
+maxfield_init = 2.50
+pal           =  33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+title_user    = ''
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+lim_blank = 0.5 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+overcontour = overcontour / 1000.
+lev = -16. + 2.*findgen(40)
+;lev = [1, 100, 200, 300, 400, 500]
+flag_cb = 'false'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_topo.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_topo.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_topo.pro	(revision 1185)
@@ -0,0 +1,45 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ntime    = 0
+nlevel   = 0
+latmin = -90 & latmax = 20 & lonmin = -180 & lonmax = 180
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS/mpi_64/WPS/geo_em.d01.nc' & save_ps  = 'polar1'
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS/mpi_64/WPS/geo_em.d02.nc' & save_ps  = 'polar2'
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS/mpi_64/WPS/geo_em.d03.nc' & save_ps  = 'polar3'
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS/mpi_64/WPS/geo_em.d04.nc' & save_ps  = 'polar4'
+latmin = -40 & latmax = -10 & lonmin = -45 & lonmax = -15
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS/mpi_64/WPS/geo_em.d04.nc' & save_ps  = 'polarz4'
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS/mpi_64/WPS/geo_em.d03.nc' & save_ps  = 'polarz3'
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS/mpi_64/WPS/geo_em.d02.nc' & save_ps  = 'polarz2'
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS/mpi_64/WPS/geo_em.d01.nc' & save_ps  = 'polarz1'
+latmin = -30 & latmax = -24 & lonmin = -38 & lonmax = -32
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS/mpi_64/WPS/geo_em.d04.nc' & save_ps  = 'polarzzz4'
+cfield1  = 'HGT_M'
+;cfield1  = 'THERMAL_INERTIA'
+cfield2  = 'HGT_M'
+cfield3  = 'HGT_M'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(I0)'
+colors        = 128
+minfield_init = -8000 
+maxfield_init = +12000
+pal           =  33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+;minfield_init = 150.
+;maxfield_init = 550.
+;pal           =  3
+minfield_init = -2500
+maxfield_init = +1500
+pal           =  33  
+title_user    = ''
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+;lim_blank = 0.5 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+overcontour = overcontour / 1000.
+lev = -10. + 1.*findgen(40)
+lev = -10. + 0.5*findgen(80)
+flag_cb = 'false'
+flag_cb = 'true'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_topo.pro.intercomp
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_topo.pro.intercomp	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_topo.pro.intercomp	(revision 1185)
@@ -0,0 +1,46 @@
+        model = 'LMD_MMM' & interptype = '_zabg' & numnest = '1' & nlevel = 0 & cfield1  = 'HGT' & lonfield = 'XLONG' & latfield = 'XLAT'
+        ;model = 'LMD_MMM' & interptype = '_zabg' & numnest = '2' & nlevel = 0 & cfield1  = 'HGT' & lonfield = 'XLONG' & latfield = 'XLAT'
+        ;model = 'LMD_MMM' & interptype = '_zabg' & numnest = '3' & nlevel = 0 & cfield1  = 'HGT' & lonfield = 'XLONG' & latfield = 'XLAT'
+        ;model = 'LMD_MMM' & interptype = '_zabg' & numnest = '4' & nlevel = 0 & cfield1  = 'HGT' & lonfield = 'XLONG' & latfield = 'XLAT'
+        ;model = 'MRAMS'   & interptype = '_zabg' & numnest = '1' & nlevel = 0 & cfield1  = 'topo' & lonfield = 'glon' & latfield = 'glat'
+        ;model = 'MRAMS'   & interptype = '_zabg' & numnest = '2' & nlevel = 0 & cfield1  = 'topo' & lonfield = 'glon' & latfield = 'glat'
+        ;model = 'MRAMS'   & interptype = '_zabg' & numnest = '3' & nlevel = 0 & cfield1  = 'topo' & lonfield = 'glon' & latfield = 'glat'
+        ;model = 'MRAMS'   & interptype = '_zabg' & numnest = '4' & nlevel = 0 & cfield1  = 'topo' & lonfield = 'glon' & latfield = 'glat'
+
+;;;;;*************************************** FOLDER etc...
+        folder  = '../INTERCOMP/' + model + '/'
+        filename        = folder + model + '_d0'+numnest+'_2024-05-57_06:00:00'
+        filename        = filename + interptype
+        save_ps         = model + numnest + interptype + string(nlevel,'(I0)') + '_HGT';___'
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+latmin = -90 & latmax = 40 & lonmin = -180 & lonmax = 180  ;; vue complete nest 1
+;latmin = -90 & latmax = 20 & lonmin = -90 & lonmax = 30 ;-0.0001  ;; vue d'un quartier nest2
+;latmin = -40 & latmax = -10 & lonmin = -60 & lonmax = -15  ;; vue quartier un peu plus zoom
+;latmin = -30 & latmax = -24 & lonmin = -38 & lonmax = -32  ;; vue centree nest 4
+;latmin = -30 & latmax = -20 & lonmin = -45 & lonmax = -30  ;; vue centree nest 4
+;
+cfield2  = cfield1
+cfield3  = cfield1
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(I0)'
+colors        = 128
+minfield_init = -8000. 
+maxfield_init = +12000.
+pal           =  33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+	minfield_init = -2500.
+	maxfield_init = +1500.
+title_user    = ''
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+;lim_blank = 0.5 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+overcontour = overcontour / 1000.
+lev = -10. + 1.*findgen(40)
+lev = -10. + 0.5*findgen(80)
+flag_cb = 'false'
+;flag_cb = 'true'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro	(revision 1185)
@@ -0,0 +1,143 @@
+;;;;;*************************************** FOLDER
+	folder  = '../INTERCOMP/lmd/'
+        ;coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	filename        = folder + 'wrfout_d03_2024-05-59_06:00:00_zabg'
+	ini_utc         = 6           ;; cf. name of file
+	freq            = 1           ;; cf. 1 output per ... hour
+	save_ps         = 'lmd_winds'
+
+;;;;;*************************************** LVL & FLD & TIME
+	nlevel          = 0 ;1 ;0
+	use_lt          = 12           ;; cf. what user wants
+	;field1          = 'TSURF'       ;; comment to trace horizontal velocity
+	;field2  	= 'XLAT' 	;; contour
+	no3d            = 'true'
+	;overvector_x    = 0             ;; comment out to get rid of vectors
+	;overvector_y    = 0             ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        ;what_I_plot = what_I_plot * 100.
+        ;print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user    = 'Horizontal wind (m s!U-1!N) 20m AGL'
+	;title_user    = 'Horizontal wind (m s!U-1!N) 6km AMR'
+	;title_user    = 'Horizontal wind (m s!U-1!N) 20km AMR'
+	subtitle_user   = 'LMD_MM'
+filename = '../INTERCOMP/mrams/holden_ls150-S-g3_day316.nc_zabg'
+save_ps = 'mrams_winds'
+model = 'mrams'
+subtitle_user   = 'MRAMS'
+	subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+	;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+	subtitle_user   = subtitle_user + ' / Ls = 149!Uo!N'
+	subtitle_user   = subtitle_user + ' / dx = 27km [N3]'
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+        poscb           =       0.75 ;0.95
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       22              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11, 19, 0
+        ;pal             =       4
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       00.
+        maxfield_init   =       30.
+
+        ;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+                missing_value=1.e30
+                lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+                lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+                ;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        ;windex          =       10.            ;; DEF: 20.
+        windex          =       20.             ;; DEF: 20.
+        ;stride          =       1.             ;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        ;lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+	lev		=	-10. + 0.5*findgen(50)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'		;; DEF: 'true'
+        ;intervalx       =       0.5
+        intervalx       =       2.0
+        intervaly       =      intervalx
+        ;intervaly       =       1.0
+
+;;;;;*************************************** MAP LIMITS
+        ;windowx         =       [-144.,-126.] 
+        ;windowy         =       [10.,26.] 
+        windowx         =       [-42.,-26.]
+        windowy         =      	[-34.,-20.]
+
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;;;*************************************** SETTING TIME (do not modify)
+	utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+	use_utc 	= use_lt - utc_to_lt
+	zentime   	= floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... ajouter un modulo...
+	;ntime = zentime  ;; A COMMENTER SI ON VEUT TOUS LES TEMPS
+
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.appere
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.appere	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.appere	(revision 1185)
@@ -0,0 +1,65 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ntime    = 7  ;; le vrai indice IDL 
+nlevel   = 2 
+filename = '/tmp15/aslmd/polar_61pts/wrfout_d01_2024-03-04_06:00:00_zabg'
+;filename = '/tmp15/aslmd/polar_61pts/wrfout_d01_2024-03-02_06:00:00_zabg'
+save_ps  = 'mesoscale_polar_winds_friction'
+;coord2d  = 'true' 
+field1   = 'USTM'  ;; omettre trace vitesse horizontale
+	;field1  = 'HGT'  ;; shaded
+	;field2  = 'XLAT' ;; contour 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(F5.2)'
+colors        =  32
+pal           =  22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+title_user    = ''
+title_axis    = ['grid points','grid points']
+title_user      = 'Friction velocity 50m ABG (m s!U-1!N) + Horizontal wind vectors'
+	;title_user      = 'Topography (m) + Horizontal wind vectors 50m ABG'
+subtitle_user   = 'LMD Mars Mesoscale / UTC = 01:00pm / Ls = 61.5!Uo!N / dx = 25km / single domain'
+poscb=0.85
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FILL LIMITS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+minfield_init= +00.1      
+maxfield_init= +00.6 
+	;format        = '(I0)'   
+	;minfield_init= -6500.
+	;maxfield_init= -1500.
+	;pal = 19
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; WINDS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex=12.  	;; default: 20.
+stride=2.       ;; default: 5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; CONTOUR				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;overcontour=overcontour-mean(overcontour)      
+overcontour=overcontour/1000.
+lev=-10. + 0.2*findgen(100) 
+lev=-10. + 0.5*findgen(50) 
+;lev=-10. + 0.1*findgen(200)
+;lev=0
+	overcontour=-overcontour
+	lev=0.2*findgen(200)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; AXIS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;isotropic='false'       ;; default: true
+;intervalx=0.5            
+;intervaly=0.5            
+intervalx=5.
+intervaly=5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; MAP LIMITS 				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;windowx=[-51.0,-41.0]        
+;windowy=[78.0,88.0]
+windowx=[5.,55.]
+windowy=[5.,55.]
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.appere.2
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.appere.2	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.appere.2	(revision 1185)
@@ -0,0 +1,144 @@
+;;;;;*************************************** FOLDER
+	folder  = '/home/aslmd/POLAR/POLAR_APPERE_highres/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	filename        = folder + 'wrfout_d01_2024-03-04_06:00:00_zabg'
+	ini_utc         = 6           ;; cf. name of file
+	freq            = 1           ;; cf. 1 output per ... hour
+	save_ps         = 'polar_hfx'
+
+;;;;;*************************************** LVL & FLD & TIME
+	nlevel          = 0 
+	use_lt          = -3 ;12 ;14 ;99 ;12           ;; cf. what user wants (99 pour tous, negatif pour indice)
+	field1          = 'HFX'       ;; comment to trace horizontal velocity
+	;field2  	= 'XLAT' 	;; contour
+	no3d            = 'true'
+	;overvector_x    = 0             ;; comment out to get rid of vectors
+	;overvector_y    = 0             ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        what_I_plot = - what_I_plot 
+        print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user    = 'Horizontal wind (m s!U-1!N) 10m AGL'
+	title_user    = 'Horizontal wind vectors 20m AGL'
+	;title_user    = 'Horizontal wind (m s!U-1!N) 20km AMR'
+	;title_user	= 'Surface temperature (K)'
+	title_user	= 'Downward sensible heat flux at the surface (W m!U-2!N)'
+	subtitle_user   = 'LMD_MM'
+	;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+	;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+	subtitle_user   = subtitle_user + ' / Ls = 61!Uo!N'
+	subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        ;flag_cb         =       'false'
+        poscb           =       0.68 ;0.80
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       0              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11, 19, 0
+	pal=33
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =      -5.
+        maxfield_init   =      15.
+
+        ;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+                missing_value=1.e30
+                lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+                lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+                ;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       20.            ;; DEF: 20.
+        ;windex          =       20.             ;; DEF: 20.
+        ;stride          =       1.             ;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+;stride          = 1.
+stride=3.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+       ;lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+	lev		=	-10. + 0.5*findgen(50)
+
+;;;;;*************************************** AXIS
+        ;isotropic       =       'true'		;; DEF: 'true'
+        intervalx       =     10.0
+        intervaly       =     intervalx
+	title_axis      = ['x grid point', 'y grid point']
+
+;;;;;*************************************** MAP LIMITS
+        windowx         =       [50,190] 
+        windowy         =       [40,160] 
+windowx         =       [60,180]
+     ;windowx         =       [060,110]
+     ;windowy         =       [100,150]
+     ;windowx         =       [090,120]
+     ;windowy         =       [050,080]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;;;*************************************** SETTING TIME (do not modify)
+	utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+	use_utc 	= use_lt - utc_to_lt
+	zentime   	= floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... ajouter un modulo...
+	if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+	if (use_lt lt 0) then ntime = -use_lt 
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.bak
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.bak	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.bak	(revision 1185)
@@ -0,0 +1,61 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;ntime    = 7  ;; le vrai indice IDL 
+nlevel   = 0 
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d03_2024-06-20_06:00:00_zabg'
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d03_2024-06-20_06:00:00_z'
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d03_2024-06-20_06:00:00_z' & nlevel=1
+save_ps  = 'nest_polar_winds'
+;filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d01_2024-06-20_06:00:00_z'
+;save_ps  = 'single_polar_winds'
+;filename = '/tmp7/aslmd/one_more_nest/test/wrfout_d02_2024-06-19_06:00:00_zabg'
+;save_ps  = '2nest_polar_winds'
+
+;coord2d  = 'false'  ;; si on veut grid point coordinates ;;CHANGER windowx and windowy
+;field1   = 'HGT'  ;; omettre trace vitesse horizontale
+;field2  = 'XLAT' ;; contour 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(I0)' ;'(F4.1)' ;'(I0)' 
+colors        =  32
+pal           =  22 ;19 ;22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+title_user    = 'Horizontal wind (m s!U-1!N) 20m AGL'
+title_user    = 'Horizontal wind (m s!U-1!N) 6km AMR'
+title_user    = 'Horizontal wind (m s!U-1!N) 20km AMR'
+subtitle_user   = 'LMD Mars Mesoscale'
+subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am'
+subtitle_user   = subtitle_user + ' / Ls = 160!Uo!N'
+subtitle_user   = subtitle_user + ' / dx = 12km' 
+subtitle_user   = subtitle_user + ' / nest 3'
+poscb=0.95
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FILL LIMITS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+minfield_init= 30. ;0.
+maxfield_init= 60. ;30.
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; WINDS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex=50. ;25.  	;; default: 20.
+stride=5.       ;; default: 5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; CONTOUR				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;overcontour=overcontour-mean(overcontour)      
+overcontour=overcontour/1000.
+lev=-10. + 0.5*findgen(50) 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; AXIS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;isotropic='false'       ;; default: true
+intervalx=2.
+intervaly=2.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; MAP LIMITS                                 ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windowx=[-42.,-26.]
+windowy=[-34.,-20.]
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.masse
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.masse	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.masse	(revision 1185)
@@ -0,0 +1,65 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ntime    = 7  ;; le vrai indice IDL 
+nlevel   = 2 
+filename = '/tmp15/aslmd/polar_61pts/wrfout_d01_2024-03-04_06:00:00_zabg'
+;filename = '/tmp15/aslmd/polar_61pts/wrfout_d01_2024-03-02_06:00:00_zabg'
+save_ps  = 'mesoscale_polar_winds'
+;coord2d  = 'true' 
+field1   = 'USTM'  ;; omettre trace vitesse horizontale
+	field1  = 'HGT'  ;; shaded
+	;field2  = 'XLAT' ;; contour 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(F5.2)'
+colors        =  32
+pal           =  22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+title_user    = ''
+title_axis    = ['grid points','grid points']
+title_user      = 'Friction velocity 50m ABG (m s!U-1!N) + Horizontal wind vectors'
+	title_user      = 'Topography (m) + Horizontal wind vectors 50m ABG'
+subtitle_user   = 'LMD Mars Mesoscale / UTC = 01:00pm / Ls = 61.5!Uo!N / dx = 25km / single domain'
+poscb=0.85
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FILL LIMITS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+minfield_init= +00.1      
+maxfield_init= +00.6 
+	format        = '(I0)'   
+	minfield_init= -6500.
+	maxfield_init= -1500.
+	pal = 19
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; WINDS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex=12.  	;; default: 20.
+stride=2.       ;; default: 5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; CONTOUR				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;overcontour=overcontour-mean(overcontour)      
+overcontour=overcontour/1000.
+lev=-10. + 0.2*findgen(100) 
+lev=-10. + 0.5*findgen(50) 
+;lev=-10. + 0.1*findgen(200)
+lev=0
+	;overcontour=-overcontour
+	;lev=0.2*findgen(200)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; AXIS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;isotropic='false'       ;; default: true
+;intervalx=0.5            
+;intervaly=0.5            
+intervalx=5.
+intervaly=5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; MAP LIMITS 				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;windowx=[-51.0,-41.0]        
+;windowy=[78.0,88.0]
+windowx=[5.,55.]
+windowy=[5.,55.]
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.masse.2
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.masse.2	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro.masse.2	(revision 1185)
@@ -0,0 +1,84 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ntime    = 7  ;; le vrai indice IDL 
+ntime    = 1
+ntime    = 20
+nlevel   = 2 
+filename = '/d5/aslmd/LMD_MM_MARS_SIMUS/polar_61pts/wrfout_d01_2024-03-04_06:00:00_zabg'
+;filename = '/tmp15/aslmd/polar_61pts/wrfout_d01_2024-03-02_06:00:00_zabg'
+save_ps  = 'mesoscale_polar_winds_friction'
+	filename = '/tmp15/aslmd/polar_61pts/wrfout_d01_2024-03-04_06:00:00_zabg'
+	save_ps  = 'mesoscale_polar_winds_friction_hires'
+;coord2d  = 'true' 
+field1   = 'USTM'  ;; omettre trace vitesse horizontale
+		;field1  = 'HGT'  ;; shaded
+			;field2  = 'XLAT' ;; contour 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(F5.2)'
+colors        =  32
+pal           =  22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+title_user    = ''
+title_axis    = ['grid points','grid points']
+title_user      = 'Friction velocity (m s!U-1!N) + Horizontal wind vectors 50m ABG'
+		;title_user      = 'Topography (m) + Horizontal wind vectors 50m ABG'
+subtitle_user   = 'LMD Mars Mesoscale'
+;subtitle_user   = subtitle_user + ' / UTC = 01:00pm'
+subtitle_user   = subtitle_user + ' / Ls = 61.5!Uo!N'
+subtitle_user   = subtitle_user + ' / dx = 10km' ;25km'
+subtitle_user   = subtitle_user + ' / single domain'
+poscb=0.85
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FILL LIMITS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+minfield_init= +00.1      
+maxfield_init= +00.6 
+		;format        = '(I0)'   
+		;minfield_init= -6500.
+		;maxfield_init= -1500.
+		;pal = 19
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; WINDS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex=12.  	;; default: 20.
+stride=2.       ;; default: 5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; CONTOUR				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;overcontour=overcontour-mean(overcontour)      
+overcontour=overcontour/1000.
+lev=-10. + 0.2*findgen(100) 
+lev=-10. + 0.5*findgen(50) 
+;lev=-10. + 0.1*findgen(200)
+lev=0
+		overcontour=-overcontour
+		lev=0.2*findgen(200)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; AXIS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;isotropic='false'       ;; default: true
+;intervalx=0.5            
+;intervaly=0.5            
+intervalx=5.
+intervaly=5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; MAP LIMITS 				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;windowx=[-51.0,-41.0]        
+;windowy=[78.0,88.0]
+windowx=[5.,55.]
+windowy=[5.,55.]
+
+windex=12.
+stride=4.
+windowx=[40.,200.]
+windowy=[20.,180.]
+intervalx=10.
+intervaly=10.
+                ;windex=25.
+                ;stride=1.
+		;windowx=[130.,160.]
+		;windowy=[130.,160.]
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_polar
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_polar	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_polar	(revision 1185)
@@ -0,0 +1,136 @@
+;;;;;*************************************** FOLDER
+	folder  = '/home/aslmd/polar_61pts/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy
+	filename        = folder + 'wrfout_d01_2024-03-04_06:00:00_zabg'
+	ini_utc         = 6           ;; cf. name of file
+	freq            = 1           ;; cf. 1 output per ... hour
+	save_ps         = 'polar_hfx'
+
+;;;;;*************************************** LVL & FLD & TIME
+	nlevel          = 0 
+	use_lt          = -3 ;12 ;14 ;99 ;12           ;; cf. what user wants (99 pour tous, negatif pour indice)
+	field1          = 'HFX'       ;; comment to trace horizontal velocity
+	;field2  	= 'XLAT' 	;; contour
+	no3d            = 'true'
+	;overvector_x    = 0             ;; comment out to get rid of vectors
+	;overvector_y    = 0             ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        what_I_plot = - what_I_plot 
+        print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user    = 'Horizontal wind (m s!U-1!N) 10m AGL'
+	title_user    = 'Horizontal wind vectors 20m AGL'
+	;title_user    = 'Horizontal wind (m s!U-1!N) 20km AMR'
+	;title_user	= 'Surface temperature (K)'
+	title_user	= 'Downward sensible heat flux at the surface (W m!U-2!N)'
+	subtitle_user   = 'LMD_MM'
+	;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+	subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+	subtitle_user   = subtitle_user + ' / Ls = 61!Uo!N'
+	subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        ;flag_cb         =       'false'
+        poscb           =       0.80
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       0              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11, 19, 0
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =      -5.
+        maxfield_init   =      15.
+
+        ;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+                missing_value=1.e30
+                lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+                lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+                ;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       20.            ;; DEF: 20.
+        ;windex          =       20.             ;; DEF: 20.
+        ;stride          =       1.             ;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       5.              ;; DEF: 5.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+        lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+	;lev		=	-10. + 0.5*findgen(50)
+
+;;;;;*************************************** AXIS
+        ;isotropic       =       'true'		;; DEF: 'true'
+        intervalx       =        10.0
+        intervaly       =      intervalx
+
+;;;;;*************************************** MAP LIMITS
+        windowx         =       [50,190] 
+        windowy         =       [40,160] 
+
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;;;*************************************** SETTING TIME (do not modify)
+	utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+	use_utc 	= use_lt - utc_to_lt
+	zentime   	= floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... ajouter un modulo...
+	if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+	if (use_lt lt 0) then ntime = -use_lt 
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_ref
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_ref	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_ref	(revision 1185)
@@ -0,0 +1,144 @@
+;;;;;*************************************** FOLDER
+	folder  = '/home/aslmd/POLAR/POLAR_APPERE_highres/'
+        coord2d = 'false'       ;; for non-regular projections  ;;CHANGER windowx and windowy  ;; egalement 'regular'
+	filename        = folder + 'wrfout_d01_2024-03-04_06:00:00_zabg'
+	ini_utc         = 6           ;; cf. name of file
+	freq            = 1           ;; cf. 1 output per ... hour
+	save_ps         = 'polar_hfx'
+
+;;;;;*************************************** LVL & FLD & TIME
+	nlevel          = 0 
+	use_lt          = -3 ;12 ;14 ;99 ;12           ;; cf. what user wants (99 pour tous, negatif pour indice)
+	field1          = 'HFX'       ;; comment to trace horizontal velocity
+	;field2  	= 'XLAT' 	;; contour
+	no3d            = 'true'
+	;overvector_x    = 0             ;; comment out to get rid of vectors
+	;overvector_y    = 0             ;; comment out to get rid of vectors
+
+;;;;;*************************************** TWEAK VAR
+        what_I_plot = - what_I_plot 
+        print, max(what_I_plot), min(what_I_plot)
+
+;;;;;*************************************** PLOT TITLES
+        title_user    = 'Horizontal wind (m s!U-1!N) 10m AGL'
+	title_user    = 'Horizontal wind vectors 20m AGL'
+	;title_user    = 'Horizontal wind (m s!U-1!N) 20km AMR'
+	;title_user	= 'Surface temperature (K)'
+	title_user	= 'Downward sensible heat flux at the surface (W m!U-2!N)'
+	subtitle_user   = 'LMD_MM'
+	;subtitle_user   = subtitle_user + ' / LT = '+string(use_lt,'(I0)')+'h'
+	;subtitle_user   = subtitle_user + ' / UTC!D0!N = 06:00am' ;; pour les series
+	subtitle_user   = subtitle_user + ' / Ls = 61!Uo!N'
+	subtitle_user   = subtitle_user + ' / dx = 10km [S]'
+
+;;;;;*************************************** COLOR TABLES
+        ;flag_cb         =       'false'
+        poscb           =       0.68 ;0.80
+        format          =       '(I0)'
+        ;format          =       '(F4.1)' 
+        ;colors          =       128
+        colors          =       32
+        pal             =       0              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11, 19, 0
+	pal=33
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =      -5.
+        maxfield_init   =      15.
+
+        ;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+                missing_value=1.e30
+                lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+                lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+                ;lim_blank = 2. & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** WINDS
+        windex          =       20.            ;; DEF: 20.
+        ;windex          =       20.             ;; DEF: 20.
+        ;stride          =       1.             ;; DEF: 5.
+        ;stride          =       2.              ;; DEF: 5.
+        stride          =       3.              ;; DEF: 5.
+;stride          = 1.
+stride=3.
+
+;;;;;*************************************** CONTOUR
+        overcontour     =       overcontour/1000.
+        ;lev             =       50. + 50.*findgen(20)
+        ;lev             =       -10. + 0.2*findgen(20)
+       ;lev             =       -10. + 2.*findgen(20)
+        ;lev             =       -10. + 1.*findgen(40)
+	lev		=	-10. + 0.5*findgen(50)
+
+;;;;;*************************************** AXIS
+        ;isotropic       =       'true'		;; DEF: 'true'
+        intervalx       =     10.0
+        intervaly       =     intervalx
+	title_axis      = ['x grid point', 'y grid point']
+
+;;;;;*************************************** MAP LIMITS
+        windowx         =       [50,190] 
+        windowy         =       [40,160] 
+windowx         =       [60,180]
+     ;windowx         =       [060,110]
+     ;windowy         =       [100,150]
+     ;windowx         =       [090,120]
+     ;windowy         =       [050,080]
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;;;*************************************** SETTING TIME (do not modify)
+	utc_to_lt       = mean(windowx) / 15.    ;; cf. longitude -- LT = UTC + utc_to_lt
+	use_utc 	= use_lt - utc_to_lt
+	zentime   	= floor(((24 + use_utc - ini_utc) MOD 24)/freq)        ;; TRUE IDL SUBSCRIPT... ajouter un modulo...
+	if (use_lt ne 99) then ntime = zentime else ntime = 99    ;; ou commenter pour avoir tous les pas de temps
+	if (use_lt lt 0) then ntime = -use_lt 
+
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+;;;;;***************************************;;;;;
+
+
+;;;
+;;; VERTICAL SECTION LIMITS
+;;;
+;minalt=-5.             ;; grepSEC
+;maxalt=40.             ;; grepSEC
+;minspace=0.0           ;; grepSEC
+;maxspace=35.0          ;; grepSEC
+
+;;;
+;;; METRIC UNITS FOR VERTICAL SECTION
+;;;
+;factor=10.        ;; grepSEC
+;space=space*60. & spacekm='true'       ;; grepSEC
+;minspace=minspace*60./factor           ;; grepSEC
+;maxspace=maxspace*60./factor           ;; grepSEC
+;intervalx=round(intervalx*60./factor)   ;; grepSEC
+
+
+;;;
+;;; TRICKS
+;;;
+
+;; pour tracer juste les vecteurs sur un fond uni ou vide
+;pal=0                                          ;; 1/4 grepMAP
+;what_I_plot(*,*)=what_I_plot(*,*)*0.+0.2       ;; 2/4 grepMAP
+;what_I_plot(0,0)=0.                            ;; 3/4 grepMAP
+;flag_cb='false'                                        ;; 4/4 grepMAP
+
+;;; truc pour tracer juste les contours et une zone grisee de topo
+;pal=0                                           ;; 1/9 grepALL
+;w=where(abs(what_I_plot) lt missing_value)     ;; 2/9 grepALL
+;what_I_plot[w]=0.                              ;; 3/9 grepALL
+;w=where(abs(what_I_plot) gt missing_value)     ;; 4/9 grepALL
+;what_I_plot[w]=0.75                            ;; 5/9 grepALL
+;w=where(what_I_plot eq 0.)                     ;; 6/9 grepALL
+;what_I_plot[w]=missing_value                           ;; 7/9 grepALL
+;what_I_plot(0,0)=1. & what_I_plot(1,0)=0.      ;; 8/9 grepALL
+;flag_cb='false'                                ;; 9/9 grepALL
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_sav
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_sav	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_sav	(revision 1185)
@@ -0,0 +1,80 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ntime    = 8  ;; le vrai indice IDL 
+nlevel   = 0 
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d04_2024-06-20_06:00:00_zabg' 
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d01_2024-06-20_06:00:00_zabg'
+save_ps  = 'uvsingle_utc14'
+;filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d03_2024-06-20_06:00:00_zabg'
+;coord2d  = 'true' & save_ps  = 'uvnest3_utc14'
+;field1  = 'WAVE'  ;; omettre trace vitesse horizontale
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(F4.1)'
+colors        = 128
+pal           =  22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+title_user    = ''
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FILL LIMITS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+minfield_init= +00.      
+maxfield_init= +20.    
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; WINDS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex=20.  	;; default: 20.
+stride=3.       ;; default: 5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; CONTOUR				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;overcontour=overcontour-mean(overcontour)      
+overcontour=overcontour/1000.
+lev=-10. + 0.2*findgen(100) 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; AXIS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;isotropic='false'       ;; default: true
+intervalx=0.5            
+intervaly=0.5            
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; MAP LIMITS 				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windowx=[-36.0,-32.0]        
+windowy=[-28.0,-24.5]
+
+intervalx=1.0
+intervaly=1.0
+windowx=[-41.0,-31.0]
+windowy=[-32.0,-22.0]
+stride=2.
+minfield_init= +00.
+maxfield_init= +15.
+windex=15.
+
+
+
+;filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d01_2024-06-20_06:00:00_z'
+;save_ps  = 'uvsingle_utc14_10km'
+;;filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d03_2024-06-20_06:00:00_z'
+;;coord2d  = 'true' & save_ps  = 'uvsingle_utc14_10km'
+;intervalx=1.0
+;intervaly=1.0
+;windowx=[-50.0,-30.0]
+;windowy=[-40.0,-20.0]
+;stride=5.
+;minfield_init= +00.
+;maxfield_init= +40.
+;windex=30.
+
+filename='/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d01_2024-07-03_06:00:00_z'     
+save_ps  = 'windgw'
+intervalx=1.0 & intervaly=1.0
+windowx=[ 0., 180.] & windowy=[-90.,-40.]
+stride=5. & windex=60.
+minfield_init= +00. & maxfield_init= +40.
+lev=-10. + 0.1*findgen(200)
+
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_winds
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_winds	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_uv.pro_winds	(revision 1185)
@@ -0,0 +1,61 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;ntime    = 7  ;; le vrai indice IDL 
+nlevel   = 0 
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d03_2024-06-20_06:00:00_z'
+save_ps  = 'nest_polar_winds'
+filename = '/donnees/aslmd/MODELES/LMD_MM_MARS/OUTILS_CONVERSION/wrfout_d01_2024-06-20_06:00:00_z'
+save_ps  = 'single_polar_winds'
+;filename = '/tmp7/aslmd/one_more_nest/test/wrfout_d02_2024-06-19_06:00:00_zabg'
+;save_ps  = '2nest_polar_winds'
+
+;coord2d  = 'true' 
+field1   = 'HGT'  ;; omettre trace vitesse horizontale
+;field2  = 'XLAT' ;; contour 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(I0)' ;'(F5.2)'
+colors        =  32
+pal           =  19 ;22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+title_user    = 'Topography (m) + Horizontal wind vectors 6km ABG'
+title_axis    = ['grid points','grid points']
+subtitle_user   = 'LMD Mars Mesoscale'
+;subtitle_user   = subtitle_user + ' / UTC = 01:00pm'
+;subtitle_user   = subtitle_user + ' / Ls = 61.5!Uo!N'
+;subtitle_user   = subtitle_user + ' / dx = 10km' ;25km'
+;subtitle_user   = subtitle_user + ' / single domain'
+poscb=0.85
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; FILL LIMITS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+minfield_init= -3000.
+maxfield_init= +3000.
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max 
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min 
+;lim_blank = 0.2 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; WINDS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windex=25.  	;; default: 20.
+stride=5.       ;; default: 5.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; CONTOUR				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;overcontour=overcontour-mean(overcontour)      
+overcontour=overcontour/1000.
+lev=-10. + 0.2*findgen(100) 
+lev=-10. + 0.5*findgen(50) 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; AXIS				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;isotropic='false'       ;; default: true
+intervalx=20.
+intervaly=20.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; MAP LIMITS 				       ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+windowx=[0.,120.]
+windowy=[0.,120.]
+windowx=[40.,140.]
+windowy=[40.,140.]
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_w.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_w.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polar_inc_w.pro	(revision 1185)
@@ -0,0 +1,57 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ntime    = 2 
+nlevel   = 1 
+latmin = -90 & latmax = 20 & lonmin = -180 & lonmax = 180 & hem = -1.
+latmin = -40 & latmax = -10 & lonmin = -45 & lonmax = -15 & hem = -1.
+filename = '/tmp1/aslmd/wrfout_d01_2024-06-17_06:00:00' & save_ps  = 'wpolarz1'
+;filename = '/tmp1/aslmd/wrfout_d02_2024-06-17_06:00:00' & save_ps  = 'wpolarz2'
+;filename = '/tmp1/aslmd/wrfout_d03_2024-06-17_06:00:00' & save_ps  = 'wpolarz3'
+;filename = '/tmp1/aslmd/wrfout_d04_2024-06-17_06:00:00' & save_ps  = 'wpolarz4'
+latmin = -30 & latmax = -24 & lonmin = -38 & lonmax = -32
+filename = '/tmp1/aslmd/wrfout_d04_2024-06-17_06:00:00' & save_ps  = 'wpolarzz4'
+cfield1  = 'WAVE'
+cfield2  = 'HGT'
+;cfield3  = 'HGT_M'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(F4.1)'
+colors        = 128
+minfield_init = -8. 
+maxfield_init = +2.
+pal           =  22 ;33 ;39 ;6 ;11 ;0 ;11 ;6 ;0 ;6 ;39 ;19 
+title_user    = ''
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+;lim_blank = 0.5 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+overcontour = overcontour / 1000.
+lev = -10. + 1.*findgen(40)
+;flag_cb = 'false'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;
+;; T. Appere paper
+;;
+latmin = 76 & latmax = 90. & lonmin = -180 & lonmax = 180 & hem = 1.
+ntime    = 0  ;; le vrai indice IDL 
+nlevel   = 0
+filename = '/tmp15/aslmd/polar_61pts/wrfout_d01_2024-03-04_06:00:00_zabg'
+save_ps  = 'appere'
+cfield1  = 'USTM'
+minfield_init = 0.1
+maxfield_init = 0.6
+pal           =  22
+format        = '(F5.2)'
+colors        = 32
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+lev = -10. + 0.2*findgen(50)
+;lev = -10. + 0.5*findgen(20)
+overcontour = - overcontour
+lev = 0.5*findgen(20)
+lev = 0.2*findgen(50)
+
+
+
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/defs/polaract_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/defs/polaract_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/defs/polaract_inc.pro	(revision 1185)
@@ -0,0 +1,36 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+filename = 'wrfout_d01_2024-07-03_06:00:00_z'
+;filename = 'wrfout_d01_2024-07-02_06:00:00_z'
+;filename = 'wrfout_d01_2024-07-04_06:00:00_z'
+;filename = 'wrfout_d01_2024-07-99_06:00:00_z' ;;1234
+filename = 'wrfout_d01_2024-07-234_06:00:00_z' ;;234
+;filename = 'wrfout_d01_2024-07-34_06:00:00_z'
+;filename = 'wrfout_d01_2024-07-23_06:00:00_z'
+save_ps  = 'polar'
+cfield1  = 'W'
+cfield2  = 'HGT'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+format        = '(F4.1)'
+colors        = 32 ;128
+minfield_init = -5000.
+maxfield_init = 5000.
+pal           =  0 ;4;16;22 ;33 ;39 ;11 ;0 39 19 ;NON: 6,11
+title_user    = ''
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+missing_value=1.e30
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+;lim_blank = 1.5 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+;overcontour = overcontour / 1000.
+;lev = -16. + 2.*findgen(40)
+lev = [0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6.]
+;lev = [0.5, 0.8,1.2,1.6,2.0] 
+;lev = [0.75, 1.,2.,3.]
+lev = [0.2, 0.3, 0.5, 1., 2., 3., 5., 10.]
+;lev = [0.3, 0.5, 1., 2., 3., 5., 10.]
+;lev = [0.25, 0.5, 0.75, 1.]
+flag_cb = 'false'
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Index: trunk/UTIL/IDLplot/SPEC/POLAR/polar.README
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/polar.README	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/polar.README	(revision 1185)
@@ -0,0 +1,12 @@
+polar_topo : vieux (trace des cartes 2D en projection polaire)
+polar_w : trace avec map-set
+polar_uv : trace sans map-set et avec winds possible // avec map-set commente
+
+profile_uvt pour un profil
+
+map_uvt est un vieux truc, non OK pour tracer hors des poles
+
+
+GW studies with Francesca
+polaract
+polar
Index: trunk/UTIL/IDLplot/SPEC/POLAR/polar.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/polar.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/polar.pro	(revision 1185)
@@ -0,0 +1,123 @@
+pro polar
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+@polar_inc.pro
+SPAWN, '\rm param_plot.idl ; cp polar_inc.pro param_plot.idl'
+;
+;
+;
+  ;zefile=save_ps
+  ;PS_Start, filename=zefile+'.ps'
+  ;print, zefile+'.ps'
+  ;;!p.multi=[0,3,2]
+  ;;!p.multi=[0,3,1] 
+  ;!p.multi=[0,2,2]
+  ;!P.Charsize = 0.6
+;
+;
+;
+        jojo = ['gw','gwsmooth']
+        ;jojo = ['gwhires','gw']
+        jojo = ['gw/30km']
+filename_sav = filename
+for i=0,n_elements(jojo)-1 do begin
+;
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS//OUTILS_CONVERSION/'+jojo(i)+'/'+filename_sav
+print, filename
+;
+getcdf, file=filename, charvar=cfield1, invar=field1
+getcdf, file=filename, charvar=cfield2, invar=field2
+getcdf, file=filename, charvar=cfield3, invar=field3
+getcdf, file=filename, charvar='XLONG', invar=longi
+getcdf, file=filename, charvar='XLAT', invar=lati
+;
+;
+;
+
+for ntime = 0, n_elements(field1(0,0,0,*))-1 do begin
+;  for ntime = 11, n_elements(field1(0,0,0,*))-1, 5 do begin
+;for ntime = 16, n_elements(field1(0,0,0,*))-1, 5 do begin
+
+;for ntime = 06, n_elements(field1(0,0,0,*))-1, 5 do begin
+
+	;;; MOVIE MOVIE MOVIE
+	zefile=save_ps+string(100+ntime,'(I0)')
+	PS_Start, filename=zefile+'.ps'
+	;!P.Charsize = 1.2
+	;!p.charthick = 2.0
+	;!p.thick = 2.0
+	;!x.thick = 2.0
+	;!y.thick = 2.0
+;
+;
+;
+latmin = -90. & latmax = -50.01 & lonmin = -180. & lonmax = 180.
+map_set, -90., 0., /isotropic, /azimuthal, /noborder, limit=[latmin,lonmin,latmax,lonmax],title=title_user,/advance ;, position=[0.10, 0.12, 0.90, 0.92]
+;
+;
+;
+what_I_plot = reform(field1(*,*,nlevel,ntime))
+overcontour = reform(field2(*,*,ntime))
+lon = reform(longi(*,*,ntime))
+lat = reform(lati (*,*,ntime))
+overvector_x=0.
+overvector_y=0.
+;
+;
+;
+	;loadct, 0
+	;w=where(overcontour lt -5000.) & overcontour[w]=-5000.
+	;contour, overcontour, lon, lat, /cell_fill, nlevels=32, /overplot ;& overcontour=0
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;
+;
+loadct, 0
+contour, reform(field3(*,*,ntime)), $
+	lon,lat, $
+        /overplot, $ 
+	levels=[1,100,200,300], $
+	c_labels=[0,1,0,1], $
+        c_thick=1.5, $ 
+	;c_linestyle=2,$
+	color=0;255
+;
+;
+;
+loadct, 0
+MAP_GRID, CHARSIZE = 0.6, $
+          COLOR    = 0,   $
+          LABEL    = 1,   $   ;(one label any 1 grid lines)
+          LATDEL   = 05., $   
+          LONDEL   = 45., $   
+          lats=-60, $
+          GLINESTYLE = 1, $
+          GLINETHICK = 0.1, $
+          LONLAB   = -70., $ 
+          LATLAB   = (lonmin+lonmax)/2.
+;
+;
+;
+PS_End, /PNG
+ endfor
+  endfor
+;PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/POLAR/polar_topo.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/polar_topo.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/polar_topo.pro	(revision 1185)
@@ -0,0 +1,104 @@
+pro polar_topo
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+@polar_inc_topo.pro
+SPAWN, '\rm param_plot.idl ; cp polar_inc_topo.pro param_plot.idl'
+;
+;
+;
+  zefile=save_ps
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  ;!p.multi=[0,2,2]
+  ;!P.Charsize = 0.6
+;
+;
+;
+getcdf, file=filename, charvar=cfield1, invar=field1
+getcdf, file=filename, charvar=cfield2, invar=field2
+getcdf, file=filename, charvar=cfield3, invar=field3
+getcdf, file=filename, charvar='XLONG_M', invar=longi
+getcdf, file=filename, charvar='XLAT_M', invar=lati
+;
+;
+;
+
+;zefile=save_ps+string(100+ntime,'(I0)')
+;PS_Start, filename=zefile+'.ps'
+;!P.Charsize = 1.2
+;!p.charthick = 2.0
+;!p.thick = 2.0
+;!x.thick = 2.0
+;!y.thick = 2.0
+;
+;
+;
+	;latmin = -90. & latmax = 10.0 & lonmin = -180. & lonmax = 180.
+map_set, -90., 0., /isotropic, /azimuthal, /noborder, limit=[latmin,lonmin,latmax,lonmax],title=title_user,/advance ;, position=[0.10, 0.12, 0.90, 0.92]
+;
+;
+;
+what_I_plot = field1
+overcontour = field2
+lon = longi
+lat = lati
+overvector_x=0.
+overvector_y=0.
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;;
+;;
+;;
+;loadct, 0
+;contour, reform(field3(*,*,ntime)), $
+;	lon,lat, $
+;        /overplot, $ 
+;	levels=[1,100,200], $
+;	c_labels=[0,0,0], $
+;        c_thick=1.5, $
+;	color=255
+
+;
+;
+;
+loadct, 0
+MAP_GRID, $
+          CHARSIZE = 1., $
+          COLOR    = 0,   $
+        ;  LABEL    = 2,   $   ;; /LABEL or LABEL=2 (one label any 2 grid lines)
+	;          LATDEL   = 10., $   ;;5
+	;          LONDEL   = 30., $   ;;15
+	;lats=-60, $
+	;          LONLAB   = -70., $ ;(latmin+latmax)/2., $
+	;          LATLAB   = (lonmin+lonmax)/2., $
+          LABEL    = 1,   $   ;; /LABEL or LABEL=2 (one label any 2 grid lines)
+          LATDEL   = 10., $   ;;5
+          LONDEL   = 15., $   ;;15
+          LONLAB   = -0., $ ;(latmin+latmax)/2., $
+          LATLAB   = -0.001, $
+          GLINESTYLE = 2, $
+          GLINETHICK = 0.3
+	  ;LONALIGN = 0., $
+	  ;LATALIGN = 1.
+
+;;
+;;
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/POLAR/polar_topo.pro.intercomp
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/polar_topo.pro.intercomp	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/polar_topo.pro.intercomp	(revision 1185)
@@ -0,0 +1,112 @@
+pro polar_topo
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+@polar_inc_topo.pro
+SPAWN, '\rm param_plot.idl ; cp polar_inc_topo.pro param_plot.idl'
+;
+;
+;
+  zefile=save_ps
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  ;!p.multi=[0,2,2]
+  ;!P.Charsize = 0.6
+;
+;
+;
+getcdf, file=filename, charvar=cfield1, invar=field1
+getcdf, file=filename, charvar=cfield2, invar=field2
+getcdf, file=filename, charvar=cfield3, invar=field3
+getcdf, file=filename, charvar=lonfield, invar=longi
+getcdf, file=filename, charvar=latfield, invar=lati
+;
+;
+;
+
+;zefile=save_ps+string(100+ntime,'(I0)')
+;PS_Start, filename=zefile+'.ps'
+;!P.Charsize = 1.2
+;!p.charthick = 2.0
+;!p.thick = 2.0
+;!x.thick = 2.0
+;!y.thick = 2.0
+;
+;
+;
+	;latmin = -90. & latmax = 10.0 & lonmin = -180. & lonmax = 180.
+map_set, -90., 0., /isotropic, /azimuthal, /noborder, limit=[latmin,lonmin,latmax,lonmax],title=title_user,/advance ;, position=[0.10, 0.12, 0.90, 0.92]
+;
+;
+;
+what_I_plot = reform(field1(*,*,0))
+overcontour = reform(field2(*,*,0))
+lon = reform(longi(*,*,0))
+lat = reform(lati(*,*,0))
+overvector_x=0.
+overvector_y=0.
+
+;contour, what_I_plot, lon, lat
+;PS_End, /PNG
+;stop
+
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;;
+;;
+;;
+;loadct, 0
+;contour, reform(field3(*,*,ntime)), $
+;	lon,lat, $
+;        /overplot, $ 
+;	levels=[1,100,200], $
+;	c_labels=[0,0,0], $
+;        c_thick=1.5, $
+;	color=255
+					;PS_End, /PNG
+					;end
+;
+;
+;
+loadct, 0
+MAP_GRID, $
+          CHARSIZE = 1., $
+          COLOR    = 0,   $
+        ;  LABEL    = 2,   $   ;; /LABEL or LABEL=2 (one label any 2 grid lines)
+	;          LATDEL   = 10., $   ;;5
+	;          LONDEL   = 30., $   ;;15
+	;lats=-60, $
+	;          LONLAB   = -70., $ ;(latmin+latmax)/2., $
+	;          LATLAB   = (lonmin+lonmax)/2., $
+;LATLAB   = lonmax, $
+;LABEL    = 1,   $   
+	LABEL    = 2,   $   
+	LATDEL   = 10., $   
+	LONDEL   = 15., $   
+	LONLAB   = latmax, $ 
+	LATLAB   = -0.001, $
+          GLINESTYLE = 2, $
+          GLINETHICK = 0.3
+	  ;LONALIGN = 0., $
+	  ;LATALIGN = 1.
+
+;;
+;;
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/POLAR/polar_uv.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/polar_uv.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/polar_uv.pro	(revision 1185)
@@ -0,0 +1,178 @@
+pro polar_uv
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+@polar_inc_uv.pro
+SPAWN, '\rm param_plot.idl ; cp polar_inc_uv.pro param_plot.idl ; cp -f polar_inc_uv.pro '+save_ps+'_polar_inc_uv.pro'
+if (n_elements(coord2d) eq 0) then coord2d='true'
+if (n_elements(model) eq 0) then model='LMD_MMM'
+;
+;
+;
+if (n_elements(field1) ne 0) then getcdf, file=filename, charvar=field1, invar=cfield1
+getcdf, file=filename, charvar='Um', invar=u
+getcdf, file=filename, charvar='Vm', invar=v
+case model of
+'LMD_MMM': begin
+  getcdf, file=filename, charvar='XLONG', invar=longi
+  getcdf, file=filename, charvar='XLAT', invar=lati
+  getcdf, file=filename, charvar='HGT', invar=hgt
+end
+'MRAMS': begin
+  getcdf, file=filename, charvar='topo', invar=hgt
+  getcdf, file=filename, charvar='glat', invar=lati
+  getcdf, file=filename, charvar='glon', invar=longi
+end
+endcase
+if (n_elements(field2) ne 0) then getcdf, file=filename, charvar=field2, invar=cfield2
+;
+;
+;
+	;sp = 5 ;; relaxation width
+	;nx = n_elements(longi(0,*))
+	;ny = n_elements(longi(*,0))
+	;if (n_elements(field1) ne 0) then begin
+	;	cfield1	= cfield1	(sp:nx-sp-1,sp:ny-sp-1,*,*)
+	;endif
+	;if (n_elements(field2) ne 0) then begin
+	;        cfield2 = cfield2       (sp:nx-sp-1,sp:ny-sp-1,*,*)
+	;endif
+	;u 		= u		(sp:nx-sp-1,sp:ny-sp-1,*,*) 
+	;v       	= v       	(sp:nx-sp-1,sp:ny-sp-1,*,*)
+	;longi		= longi		(sp:nx-sp-1,sp:ny-sp-1,*)
+	;lati          	= lati 	        (sp:nx-sp-1,sp:ny-sp-1,*)
+	;hgt		= hgt		(sp:nx-sp-1,sp:ny-sp-1,*)
+	;nx = n_elements(longi(0,*))
+	;ny = n_elements(longi(*,0))
+;
+;
+;
+;latmin = -90. & latmax = -50.0 & lonmin = -180. & lonmax = 180.
+;map_set, -90., 0., /isotropic, /azimuthal, /noborder, limit=[latmin,lonmin,latmax,lonmax],title=title_user,/advance 
+;latmin = 75. & latmax = 90.0 & lonmin = -180. & lonmax = 180.
+;map_set, 90., 0., /isotropic, /azimuthal, /noborder, limit=[latmin,lonmin,latmax,lonmax],title=title_user,/advance 
+;
+;
+;
+		;if (n_elements(ntime) eq 0 or ntime eq 99) then begin
+		if (ntime eq 99) then begin
+			PRINT, '-- ALL TIME STEPS'
+			ntstart = 0
+			ntend = n_elements(reform(u(0,0,0,*)))-1 & print, ntend 
+		endif else begin
+			PRINT, '-- ONLY TIME STEP ', string(ntime,'(I0)')
+			ntstart = ntime
+			ntend = ntime
+		endelse
+                for ntime = ntstart,ntend do begin
+
+  zefile=save_ps+string(100+ntime,'(I0)')
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+;
+;
+;
+lon = reform(longi(*,*,ntime))
+lat = reform(lati(*,*,ntime))
+overvector_x = reform(u(*,*,nlevel,ntime))
+overvector_y = reform(v(*,*,nlevel,ntime))
+if (n_elements(field1) eq 0) then begin
+        print, 'field1: horizontal velocity'
+	zevel = overvector_x^2 + overvector_y^2  ;; attention il faut que les tableaux soient de la meme taille
+	what_I_plot = sqrt(zevel)
+endif else begin
+	if (no3d eq 'true') then what_I_plot = reform(cfield1(*,*,ntime)) else what_I_plot = reform(cfield1(*,*,nlevel,ntime))
+endelse
+if (n_elements(field2) eq 0) then overcontour = reform(hgt(*,*,ntime)) else overcontour = reform(cfield2(*,*,ntime))
+;
+;
+;
+if (coord2d eq 'false') then begin ;; SI PAS UMET et VMET
+	;npoints=n_elements(lon(*,0)) + n_elements(lon(0,*))
+        ;what_I_plot = REBIN( what_I_plot, npoints, npoints )
+        ;overvector_x = REBIN( overvector_x, npoints, npoints )
+	;overvector_y = REBIN( overvector_y, npoints, npoints )
+	;overcontour = REBIN( overcontour, npoints, npoints )
+        ;lon =  minlon + (maxlon - minlon)*findgen(npoints)/float(npoints-1)
+        ;lat =  minlat + (maxlat - minlat)*findgen(npoints)/float(npoints-1)
+lon = findgen( n_elements(what_I_plot(*,0)) )
+lat = findgen( n_elements(what_I_plot(0,*)) )
+print, 'ATTENTION!!!! NOUS SOMMES BIEN D ACCORD QUE VOUS NE CHARGEZ PAS UMET et VMET ??'
+endif
+if (coord2d eq 'regular') then begin ;; carte avec mercator
+lon = reform(lon(*,0))
+lat = reform(lat(0,*))
+endif
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;;
+;;
+;;
+;loadct, 0
+;contour, reform(field3(*,*,ntime)), $
+;	lon,lat, $
+;        /overplot, $ 
+;	levels=[1,100,200], $
+;	c_labels=[0,0,0], $
+;        c_thick=1.5, $
+;	color=255
+;
+
+
+PS_End, /PNG
+		endfor
+end
+
+
+
+;
+; SI MAP_SET EST REGLE....
+;
+;; marche pas avec les vecteurs
+
+
+loadct, 0
+MAP_GRID, $
+          CHARSIZE = 1., $
+          COLOR    = 0,   $
+        ;  LABEL    = 2,   $   ;; /LABEL or LABEL=2 (one label any 2 grid lines)
+	;          LATDEL   = 10., $   ;;5
+	;          LONDEL   = 30., $   ;;15
+	;lats=-60, $
+	;          LONLAB   = -70., $ ;(latmin+latmax)/2., $
+	;          LATLAB   = (lonmin+lonmax)/2., $
+          LABEL    = 1,   $   ;; /LABEL or LABEL=2 (one label any 2 grid lines)
+          LATDEL   = 10., $   ;;5
+          LONDEL   = 15., $   ;;15
+          LONLAB   = -0., $ ;(latmin+latmax)/2., $
+          LATLAB   = -0.001, $
+          GLINESTYLE = 2, $
+          GLINETHICK = 0.3
+	  ;LONALIGN = 0., $
+	  ;LATALIGN = 1.
+
+;;
+;;
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/POLAR/polar_uvt_passur.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/polar_uvt_passur.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/polar_uvt_passur.pro	(revision 1185)
@@ -0,0 +1,112 @@
+pro map_uvt
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+@map_uvt_inc.pro
+SPAWN, '\rm param_plot.idl ; cp map_uvt_inc.pro param_plot.idl'
+if (n_elements(coord2d) eq 0) then coord2d='false'
+;
+;
+;
+  zefile=save_ps
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+;
+;
+;
+if (n_elements(field1) ne 0) then getcdf, file=filename, charvar=field1, invar=cfield1
+getcdf, file=filename, charvar='Um', invar=u
+getcdf, file=filename, charvar='Vm', invar=v
+getcdf, file=filename, charvar='XLONG_M', invar=longi
+getcdf, file=filename, charvar='XLAT_M', invar=lati
+getcdf, file=filename, charvar='HGT_M', invar=hgt
+;
+;
+;
+sp = 5 ;; relaxation width
+nx = n_elements(longi(0,*))
+ny = n_elements(longi(*,0))
+if (n_elements(field1) ne 0) then begin
+	cfield1	= cfield1	(sp:nx-sp-1,sp:ny-sp-1,*,*)
+endif
+u 		= u		(sp:nx-sp-1,sp:ny-sp-1,*,*) 
+v       	= v       	(sp:nx-sp-1,sp:ny-sp-1,*,*)
+longi		= longi		(sp:nx-sp-1,sp:ny-sp-1,*)
+lati           	= lati 	        (sp:nx-sp-1,sp:ny-sp-1,*)
+hgt		= hgt		(sp:nx-sp-1,sp:ny-sp-1,*)
+nx = n_elements(longi(0,*))
+ny = n_elements(longi(*,0))
+;
+;
+;
+overcontour = reform(hgt(*,*,ntime))
+lon = reform(longi(*,*,ntime))
+lat = reform(lati(*,*,ntime))
+overvector_x = reform(u(*,*,nlevel,ntime))
+overvector_y = reform(v(*,*,nlevel,ntime))
+if (n_elements(field1) eq 0) then begin
+        print, 'field1: horizontal velocity'
+	zevel = overvector_x^2 + overvector_y^2  ;; attention il faut que les tableaux soient de la meme taille
+	what_I_plot = sqrt(zevel)
+endif else begin
+;	what_I_plot = reform(cfield1(*,*,nlevel,ntime))
+what_I_plot = reform(cfield1(*,*))
+endelse
+;
+;
+;
+minlat=min(lat) & maxlat=max(lat) & minlon=min(lon) & maxlon=max(lon)
+if (coord2d eq 'true') then begin
+	npoints=n_elements(lon(*,0)) + n_elements(lon(0,*))  ;; trop de points, mais au moins on ne perd rien 
+	TRIANGULATE, lon, lat, tr 
+	what_I_plot  = GRIDDATA( lon, lat, what_I_plot,  /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+	overvector_x = GRIDDATA( lon, lat, overvector_x, /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+	overvector_y = GRIDDATA( lon, lat, overvector_y, /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+        overcontour  = GRIDDATA( lon, lat, overcontour,  /LINEAR, triangles=tr, dimension=npoints, MISSING=!VALUES.F_NAN )
+			; sale sale sale
+			if (minlat lt min(lat(*,0))) then overvector_y=-overvector_y
+			if (minlon lt min(lon(0,*))) then overvector_x=-overvector_x
+        lon =  minlon + (maxlon - minlon)*findgen(npoints)/float(npoints-1)
+        lat =  minlat + (maxlat - minlat)*findgen(npoints)/float(npoints-1)
+endif else begin
+	;npoints=n_elements(lon(*,0)) + n_elements(lon(0,*))
+        ;what_I_plot = REBIN( what_I_plot, npoints, npoints )
+        ;overvector_x = REBIN( overvector_x, npoints, npoints )
+	;overvector_y = REBIN( overvector_y, npoints, npoints )
+	;overcontour = REBIN( overcontour, npoints, npoints )
+        ;lon =  minlon + (maxlon - minlon)*findgen(npoints)/float(npoints-1)
+        ;lat =  minlat + (maxlat - minlat)*findgen(npoints)/float(npoints-1)
+endelse
+
+;lon = reform(lon(*,0))
+;lat = reform(lat(0,*))
+
+help, what_I_plot, lon, lat
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;
+;
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/POLAR/polar_w.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/polar_w.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/polar_w.pro	(revision 1185)
@@ -0,0 +1,97 @@
+pro polar_w
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+hem = -1.
+@polar_inc_w.pro
+SPAWN, '\rm param_plot.idl ; cp polar_inc_w.pro param_plot.idl'
+;
+;
+;
+  zefile=save_ps
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  ;!p.multi=[0,2,2]
+  ;!P.Charsize = 0.6
+;
+;
+;
+getcdf, file=filename, charvar=cfield1, invar=field1
+getcdf, file=filename, charvar=cfield2, invar=field2
+;getcdf, file=filename, charvar=cfield3, invar=field3
+getcdf, file=filename, charvar='XLONG', invar=longi
+getcdf, file=filename, charvar='XLAT', invar=lati
+;
+;
+;
+
+;zefile=save_ps+string(100+ntime,'(I0)')
+;PS_Start, filename=zefile+'.ps'
+;!P.Charsize = 1.2
+;!p.charthick = 2.0
+;!p.thick = 2.0
+;!x.thick = 2.0
+;!y.thick = 2.0
+;
+;
+;
+	;latmin = -90. & latmax = 10.0 & lonmin = -180. & lonmax = 180.
+map_set, hem*90., 0., /isotropic, /azimuthal, /noborder, limit=[latmin,lonmin,latmax,lonmax],title=title_user,/advance ;, position=[0.10, 0.12, 0.90, 0.92]
+;
+;
+;
+what_I_plot = reform(field1(*,*,nlevel,ntime))
+overcontour = reform(field2(*,*,ntime))
+;overcontour = 0.
+lon = reform(longi(*,*,ntime))
+lat = reform(lati(*,*,ntime))
+overvector_x=0.
+overvector_y=0.
+;
+;
+;
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;;
+;;
+;;
+;loadct, 0
+;contour, reform(field3(*,*,ntime)), $
+;	lon,lat, $
+;        /overplot, $ 
+;	levels=[1,100,200], $
+;	c_labels=[0,0,0], $
+;        c_thick=1.5, $
+;	color=255
+
+;
+;
+;
+loadct, 0
+MAP_GRID, CHARSIZE = 0.8, $
+          COLOR    = 0,   $
+          LABEL    = 1,   $   ;(one label any 1 grid lines)
+          LATDEL   = 02., $
+          LONDEL   = 45., $
+          ;lats=-60, $
+          GLINESTYLE = 1, $
+          GLINETHICK = 0.1, $
+          LONLAB   = -77., $
+          LATLAB   = 180.
+;;
+;;
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/POLAR/polaract.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/POLAR/polaract.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/POLAR/polaract.pro	(revision 1185)
@@ -0,0 +1,108 @@
+pro polaract
+;
+;
+;
+what_I_plot=0.
+overcontour=0.
+@polaract_inc.pro
+SPAWN, '\rm param_plot.idl ; cp polar_inc.pro param_plot.idl'
+;
+;
+;
+  zefile=save_ps
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 0.6
+  !P.multi=[0,2,1]
+	;!p.charthick = 2.0
+	;!p.thick = 2.0
+	;!x.thick = 2.0
+	;!y.thick = 2.0
+;
+;
+;
+jojo = ['gw','gwsmooth']
+	;jojo = ['gwplus','gwsmooth']
+	;jojo = ['gwhires','gw']
+filename_sav = filename
+for i=0,n_elements(jojo)-1 do begin
+;
+filename = '/donnees/aslmd/MODELES//LMD_MM_MARS//OUTILS_CONVERSION/'+jojo(i)+'/'+filename_sav
+print, filename
+;
+getcdf, file=filename, charvar=cfield1, invar=field1
+getcdf, file=filename, charvar=cfield2, invar=field2
+getcdf, file=filename, charvar='XLONG', invar=longi
+getcdf, file=filename, charvar='XLAT', invar=lati
+;
+;
+;
+if (jojo(i) eq 'gwhires') then begin
+	sp = 6;5 ;; relaxation width
+	nx = n_elements(longi(0,*))
+	ny = n_elements(longi(*,0))
+	field1 		= field1        (sp:nx-sp-1,sp:ny-sp-1,*,*)
+	field2          = field2        (sp:nx-sp-1,sp:ny-sp-1,*)
+	longi           = longi         (sp:nx-sp-1,sp:ny-sp-1,*)
+	lati            = lati          (sp:nx-sp-1,sp:ny-sp-1,*)
+endif
+;
+;
+;
+latmin = -90. & latmax = -50.0 & lonmin = -180. & lonmax = 180.
+	;lonmin = 0. & lonmax = 90. ;; pour des tranches
+map_set, -90., 0., /isotropic, /azimuthal, /noborder, limit=[latmin,lonmin,latmax,lonmax],title=title_user,/advance ;, position=[0.10, 0.12, 0.90, 0.92]
+;
+;
+;
+  ;; average on time and height
+dbl_integral = TOTAL(TOTAL(field1*field1,3),3) 
+dbl_integral = TEMPORARY(dbl_integral) / n_elements(field1(0,0,*,0)) / n_elements(field1(0,0,0,*))
+print, n_elements(field1(0,0,*,0)), n_elements(field1(0,0,0,*))
+  ;; smooth a little bit
+smoothampl=2 ;0;3
+overcontour = smooth(TEMPORARY(dbl_integral),[smoothampl,smoothampl],/EDGE_TRUNCATE)
+  ;; plot topography
+what_I_plot = reform(field2(*,*,0))
+  ;; coordinates
+lon = reform(longi(*,*,0))
+lat = reform(lati (*,*,0))
+overvector_x=0.
+overvector_y=0.
+;
+;
+;
+SPAWN, '\rm param_plot.idl ; cp polaract_inc.pro param_plot.idl'
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        lon, $                                  ; 1D latitude
+        lat, $                                  ; 1D longitude
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+        colors=colors, $                        ; number of colors/levels (32 is default)
+        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+;
+;
+;
+loadct, 0
+MAP_GRID, CHARSIZE = 0.6, $
+          COLOR    = 0,   $
+          LABEL    = 1,   $   (one label any 1 grid lines)
+          LATDEL   = 05., $   
+          LONDEL   = 45., $   
+	  lats=-60, $
+          GLINESTYLE = 1, $ 
+          GLINETHICK = 0.1, $ 
+          LONLAB   = -70., $ 
+          LATLAB   = (lonmin+lonmax)/2.
+;
+;
+;
+endfor
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/PROFILE/profile_uvt.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/PROFILE/profile_uvt.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/PROFILE/profile_uvt.pro	(revision 1185)
@@ -0,0 +1,152 @@
+pro profile_uvt
+;
+;
+;
+what_I_plot=0.
+overcontour=0
+mention=''
+@map_uvt_inc.pro
+SPAWN, '\rm param_plot.idl ; cp map_uvt_inc.pro param_plot.idl ; cp -f map_uvt_inc.pro '+save_ps+'.map_uvt_inc.pro'
+if (n_elements(coord2d) eq 0) then coord2d='false'
+;
+;
+;
+  zefile=save_ps
+  PS_Start, filename=zefile+'.ps'
+  print, zefile+'.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+!p.multi=[0,2,2]
+!P.Charsize = 1.0
+;
+;
+;
+if (n_elements(field1) ne 0) then getcdf, file=filename, charvar=field1, invar=cfield1
+u  = getget(filename, 'Um',   count=[1,1,0,1], offset=[zex, zey, 0,ntime])
+v  = getget(filename, 'Vm',   count=[1,1,0,1], offset=[zex, zey, 0,ntime])
+w  = getget(filename, 'WAVE', count=[1,1,0,1], offset=[zex, zey, 0,ntime]) 
+u2 = getget(filename, 'Um',   count=[1,1,0,1], offset=[zex2,zey2,0,ntime])
+v2 = getget(filename, 'Vm',   count=[1,1,0,1], offset=[zex2,zey2,0,ntime])
+w2 = getget(filename, 'WAVE', count=[1,1,0,1], offset=[zex2,zey2,0,ntime])
+tk = getget(filename, 'tk',   count=[1,1,0,1], offset=[zex, zey, 0,ntime])
+tk2 = getget(filename, 'tk',   count=[1,1,0,1], offset=[zex2, zey2, 0,ntime])
+tpot = getget(filename, 'tpot',   count=[1,1,0,1], offset=[zex, zey, 0,ntime])
+tpot2 = getget(filename, 'tpot',   count=[1,1,0,1], offset=[zex2, zey2, 0,ntime])
+getcdf, file=filename, charvar='XLONG', invar=longi
+getcdf, file=filename, charvar='XLAT', invar=lati
+getcdf, file=filename, charvar='HGT', invar=hgt
+getcdf, file=filename, charvar='vert', invar=vert
+getcdf, file=filename, charvar='TSURF', invar=tsurf
+getcdf, file=filename, charvar='USTM', invar=ustar
+print, longi(zex ,zey ,0), lati(zex ,zey ,0)
+print, longi(zex2,zey2,0), lati(zex2,zey2,0)
+;
+;
+;
+loadct, 0
+contour, reform(hgt(*,*,ntime)), $
+reform(longi(*,*,ntime)), $
+reform(lati(*,*,ntime)), $
+nlevels=20, $
+xtitle='Longitude', $
+ytitle='Latitude', $
+;xrange=[-146.,-126.], $
+;yrange=[11.,27.], $
+xrange=[-141.,-133.], $
+yrange=[18.,26.], $
+xtickinterval=1., $
+ytickinterval=1., $
+max_value=22000., $
+min_value=-4000., $
+/cell_fill
+xyouts, longi(zex ,zey ,0), lati(zex ,zey ,0), '+ full', color=255, charsize=1.5
+xyouts, longi(zex2 ,zey2 ,0), lati(zex2 ,zey2 ,0), '+ dashed', color=255, charsize=1.5
+;
+;
+;
+	;plot, tsurf(zex ,zey ,*), yrange=[150, 300]
+	;oplot, tsurf(zex2 ,zey2 ,*), linestyle=1
+;
+;
+;
+what_I_plot = tk & column = vert
+;yeye = tsurf(zex,zey,ntime) & what_I_plot = [yeye,reform(what_I_plot)] & column = [0.01, vert]
+overplot = tk2 & overplot_column = vert
+;yeye = tsurf(zex2,zey2,ntime) & overplot = [yeye,reform(overplot)] & overplot_column = [0.01, vert]
+print, min(what_I_plot), max(what_I_plot)
+print, min(overplot), max(overplot)
+mention='three'
+;
+;
+;
+profile, $
+        what_I_plot, $                          ; 1D vertical profile
+        column, $                               ; altitudes     
+        alt=alt, $                              ; altitude range [altmin, altmax]
+        minfield=minfield_init2, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init2, $               ; maximum value of plotted field (=0: calculate)
+        inprofile=overplot, $                   ; another vertical profile to overplot
+        incolumn=overplot_column, $             ; altitudes of the other vertical profile (in case /= column)
+        discrete=discrete, $                    ; show the profile points (= type of points in !psym)
+        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+        title_axis=title_axis2, $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+        mention=mention                         ; add text precision within the plot window (default is nothing or '')
+xyouts, 210.,20.,'T!Ds!N = '+string(tsurf(zex,zey,ntime),'(I0)')+' K'
+xyouts, 163.,20.,'T!Ds!N = '+string(tsurf(zex2,zey2,ntime),'(I0)')+' K'
+;
+;
+;
+what_I_plot = w & column = vert
+overplot = w2 & overplot_column = vert
+;
+;
+;
+profile, $
+        what_I_plot, $                          ; 1D vertical profile
+        column, $                               ; altitudes     
+        alt=alt, $                              ; altitude range [altmin, altmax]
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        inprofile=overplot, $                   ; another vertical profile to overplot
+        incolumn=overplot_column, $             ; altitudes of the other vertical profile (in case /= column)
+        discrete=discrete, $                    ; show the profile points (= type of points in !psym)
+        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+        title_axis=title_axis, $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+        mention=mention                         ; add text precision within the plot window (default is nothing or '')
+;
+;
+;
+	;plot, tpot, vert
+	;oplot, tpot2, vert, linestyle=2
+	;PS_End, /PNG
+	;stop
+what_I_plot = u*u + v*v & what_I_plot = sqrt(what_I_plot) & column = vert
+overplot = u2*u2 + v2*v2 & overplot = sqrt(overplot) & overplot_column = vert
+print, min(what_I_plot), max(what_I_plot)
+print, min(overplot), max(overplot)
+mention='two'
+;
+;
+;
+profile, $
+        what_I_plot, $                          ; 1D vertical profile
+        column, $                               ; altitudes     
+        alt=alt, $                              ; altitude range [altmin, altmax]
+        minfield=minfield_init2, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init2, $               ; maximum value of plotted field (=0: calculate)
+        inprofile=overplot, $                   ; another vertical profile to overplot
+        incolumn=overplot_column, $             ; altitudes of the other vertical profile (in case /= column)
+        discrete=discrete, $                    ; show the profile points (= type of points in !psym)
+        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+        title_axis=title_axis2, $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+        mention=mention                         ; add text precision within the plot window (default is nothing or '')
+xyouts, 23.5,20.,'u!D*!N = '+string(ustar(zex,zey,ntime),'(F4.1)')+' m s!U-1!N'
+xyouts, 5.,20.,'u!D*!N = '+string(ustar(zex2,zey2,ntime),'(F4.1)')+' m s!U-1!N'
+;
+;
+;
+PS_End, /PNG
+end
Index: trunk/UTIL/IDLplot/SPEC/SERIES/hodo.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/SERIES/hodo.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/SERIES/hodo.pro	(revision 1185)
@@ -0,0 +1,146 @@
+pro hodo
+
+;;Procedure pour tracer des hodographes des vents ou des vents effectifs
+	;;On trace en un point donne les vecteurs vents au cours du temps
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;Choix du fichier
+	;file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_68.5/jour20/wrfout_d01_2024-03-20_06:00:00'
+	;file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_244_tau2/wrfout_d01_2024-09-08_00:00:00'
+	;file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_244_tau05/wrfout_d01_2024-09-08_00:00:00'
+	file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_244_tau5/wrfout_d01_2024-09-08_00:00:00'
+	;file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_244_tau1/wrfout_d01_2024-09-08_00:00:00'
+	
+;;Choix de la methode
+	effective='true'
+	;effective='false'
+	
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;Reglages
+
+;;Nom du fichier
+	nomfich='Hodo_landingsite_tau5'
+	
+;;Choix des heures (0 = 1ere heure du ncdf)
+	start_hour=0.
+	end_hour=23.	
+	
+	
+;;Choix de l'eta-level (premier a 1)
+	level=2
+	
+;;Choix de la position (en indices)
+	pos=[72.,72.]
+	
+;;Choix de l'affichage des heures
+	debut=0	;;heure reelle (a adapter a start_hour)
+	pas=2	;;commenter si on ne veut rien
+	
+;;Sous titre (commentable)	
+	subtitre='Tau = 5'	
+	
+;;Echelle (commenter pour echelle automatique)
+	hrange=[-20.,15.]
+	xdiv=7
+	vrange=[-30.,5.]
+	ydiv=7
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+getcdf, file=file, charvar='XLAT', invar=lat
+getcdf, file=file, charvar='XLONG', invar=lon
+	lon=reform(lon(*,0,0))		;;pour un [i,j] donne l'abscisse de lon donne la longitude
+	lat=reform(lat(0,*,0))
+
+if (effective eq 'false') then begin
+
+	getcdf, file=file, charvar='U', invar=u
+	getcdf, file=file, charvar='V', invar=v
+
+	u=reform(u(*,*,level-1,start_hour:end_hour))
+	v=reform(v(*,*,level-1,start_hour:end_hour))
+	
+	var=''
+	lev='_lev'+STRTRIM(level,2)
+
+
+endif else begin
+
+	;;Vent effectif obtenu par integration sur l'altitude
+	effwind, $
+		'U', $	
+		file, $		
+		u, $	
+		start_time=start_hour, $	
+		end_time=end_hour		
+
+	effwind, $
+		'V', $	
+		file, $		
+		v, $
+		start_time=start_hour, $
+		end_time=end_hour
+
+	var='Effective'
+	lev=''
+	
+endelse
+	
+	u=reform(u(pos[0],pos[1],*))
+	v=reform(v(pos[0],pos[1],*))
+	
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+PS_Start,filename=nomfich+var+'_pos'+STRTRIM(pos[0],2)+'-'+STRTRIM(pos[1],2)+lev+'.ps',xsize=8,ysize=8
+	!P.Charsize = 1.2
+
+;;Reglages graphiques
+
+if (n_elements(hrange) eq 0.) then begin	
+	if ( abs( max(u)-min(u)) ge  abs( max(v)-min(v))) then range=abs( max(u)-min(u)) else range=abs( max(v)-min(v))
+	hrange=[min(u)-1,min(u)-1+ range +2] 
+	vrange=[min(v)-1,min(v)-1 + range +2]
+endif
+	
+	valon=lon(pos[0])
+	valat=lat(pos[1])
+	
+;;Trace	
+	plot, $
+		u, $
+		v, $
+		xtitle=var+' U Wind Velocity (m/s)', $
+		ytitle=var+' V Wind Velocity (m/s)', $
+		title='Hodograph : lon '+string(valon, FORMAT='(F7.2)')+' | lat '+string(valat, FORMAT='(F7.2)'), $
+		subtitle=subtitre, $
+		PSYM=-4, $
+		Xrange=hrange, $
+		Xticks=xdiv, $
+		Yrange=vrange, $
+		Yticks=ydiv, $
+		XTicklen=1.0, $
+	 	YTicklen=1.0, $
+		XGridStyle=1, $
+		YGridStyle=1
+
+	;;affichage de l'origine	
+	oplot,[0],[0],PSYM=5,symsize=1.5
+
+;;Reperage des heures 
+if n_elements(pas) ne 0 then begin
+
+	for t=0,end_hour-start_hour,pas do begin
+	
+	XYOUTS, u(t),v(t),debut+t,CHARSIZE=0.9
+	
+	endfor
+	 
+endif
+	
+;;Conversion en .png
+	PS_End, /PNG
+
+end
Index: trunk/UTIL/IDLplot/SPEC/SERIES/mawd.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/SERIES/mawd.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/SERIES/mawd.pro	(revision 1185)
@@ -0,0 +1,98 @@
+pro mawd
+
+;;;;;;;
+experiment='a035'
+;experiment='a040'
+;experiment='a045'
+;;f_user='/donnees/aslmd/SVN/trunk/mesoscale/TMPDIR/GCMINI/mawd.nc'
+;;f_user='/tmp7/aslmd/mawd.nc'
+f_user='/d5/aslmd/WATERCYCLE/mawd_'+experiment+'.nc'
+v_user = 'mtot'
+x_user = 'Time'
+y_user = 'latitude'
+transp = 'yes'
+tes = 'no'
+;;;;;;;
+;f_user='/donnees/aslmd/TES/TES.SeasonalClimatology.nc'
+;v_user = 'water'
+;x_user = 'time'
+;y_user = 'latitude'
+;transp = 'yes'
+;tes = 'yes'
+;;;;;;;
+
+
+what_I_plot=0.
+overcontour=0
+@mawd_inc.pro
+print, lev
+SPAWN, '\rm param_plot.idl ; cp mawd_inc.pro param_plot.idl'
+
+PS_START, file='mawd_'+experiment+'.ps'
+;  !P.Charsize = 1.2
+;  !p.charthick = 2.0
+;  !p.thick = 2.0
+;  !x.thick = 2.0
+;  !y.thick = 2.0
+
+cdfid = ncdf_open(f_user)
+
+varid=ncdf_varid(cdfid,v_user)
+ncdf_varget, cdfid, varid, champ
+
+varid=ncdf_varid(cdfid,y_user)
+ncdf_varget, cdfid, varid, yy
+
+varid=ncdf_varid(cdfid,x_user)
+ncdf_varget, cdfid, varid, xx
+
+if (tes eq 'no') then begin
+  ;;; en precip-microns
+  champ = champ * 1.e6 / 917.
+  ;;;; entre 0 et 360
+  ;xx = xx MOD 360
+  xx = xx - 360.*3.
+endif else begin
+  xx = xx - 360.*2.
+endelse
+
+help, champ
+if (tes eq 'no') then begin
+  what_I_plot = champ
+endif else begin
+  what_I_plot = float(reform(champ(0,*,*)))
+endelse
+help, what_I_plot
+overcontour = what_I_plot
+
+if (tes eq 'yes') then begin
+  w=where(what_I_plot eq -1.)
+  what_I_plot[w] = !VALUES.F_NAN
+  overcontour[w] = !VALUES.F_NAN
+endif
+
+if (transp eq 'yes') then begin
+	what_I_plot = transpose(what_I_plot)
+	overcontour = transpose(overcontour)
+endif
+
+what_I_plot = smooth(what_I_plot,[10,1])
+
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        xx, $                                  ; 1D latitude OR 2D
+        yy, $                                  ; 1D longitude OR 2D
+;        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+;        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+;        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+;        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+;        colors=colors, $                        ; number of colors/levels (32 is default)
+;        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+
+
+PS_END, /PNG
+
+end
Index: trunk/UTIL/IDLplot/SPEC/SERIES/mawd_inc.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/SERIES/mawd_inc.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/SERIES/mawd_inc.pro	(revision 1185)
@@ -0,0 +1,44 @@
+;;;;;*************************************** PLOT TITLES
+        title_user 	= 	'Water vapor column [precip. microns]' 
+        title_axis      =       ['L!DS!N','North Latitude']
+
+;;;;;*************************************** COLOR TABLES
+        flag_cb         =       'true'
+	poscb		=	0.75
+        format          =       '(I0)' 
+        colors          =       32
+        pal             =       33;22;4;33              ;; GOOD: 4, 18, 22, 16, 37, 33, 39, 6, 11
+
+;;;;;*************************************** FILL LIMITS
+        minfield_init   =       0.
+        maxfield_init   =       100. ;120. ;65.
+        ndiv            =       10 ;12 ;13
+
+	;;;;;*************************************** LIMIT TRICKS
+        ;;;;;********************* must always follow FILL LIMITS
+        	missing_value=1.e30
+        	lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+        	lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+        	lim_blank = 1.0 & w=where(abs(what_I_plot) le lim_blank) & if (w[0] ne -1) then what_I_plot[w]=missing_value
+
+;;;;;*************************************** CONTOUR
+	overcontour	=	overcontour
+        lev             =       minfield_init + (maxfield_init - minfield_init)*findgen(ndiv+1)/float(ndiv)
+
+;;;;;*************************************** AXIS
+        isotropic       =       'true'
+        intervalx       =       15.0
+        intervaly       =	15.0
+
+;;;;;*************************************** MAP LIMITS
+	windowx 	= 	[30.,150.]
+        windowx         =       [30.,1500.]
+	windowy 	= 	[-15.,90.]
+
+;;;;; MULTIYEAR
+	isotropic       =       'false'
+        windowx         =       [0.,2880.] ;[0.,3600.] ;[1500.,4000.]
+        intervalx       =       360.0
+        windowy         =       [-90.,90.]
+        intervaly       =       30.0
+        lev		=       [600.] ;[100.]
Index: trunk/UTIL/IDLplot/SPEC/SERIES/windautom.idl
===================================================================
--- trunk/UTIL/IDLplot/SPEC/SERIES/windautom.idl	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/SERIES/windautom.idl	(revision 1185)
@@ -0,0 +1,56 @@
+; cf gw.def apres 'change plot settings'
+;
+
+;title_user='Evolution of mean wind speed (m/s) with height ABG and LT'
+        ;;'Evolution of mean temperature (K) with height ABG and LT'
+        ;;'Evolution of mean wind speed (m/s) with height ABG and LT'
+
+
+title_user='Evolution of horizontal wind speed (m/s) with height AGL and LT'
+;  title_user='Evolution of vertical wind speed (m/s) with height ABG and LT'
+;title_user='Evolution of temperature (K) with height AGL and LT'
+
+;subtitle_user='Tau dust 5 minus Tau dust 2'
+
+windowx=[6.,29.]
+windowx=[0.,23.]
+windowy=[0.,45.]
+intervalx=1.
+intervaly=5.
+
+pal=33
+numdiv=14
+
+pal=22
+format='(I0)'
+
+minfield_init=0.
+maxfield_init=80.
+numdiv=10
+
+	;windowx=[0.,23.]
+	;windowy=[0.,12.]
+	;intervalx=1.
+	;intervaly=2.
+	;minfield_init=0.
+	;maxfield_init=30.
+
+;minfield_init=120.
+;maxfield_init=220.
+
+
+  ;numdiv=10
+  ;minfield_init=-2.
+  ;maxfield_init=2.
+  ;minfield_init=-0.5
+  ;maxfield_init=0.5
+  ;pal=33
+
+
+isotropic='false'
+
+lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
+lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
+
+;;pour tracer les vents en fonction du temps mettre :
+title_axis=['Martian hour (h)','Height above ground (km)']
Index: trunk/UTIL/IDLplot/SPEC/SERIES/windmeso.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/SERIES/windmeso.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/SERIES/windmeso.pro	(revision 1185)
@@ -0,0 +1,243 @@
+pro windmeso
+
+;;Procedure de trace de valeurs issues du Mesoscale en temps-altitude
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;Choix des champs a tracer, 3 cas :
+;;Un champ de deux variables, dont on trace le module, entrer [X,Y]
+;;Une variable X seule, dont on trace la valeur entrer  [X,X]
+;;tk, entrer [T,PTOT]
+
+;champ1='U' & champ2='V' & champlat = 'XLAT' & champlon = 'XLONG' & champhgt = 'HGT' & file='/home/aymeric/Science/INTERCOMP/LMD_MMM/LMD_MMM_d04_2024-05-57_06:00:00' & nomfich='nest4_MSL' & charphtot = 'PHTOT'
+
+champ1='u_avg' & champ2='v_avg' & champlat = 'glat' & champlon = 'glon' & champhgt = 'topo' & file='/home/aymeric/Science/INTERCOMP/MRAMS/MRAMS_d04_2024-05-57_06:00:00' & nomfich='nest4_MSL_mrams' & charphtot = 'z_lyrmid_agl'
+
+;nomfich=nomfich+'proch'
+
+;champ1='T' & champ2='PTOT' & champlat = 'XLAT' & champlon = 'XLONG' & champhgt = 'HGT' & file='/home/aymeric/Science/INTERCOMP/LMD_MMM/LMD_MMM_d04_2024-05-57_06:00:00' & nomfich='nest4_MSLtemp' & charphtot = 'PHTOT'
+
+;champ1='tempk' & champ2='tempk' & champlat = 'glat' & champlon = 'glon' & champhgt = 'topo' & file='/home/aymeric/Science/INTERCOMP/MRAMS/MRAMS_d04_2024-05-57_06:00:00' & nomfich='nest4_MSL_mramstemp' & charphtot = 'z_lyrmid_agl'
+
+
+;;Decommenter pour un fichier d'API
+;api='on'	;;a tester, voir REF si ca ne marche pas
+
+;;Choix du fichier de simulation
+;file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_68.5/jour20/wrfout_d01_2024-03-20_06:00:00'
+;file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_244_tau2/wrfout_d01_2024-09-08_00:00:00'
+;file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_244_tau05/wrfout_d01_2024-09-08_00:00:00'
+;file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_244_tau5/wrfout_d01_2024-09-08_00:00:00'
+;file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_244_tau1/wrfout_d01_2024-09-08_00:00:00'
+;file='/tmp7/aslmd/wrfout_d01_2024-09-10_06:00:00'
+;file='/tmp7/aslmd/MERIDIANI_FLUSH/wrfout_d01_2024-09-07_06:00:00'
+;file='/tmp7/aslmd/MERIDIANI_FLUSH/wrfout_d01_2024-09-13_06:00:00'
+;file='/tmp7/aslmd/MERIDIANI_FLUSH2/wrfout_d01_2024-09-07_06:00:00'
+;file='/tmp7/aslmd/MERIDIANI_FLUSH2/wrfout_d01_2024-09-13_06:00:00'
+;file='/tmp7/aslmd/MERIDIANI_BOMB/wrfout_d01_2024-09-07_06:00:00'
+;file='/home/aymeric/Science/INTERCOMP/LMD_MMM/LMD_MMM_d04_2024-05-57_06:00:00'
+
+;;Nom du fichier de sortie
+	;nomfich='flush'
+        ;nomfich='nest4_MSL'
+	;nomfich='flush_late'
+	;nomfich='flush2'
+	;nomfich='flush2_late'
+	;nomfich='bomb'
+        nomfich= nomfich+'_vert'
+        ;nomfich='LS244_tau1_vent_bas'
+	;nomfich='test'
+	
+;; Choix des options :
+;;Heure de depart du trace sur les abscisses (ne fait que decaler le trace : le mettre a l'heure de debut de la simu)
+	start_time=0. ;6. ;0.
+;;Intervalle horaire (ne fait qu'elargir le trace, en placant une heure de simu tous les interv)
+	interv=1. 
+	
+;;Gestion des sites
+n = 1 ;;nombre de sites
+sites = make_array(n,/STRING)
+coord = make_array(2,n,/FLOAT)
+	sites[0] ='landing_site'
+	;sites[0] = 'landing_site'
+	;sites[1] = 'crater'
+	;sites[2] = 'crater_rim'
+	;sites[3] = 'high_area'
+	;sites[4] = 'low_area'
+	;sites[5] = 'plain'
+	;sites[] = ''
+	;; si on ne veut pas de nom avec les coordonnes rajouter une case avec rien dedans
+        coord[0,0] =325.149-360.        & coord[1,0] =-26.372
+	;coord[0,0] =353.87-360.	& coord[1,0] =-1.88
+	;coord[0,1] =-9.93 		& coord[1,1] =5.45
+	;coord[0,2] =-9.78		& coord[1,2] =6.63
+	;coord[0,3] =5.77		& coord[1,3] =-6.84
+	;coord[0,4] =-11.78		& coord[1,4] =7.80
+	;coord[0,5] =-2.67		& coord[1,5] =-1.8
+	;coord[0,] =-2.67		& coord[1,] =-1.8
+	
+;;sites de reference:
+;'landing_site'	coord[0,] =353.87-360.		& coord[1,] =-1.88
+;'crater'		coord[0,] =-9.93 		& coord[1,] =5.45
+;'crater_rim'		coord[0,] =-9.78		& coord[1,] =6.63
+;'high_area'		coord[0,] =5.77			& coord[1,] =-6.84
+;'low_area'		coord[0,] =-11.78		& coord[1,] =7.80
+;'plain'		coord[0,] =-2.67		& coord[1,] =-1.8
+;'crater_slope'	coord[0,] =-9.59		& coord[1,] =5.96
+;'crater_LS'		coord[0,] =-3.68		& coord[1,] =-3.65
+;'crater_LS_rim'	coord[0,] =-4.70		& coord[1,] =-3.65
+;'holden' 		coord[0,] =-34.851		& coord[1,] =-26.372
+
+	
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
+
+;;Pour regler les parametres de trace dans autre chose que param_plot qui risaue de mal finir un jour
+SPAWN, '\rm param_plot.idl ; cp -f windautom.idl param_plot.idl'	
+	
+	
+;;Recuperation de la latitude, longitude, topographie et pression (pour le calcul de la heuteur)
+
+       	getcdf, file=file, charvar=champlat, invar=lat
+	getcdf, file=file, charvar=champlon, invar=lon
+	getcdf, file=file, charvar=champhgt, invar=elevation	
+
+
+	;;Recuperation des variables
+	if champ1 eq champ2 then begin
+		getcdf, file=file, charvar=champ1, invar=c
+	endif  else begin
+		getcdf, file=file, charvar=champ1, invar=c1
+		getcdf, file=file, charvar=champ2, invar=c2
+	endelse
+	
+	
+for i = 0,n-1 do begin
+
+;;Site du trace
+	name_site = sites[i]
+	landing_site=[ coord[0,i] , coord[1,i] ]
+	
+;;Recuperation de [i,j] a partir de [lon,lat]
+	findxy, $
+		x=lon, $
+		y=lat, $
+       	 	point=landing_site, $
+		ind=indp, $
+		flag=2
+
+	
+if (n_elements(api) eq 0) then begin
+	print,'----------- Standard output'
+		
+;;Recuperation de la hauteur
+	getcdf, file=file, charvar=charphtot, invar=ph
+        height=reform(ph(indp[0],indp[1],*,*))
+                ;;on se debarasse de la position
+        height=total(height,2)/n_elements(height(0,*))
+                ;;on somme sur le temps et on moyenne: on obtient un tableau de valeurs d'altitudes moyennes
+if (charphtot eq 'z_lyrmid_agl') then begin
+	heightp=height/1000.
+	print, heightp
+endif else begin
+	height=height/1000./3.72
+	heightp=height(0:n_elements(height(*))-2)-elevation(indp[0],indp[1])/1000.
+		;;on soustrait la topographie et on obtient une colonne des hauteurs finales
+        print, heightp
+endelse
+;if (champ1 eq 'W') then heightp=height(0:n_elements(height(*))-1)-elevation(indp[0],indp[1])/1000.
+
+		
+	;;Utiliser la boucle ci dessous pour imprimer les hauteurs à entrer dans la création d'un API
+	;print='on'
+	if (n_elements(print) ne 0) then begin
+		for i=0,n_elements(heightp)-1 do begin
+			print, STRTRIM(heightp(i),2)+','
+		endfor
+	endif
+	
+endif else begin
+	print,'----------- API output'
+	
+	;;créer avec API un fichier contenant Um, Vm (ou autres) et vert, dans namelist.api mettre les interp_levels voulus (par ex avec la boucle print ci dessus)
+	getcdf, file=file, charvar='vert', invar=height
+	heightp=height/1000.		
+endelse	
+		
+		
+;;Creation du champ a tracer
+
+if champ1 eq champ2 then begin
+	print,'Vous tracez les valeurs de '+champ1
+	champi = reform(c(indp[0],indp[1],*,*)) 
+	what_I_plot = champi
+
+if (champ1 eq 'W') then what_I_plot =  what_I_plot[0:n_elements(what_I_plot(*,0))-2,*]
+	
+endif  else begin
+
+if (champ1 eq 'T') and (champ2 eq 'PTOT') then begin 
+	print,'Vous tracez la temperature normale'
+	T = reform( c1(indp[0],indp[1],*,*) )  
+	PTOT = reform( c2(indp[0],indp[1],*,*) ) 
+	what_I_plot =(T+220.)*(PTOT/610.)^(192./844.)
+	 
+endif else begin
+	print,'Vous tracez le module de '+champ1+' et '+champ2
+	champi1 = reform(c1(indp[0],indp[1],*,*)) 
+	champi2 = reform(c2(indp[0],indp[1],*,*)) 
+	what_I_plot = sqrt(champi1^2 + champi2^2)
+
+endelse
+endelse
+
+
+;print, 'mean(what_I_plot) ', mean(what_I_plot) 
+;print, what_I_plot
+
+;;Gestion du temps
+;;definition des abscisses : il va tracer toutes les valeurs du fichier de simu, mais en les decalant a start time
+	localtime = float(start_time) + float(interv)*findgen(n_elements(what_I_plot(0,*))) 	
+	
+;;Nom du fichier de sortie
+
+PS_Start,filename=nomfich+'_'+name_site+'_lon'+string(coord[0,i],'(I0)')+'_lat'+string(coord[1,i],'(I0)')+'.ps'
+!P.Charsize = 1.2
+
+help, transpose(what_I_plot), localtime, heightp
+	
+map_latlon, $
+        transpose(what_I_plot), $      ; 2D field
+        localtime, $                   ; 1D latitude
+        heightp, $                      ; 1D longitude
+	overcontour=0		
+	
+
+;;Conversion en .png
+PS_End, /PNG
+
+endfor
+
+
+end	
+	
+	
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;yeah=where(localtime lt 0) & if (yeah(0) ne -1) then localtime[yeah]=24+localtime[yeah]
+;;; 24h issue
+;localtime=localtime MOD 24 & yeah=where(localtime eq 0) & if (yeah(0) ne -1) then localtime[yeah]=24
+;localtime=24.+localtime
+
+;!p.charthick = 2.0
+;!p.thick = 3.0
+;!x.thick = 1.0
+;!y.thick = 2.0
+
+;overcontour=transpose(what_I_plot)     ; another 2D field to overplot with contour lines (=0: no)
+
+;;ATTENTION : a ne JAMAIS, JAMAIS, JAMAIS faire	
+	;field=sqrt(c1^2+c2^2) & c1=0. & c2=0.
+	;what_I_plot=reform(field(indp[0],indp[1],*,*))
+	;what_I_plot = field
Index: trunk/UTIL/IDLplot/SPEC/getget.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/getget.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/getget.pro	(revision 1185)
@@ -0,0 +1,125 @@
+function getget, name, charvar, count=count, offset=offset, stride=stride, coordmean=coordmean, anomaly=anomaly
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; name: char
+; charvar: char
+; count: 4 elements array   ; The dimensions of the sub-image
+; offset: 4 elements array  ; A variable that contains the offset for the sub-image
+; stride: 4 elements array  ; Create a variable to be used as a value for the STRIDE keyword
+; coordmean: 1 to 4 elements array (dimension 1 is 1)
+; anomaly: a non-null element that would be filled with mean
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;print, charvar
+
+
+nosave = 1  ;; comment to get an IDL data file
+notime = 1  ;; comment to get mention of time taken
+if (n_elements(notime) eq 0) then timetime = SYSTIME(1)
+
+;
+; MINIMAL ARGUMENTS
+;
+if (n_elements(name) eq 0) then stop
+if (n_elements(charvar) eq 0) then stop
+
+;
+; IDL DATA DIRECTORY
+;
+name_idl = charvar+name+'.idl'
+  if (n_elements(coordmean) ne 0) then begin
+    nc = n_elements(coordmean)
+    for i=0,nc-1 do begin
+     name_idl = string(coordmean(i),'(I0)')+name_idl   
+    endfor
+  endif
+name_idl = './idl_dat/'+name_idl
+
+;
+; TEST IF FILE EXISTS
+;
+openr,unit,name_idl,/get_lun,error=err
+
+;
+; IF IDL FILE EXISTS, THAT IS RATHER SIMPLE
+;
+IF (err EQ 0) THEN BEGIN
+
+   print, 'read from file'
+   free_lun,unit
+   restore, filename=name_idl
+
+;
+; IF IDL FILE DOES NOT EXIST, WELL, READ NETCDF
+;
+ENDIF ELSE BEGIN
+
+  ;
+  ; check save directory
+  ;
+  if (n_elements(nosave) eq 0) then SPAWN, 'mkdir -p idl_dat'  
+
+  ;
+  ; open file
+  ;
+  id=ncdf_open(name) 
+
+  ;
+  ; get dimensions
+  ;
+  var = intarr(4)
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), toto, titi & var(0) = titi
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), toto, titi & var(1) = titi 
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'bottom_top'   ), toto, titi & var(2) = titi
+  NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), toto, titi & var(3) = titi 
+  ;print, var
+
+  ;
+  ; define default data windows
+  ;
+  if (n_elements(offset) le 3) then offset=[0,0,0,0]
+  if (n_elements(stride) le 3) then stride=[1,1,1,1]
+  if (n_elements(count) le 3) then count=intarr(4)
+  w = where(count eq 0) & if (w(0) ne -1) then count[w] = var[w] / stride[w]
+
+  ;
+  ; read variable
+  ;
+  varid=ncdf_varid(id,charvar) ;& print, 'get '+charvar 
+  if (n_elements(notime) eq 0) then timetime = SYSTIME(1) ;& help, /memory
+  ncdf_varget, id, varid, invar, count=count, offset=offset, stride=stride & if (n_elements(notime) eq 0) then print, SYSTIME(1) - timetime, ' s' ;& help, /memory
+  ncdf_close, id
+
+  ;
+  ; OPTIONAL: ANOMALY (value is returned in the keyword)
+  ; 
+  if (n_elements(anomaly) ne 0) then begin
+    anomaly=TOTAL(TOTAL(invar,1),1)/float(var[0])/float(var[1])
+    for i=0,var[0]-1 do for j=0,var[1]-1 do invar(i,j,*,*) = TEMPORARY(invar(i,j,*,*)) - anomaly  ; coute cher ; pas tant
+  endif
+
+  ;
+  ; OPTIONAL: MEAN 
+  ;
+  if (n_elements(coordmean) ne 0) then begin
+  for i=0,nc-1 do begin
+   print, 'mean over dimension '+string(coordmean(i),'(I0)')+' - '+string(var(coordmean(i)),'(I0)')+' elements'
+   invar=total(TEMPORARY(invar),coordmean(i))/var(coordmean(i))
+  endfor
+  endif
+
+  ;
+  ; SAVE
+  ;
+  if (n_elements(nosave) eq 0) then save, invar, filename=name_idl
+
+ENDELSE
+
+if (n_elements(notime) eq 0) then print, SYSTIME(1) - timetime, ' s'
+
+;
+; RETURN FIELD
+;
+return, invar
+
+end
Index: trunk/UTIL/IDLplot/SPEC/quick_plot.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/quick_plot.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/quick_plot.pro	(revision 1185)
@@ -0,0 +1,76 @@
+
+
+SPAWN, '\rm param_plot.idl'
+SPAWN, "echo 'intervaly=5.' > param_plot.idl"
+SPAWN, "echo 'intervalx=5.' >> param_plot.idl"
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+file='gcm' & header='' & nlines_header=4 & ncol = 2
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+nlines = FILE_LINES(file)-nlines_header & data=FLTARR(ncol,nlines)
+OPENR, lun, file, /GET_LUN & READF, lun, header & READF, lun, header & READF, lun, header & READF, lun, header 
+READF, lun, data & CLOSE, lun & FREE_LUN, lun
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+altitude        = reform(data(0,*))
+temp            = reform(data(1,*)) 
+data = 0.
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+file='meso' & header='' & nlines_header=4 & ncol = 2
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+nlines = FILE_LINES(file)-nlines_header & data=FLTARR(ncol,nlines)
+OPENR, lun, file, /GET_LUN & READF, lun, header & READF, lun, header & READF, lun, header & READF, lun, header
+READF, lun, data & CLOSE, lun & FREE_LUN, lun
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+altitude2       = reform(data(0,*))         
+temp2           = reform(data(1,*)) 
+data = 0.
+
+
+;
+; extremes
+;
+temp = temp - 12.
+temp2 = temp2 - 12.
+print, 'ATTENTION CACA CACA CACA'
+
+what_I_plot = temp ;- temp2
+column = altitude
+alt = [20.,60.]
+minfield_init = 100. ;-20 ;100.
+maxfield_init = 200. ;20. ;200.
+overplot = temp2
+overplot_column = altitude2
+discrete = 0
+title_user = 'GCM vs. mesoscale simulations'
+title_axis = ['Temperature (K)','Altitude above MOLA (km)']
+mention = ''
+
+profile, $
+        what_I_plot, $                          ; 1D vertical profile
+        column, $                               ; altitudes     
+        alt=alt, $                              ; altitude range [altmin, altmax]
+        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        inprofile=overplot, $                   ; another vertical profile to overplot
+        incolumn=overplot_column, $             ; altitudes of the other vertical profile (in case /= column)
+        discrete=discrete, $                    ; show the profile points (= type of points in !psym)
+        title_plot=title_user, $                ; title of the plot ('Profile' is default)
+        title_axis=title_axis, $                ; title of the [x,y] axis (['Field','Altitude'] is default)
+        mention=mention                         ; add text precision within the plot window (default is nothing or '')
+
+
+
+;
+; condensation
+;
+latcond=5.9e5
+tcond1mb=136.27
+r=192.
+bcond=1./tcond1mb
+acond=r/latcond
+press=610.*exp(-altitude/10.)
+overplot=1./(bcond-acond*alog(.0095*press))
+overplot_column=altitude
+oplot, overplot, overplot_column, psym=5
+
Index: trunk/UTIL/IDLplot/SPEC/quick_plot2.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/quick_plot2.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/quick_plot2.pro	(revision 1185)
@@ -0,0 +1,67 @@
+pro script_con
+
+;;;;;;;
+file_user='/home/aslmd/EXOMARS/LMD_MM_MARS_Meridiani_S114_Ls247_LT0-23.nc'
+var_user = 'TSURF'
+var_user2 = 'HGT'
+nt = 5
+format = '(I0)'
+pal=33
+;;;;;;;
+
+PS_START, file='toto.ps'
+
+
+cdfid = ncdf_open(file_user)
+varid=ncdf_varid(cdfid,var_user)
+ncdf_varget, cdfid, varid, champ
+
+cdfid = ncdf_open(file_user)
+varid=ncdf_varid(cdfid,var_user2)
+ncdf_varget, cdfid, varid, champ2
+
+cdfid = ncdf_open(file_user)
+varid=ncdf_varid(cdfid,'XLONG')
+ncdf_varget, cdfid, varid, lon
+
+cdfid = ncdf_open(file_user)
+varid=ncdf_varid(cdfid,'XLAT')
+ncdf_varget, cdfid, varid, lat
+
+
+
+nx = 25
+ny = 25
+what_I_plot = reform(champ(nx,ny,*))
+
+plot, what_I_plot
+
+PS_END, /PNG
+
+end
+
+
+
+what_I_plot = reform(champ(*,*,nt))
+overcontour = reform(champ2(*,*,nt))
+longi = reform(lon(*,0))
+lati = reform(lat(0,*))
+
+map_latlon, $
+        what_I_plot, $                          ; 2D field
+        longi, $                                  ; 1D latitude OR 2D
+        lati, $                                  ; 1D longitude OR 2D
+;        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
+;        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
+        overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
+;        overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
+;        overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
+        ct=pal, $                               ; color table (33-rainbow is default)
+;        colors=colors, $                        ; number of colors/levels (32 is default)
+;        title=title_user, $                     ; title of the plot ('' is default)
+        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
+
+
+PS_END, /PNG
+
+end
Index: trunk/UTIL/IDLplot/SPEC/tempcond.inc
===================================================================
--- trunk/UTIL/IDLplot/SPEC/tempcond.inc	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/tempcond.inc	(revision 1185)
@@ -0,0 +1,16 @@
+;
+; input: log-pressure altitude
+;
+
+latcond=5.9e5
+tcond1mb=136.27
+r=192.
+
+bcond=1./tcond1mb
+acond=r/latcond
+
+;press=610.*exp(-column/10.)
+press=columnp
+
+overplot=1./(bcond-acond*alog(.0095*press))
+overplot_column=column
Index: trunk/UTIL/IDLplot/SPEC/ti_vs_tsurf.pro
===================================================================
--- trunk/UTIL/IDLplot/SPEC/ti_vs_tsurf.pro	(revision 1185)
+++ trunk/UTIL/IDLplot/SPEC/ti_vs_tsurf.pro	(revision 1185)
@@ -0,0 +1,42 @@
+pro ti_vs_tsurf
+
+getcdf, $
+        file='/d6/vblmd/MERIDIANI_EXOMARS/saves_simu_LS_244_tau05/wrfout_d01_2024-09-08_00:00:00', $
+        charvar='TSURF', $
+        invar=tsurf
+tsurf = max ( tsurf, DIMENSION=3 )
+
+getcdf, $
+        file='./geo_em.d01.nc', $
+        charvar='THERMAL_INERTIA', $
+        invar=ti
+
+getcdf, $
+        file='./geo_em.d01.nc', $
+        charvar='ALBEDO_GCM', $
+        invar=alb
+
+PS_START, file='ti.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+plot, ti, tsurf, psym=3, title='Daily maximum of surface temperature at ExoMars landing season and region', xtitle='Thermal Inertia (tiu)', ytitle='Surface temperature (K)', xrange=[0,500], yrange=[270,320]
+oplot, ti[where(tsurf eq max(tsurf))], tsurf[where(tsurf eq max(tsurf))], psym=4
+xyouts, 380, 310, 'TI = '+string(ti[where(tsurf eq max(tsurf))],'(I0)')+' tiu'
+PS_END, /PNG
+
+PS_START, file='alb.ps'
+  !P.Charsize = 1.2
+  !p.charthick = 2.0
+  !p.thick = 2.0
+  !x.thick = 2.0
+  !y.thick = 2.0
+plot, alb, tsurf, psym=3, title='Daily maximum of surface temperature at ExoMars landing season and region', xtitle='Albedo', ytitle='Surface temperature (K)', xrange=[0.1,0.3], yrange=[270,320]
+oplot, alb[where(tsurf eq max(tsurf))], tsurf[where(tsurf eq max(tsurf))], psym=4
+xyouts, 0.25, 310, 'ALB = '+string(alb[where(tsurf eq max(tsurf))],'(F4.2)')
+PS_END, /PNG
+
+
+end
