Changeset 1158 in lmdz_wrf
- Timestamp:
- Oct 7, 2016, 4:44:55 PM (8 years ago)
- Location:
- trunk/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r1157 r1158 670 670 draw_2D_shad_cont(ncfile, values, varn) 671 671 ncfile= [ncfilevars],[ncfilevarc] files to use (one value, same file) 672 values=[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyf mt];[colorbarvals];[ckind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];[figt];[kindfig];[reverse];[timevals];[close]672 values=[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyf];[colorbarvals];[ckind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];[figt];[kindfig];[reverse];[timevals];[close] 673 673 [vnamefs],[vnamefc]: Name in the figure of the shaded and the contour variables 674 674 [dimvals/c]: list of [dimname]|[value] telling at which dimension of the … … 676 676 [dimxvn]: name of the variables with the values of the dimension of the x-axis 677 677 [dimyvn]: name of the variables with the values of the dimension of the y-axis 678 [dimxyf mt]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis678 [dimxyf]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis 679 679 [dxs]: style of x-axis ('auto' for 'pretty') 680 'Nfix', values computed at even 'Ndx' 680 'Nfix', values computed at even 'Ndx' (unique map plotted with constant pixel size) 681 681 'Vfix', values computed at even 'Ndx' increments 682 682 'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10) … … 736 736 quit() 737 737 738 expectargs = '[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyf mt];' +\738 expectargs = '[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyf];' + \ 739 739 '[colorbarvals];[ckind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];' + \ 740 740 '[figt];[kindfig];[reverse];[timevals];[close]' … … 747 747 vdimxn = values.split(';')[3] 748 748 vdimyn = values.split(';')[4] 749 dimxyf mt= values.split(';')[5]750 col barvals = values.split(';')[6]749 dimxyf = values.split(';')[5] 750 colorbarvals = values.split(';')[6] 751 751 countkind = values.split(';')[7] 752 752 countlabelfmt = values.split(';')[8] … … 4227 4227 """ Fucntion to plot two lines in different axes (x/x2 or y/y2) 4228 4228 values= [commonvardim]:[varangeA]:[varangeB]:[varangeaxis]:[axisvals]:[figvarns]:[colors]: 4229 [widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:[labelaxis]:[legvals]:[figname]:[figkind] 4229 [widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:[labelaxis]:[legvals]:[figname]:[figkind]:[close] 4230 4230 [commonvardim]: name of the common variable-dimension 4231 4231 [varangeA]: ',' separated list of range (min,max) for A values ('None', automatic; 'Extrs' from values extremes) … … 4250 4250 [figname]: name of the figure 4251 4251 [figkind]: kind of figure 4252 [close]: Whether figure should be finished or not 4252 4253 ncfiles= ',' separated list of files to use 4253 4254 varnames= ',' separated list of variables names in the files to plot … … 4262 4263 expectargs = '[commonvardim]:[varangeA]:[varangeB]:' + \ 4263 4264 '[varangeaxis]:[axisvals]:[figvarns]:[colors]:[widths]:[styles]:[sizemarks]:' + \ 4264 '[marks]:[graphtitle]:[labelaxis]:[lloc]:[figname]:[figkind] '4265 '[marks]:[graphtitle]:[labelaxis]:[lloc]:[figname]:[figkind]:[close]' 4265 4266 4266 4267 drw.check_arguments(fname,values,expectargs,':') … … 4282 4283 figname = values.split(':')[14] 4283 4284 figkind = values.split(':')[15] 4285 close = gen.Str_Bool(values.split(':')[16]) 4284 4286 4285 4287 files = ncfiles.split(',') … … 4397 4399 varangeB, varangeaxis, axisvals, figvarns, varunits, colvalues, lwidths, \ 4398 4400 linekinds, psizes, pointkinds, graphtitle, labelaxis, lloc, lsize, figname, \ 4399 figkind) 4400 4401 figkind, close) 4401 4402 4402 4403 def draw_2lines_time(ncfiles, values, varnames): 4403 4404 """ Function to plot two time-lines in different axes (x/x2 or y/y2) 4404 4405 values= [timevardim]:[varangeA]:[varangeB]:[timeaxisfmt]:[timeaxis]:[figvarns]:[colors]: 4405 [widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:[labelaxis]:[legvals]:[figname]:[figkind] 4406 [widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:[labelaxis]:[legvals]:[figname]:[figkind]:[close] 4406 4407 [timevardim]: name of the common variable-dimension time 4407 4408 [varangeA]: ',' separated list of range (min,max) for A values ('None', automatic; 'Extrs' from values extremes) … … 4432 4433 [figname]: name of the figure 4433 4434 [figkind]: kind of figure 4435 [close]: Whether figure should be finished or not 4434 4436 ncfiles= ',' separated list of files to use 4435 4437 varnames= ',' separated list of variables names in the files to plot … … 4444 4446 expectargs = '[timevardim]:[varangeA]:[varangeB]:[timeaxisfmt]:[timeaxis]:' + \ 4445 4447 '[figvarns]:[colors]:[widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:' + \ 4446 '[labelaxis]:[lloc]:[figname]:[figkind] '4448 '[labelaxis]:[lloc]:[figname]:[figkind]:[close]' 4447 4449 4448 4450 drw.check_arguments(fname,values,expectargs,':') … … 4464 4466 figname = values.split(':')[14] 4465 4467 figkind = values.split(':')[15] 4468 close = gen.Str_Bool(values.split(':')[15]) 4466 4469 4467 4470 files = ncfiles.split(',') … … 4578 4581 varangeB, tpos, tlabels, timeaxis, figvarns, varunits, colvalues, lwidths, \ 4579 4582 linekinds, psizes, pointkinds, graphtitle, labelaxis, lloc, lsize, figname, \ 4580 figkind )4583 figkind, close) 4581 4584 4582 4585 #quit() -
trunk/tools/drawing_tools.py
r1157 r1158 4538 4538 dimxt0 = np.array(pretty_int(dxn,dxx,xaxv[2])) 4539 4539 elif xaxv[0] == 'Nfix': 4540 dimxt0 = np.arange( dxn,dxx,(dxx-dxn)/(1.*xaxv[2]))4540 dimxt0 = np.arange(0.,1.,1./xaxv[2]) 4541 4541 elif xaxv[0] == 'Vfix': 4542 4542 dimxt0 = np.arange(0,dxx,xaxv[2]) … … 4544 4544 dimyt0 = np.array(pretty_int(dyn,dyx,yaxv[2])) 4545 4545 elif yaxv[0] == 'Nfix': 4546 dimyt0 = np.arange( dyn,dyx,(dyx-dyn)/(1.*yaxv[2]))4546 dimyt0 = np.arange(0.,1.,1./yaxv[2]) 4547 4547 elif yaxv[0] == 'Vfix': 4548 4548 dimyt0 = np.arange(0,dyx,yaxv[2]) 4549 4549 4550 4550 dimxl0 = [] 4551 for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(dimxt0[i], style=xaxv[1])) 4551 if xaxv[0] != Nfix: 4552 for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(dimxt0[i], style=xaxv[1])) 4553 else: 4554 xv=dxn+dimxt0[i]*(dxx-dxn)/(1.*xaxv[2]) 4555 for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(xv, style=xaxv[1])) 4552 4556 dimyl0 = [] 4553 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 4557 if yaxv[0] != Nfix: 4558 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 4559 else: 4560 yv=dyn+dimyt0[i]*(dyx-dyn)/(1.*yaxv[2]) 4561 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(yv, style=yaxv[1])) 4554 4562 4555 4563 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')' … … 4649 4657 else: 4650 4658 # No following data values 4651 #x = dimxv4652 #y = dimyv4653 x = (dimxv-np.min(dimxv))/(np.max(dimxv) - np.min(dimxv))4654 y = (dimyv-np.min(dimyv))/(np.max(dimyv) - np.min(dimyv))4659 x = dimxv 4660 y = dimyv 4661 # x = (dimxv-np.min(dimxv))/(np.max(dimxv) - np.min(dimxv)) 4662 # y = (dimyv-np.min(dimyv))/(np.max(dimyv) - np.min(dimyv)) 4655 4663 4656 4664 plt.rc('text', usetex=True) … … 4743 4751 # prettylev, ['$ms^{-1}$','$kJm^{-1}s^{-1}$'], 'test var1 & var2', 'pdf', False) 4744 4752 4745 def plot_2D_shadow_contour_old(varsv,varcv,vnames,dimxv,dimyv,dimxu,dimyu,dimn, \4746 colorbar,ckind,clabfmt,vs,vc,uts,vtit,kfig,reva,mapv):4747 """ Adding labels and other staff to the graph4748 varsv= 2D values to plot with shading4749 varcv= 2D values to plot with contours4750 vnames= variable names for the figure4751 dim[x/y]v = values at the axes of x and y4752 dim[x/y]u = units at the axes of x and y4753 dimn= dimension names to plot4754 colorbar= name of the color bar to use4755 ckind= contour kind4756 'cmap': as it gets from colorbar4757 'fixc,[colname]': fixed color [colname], all stright lines4758 'fixsigc,[colname]': fixed color [colname], >0 stright, <0 dashed line4759 clabfmt= format of the labels in the contour plot (None, no labels)4760 vs= minmum and maximum values to plot in shadow4761 vc= vector with the levels for the contour4762 uts= units of the variable [u-shadow, u-contour]4763 vtit= title of the variable4764 kfig= kind of figure (jpg, pdf, png)4765 reva=4766 * 'transpose': reverse the axes (x-->y, y-->x)4767 * 'flip'@[x/y]: flip the axis x or y4768 mapv= map characteristics: [proj],[res]4769 see full documentation: http://matplotlib.org/basemap/4770 [proj]: projection4771 * 'cyl', cilindric4772 * 'lcc', lamvbert conformal4773 [res]: resolution:4774 * 'c', crude4775 * 'l', low4776 * 'i', intermediate4777 * 'h', high4778 * 'f', full4779 """4780 ## import matplotlib as mpl4781 ## mpl.use('Agg')4782 ## import matplotlib.pyplot as plt4783 fname = 'plot_2D_shadow_contour'4784 4785 if varsv == 'h':4786 print fname + '_____________________________________________________________'4787 print plot_2D_shadow_contour.__doc__4788 quit()4789 4790 if reva[0:4] == 'flip':4791 reva0 = 'flip'4792 if len(reva.split('@')) != 2:4793 print errormsg4794 print ' ' + fname + ': flip is given', reva, 'but not axis!'4795 quit(-1)4796 else:4797 reva0 = reva4798 4799 if reva0 == 'transpose':4800 print ' reversing the axes of the figure (x-->y, y-->x)!!'4801 varsv = np.transpose(varsv)4802 varcv = np.transpose(varcv)4803 dxv = dimyv4804 dyv = dimxv4805 dimxv = dxv4806 dimyv = dyv4807 4808 if not mapv is None:4809 if len(dimxv[:].shape) == 3:4810 lon0 = dimxv[0,]4811 lat0 = dimyv[0,]4812 elif len(dimxv[:].shape) == 2:4813 lon0 = dimxv[:]4814 lat0 = dimyv[:]4815 elif len(dimxv[:].shape) == 1:4816 lon00 = dimxv[:]4817 lat00 = dimyv[:]4818 lon0 = np.zeros( (len(lat00),len(lon00)), dtype=np.float )4819 lat0 = np.zeros( (len(lat00),len(lon00)), dtype=np.float )4820 4821 for iy in range(len(lat00)):4822 lon0[iy,:] = lon004823 for ix in range(len(lon00)):4824 lat0[:,ix] = lat004825 4826 map_proj=mapv.split(',')[0]4827 map_res=mapv.split(',')[1]4828 4829 dx = lon0.shape[1]4830 dy = lon0.shape[0]4831 4832 nlon = lon0[0,0]4833 xlon = lon0[dy-1,dx-1]4834 nlat = lat0[0,0]4835 xlat = lat0[dy-1,dx-1]4836 4837 # Thats too much! :)4838 # if lonlatLims is not None:4839 # print ' ' + fname + ': cutting the domain to plot !!!!'4840 # plt.xlim(lonlatLims[0], lonlatLims[2])4841 # plt.ylim(lonlatLims[1], lonlatLims[3])4842 # print ' limits: W-E', lonlatLims[0], lonlatLims[2]4843 # print ' limits: N-S', lonlatLims[1], lonlatLims[3]4844 4845 # if map_proj == 'cyl':4846 # nlon = lonlatLims[0]4847 # nlat = lonlatLims[1]4848 # xlon = lonlatLims[2]4849 # xlat = lonlatLims[3]4850 # elif map_proj == 'lcc':4851 # lon2 = (lonlatLims[0] + lonlatLims[2])/2.4852 # lat2 = (lonlatLims[1] + lonlatLims[3])/2.4853 # nlon = lonlatLims[0]4854 # xlon = lonlatLims[2]4855 # nlat = lonlatLims[1]4856 # xlat = lonlatLims[3]4857 4858 lon2 = lon0[dy/2,dx/2]4859 lat2 = lat0[dy/2,dx/2]4860 4861 print 'lon2:', lon2, 'lat2:', lat2, 'SW pt:', nlon, ',', nlat, 'NE pt:', \4862 xlon, ',', xlat4863 4864 if map_proj == 'cyl':4865 m = Basemap(projection=map_proj, llcrnrlon=nlon, llcrnrlat=nlat, \4866 urcrnrlon=xlon, urcrnrlat= xlat, resolution=map_res)4867 elif map_proj == 'lcc':4868 m = Basemap(projection=map_proj, lat_0=lat2, lon_0=lon2, llcrnrlon=nlon, \4869 llcrnrlat=nlat, urcrnrlon=xlon, urcrnrlat= xlat, resolution=map_res)4870 4871 if len(dimxv.shape) == 1:4872 lons, lats = np.meshgrid(dimxv, dimyv)4873 else:4874 if len(dimxv.shape) == 3:4875 lons = dimxv[0,:,:]4876 lats = dimyv[0,:,:]4877 else:4878 lons = dimxv[:]4879 lats = dimyv[:]4880 4881 x,y = m(lons,lats)4882 4883 else:4884 if len(dimxv.shape) == 2:4885 x = dimxv4886 else:4887 if len(dimyv.shape) == 1:4888 x = np.zeros((len(dimyv),len(dimxv)), dtype=np.float)4889 for j in range(len(dimyv)):4890 x[j,:] = dimxv4891 else:4892 x = np.zeros((dimyv.shape), dtype=np.float)4893 if x.shape[0] == dimxv.shape[0]:4894 for j in range(x.shape[1]):4895 x[:,j] = dimxv4896 else:4897 for j in range(x.shape[0]):4898 x[j,:] = dimxv4899 4900 if len(dimyv.shape) == 2:4901 y = dimyv4902 else:4903 if len(dimxv.shape) == 1:4904 y = np.zeros((len(dimyv),len(dimxv)), dtype=np.float)4905 for i in range(len(dimxv)):4906 y[:,i] = dimyv4907 else:4908 y = np.zeros((dimxv.shape), dtype=np.float)4909 4910 if y.shape[0] == dimyv.shape[0]:4911 for i in range(y.shape[1]):4912 y[i,:] = dimyv4913 else:4914 for i in range(y.shape[0]):4915 y[i,:] = dimyv4916 4917 plt.rc('text', usetex=True)4918 4919 plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vs[0], vmax=vs[1])4920 cbar = plt.colorbar()4921 4922 # contour4923 ##4924 contkind = ckind.split(',')[0]4925 if contkind == 'cmap':4926 cplot = plt.contour(x, y, varcv, levels=vc)4927 elif contkind == 'fixc':4928 plt.rcParams['contour.negative_linestyle'] = 'solid'4929 coln = ckind.split(',')[1]4930 cplot = plt.contour(x, y, varcv, levels=vc, colors=coln)4931 elif contkind == 'fixsigc':4932 coln = ckind.split(',')[1]4933 cplot = plt.contour(x, y, varcv, levels=vc, colors=coln)4934 else:4935 print errormsg4936 print ' ' + fname + ': contour kind "' + contkind + '" not defined !!!!!'4937 quit(-1)4938 4939 if clabfmt is not None:4940 plt.clabel(cplot, fmt=clabfmt)4941 mincntS = format(vc[0], clabfmt[1:len(clabfmt)])4942 maxcntS = format(vc[len(vc)-1], clabfmt[1:len(clabfmt)])4943 else:4944 mincntS = '{:g}'.format(vc[0])4945 maxcntS = '{:g}'.format(vc[len(vc)-1])4946 4947 if not mapv is None:4948 m.drawcoastlines()4949 4950 meridians = pretty_int(nlon,xlon,5)4951 m.drawmeridians(meridians,labels=[True,False,False,True])4952 parallels = pretty_int(nlat,xlat,5)4953 m.drawparallels(parallels,labels=[False,True,True,False])4954 4955 plt.xlabel('W-E')4956 plt.ylabel('S-N')4957 else:4958 plt.xlabel(variables_values(dimn[1])[0] + ' (' + units_lunits(dimxu) + ')')4959 plt.ylabel(variables_values(dimn[0])[0] + ' (' + units_lunits(dimyu) + ')')4960 4961 txpos = pretty_int(x.min(),x.max(),5)4962 typos = pretty_int(y.min(),y.max(),5)4963 txlabels = list(txpos)4964 for i in range(len(txlabels)): txlabels[i] = '{:.1f}'.format(txlabels[i])4965 tylabels = list(typos)4966 for i in range(len(tylabels)): tylabels[i] = '{:.1f}'.format(tylabels[i])4967 plt.xticks(txpos, txlabels)4968 plt.yticks(typos, tylabels)4969 4970 # set the limits of the plot to the limits of the data4971 if reva0 == 'flip':4972 if reva.split('@')[1] == 'x':4973 plt.axis([x.max(), x.min(), y.min(), y.max()])4974 else:4975 plt.axis([x.min(), x.max(), y.max(), y.min()])4976 else:4977 plt.axis([x.min(), x.max(), y.min(), y.max()])4978 4979 4980 # units labels4981 cbar.set_label(vnames[0].replace('_','\_') + ' (' + units_lunits(uts[0]) + ')')4982 plt.annotate(vnames[1].replace('_','\_') +' (' + units_lunits(uts[1]) + ') [' + \4983 mincntS + ', ' + maxcntS + ']', xy=(0.55,0.04), xycoords='figure fraction', \4984 color=coln)4985 4986 figname = '2Dfields_shadow-contour'4987 graphtit = vtit.replace('_','\_').replace('&','\&')4988 4989 plt.title(graphtit)4990 4991 output_kind(kfig, figname, True)4992 4993 return4994 4753 4995 4754 def plot_2D_shadow_contour_time(varsv, varcv, vnames, valv, timv, timpos, timlab, \ … … 5028 4787 ifclose= boolean value whether figure should be close (finish) or not 5029 4788 """ 5030 ## import matplotlib as mpl5031 ## mpl.use('Agg')5032 ## import matplotlib.pyplot as plt5033 4789 fname = 'plot_2D_shadow_contour_time' 5034 4790 … … 5049 4805 5050 4806 # Axis ticks 5051 # Usually axis > x must be the time, thus...5052 dimxv0 = timv.copy()5053 dimyv0 = valv.copy()4807 # Usually time axis is the most upper dimension, thus... 4808 dimxv0 = valv.copy() 4809 dimyv0 = timv.copy() 5054 4810 5055 4811 dxn = dimxv0.min() … … 5059 4815 5060 4816 # Time ticks-labels are already given from another function 5061 dimxt0 = np.array(timpos) 5062 if yaxv[0] == 'pretty': 5063 dimyt0 = np.array(pretty_int(dyn,dyx,yaxv[2])) 5064 elif yaxv[0] == 'Nfix': 5065 dimyt0 = np.arange(dyn,dyx,(dyx-dyn)/(1.*yaxv[2])) 5066 elif yaxv[0] == 'Vfix': 5067 dimyt0 = np.arange(0,dyx,yaxv[2]) 5068 5069 dimxl0 = list(timlab) 5070 dimyl0 = [] 5071 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 5072 5073 dimxT0 = timeu 5074 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')' 5075 5076 # Variable values will have time variable as 0 dimension 5077 reva = 'transpose' 5078 5079 if axist == 'y': 5080 valx0 = dimyv0 5081 valy0 = dimxv0 5082 dimxv0 = valx0 5083 dimyv0 = valy0 5084 5085 valx1 = dimyt0 5086 valy1 = dimxt0 5087 dimxt0 = valx1 5088 dimyt0 = valy1 5089 5090 valx2 = dimyl0 5091 valy2 = dimxl0 5092 dimxl0 = valx2 5093 dimyl0 = valy2 5094 5095 valx3 = dimyT0 5096 valy3 = dimxT0 5097 dimxT0 = valx3 5098 dimyT0 = valy3 5099 5100 reva = None 4817 if xaxv[0] == 'pretty': 4818 dimxt0 = np.array(pretty_int(dxn,dxx,xaxv[2])) 4819 elif xaxv[0] == 'Nfix': 4820 dimxt0 = np.arange(0.,1.+1./xaxv[2],1./xaxv[2]) 4821 dimxv0 = np.arange(0.,1.,1./valv.shape[0]) 4822 elif xaxv[0] == 'Vfix': 4823 dimxt0 = np.arange(0,dxx,xaxv[2]) 4824 dimyt0 = np.array(timpos) 4825 4826 dimxl0 = [] 4827 if xaxv[0] != 'Nfix': 4828 for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(dimxt0[i], \ 4829 style=xaxv[1])) 4830 else: 4831 for i in range(len(dimxt0)): 4832 xv=dxn+i*(dxx-dxn)/(1.*(xaxv[2])) 4833 dimxl0.append('{:{style}}'.format(xv, style=xaxv[1])) 4834 dimyl0 = list(timlab) 4835 4836 dimxT0 = gen.latex_text(variables_values(dimn[0])[0]) +' ('+ units_lunits(valu) +\ 4837 ')' 4838 dimyT0 = timeu 4839 4840 # Variable values usually will have time variable as 0 dimension 4841 reva = None 4842 4843 if axist == 'x': 4844 print warnmsg 4845 print ' ' + fname + ': imposing transposition of values due to use time ' + \ 4846 'variable at the x-axis!!' 4847 reva = 'transpose' 5101 4848 5102 4849 if reva is not None: … … 5119 4866 dy=varsv.shape[0] 5120 4867 5121 # No following data values 5122 # x,y = gen.lonlat2D(dimxv,dimyv) 5123 x = (dimxv-np.min(dimxv))/(np.max(dimxv) - np.min(dimxv)) 5124 y = (dimyv-np.min(dimyv))/(np.max(dimyv) - np.min(dimyv)) 4868 x,y = gen.lonlat2D(dimxv,dimyv) 5125 4869 5126 4870 plt.rc('text', usetex=True) … … 5128 4872 plt.xticks(dimxt, dimxl, rotation=xaxv[3]) 5129 4873 plt.yticks(dimyt, dimyl, rotation=yaxv[3]) 5130 5131 plt.xlim(0,dx) 5132 plt.ylim(0,dy) 4874 # plt.xlim(dimxt[0],dimxt[len(dimxt)-1]) 4875 # plt.ylim(dimyt[0],dimyt[len(dimyt)-1]) 5133 4876 5134 4877 plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vs[0], vmax=vs[1]) … … 5173 4916 5174 4917 # set the limits of the plot to the limits of the data 5175 plt.axis([dimxv.min(), dimxv.max(), dimyv.min(), dimyv.max()])4918 # plt.axis([dimxv.min(), dimxv.max(), dimyv.min(), dimyv.max()]) 5176 4919 5177 4920 # units labels … … 7596 7339 def plot_2lines(valsA, valsB, valsaxisA, valsaxisB, rangeA, rangeB, rangeaxis, \ 7597 7340 axisvals, varns, varus, cols, wdths, styls, szmks, marks, gtitle, axisn, gloc, \ 7598 sloc, fign, figk ):7341 sloc, fign, figk, ifclose): 7599 7342 """ Function to plot two lines in different axes (x/x2 or y/y2) 7600 7343 valsA= values to be plotted on axis x or y … … 7619 7362 fign= name of the figure 7620 7363 figk= kind of figure 7364 ifclose: Whether figure should be finished or not 7621 7365 """ 7622 7366 fname = 'plot_2lines' … … 7691 7435 # plt.legend([lA, lB], loc=gloc, fontsize=gsiz) 7692 7436 7693 output_kind(figk, fign, True)7437 output_kind(figk, fign, ifclose) 7694 7438 7695 7439 return … … 7697 7441 def plot_2lines_time(valsA, valsB, valsaxisA, valsaxisB, rangeA, rangeB, valstaxis, \ 7698 7442 labelstaxis, taxis, varns, varus, cols, wdths, styls, szmks, marks, gtitle, axisn, \ 7699 gloc, gsize, fign, figk ):7443 gloc, gsize, fign, figk, ifclose): 7700 7444 """ Function to plot two time-lines in different axes (x/x2 or y/y2) 7701 7445 valsA= values to be plotted on axis x or y … … 7721 7465 fign= name of the figure 7722 7466 figk= kind of figure 7467 ifclose: Whether figure should be finished or not 7723 7468 """ 7724 7469 fname = 'plot_2lines_time' … … 7798 7543 # plt.legend([lA, lB], loc=gloc, fontsize=gsiz) 7799 7544 7800 7801 output_kind(figk, fign, True) 7545 output_kind(figk, fign, ifclose) 7802 7546 7803 7547 return -
trunk/tools/model_graphics.py
r1157 r1158 644 644 Svarcompute = Svarcompute + ',' + Svc 645 645 646 allvarcomp[vn + '_' + op] = [vcomp.fheader, vcomp.model, vcomp.diag, globalP] 647 ivop = ivop + 1 646 # To get a combination of operations, all the precedent steps are kept 647 # thus, they are also available ! 648 seqops = op.split('+') 649 for seqop in seqops: 650 if seqop == seqops[0]: seqopS=seqop 651 else: seqopS = seqopS + '+' + seqop 652 allvarcomp[vn+'_'+seqopS] = [vcomp.fheader, vcomp.model, vcomp.diag, \ 653 globalP] 654 ivop = ivop + 1 648 655 649 656 if debug: … … 689 696 diag = Vvals[4].split(':') 690 697 691 # To get a combination of operations, all the precedent steps are kept 692 # thus, they are also available ! 693 seqops = Vvals[1].split('+') 694 for seqop in seqops: 695 if seqop == seqops[0]: seqopS=seqop 696 else: seqopS = seqopS + '+' + seqop 697 allvarcomp[Vvals[0]+'_'+seqopS] = [Vvals[2], mod, diag, Vvals[5]] 698 allvarcomp[Vvals[0]+'_'+Vvals[1]] = [Vvals[2], mod, diag, Vvals[5]] 699 700 # # To get a combination of operations, all the precedent steps are kept 701 # # thus, they are also available ! 702 # seqops = Vvals[1].split('+') 703 # for seqop in seqops: 704 # if seqop == seqops[0]: seqopS=seqop 705 # else: seqopS = seqopS + '+' + seqop 706 # allvarcomp[Vvals[0]+'_'+seqopS] = [Vvals[2], mod, diag, Vvals[5]] 698 707 elif vals[0] == 'itotv:': 699 708 ivop = int(vals[1]) … … 1900 1909 + Bline + ':2.,2.:' + Akind + ',' + Bkind + ':2.,2.:,:' + figtit + ':' \ 1901 1910 + timelabel + ':0,auto:' + finame.replace('.'+kfig, '') + ':' + \ 1902 +kfig + ':True'1911 kfig + ':True' 1903 1912 1904 1913 fvarS = ','.join(vplot) … … 2167 2176 2168 2177 graphvals = ','.join(CFvplot) 2169 graphvals = graphvals + '; auto;'+ dims +';'+ cbar + ',auto,auto' + ';' +\2170 ckind + ',' + cline + ';' + cfmt + ';' + srange + ';' + crange +\2178 graphvals = graphvals + ';' + dims +';auto;' + cbar + ',auto,auto' + ';' \ 2179 + ckind + ',' + cline + ';' + cfmt + ';' + srange + ';' + crange + \ 2171 2180 ',9;' + figtit + ';' + kfig + ';' + reverse + ';' + 'time|' + tunits + \ 2172 2181 '|'+ timekind + '|' + timefmt + '|' + timelabel + ';True'
Note: See TracChangeset
for help on using the changeset viewer.