Changeset 1108 for trunk/UTIL


Ignore:
Timestamp:
Nov 19, 2013, 3:32:54 PM (11 years ago)
Author:
aslmd
Message:

PLANETOPLOT. How to include a streamfunction in a separate file without a longitude dimension. See stream.py in examples.

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

Legend:

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

    r1094 r1108  
    165165                      svy=1,\
    166166                      compute="mean",\
     167                      kind3d="tyx",\
    167168                      verbose=False,\
    168169                      quiet=False,\
     
    223224        self.svy = svy
    224225        self.compute = compute
     226        self.kind3d = kind3d
    225227        self.verbose = verbose
    226228        self.quiet = quiet
     
    290292            self.sx = other.sx ; self.sy = other.sy
    291293            self.sz = other.sz ; self.st = other.st
     294            self.compute = other.compute
     295            self.kind3d = other.kind3d
    292296            self.verbose = other.verbose
    293297            self.noproj = other.noproj
     
    628632              # indicate the computation method
    629633              obj.compute = self.compute
     634              # indicate the kind of 3D fields
     635              obj.kind3d = self.kind3d
    630636              # open the files (the same file might be opened several times but this is cheap)
    631637              obj.openfile()
     
    749755              elif obj.field.ndim == 2:
    750756                  obj.field = ppcompute.smooth2d(obj.field,window=window)
     757                  #obj.field = ppcompute.smooth2diter(obj.field,n=window)
    751758
    752759    ############################################################################################## 
     
    13151322        self.sx = 1 ; self.sy = 1 ; self.sz = 1 ; self.st = 1
    13161323        self.missing = '!! missing value: I am not set, damned !!'
     1324        self.kind3d = '!! kind3d: I am not set, damned !!'
    13171325
    13181326    # open a file. for now it is netcdf. TBD for other formats.
     
    13561364          elif self.dim == 3:
    13571365              if self.verbose: print "**** OK. 3D field. I assume this is time-varying lat-lon map."
    1358               self.dim_x = shape[2] ; self.dim_y = shape[1] ; self.dim_z = 1 ; self.dim_t = shape[0]
     1366              ## see below for comment
     1367              if self.kind3d == "tyx":
     1368                self.dim_x = shape[2] ; self.dim_y = shape[1] ; self.dim_z = 1 ; self.dim_t = shape[0]
     1369              elif self.kind3d == "tzy":
     1370                self.dim_x = 1 ; self.dim_y = shape[2] ; self.dim_z = shape[1] ; self.dim_t = shape[0]
     1371              else:
     1372                print "!! ERROR !! This kind of 3D field is not supported. Please send feedback."
     1373                print self.kind3d
     1374                exit()
    13591375          elif self.dim == 4:
    13601376              if self.verbose: print "**** OK. 4D field."
     
    17031719            self.field = self.f.variables[self.var][self.index_y,self.index_x]
    17041720        elif self.dim == 3:
    1705             nt = self.index_t.size ; nz = 1 ; ny = self.index_y.size ; nx = self.index_x.size
    1706             self.field = self.f.variables[self.var][self.index_t,self.index_y,self.index_x]
     1721            ## DEFAULT tyx (time-varying 2D field)
     1722            if self.kind3d == "tyx":
     1723               nt = self.index_t.size ; nz = 1 ; ny = self.index_y.size ; nx = self.index_x.size
     1724               self.field = self.f.variables[self.var][self.index_t,self.index_y,self.index_x]
     1725            ## CASE tzy (e.g. time-varying zonal mean y-z field)
     1726            elif self.kind3d == "tzy":
     1727               nt = self.index_t.size ; nz = self.index_z.size ; ny = self.index_y.size ; nx = 1
     1728               self.field = self.f.variables[self.var][self.index_t,self.index_z,self.index_y]
     1729            else:
     1730               print "!! ERROR !! This kind of 3D field is not supported. Please send feedback." ; exit()
    17071731            # this is far faster than retrieving each term with a loop
    17081732        elif self.dim == 4:
Note: See TracChangeset for help on using the changeset viewer.