Changeset 402 for trunk/UTIL/PYTHON/planetoplot.py
- Timestamp:
- Nov 21, 2011, 1:00:48 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot.py
r401 r402 65 65 zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\ 66 66 getname,localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar 67 from mymath import deg,max,min,mean,get_tsat 67 from mymath import deg,max,min,mean,get_tsat,writeascii 68 68 import matplotlib as mpl 69 69 from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title … … 135 135 ########################################################## 136 136 if typefile == "gcm": 137 lat = nc.variables["latitude"][:] 138 lon = nc.variables["longitude"][:] 139 if "Time" in nc.variables: 140 time = nc.variables["Time"][:] 141 elif "time" in nc.variables: 142 time = nc.variables["time"][:] 143 else: 144 print "no time axis found." 145 exit() 137 lat = nc.variables["latitude"][:] ; lon = nc.variables["longitude"][:] 138 if "Time" in nc.variables: time = nc.variables["Time"][:] 139 elif "time" in nc.variables: time = nc.variables["time"][:] 140 else: errormess("no time axis found.") 146 141 vert = nc.variables["altitude"][:] 147 142 elif typefile in ['meso','mesoapi']: … … 155 150 if varname in ['U']: londim='WEST-EAST_PATCH_END_STAG' 156 151 else: londim='WEST-EAST_PATCH_END_UNSTAG' 157 lon = np.arange(0,getattr(nc,londim),1) 158 lat = np.arange(0,getattr(nc,latdim),1) 152 lon = np.arange(0,getattr(nc,londim),1) ; lat = np.arange(0,getattr(nc,latdim),1) 159 153 if vertmode is None: vertmode=0 160 154 if vertmode == 0: vert = np.arange(0,getattr(nc,vertdim),1) … … 179 173 if zoom: [wlon,wlat] = zoomset(wlon,wlat,zoom) 180 174 175 all_varname[k] = varname 176 all_namefile[k] = namefile 177 if var2: all_var2[k] = getfield(nc,var2) 181 178 ##### SPECIFIC 182 179 if varname in ["temp","t","T_nadir_nit","T_nadir_day","temp_day","temp_night"] and tsat: … … 188 185 ##### GENERAL STUFF HERE 189 186 all_var[k] = getfield(nc,varname) 190 all_varname[k] = varname191 all_namefile[k] = namefile192 if var2: all_var2[k] = getfield(nc,var2)193 194 187 print "********** all_var[k].shape", all_var[k].shape 195 188 k += 1 … … 207 200 if ope == "-": all_var[k+1]= all_var[k-1] - all_var[k] 208 201 elif ope == "+": all_var[k+1]= all_var[k-1] + all_var[k] 209 all_varname[k+1] = all_varname[k] 210 numplot = numplot+2 202 all_varname[k+1] = all_varname[k] ; numplot = numplot+2 211 203 elif ope in ["cat"]: 212 204 tab = all_var[0];k = 1 213 205 while k != len(namefiles)-1: 214 tab = np.append(tab,all_var[k],axis=0) 215 k += 1 216 time = np.arange(0,len(tab),1) ### AS: time reference is simple, should be better 217 all_var[0] = np.array(tab);numplot = 1 206 tab = np.append(tab,all_var[k],axis=0) ; k += 1 207 time = np.arange(0,len(tab),1) ### AS: time reference is too simplistic, should be better 208 all_var[0] = np.array(tab) ; numplot = 1 218 209 elif ope is not None: 219 210 errormess(ope+" : non-implemented operation. Available op. are + and -.") … … 229 220 if itstep is None and numplot > 0: itstep = int(24./numplot) 230 221 elif numplot <= 0: itstep = 1 231 232 222 print "********************************************" 233 223 while error is False: … … 270 260 indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time) 271 261 272 if fileref is not None: 273 index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(len(namefiles)+2) ## OK only 1 var, see test in the beginning 274 else: 275 yeah = len(namefiles)*len(var) 276 index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah 277 #print nlon, nlat, nvert, ntime 278 #print slon, slat, svert, stime 279 #print index_f 280 #print "index lon,lat,vert,time", indexlon, indexlat, indexvert, indextime 281 #if varname != all_varname[index_f]: indextime = first 262 if fileref is not None: index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(len(namefiles)+2) ## OK only 1 var, see test in the beginning 263 else: yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah 282 264 #################################################################### 283 265 … … 341 323 #contourf(what_I_plot, zelevels, cmap = palette ) 342 324 343 if mapmode == 1: 344 m.contourf( x, y, what_I_plot, zelevels, cmap = palette) 345 elif mapmode == 0: 346 contourf( x, y, what_I_plot, zelevels, cmap = palette) 347 348 zxmin, zxmax = xaxis 349 zymin, zymax = yaxis 325 if mapmode == 1: m.contourf( x, y, what_I_plot, zelevels, cmap = palette) 326 elif mapmode == 0: contourf( x, y, what_I_plot, zelevels, cmap = palette) 327 328 zxmin, zxmax = xaxis ; zymin, zymax = yaxis 350 329 if zxmin is not None: mpl.pyplot.xlim(xmin=zxmin) 351 330 if zxmax is not None: mpl.pyplot.xlim(xmax=zxmax) … … 376 355 elif len(what_I_plot.shape) is 1: 377 356 plot(x,what_I_plot) 357 if save == 'txt': writeascii(np.transpose(what_I_plot),'profile'+str(nplot)+'.txt') 358 378 359 #### Other cases: (maybe plot 3-D field one day or movie ??) 379 360 else: … … 418 399 else: 419 400 if fileref is not None: 420 if index_f is numplot-1: 421 plottitle = basename+' '+"fig(1) "+ope+" fig(2)" 422 elif index_f is numplot-2: 423 plottitle = basename+' '+fileref 424 else: 425 plottitle = basename+' '+namefiles[0]#index_f] 426 else: 427 plottitle = basename+' '+namefiles[0]#index_f] 428 if mult != 1: plottitle = str(mult) + "*" + plottitle 429 if zetitle != "fill": 401 if index_f is numplot-1: plottitle = basename+' '+"fig(1) "+ope+" fig(2)" 402 elif index_f is numplot-2: plottitle = basename+' '+fileref 403 else: plottitle = basename+' '+namefiles[0]#index_f] 404 else: plottitle = basename+' '+namefiles[0]#index_f] 405 if mult != 1: plottitle = str(mult) + "*" + plottitle 406 if zetitle != "fill": 430 407 plottitle = zetitle 431 if titleref is "fill": 432 titleref=zetitle 408 if titleref is "fill": titleref=zetitle 433 409 if fileref is not None: 434 if index_f is numplot-2: 435 plottitle = titleref 436 if index_f is numplot-1: 437 plottitle = "fig(1) "+ope+" fig(2)" 438 # if indexlon is not None: 439 # plottitle = plottitle + " lon: " + str(min(lon[indexlon])) +" "+ str(max(lon[indexlon])) 440 # if indexlat is not None: 441 # plottitle = plottitle + " lat: " + str(min(lat[indexlat])) +" "+ str(max(lat[indexlat])) 442 # if indexvert is not None: 443 # plottitle = plottitle + " vert: " + str(min(vert[indexvert])) +" "+ str(max(vert[indexvert])) 444 # if indextime is not None: 445 # plottitle = plottitle + " time: " + str(min(time[indextime])) +" "+ str(max(time[indextime])) 410 if index_f is numplot-2: plottitle = titleref 411 if index_f is numplot-1: plottitle = "fig(1) "+ope+" fig(2)" 412 # if indexlon is not None: plottitle = plottitle + " lon: " + str(min(lon[indexlon])) +" "+ str(max(lon[indexlon])) 413 # if indexlat is not None: plottitle = plottitle + " lat: " + str(min(lat[indexlat])) +" "+ str(max(lat[indexlat])) 414 # if indexvert is not None: plottitle = plottitle + " vert: " + str(min(vert[indexvert])) +" "+ str(max(vert[indexvert])) 415 # if indextime is not None: plottitle = plottitle + " time: " + str(min(time[indextime])) +" "+ str(max(time[indextime])) 446 416 title( plottitle ) 447 417 itime += itstep 448 if nplot >= numplot: 449 error = True 418 if nplot >= numplot: error = True 450 419 nplot += 1 451 420 … … 480 449 if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True) ## a miniature 481 450 makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False) 482 elif save in ['eps','svg','pdf']: 483 makeplotres(zeplot, pad_inches_value=pad_inches_value,disp=False,ext=save) 484 elif save == 'gui': 485 show() 451 elif save in ['eps','svg','pdf']: makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save) 452 elif save == 'gui': show() 453 elif save == 'txt': print "Saved results in txt file." 486 454 else: 487 455 print "INFO: save mode not supported. using gui instead."
Note: See TracChangeset
for help on using the changeset viewer.