Changeset 2105 in lmdz_wrf
- Timestamp:
- Aug 27, 2018, 5:49:19 PM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r2103 r2105 66 66 ## e.g. # drawing.py -o draw_stations_map -f stations.inf -S 'snd|x|#FFAAAA|2|8@sfc|x|#AAFFAA|2|8:cyl,l:1.,20.,35.,49.:FPS!Alps!stations:pdf:true' 67 67 ## e.g. # drawing.py -o draw_WRFeta_levels -f 120lev/simin_vars.nc,80lev/simin_vars.nc,50lev/simin_vars.nc,50lev_assigned/simin_vars.nc,38lev/simin_vars.nc -f '120lev,80lev,50lev,50leva,38lev:auto:auto:0|6|2:FPS!Alps!vert!levels:pdf:no:true' 68 68 ## e.g. # drawing.py -o draw_2Dshad_map -S 'orog;$conv^{ini}$;lat|-1,lon|-1;lon;lat;auto;rainbow#auto#auto#time@minutes!since!1949-12-01!00:00:00|exct,6,h|%d$^{%H}$|date!([DD]$^{[HH]}$);Srange,Srange;convini|Case1|1a;pdf;binary|shadow,NW,auto|-70.,-36,-62.,-30.;cyl,c;yes' -v convini -f UBA_ERA-I_1a_2D.nc 69 69 70 70 ####### … … 10632 10632 [figt]: title of the figure ('|' for spaces) 10633 10633 [kindfig]: kind of file for the figure output (ps, eps, png, pdf, ...) 10634 [mapfmt] = [cbarmap]|[mapkind] values for the map10634 [mapfmt] = [cbarmap]|[mapkind]|[lonlatbox] values for the map 10635 10635 cbarmap: name of the colorbar for the map 10636 10636 mapkind: kind of map to use in the plot 10637 10637 'direct': values are they come 10638 'shadow',[pos] : pseudo-shadding from a given location of the sun10638 'shadow',[pos],[enhance]: pseudo-shadding from a given location of the sun 10639 10639 [pos]: 'N', 'NW' 10640 [enhance]: enhance factor for the shading ('auto' for 1./5.) 10641 lonlatbox: [lonSW],[latSW],[lonNE],[latNE] to plot only a lon,lat box 10642 'full': for the whole domain 10640 10643 [mapv]: map characteristics: [proj],[res] 10641 10644 see full documentation: http://matplotlib.org/basemap/ … … 10712 10715 10713 10716 mapkind = mapfmt[1] 10717 if mapfmt[2] == 'full': 10718 lonlatbox = None 10719 elif len(mapfmt[2].split(',')) == 4: 10720 lonlatbox = [] 10721 for lL in mapfmt[2].split(','): 10722 lonlatbox.append(np.float(lL)) 10723 else: 10724 print errormsg 10725 print ' ' + fname + ": lonlatbox value '" + mapfmt[2] + "' not ready !!" 10726 print ' for a lonlatbox 4 values are required. Values passed:', \ 10727 mapfmt[2].splot(',') 10728 quit(-1) 10729 10714 10730 10715 10731 if mapkind == 'direct': … … 10718 10734 mapv = np.zeros((dy,dx), dtype=np.float) 10719 10735 sunpos = mapkind.split(',')[1] 10736 enhance = gen.auto_val(mapkind.split(',')[2], 1./5.) 10720 10737 if sunpos == 'N': 10721 10738 ## Linear shadow from N … … 10733 10750 print ' available ones:', availsunpos 10734 10751 quit(-1) 10752 xmapv = np.max(mapv)*enhance 10753 mapv = np.where(mapv > xmapv, xmapv, mapv) 10754 mapv = ma.masked_less(mapv, 0.) 10735 10755 else: 10736 10756 print errormsg … … 10824 10844 cbarlab.append('{:6g}'.format(cpos)) 10825 10845 elif colorbarv[3][0:4] == 'time': 10826 print 'Lluis colorbarv', colorbarv10827 10846 timevals = colorbarv[3].split('@')[1] 10828 10847 timeunit = timevals.split('|')[0].replace('!',' ') … … 10832 10851 cbarpos, cbarlab = drw.CFtimes_plot([nbarv, xbarv], timeunit, timekind, timefmt) 10833 10852 vnamesfig = timelabel 10834 varunits = '-'10853 varunits = None 10835 10854 fmtcolbar = '%s' 10836 10855 … … 10842 10861 10843 10862 drw.plot_2Dshad_map(mapv, valshad, mapfmt[0], colormapv, xaxis, yaxis, odimxv, \ 10844 odimyv, mapvalue, shading_nx, figtitle, figkind, close)10863 odimyv, lonlatbox, mapvalue, shading_nx, figtitle, figkind, close) 10845 10864 10846 10865 return … … 10851 10870 #values='orog;$conv^{ini}$;lat|-1,lon|-1;lon;lat;auto;rainbow#auto#auto#' + \ 10852 10871 # 'time@minutes!since!1949-12-01!00:00:00|exct,12,h|%d$^{%H}$|date!'+ \ 10853 # '([DD]$^{[HH]}$);Srange,Srange;Case1|1a;pdf;binary|shadow,NW;cyl,c;yes' 10872 # '([DD]$^{[HH]}$);Srange,Srange;Case1|1a;pdf;binary|shadow,NW,auto|' + \ 10873 # '-70.,-36,-62.,-30.;cyl,c;yes' 10854 10874 #draw_2Dshad_map(ncfile, values, 'convini', axfig=None, fig=None) 10855 10875 -
trunk/tools/drawing_tools.py
r2102 r2105 148 148 # date_CFtime: 149 149 # pot_values: Function to modify a seies of values by their potency of 10 150 # CFtimes_plot: 150 # CFtimes_plot: Function to provide a list of string values from a CF time values in order 151 # to use them in a plot, according to the series of characteristics. 151 152 # color_lines: 152 153 # output_kind: … … 2416 2417 if trefu == 'd': timev = timev - secs0001_1901/(24.*3600.) 2417 2418 if trefu == 'h': timev = timev - secs0001_1901/(3600.) 2418 if trefu == ' m': timev = timev - secs0001_1901/(60.)2419 if trefu == 'i': timev = timev - secs0001_1901/(60.) 2419 2420 if trefu == 's': timev = timev - secs0001_1901 2420 2421 if trefu == 'l': timev = timev - secs0001_1901*1000. … … 2618 2619 timeout.append(datev) 2619 2620 it = it + 1 2621 2620 2622 elif tu == 'i': 2621 2623 datev=firstTdt … … 2643 2645 datev = firstTdt + dt.timedelta(seconds=Nunits*60*it) 2644 2646 timeout.append(datev) 2645 it = it + 1 2647 it = it + 1 2646 2648 elif tu == 's': 2647 2649 datev=firstTdt … … 13465 13467 #prop={'size':legvs[1]}, ncol=legvs[2])prop={'size':8})prop={'size':8})prop={'size':8}) 13466 13468 13467 def plot_2Dshad_map(mapvals, values, cbarmap, cbarv, xaxv, yaxv, dimxv, dimyv, mapv,\13468 vs, figtitle, figk, close):13469 def plot_2Dshad_map(mapvals, values, cbarmap, cbarv, xaxv, yaxv, dimxv, dimyv, lLbox,\ 13470 mapv, vs, figtitle, figk, close): 13469 13471 """ Function to plot a map of mask values on top of a map in shadow 13470 13472 mapvals: 2D values to use for the map … … 13483 13485 yaxv= list with the y-axis paramteres [style, format, number and orientation] 13484 13486 dim[x/y]v: values along x/y axes 13487 lLbox: whether only a lonlatbox for the map should be used or not 13485 13488 mapv: values of the map 13486 13489 vs: range of values in the figure … … 13544 13547 dy = lat0.shape[0] 13545 13548 13546 nlon = np.min(lon0) 13547 xlon = np.max(lon0) 13548 nlat = np.min(lat0) 13549 xlat = np.max(lat0) 13549 if lLbox is None: 13550 nlon = np.min(lon0) 13551 xlon = np.max(lon0) 13552 nlat = np.min(lat0) 13553 xlat = np.max(lat0) 13554 else: 13555 nlon = lLbox[0] 13556 xlon = lLbox[2] 13557 nlat = lLbox[1] 13558 xlat = lLbox[3] 13550 13559 13551 13560 lon2 = lon0[dy/2,dx/2] … … 13580 13589 plt.pcolormesh(x, y, values, cmap=plt.get_cmap(cbarv[2]), vmin=vsend[0], vmax=vsend[1]) 13581 13590 13582 print 'Lluis cbarv:', cbarv 13583 13584 cbar = plt.colorbar(format=cbarv[3],orientation=cbarv[4], ticks=cbarv[5]) 13591 cbar = plt.colorbar(orientation=cbarv[4], ticks=cbarv[5]) 13585 13592 if cbarv[4] == 'horizontal': 13586 13593 # From: http://stackoverflow.com/questions/32050030/rotation-of-colorbar-tick-labels-in-matplotlib 13587 13594 cbar.ax.set_xticklabels(cbarv[6],rotation=90) 13588 13595 else: 13589 cbar.ax.set_ xticklabels(cbarv[6])13596 cbar.ax.set_yticklabels(cbarv[6]) 13590 13597 13591 13598 if not mapv is None: … … 13668 13675 13669 13676 # units labels 13670 cbar.set_label(gen.latex_text(cbarv[0]) + ' (' + units_lunits(cbarv[1]) + ')') 13677 if cbarv[1] is not None: 13678 cbar.set_label(gen.latex_text(cbarv[0]) + ' (' + units_lunits(cbarv[1]) + ')') 13679 else: 13680 cbar.set_label(gen.latex_text(cbarv[0])) 13671 13681 13672 13682 plt.title(gen.latex_text(figtitle))
Note: See TracChangeset
for help on using the changeset viewer.