Пример #1
0
 def load(self, mn=1):
     """ Load mixed layer climatology for a given day"""
     self.mn = mn
     nc = netcdf_file(self.datadir + "/" + self.mldFile)
     self.mld = gmtgrid.convert(nc.variables["mld"][self.mn - 1, self.j1 : self.j2, self.i1 : self.i2], self.gr)
     self.mld[self.mld < 0] = np.nan
     self.mld[self.mld > 1e4] = np.nan
Пример #2
0
 def add_landmask(self):
     """Add landmask defined as 1=land 0=ocean"""
     gc = pycdf.CDF(self.datadir + "/" + self.gridfile)
     u = nc.var('u')[:,:,:,:1081]
     msk = np.squeeze(nanmean(u,axis=0))
     msk = msk*0
     msk[np.isnan(msk)]=1
     self.landmask = gmtgrid.convert(msk,self.gr)
Пример #3
0
 def read_bin(self, filename):
     """ Read binary output from Poseidon """
     with open(filename) as fd:
         size = np.fromfile(fd,'<i4',count=1)[0]
         assert size == (self.i2+1) * (self.j2+1) * 4
         data = np.fromfile(fd,'<f4',count=(self.j2+1) * (self.i2+1))
         return gmtgrid.convert(
             data.reshape(self.j2+1,self.i2+1), self.gr)
Пример #4
0
 def load(self, mn=1):
     """ Load mixed layer climatology for a given day"""
     self.mn = mn
     nc = netcdf_file(self.datadir + "/" + self.mldFile)
     self.mld = gmtgrid.convert(
         nc.variables['mld'][self.mn - 1, self.j1:self.j2, self.i1:self.i2],
         self.gr)
     self.mld[self.mld < 0] = np.nan
     self.mld[self.mld > 1e4] = np.nan
Пример #5
0
    def load(self, fld="nwnd", **kwargs):
	"""Load field for a given julian date. Returns u,v, or nwnd(windnorm)"""
        self._timeparams(**kwargs)
	filename = os.path.join(self.datadir,
				"analysis_%04i%02i%02i_v11l30flk.nc" %
                                  	(self.yr,self.mn,self.dy))
        if os.path.isfile(filename):
            nc = netcdf_file(filename)
        else:
            raise IOError, 'Error opening the windfile %s' % filename
	uH = nc.variables['uwnd']
	vH = nc.variables['vwnd']
	uvel = self.gmt.field(uH.data.copy()) * uH.scale_factor
	vvel = self.gmt.field(vH.data.copy()) * vH.scale_factor
	
	uvel[uvel<(uH.missing_value * uH.scale_factor)] = np.nan
	vvel[vvel<(vH.missing_value * vH.scale_factor)] = np.nan
	if (fld=="u") | (fld=="uvel"):
	    self.uvel = gmtgrid.convert(np.squeeze(u), self.gr)
	elif (fld=="v") | (fld=="vvel"):
	    self.vvel = gmtgrid.convert(np.squeeze(v), self.gr)
	else:
   	    self.nwnd = gmtgrid.convert(np.squeeze(np.sqrt(u**2 + v**2)),self.gr)
Пример #6
0
    def load(self, fld="nwnd", **kwargs):
        """Load field for a given julian date. Returns u,v, or nwnd(windnorm)"""
        self._timeparams(**kwargs)
        filename = os.path.join(
            self.datadir,
            "analysis_%04i%02i%02i_v11l30flk.nc" % (self.yr, self.mn, self.dy))
        if os.path.isfile(filename):
            nc = netcdf_file(filename)
        else:
            raise IOError, 'Error opening the windfile %s' % filename
        uH = nc.variables['uwnd']
        vH = nc.variables['vwnd']
        uvel = self.gmt.field(uH.data.copy()) * uH.scale_factor
        vvel = self.gmt.field(vH.data.copy()) * vH.scale_factor

        uvel[uvel < (uH.missing_value * uH.scale_factor)] = np.nan
        vvel[vvel < (vH.missing_value * vH.scale_factor)] = np.nan
        if (fld == "u") | (fld == "uvel"):
            self.uvel = gmtgrid.convert(np.squeeze(u), self.gr)
        elif (fld == "v") | (fld == "vvel"):
            self.vvel = gmtgrid.convert(np.squeeze(v), self.gr)
        else:
            self.nwnd = gmtgrid.convert(np.squeeze(np.sqrt(u**2 + v**2)),
                                        self.gr)
Пример #7
0
 def load(self,jd):
     yr = pl.num2date(jd).year
     yd = int((jd - pl.date2num(dtm(yr,1,1))) * 4)
     ufile = "uwnd.sig995.%04i.nc" % yr
     vfile = "vwnd.sig995.%04i.nc" % yr
     try:
         un = pycdf.CDF(self.datadir + ufile)
     except:
         print 'Error opening the windfile %s' % datadir + ufile
         raise
     try:
         vn = pycdf.CDF(self.datadir + vfile)
     except:
         print 'Error opening the windfile %s' % datadir + vfile
         raise    
     u = un.var('uwnd')[yd,:,:] * 0.01 + 225.45
     v = vn.var('vwnd')[yd,:,:] * 0.01 + 225.45
     nwnd = gmtgrid.convert(np.sqrt(u**2 + v**2),self.gr)
     nwnd[nwnd>200]=np.nan
     return nwnd
Пример #8
0
 def load(self, jd):
     yr = pl.num2date(jd).year
     yd = int((jd - pl.date2num(dtm(yr, 1, 1))) * 4)
     ufile = "uwnd.sig995.%04i.nc" % yr
     vfile = "vwnd.sig995.%04i.nc" % yr
     try:
         un = pycdf.CDF(self.datadir + ufile)
     except:
         print 'Error opening the windfile %s' % datadir + ufile
         raise
     try:
         vn = pycdf.CDF(self.datadir + vfile)
     except:
         print 'Error opening the windfile %s' % datadir + vfile
         raise
     u = un.var('uwnd')[yd, :, :] * 0.01 + 225.45
     v = vn.var('vwnd')[yd, :, :] * 0.01 + 225.45
     nwnd = gmtgrid.convert(np.sqrt(u**2 + v**2), self.gr)
     nwnd[nwnd > 200] = np.nan
     return nwnd