Ignore:
Timestamp:
Nov 6, 2013, 10:23:11 AM (11 years ago)
Author:
aslmd
Message:

PLANETOPLOT. fix to handle missing values in complex netCDF files.

File:
1 edited

Legend:

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

    r1084 r1089  
    17791779          # there is a problem above if stride != 1. a fix must be found. rewrite might be necessary. TBD
    17801780          pass
    1781         # make a mask in case there are non-NaN missing values. (what about NaN missing values?)
     1781        # check if 'not finite' values are present
     1782        # (happens with some netCDF files where -- appears in arrays)
     1783        # (but isn't it that netcdf4 returns masked arrays?)
     1784        w = np.where(np.isfinite(self.field) != True)
     1785        self.field[w] = np.NaN
     1786        ## catch netCDF missing values (TBD: add a test try)
     1787        #miss = self.f.variables[self.var].missing_value
     1788        #if miss is not None: self.missing = miss
     1789        # make a mask in case there are non-NaN missing values.
    17821790        # ... this is important for computations below (see ppcompute)
    1783         masked = np.ma.masked_where(np.abs(self.field) > self.missing,self.field)
     1791        masked = np.ma.masked_where(np.abs(self.field) >= self.missing,self.field)
    17841792        if masked.mask.any() == True:
    17851793             if self.verbose: print "!! WARNING !! Values over %5.3e are considered missing values." % self.missing
Note: See TracChangeset for help on using the changeset viewer.