Changeset 1002 for trunk/UTIL


Ignore:
Timestamp:
Jul 5, 2013, 2:34:21 PM (11 years ago)
Author:
aslmd
Message:

UTIL PYTHON planetoplot_v2. possibility to load a field in a restricted interval with e.g. -t 0,1 without performing computations (self.compute=nothing). use for histograms, see histo.py. added smooth2diter. bug correction: ensure numpy array, vector, minmax equal.

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

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/planetoplot_v2/examples/zonalmean.py

    r923 r1002  
    66temp.file = "/home/aymeric/Big_Data/DATAPLOT/diagfired.nc"
    77temp.var = "temp"
    8 temp.x = "-180,180"
     8temp.x = "-180,175"
    99temp.y = "-90,90"
    1010temp.t = "0,1"
     
    1818u.file = "/home/aymeric/Big_Data/DATAPLOT/diagfired.nc"
    1919u.var = "u"
    20 u.x = "-180,180"
     20u.x = "-180,175"
    2121u.y = None
    2222u.t = "0.5"
  • trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py

    r991 r1002  
    623623              obj = self.request[i][j][t][z][y][x]
    624624              obj.getfield()
    625               obj.computations()
     625              if self.compute != "nothing":
     626                  obj.computations()
    626627              # save fields in self.f for the user
    627628              self.f[count] = obj.field
     
    12961297          # if xy axis are apparently undefined, set 2D grid points axis.
    12971298          if "grid points" not in self.name_x:
    1298             if self.field_x.all() == self.field_x[0,0]:
     1299            if self.field_x.all() == self.field_x[0,0] \
     1300             or self.field_x.min() == self.field_x.max() \
     1301             or self.field_y.min() == self.field_y.max():
    12991302               if self.verbose: print "!! WARNING !! xy axis look undefined. creating non-dummy ones."
    13001303               self.field_x = np.array(range(self.dim_x)) ; self.name_x = "x grid points"
  • trunk/UTIL/PYTHON/planetoplot_v2/ppcompute.py

    r942 r1002  
    100100################
    101101### TBD: works with missing values
     102
     103def smooth2diter(field,n=1):
     104        count = 0
     105        result = field
     106        while count < n:
     107            result = smooth2d(result, window=2)
     108            count = count + 1
     109        return result
    102110
    103111## Author: AS. uses gauss_kern and blur_image.
  • trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py

    r991 r1002  
    262262# ----------------------------------
    263263def writeascii (field=None,absc=None,name=None):
     264    field = np.array(field)
     265    absc = np.array(absc)
    264266    if name is None:
    265267        name = "prof"
     
    368370    def check(self):
    369371        if self.field is None: print "!! ERROR !! Please define a field to be plotted" ; exit()
     372        else: self.field = np.array(self.field) # ensure this is a numpy array
    370373
    371374    # define_from_var
     
    454457            self.absc = np.array(range(self.field.shape[0]))
    455458            print "!! WARNING !! dummy coordinates on x axis"
     459        else:
     460            self.absc = np.array(self.absc) # ensure this is a numpy array
    456461        # swapping if requested
    457462        if self.swap:  x = self.field ; y = self.absc
     
    770775        if self.addvecx is not None and self.addvecy is not None:
    771776                # vectors on map projection or simple 2D mapping
    772                 if self.mapmode: [vecx,vecy] = m.rotate_vector(self.addvecx,self.addvecy,self.absc,self.ordi) # for metwinds only ?
    773                 else: vecx,vecy = self.addvecx,self.addvecy ; x,y = np.meshgrid(x,y)
     777                if self.mapmode:
     778                   [vecx,vecy] = m.rotate_vector(self.addvecx,self.addvecy,self.absc,self.ordi) # for metwinds only ?
     779                else:
     780                   vecx,vecy = self.addvecx,self.addvecy
     781                   if x.ndim < 2 and y.ndim < 2: x,y = np.meshgrid(x,y)
    774782                # reference vector is scaled
    775                 if self.wscale is None: self.wscale = ppcompute.mean(np.sqrt(self.addvecx*self.addvecx+self.addvecy*self.addvecy))
     783                if self.wscale is None:
     784                    self.wscale = ppcompute.mean(np.sqrt(self.addvecx*self.addvecx+self.addvecy*self.addvecy))
    776785                # make vector field
    777786                if self.mapmode:
Note: See TracChangeset for help on using the changeset viewer.