Changeset 1158 in lmdz_wrf


Ignore:
Timestamp:
Oct 7, 2016, 4:44:55 PM (8 years ago)
Author:
lfita
Message:

Adding `close' staff
Fixing the right axes/ticks working for `draw_2D_shad_cont_time'

Location:
trunk/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r1157 r1158  
    670670    draw_2D_shad_cont(ncfile, values, varn)
    671671      ncfile= [ncfilevars],[ncfilevarc] files to use (one value, same file)
    672       values=[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyfmt];[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]
    673673        [vnamefs],[vnamefc]: Name in the figure of the shaded and the contour variables
    674674        [dimvals/c]: list of [dimname]|[value] telling at which dimension of the
     
    676676        [dimxvn]: name of the variables with the values of the dimension of the x-axis
    677677        [dimyvn]: name of the variables with the values of the dimension of the y-axis
    678         [dimxyfmt]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis
     678        [dimxyf]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis
    679679          [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)
    681681            'Vfix', values computed at even 'Ndx' increments
    682682            'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)
     
    736736        quit()
    737737
    738     expectargs = '[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyfmt];' +     \
     738    expectargs = '[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyf];' +       \
    739739      '[colorbarvals];[ckind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];' +   \
    740740      '[figt];[kindfig];[reverse];[timevals];[close]'
     
    747747    vdimxn = values.split(';')[3]
    748748    vdimyn = values.split(';')[4]
    749     dimxyfmt = values.split(';')[5]
    750     colbarvals = values.split(';')[6]
     749    dimxyf = values.split(';')[5]
     750    colorbarvals = values.split(';')[6]
    751751    countkind = values.split(';')[7]
    752752    countlabelfmt = values.split(';')[8]
     
    42274227    """ Fucntion to plot two lines in different axes (x/x2 or y/y2)
    42284228      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]
    42304230        [commonvardim]: name of the common variable-dimension
    42314231        [varangeA]: ',' separated list of range (min,max) for A values ('None', automatic; 'Extrs' from values extremes)
     
    42504250        [figname]: name of the figure
    42514251        [figkind]: kind of figure
     4252        [close]: Whether figure should be finished or not
    42524253      ncfiles= ',' separated list of files to use
    42534254      varnames=  ',' separated list of variables names in the files to plot
     
    42624263    expectargs = '[commonvardim]:[varangeA]:[varangeB]:' +           \
    42634264     '[varangeaxis]:[axisvals]:[figvarns]:[colors]:[widths]:[styles]:[sizemarks]:' + \
    4264      '[marks]:[graphtitle]:[labelaxis]:[lloc]:[figname]:[figkind]'
     4265     '[marks]:[graphtitle]:[labelaxis]:[lloc]:[figname]:[figkind]:[close]'
    42654266 
    42664267    drw.check_arguments(fname,values,expectargs,':')
     
    42824283    figname = values.split(':')[14]
    42834284    figkind = values.split(':')[15]
     4285    close = gen.Str_Bool(values.split(':')[16])
    42844286
    42854287    files = ncfiles.split(',')
     
    43974399      varangeB, varangeaxis, axisvals, figvarns, varunits, colvalues, lwidths,       \
    43984400      linekinds, psizes, pointkinds, graphtitle, labelaxis, lloc, lsize, figname,    \
    4399       figkind)
    4400 
     4401      figkind, close)
    44014402
    44024403def draw_2lines_time(ncfiles, values, varnames):
    44034404    """ Function to plot two time-lines in different axes (x/x2 or y/y2)
    44044405      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]
    44064407        [timevardim]: name of the common variable-dimension time
    44074408        [varangeA]: ',' separated list of range (min,max) for A values ('None', automatic; 'Extrs' from values extremes)
     
    44324433        [figname]: name of the figure
    44334434        [figkind]: kind of figure
     4435        [close]: Whether figure should be finished or not
    44344436      ncfiles= ',' separated list of files to use
    44354437      varnames=  ',' separated list of variables names in the files to plot
     
    44444446    expectargs = '[timevardim]:[varangeA]:[varangeB]:[timeaxisfmt]:[timeaxis]:' +    \
    44454447     '[figvarns]:[colors]:[widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:' +     \
    4446      '[labelaxis]:[lloc]:[figname]:[figkind]'
     4448     '[labelaxis]:[lloc]:[figname]:[figkind]:[close]'
    44474449 
    44484450    drw.check_arguments(fname,values,expectargs,':')
     
    44644466    figname = values.split(':')[14]
    44654467    figkind = values.split(':')[15]
     4468    close = gen.Str_Bool(values.split(':')[15])
    44664469
    44674470    files = ncfiles.split(',')
     
    45784581      varangeB, tpos, tlabels, timeaxis, figvarns, varunits, colvalues, lwidths,     \
    45794582      linekinds, psizes, pointkinds, graphtitle, labelaxis, lloc, lsize, figname,    \
    4580       figkind)
     4583      figkind, close)
    45814584
    45824585#quit()
  • trunk/tools/drawing_tools.py

    r1157 r1158  
    45384538        dimxt0 = np.array(pretty_int(dxn,dxx,xaxv[2]))
    45394539    elif xaxv[0] == 'Nfix':
    4540         dimxt0 = np.arange(dxn,dxx,(dxx-dxn)/(1.*xaxv[2]))
     4540        dimxt0 = np.arange(0.,1.,1./xaxv[2])
    45414541    elif xaxv[0] == 'Vfix':
    45424542        dimxt0 = np.arange(0,dxx,xaxv[2])
     
    45444544        dimyt0 = np.array(pretty_int(dyn,dyx,yaxv[2]))
    45454545    elif yaxv[0] == 'Nfix':
    4546         dimyt0 = np.arange(dyn,dyx,(dyx-dyn)/(1.*yaxv[2]))
     4546        dimyt0 = np.arange(0.,1.,1./yaxv[2])
    45474547    elif yaxv[0] == 'Vfix':
    45484548        dimyt0 = np.arange(0,dyx,yaxv[2])
    45494549
    45504550    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]))
    45524556    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]))
    45544562
    45554563    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
     
    46494657    else:
    46504658        # No following data values
    4651         #x = dimxv
    4652         #y = dimyv
    4653         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))
    46554663
    46564664    plt.rc('text', usetex=True)
     
    47434751#  prettylev, ['$ms^{-1}$','$kJm^{-1}s^{-1}$'], 'test var1 & var2', 'pdf', False)
    47444752
    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 graph
    4748       varsv= 2D values to plot with shading
    4749       varcv= 2D values to plot with contours
    4750       vnames= variable names for the figure
    4751       dim[x/y]v = values at the axes of x and y
    4752       dim[x/y]u = units at the axes of x and y
    4753       dimn= dimension names to plot
    4754       colorbar= name of the color bar to use
    4755       ckind= contour kind
    4756         'cmap': as it gets from colorbar
    4757         'fixc,[colname]': fixed color [colname], all stright lines
    4758         'fixsigc,[colname]': fixed color [colname], >0 stright, <0 dashed  line
    4759       clabfmt= format of the labels in the contour plot (None, no labels)
    4760       vs= minmum and maximum values to plot in shadow
    4761       vc= vector with the levels for the contour
    4762       uts= units of the variable [u-shadow, u-contour]
    4763       vtit= title of the variable
    4764       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 y
    4768       mapv= map characteristics: [proj],[res]
    4769         see full documentation: http://matplotlib.org/basemap/
    4770         [proj]: projection
    4771           * 'cyl', cilindric
    4772           * 'lcc', lamvbert conformal
    4773         [res]: resolution:
    4774           * 'c', crude
    4775           * 'l', low
    4776           * 'i', intermediate
    4777           * 'h', high
    4778           * 'f', full
    4779     """
    4780 ##    import matplotlib as mpl
    4781 ##    mpl.use('Agg')
    4782 ##    import matplotlib.pyplot as plt
    4783     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 errormsg
    4794              print '  ' + fname + ': flip is given', reva, 'but not axis!'
    4795              quit(-1)
    4796     else:
    4797         reva0 = reva
    4798 
    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 = dimyv
    4804         dyv = dimxv
    4805         dimxv = dxv
    4806         dimyv = dyv
    4807 
    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,:] = lon00
    4823             for ix in range(len(lon00)):
    4824                 lat0[:,ix] = lat00
    4825 
    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, ',', xlat
    4863 
    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 = dimxv
    4886         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,:] = dimxv
    4891             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] = dimxv
    4896                 else:
    4897                     for j in range(x.shape[0]):
    4898                         x[j,:] = dimxv
    4899 
    4900         if len(dimyv.shape) == 2:
    4901             y = dimyv
    4902         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] = dimyv
    4907             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,:] = dimyv
    4913                 else:
    4914                     for i in range(y.shape[0]):
    4915                         y[i,:] = dimyv
    4916 
    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 # contour
    4923 ##
    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 errormsg
    4936         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 data
    4971     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 labels
    4981     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     return
    49944753
    49954754def plot_2D_shadow_contour_time(varsv, varcv, vnames, valv, timv, timpos, timlab,    \
     
    50284787      ifclose= boolean value whether figure should be close (finish) or not
    50294788    """
    5030 ##    import matplotlib as mpl
    5031 ##    mpl.use('Agg')
    5032 ##    import matplotlib.pyplot as plt
    50334789    fname = 'plot_2D_shadow_contour_time'
    50344790
     
    50494805
    50504806    # 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()
    50544810
    50554811    dxn = dimxv0.min()
     
    50594815
    50604816    # 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'
    51014848
    51024849    if reva is not None:
     
    51194866    dy=varsv.shape[0]
    51204867
    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)
    51254869
    51264870    plt.rc('text', usetex=True)
     
    51284872    plt.xticks(dimxt, dimxl, rotation=xaxv[3])
    51294873    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])
    51334876
    51344877    plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vs[0], vmax=vs[1])
     
    51734916
    51744917# 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()])
    51764919
    51774920# units labels
     
    75967339def plot_2lines(valsA, valsB, valsaxisA, valsaxisB, rangeA, rangeB, rangeaxis,       \
    75977340  axisvals, varns, varus, cols, wdths, styls, szmks, marks, gtitle, axisn, gloc,     \
    7598   sloc, fign, figk):
     7341  sloc, fign, figk, ifclose):
    75997342    """ Function to plot two lines in different axes (x/x2 or y/y2)
    76007343      valsA= values to be plotted on axis x or y
     
    76197362      fign= name of the figure
    76207363      figk= kind of figure
     7364      ifclose: Whether figure should be finished or not
    76217365    """
    76227366    fname = 'plot_2lines'
     
    76917435    # plt.legend([lA, lB], loc=gloc, fontsize=gsiz)
    76927436   
    7693     output_kind(figk, fign, True)
     7437    output_kind(figk, fign, ifclose)
    76947438
    76957439    return
     
    76977441def plot_2lines_time(valsA, valsB, valsaxisA, valsaxisB, rangeA, rangeB, valstaxis,  \
    76987442  labelstaxis, taxis, varns, varus, cols, wdths, styls, szmks, marks, gtitle, axisn, \
    7699   gloc, gsize, fign, figk):
     7443  gloc, gsize, fign, figk, ifclose):
    77007444    """ Function to plot two time-lines in different axes (x/x2 or y/y2)
    77017445      valsA= values to be plotted on axis x or y
     
    77217465      fign= name of the figure
    77227466      figk= kind of figure
     7467      ifclose: Whether figure should be finished or not
    77237468    """
    77247469    fname = 'plot_2lines_time'
     
    77987543    # plt.legend([lA, lB], loc=gloc, fontsize=gsiz)
    77997544
    7800    
    7801     output_kind(figk, fign, True)
     7545    output_kind(figk, fign, ifclose)
    78027546
    78037547    return
  • trunk/tools/model_graphics.py

    r1157 r1158  
    644644                Svarcompute = Svarcompute + ',' + Svc
    645645
    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
    648655
    649656    if debug:
     
    689696                    diag = Vvals[4].split(':')
    690697
    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]]
    698707        elif vals[0] == 'itotv:':
    699708            ivop = int(vals[1])
     
    19001909              + Bline + ':2.,2.:' + Akind + ',' + Bkind + ':2.,2.:,:' + figtit + ':' \
    19011910              + timelabel + ':0,auto:' +  finame.replace('.'+kfig, '') + ':' +       \
    1902               + kfig + ':True'
     1911              kfig + ':True'
    19031912
    19041913            fvarS = ','.join(vplot)
     
    21672176
    21682177            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 +     \
    21712180              ',9;' + figtit + ';' + kfig + ';' + reverse + ';' + 'time|' + tunits + \
    21722181              '|'+ timekind + '|' + timefmt + '|' + timelabel + ';True'
Note: See TracChangeset for help on using the changeset viewer.