Changeset 1054 for trunk/UTIL


Ignore:
Timestamp:
Sep 27, 2013, 3:48:25 AM (11 years ago)
Author:
aslmd
Message:

planetoplot. added possibility to retrieve attribute from netCDF file. added an option to set value formatting through ppclass or pp.py. added a nice example used in a press release.

Location:
trunk/UTIL/PYTHON/planetoplot_v2
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/planetoplot_v2/pp.py

    r1050 r1054  
    7171parser.add_option('-V','--void',action='store_true',dest='void',default=False,help="no colorbar, no title, no labels")
    7272parser.add_option('-U','--units',action='append',dest='units',type="string",default=None,help="units for the field")
     73parser.add_option('-F','--fmt',action='append',dest='fmt',type="string",default=None,help="values formatting. ex: '%.0f' '%3.1e'")
    7374# -- 1D plot
    7475parser.add_option('-L','--linestyle',action='append',dest='linestyle',type="string",default=None,help="[1D] linestyle: '-' '--' '.' '..'")
  • trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py

    r1050 r1054  
    5656        except: pass
    5757        print output ; output = ""
     58
     59# request a given attribute (and test if it is here)
     60def ncattr(filename,char):
     61    nc = netCDF4.Dataset(filename)
     62    if hasattr(nc,char): ncattr=getattr(nc,char)
     63    return ncattr
    5864
    5965# check a tab and exit if wrong. if just one string make it a list.
     
    164170                      savtxt=False,\
    165171                      modx=None,\
     172                      fmt=None,\
    166173                      xp=16,yp=8,\
    167174                      missing=1.e25,\
     
    223230        self.xp = xp ; self.yp = yp
    224231        self.nxticks = nxticks ; self.nyticks = nyticks
     232        self.fmt = fmt
    225233
    226234    # print status
     
    282290            self.missing = other.missing
    283291            self.nxticks = other.nxticks ; self.nyticks = other.nyticks
     292            self.fmt = other.fmt
    284293        else:
    285294            print "!! ERROR !! argument must be a pp object." ; exit()
     
    825834                    if self.nxticks is not None: plobj.nxticks = self.nxticks
    826835                    if self.nyticks is not None: plobj.nyticks = self.nyticks
     836                    if self.fmt is not None: plobj.fmt = self.fmt
    827837                    # -- 1D specific
    828838                    if dp == 1:
     
    12101220            except:
    12111221                try: self.p[iii].modx = opt.modx[0]
     1222                except: pass
     1223            ###
     1224            try: self.p[iii].fmt = opt.fmt[iii]
     1225            except:
     1226                try: self.p[iii].fmt = opt.fmt[0]
    12121227                except: pass
    12131228
  • trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py

    r1050 r1054  
    815815                objC2 = m.contour(x, y, what_I_contour, \
    816816                            zelevelsc, colors = ccol, linewidths = cline)
    817                 #mpl.clabel(objC2, inline=1, fontsize=10)
     817                #mpl.clabel(objC2, inline=1, fontsize=10,manual=True,fmt='-%2.0f$^{\circ}$C',colors='r')
    818818            m.contourf(x, y, what_I_plot, zelevels, cmap = palette, alpha = self.trans)
    819819        ############################################################################################
Note: See TracChangeset for help on using the changeset viewer.