Index: trunk/UTIL/PYTHON/planetoplot.py
===================================================================
--- trunk/UTIL/PYTHON/planetoplot.py	(revision 753)
+++ trunk/UTIL/PYTHON/planetoplot.py	(revision 754)
@@ -84,6 +84,6 @@
                        zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\
                        getname,localtime,check_localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds,\
-                       windamplitude,slopeamplitude,deltat0t1,enrichment_factor,getdimfromvar
-    from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img
+                       getdimfromvar,select_case
+    from mymath import deg,max,min,mean,writeascii,fig2data,fig2img
     import matplotlib as mpl
     from matplotlib.pyplot import contour,contourf,hist, text,subplot, figure, rcParams, savefig, colorbar, \
@@ -163,13 +163,5 @@
     ### we get the names of variables to be read. in case only one available, we choose this one.
     ### (we take out of the test specific names e.g. UV is not in the file but used to ask a wind speed computation)
-      varname=var[vvv] 
-      logical_novarname = varname not in nc.variables
-      specificname_meso = ['UV','uv','uvmet','slopexy','SLOPEXY','deltat','DELTAT']
-      logical_nospecificname_meso = not ((typefile in ['meso']) and (varname in specificname_meso))
-      specificname_gcm = ['enfact']
-      logical_nospecificname_gcm = not ((typefile in ['gcm']) and (varname in specificname_gcm))
-      if ( logical_novarname and logical_nospecificname_meso and logical_nospecificname_gcm ): 
-          if len(varinfile) == 1:   varname = varinfile[0] 
-          else:                     varname = False
+      varname = select_case(zvarname=var[vvv],znc=nc,ztypefile=typefile,mode='check')
     ### we get the names of wind variables to be read (if any)
       if winds:                                                    
@@ -314,31 +306,8 @@
       all_namefile[k] = namefile
       all_time[k] = time
-      if var2: 
-         all_var2[k] = getfield(nc,var2)
-         ### v--- too SPECIFIC (see below)
-         if ((var2 in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (var2 not in nc.variables)): all_var2[k] = slopeamplitude(nc)
+      if var2:  all_var2[k] = select_case(zvarname=var2,znc=nc,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k])
       if winds: all_windu[k] = getfield(nc,uchar) ; all_windv[k] = getfield(nc,vchar)
     ### we fill the arrays of fields to be plotted at the current step considered
-      ### ----------- SPECIFIC CASES. NOT HAPPY WITH THIS. note : we could probably call those via a "toolbox" in myplot.
-      ### ----------- 1. saturation temperature
-      if varname in ["temp","t","T_nadir_nit","T_nadir_day","temp_day","temp_night"] and tsat:
-          tt=getfield(nc,varname) ; print "computing Tsat-T, I ASSUME Z-AXIS IS PRESSURE"
-          if type(tt).__name__=='MaskedArray':  tt.set_fill_value([np.NaN]) ; tinput=tt.filled()
-          else:                                 tinput=tt
-          all_var[k]=get_tsat(vert,tinput,zlon=lon,zlat=lat,zalt=vert,ztime=time)
-      ### ----------- 2. wind amplitude
-      elif ((varname in ['UV','uv','uvmet']) and (typefile in ['meso']) and (varname not in nc.variables)):
-          all_var[k]=windamplitude(nc)
-      elif ((varname in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (varname not in nc.variables)):
-          all_var[k]=slopeamplitude(nc)
-      ### ------------ 3. Near surface instability
-      elif ((varname in ['DELTAT','deltat']) and (typefile in ['meso']) and (varname not in nc.variables)):
-          all_var[k]=deltat0t1(nc)
-      ### ------------ 4. Enrichment factor
-      elif ((typefile in ['gcm']) and (varname in ['enfact'])):
-          all_var[k]=enrichment_factor(nc,lon,lat,time)
-      else:
-      ### ideally only this line should be here
-          all_var[k] = getfield(nc,varname)
+      all_var[k] = select_case(zvarname=all_varname[k],znc=nc,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k])
     ### we inform the user about the loop then increment the loop. this is the last line of "for namefile in namefiles" 
       print "**** GOT SUBDATA:",k," NAMEFILE:",namefile," VAR:",varname, var2 ; k += 1 ; firstfile = False
@@ -355,12 +324,5 @@
                 if fileref is not None:   
                    ncref = Dataset(fileref)
-                   if ((all_varname[k-1] in ['UV','uv','uvmet']) and (typefile in ['meso']) and (all_varname[k-1] not in ncref.variables)):
-                      all_var[k] = windamplitude(ncref)
-                   elif ((all_varname[k-1] in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (all_varname[k-1] not in ncref.variables)):
-                      all_var[k] = slopeamplitude(ncref)
-                   elif ((all_varname[k-1] in ['DELTAT','deltat']) and (typefile in ['meso']) and (all_varname[k-1] not in ncref.variables)):
-                      all_var[k]=deltat0t1(ncref)
-                   else:
-                      all_var[k] = getfield(ncref,all_varname[k-1])
+                   all_var[k] = select_case(zvarname=all_varname[k-1],znc=ncref,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k],zvert=vert)
                    all_varname[k] = all_varname[k-1] ; all_time[k] = all_time[k-1] ; all_namefile[k] = all_namefile[k-1] ; all_var2[k] = all_var2[k-1]
                    if winds: all_windu[k] = getfield(ncref,uchar) ; all_windv[k] = getfield(ncref,vchar)
