Changeset 930 for trunk/UTIL


Ignore:
Timestamp:
Apr 15, 2013, 12:55:29 PM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON planetoplot_v2. Added attribute allfield so that the user can easily access values. See examples/easy_get_field.py. Added attribute includedate to select option for naming files. Corrected index bug in meanarea mode. Added an example intercompare.py which shows how to easily compare results in two quite different netCDF files.

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

Legend:

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

    r926 r930  
    100100                zesaxis[i,1] = float(a[1])         
    101101    return zesaxis
     102
     103# look for comas in the input name to separate different names (files, variables,etc ..)
    102104# (needed by readslices)
    103 # look for comas in the input name to separate different names (files, variables,etc ..)
    104105def separatenames (name):
    105106    if name is None: names = None
     
    141142                      filename="myplot",\
    142143                      folder="./",\
     144                      includedate=True,\
    143145                      xlabel=None,ylabel=None,\
    144146                      xcoeff=None,ycoeff=None,\
     
    162164        self.p = None
    163165        self.customplot = False
     166        self.allfield = None
    164167        ## what could be defined by the user
    165168        self.file = file
     
    180183        self.filename = filename
    181184        self.folder = folder
     185        self.includedate = includedate
    182186        ## here are user-defined plot settings
    183187        ## -- if not None, valid on all plots in the pp() objects
     
    238242            self.label = other.label
    239243            self.title = other.title
     244            self.includedate = other.includedate
    240245        else:
    241246            print "!! ERROR !! argument must be a pp object." ; exit()
     
    560565        # check if things were done OK before
    561566        if self.status != "defined": print "!! ERROR !! Please use .define() to define your pp object." ; exit()
     567        # create the list of allfield() objects
     568        # --> so that the user can easily access values
     569        self.allfield = [[[[[[ \
     570                        [] \
     571                        for x in range(self.nplotx)] for y in range(self.nploty)] \
     572                        for z in range(self.nplotz)] for t in range(self.nplott)] \
     573                        for j in range(self.nvin)]   for i in range(self.nfin)]
    562574        ## first get fields
    563575        ## ... only what is needed is extracted from the files
     
    572584              obj.getfield()
    573585              obj.computations()
     586              self.allfield[i][j][t][z][y][x] = obj.field
     587        # get rid of useless dimensions in allfield
     588        self.allfield = np.squeeze(self.allfield)
    574589        # change status
    575590        self.status = "retrieved"
     
    860875        print "**** PPCLASS. Done step: makeplot"
    861876        if (self.n == self.howmanyplots):
    862             ppplot.save(mode=self.out,filename=self.filename,folder=self.folder,custom=self.customplot)
     877            ppplot.save(mode=self.out,filename=self.filename,folder=self.folder,custom=self.customplot,includedate=self.includedate)
    863878            mpl.close()
    864879        # SAVE A PICKLE FILE WITH THE self.p ARRAY OF OBJECTS
     
    13801395          pass
    13811396        elif test in ["fixedfree","fixedcomp"] or test in ["freefixed","compfixed"]:
    1382           time0 = timelib.time() 
     1397          time0 = timelib.time()
    13831398          # now have to obtain the new indexes which correspond to the extracted self.field
    13841399          # for it to work with unique index, ensure that any index_* is a numpy array
     
    15181533                totarea = np.tile(totarea,(1,self.index_x.size))
    15191534        elif self.method_x == "comp" and self.method_y == "comp":
     1535            aire.field = aire.field[np.ix_(self.index_y, self.index_x)] # reduce to requested indexes only
    15201536            totarea = ppcompute.sum(ppcompute.sum(aire.field,axis=1),axis=0)
    15211537        else:
     
    15271543        aire.field = np.tile(aire.field,(self.index_t.size,self.index_z.size,1,1))
    15281544        if self.field.shape != aire.field.shape:
    1529             print "!! ERROR !! Problem in area(). Check array shapes." ; exit()
     1545            print "!! ERROR !! Problem in area(). Check array shapes."
     1546            print "Field vs. aire:",self.field.shape,aire.field.shape ; exit()
    15301547        else:
    15311548            self.field = self.field*aire.field
  • trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py

    r929 r930  
    418418                mpl.legend(loc="best",fancybox=True)
    419419        ## TBD: set with .div the number of ticks
    420         ## TBD: be able to control plot limits
    421420        #ticks = self.div + 1
    422421        #ax = mpl.gca()
    423422        #ax.get_xaxis().set_ticks(np.linspace(ppcompute.min(x),ppcompute.max(x),ticks/2+1))
     423        # control plot limits (TBD: be able to control those)
     424        ax = mpl.gca() ; ax.set_xbound(lower=ppcompute.min(x), upper=ppcompute.max(x))
     425
    424426
    425427################################
     
    660662                              angles='xy',color=self.colorvec,pivot='middle',\
    661663                              scale=zescale*reducevec,width=widthvec )
    662                 # make vector key. default is on upper left corner.
    663                 keyh = 1.025 ; keyv = 1.05
    664                 #keyh = -0.03 ; keyv = 1.08
     664                # make vector key.
     665                keyh = 1.025 ; keyv = 1.05 # upper right corner over colorbar
     666                #keyh = -0.03 ; keyv = 1.08 # upper left corner
    665667                p = mpl.quiverkey(q,keyh,keyv,\
    666668                                  zescale,str(int(zescale)),\
  • trunk/UTIL/PYTHON/planetoplot_v2/set_area.txt

    r910 r930  
    2424Xanadu ; -40 ; 20 ; 40 ; 120
    2525Hyperboreae ; 80 ; 87 ; -70 ; -10
     26VM ; -15 ; 0 ; -90 ; -60
    2627VM_alt ; -15 ; 0 ; 270 ; 300
Note: See TracChangeset for help on using the changeset viewer.