• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python io.netcdf_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中scipy.io.netcdf_file函数的典型用法代码示例。如果您正苦于以下问题:Python netcdf_file函数的具体用法?Python netcdf_file怎么用?Python netcdf_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了netcdf_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: load

    def load(self,**kwargs):
        """ Load Oscar fields for a given day"""
        self._timeparams(**kwargs)
        md  = self.jd - pl.datestr2num('1992-10-05')
        filename = os.path.join(self.datadir, "oscar_vel%i.nc" % self.yr)
        if not os.path.exists(filename):
            self.download(filename)
        filenam2 = os.path.join(self.datadir, "oscar_vel%i.nc" % (self.yr+1))
        if not os.path.exists(filenam2):
            self.download(filenam2)

        nc1 = netcdf_file(filename)        
        tvec = nc1.variables['time'][:]
        t1 = int(np.nonzero((tvec<=md))[0].max())
        print t1,max(tvec)
        if t1<(len(tvec)-1):
            nc2 = nc1
            t2 = t1 +1
        else:
            nc2 = netcdf_file(filenam2)                    
            t2 = 0
        def readfld(ncvar):
            return self.gmt.field(ncvar[t1, 0,:,:self.imt])[self.j1:self.j2,
                                                            self.i1:self.i2]
        u1 = readfld(nc1.variables['u'])
        v1 = readfld(nc1.variables['v'])
        u2 = readfld(nc2.variables['u'])
        v2 = readfld(nc2.variables['v'])
        rat = float(md-tvec[t1])/float(tvec[t2]-tvec[t1])
        self.u = u2*rat + u1*(1-rat)
        self.v = v2*rat + v1*(1-rat)
        print self.jd,md,t1,t2
开发者ID:raphaeldussin,项目名称:njord,代码行数:32,代码来源:oscar.py


示例2: load

    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,
                            "uv%04i%02i%02i.nc" % (self.yr, self.mn, self.dy))
        if not os.path.isfile(filename):
            self.download(filename)
        try:
            nc = netcdf_file(filename)
        except:
            os.remove(filename)
            self.download(filename)
            try:
                nc = netcdf_file(filename)
            except:
                filename = filename.rstrip(".nc") + "rt.nc"
                if not os.path.isfile(filename):
                    self.download(filename)
                try:
                    nc = netcdf_file(filename)
                except TypeError:
                    os.remove(filename)
                    self.download(filename)
                    nc = netcdf_file(filename)
                    
        u = nc.variables['u'][:].copy()
        v = nc.variables['v'][:].copy()
        u[u<-999] = np.nan
        v[v<-999] = np.nan
        if (fld=="u") | (fld=="uvel"):
            self.uvel = self.gmt.field(np.squeeze(u))
        elif (fld=="v") | (fld=="vvel"):
            self.vvel = self.gmt.field(np.squeeze(v))
        else:
            self.nwnd = self.gmt.field(np.squeeze(np.sqrt(u**2 + v**2)))
开发者ID:raphaeldussin,项目名称:njord,代码行数:35,代码来源:winds.py


示例3: setup_grid

 def setup_grid(self):
     """Setup necessary variables for grid """
     g = netcdf_file(self.gridfile)
     self.llat = g.variables['lat_rho'][:].copy()
     self.llon = g.variables['lon_rho'][:].copy()
     self.depth = g.variables['h'][:].copy()
     self.Cs_r = np.array([-0.882485522505154, -0.778777844867132,
                           -0.687254423585503, -0.606483342183883,
                           -0.535200908367393, -0.472291883107274,
                           -0.416772032329648, -0.367772728223386,
                           -0.324527359249072, -0.286359336228826,
                           -0.252671506867986, -0.222936813095075,
                           -0.196690045050832, -0.173520562714503,
                           -0.153065871294677, -0.135005949869352,
                           -0.11905824454479,  -0.104973247799366,
                           -0.0925305948496471, -0.0815356159649889,
                           -0.0718162907903607, -0.0632205570267136,
                           -0.0556139313622304, -0.0488774054330831,
                           -0.042905583895255, -0.0376050354769002,
                           -0.0328928312128658, -0.0286952469915389,
                           -0.0249466101148999, -0.021588271825806,
                           -0.0185676897273263, -0.0158376057382559,
                           -0.0133553067236276, -0.0110819562325242,
                           -0.00898198688799211, -0.00702254392277909,
                           -0.00517297115481568, -0.0034043313603439,
                           -0.00168895354075999, 0.])
开发者ID:brorfred,项目名称:njord,代码行数:26,代码来源:jpl.py


示例4: load

    def load(self,fldname, **kwargs):
        """ Load velocity fields for a given day"""
        if fldname == "uv":
            self.load('u',jd=jd, yr=yr, mn=mn, dy=dy, hr=hr)
            self.load('v',jd=jd, yr=yr, mn=mn, dy=dy, hr=hr)
            self.uv = np.sqrt(self.u[:,1:,:]**2 + self.v[:,:,1:]**2)
            return
        self._timeparams(**kwargs)
        tpos = np.nonzero(self.jdvec <= self.jd)[0].max()
        vc = {'uvel': ['u',    'ecom.cdf',      9.155553e-05,  0],
              'vvel': ['v',    'ecom.cdf',      9.155553e-05,  0],
              'wvel': ['v',    'ecom.cdf',      6.103702e-08,  0],
              'temp': ['temp', 'ecom.cdf',      0.0005340739, 12.5],
              'salt': ['salt', 'ecom.cdf',      0.0006103702, 20],
              'chlo': ['chl',  'bem_water.cdf', 0.001525925,  50],
              'newp': ['np',   'bem_water.cdf', 0.001525925,  50],
              'netp': ['pp',   'bem_water.cdf', 0.001525925,  50],
              'tpoc': ['tpoc', 'bem_water.cdf', 0.01525925,  500],
              }
        try:
            nc = netcdf_file(self.datadir + vc[fldname][1])
        except KeyError:
            raise KeyError, "%s is not included" % fldname

        fld = nc.variables[vc[fldname][0]][tpos,:,
                                           self.j1:self.j2,
                                           self.i1:self.i2]
        fld = (fld * vc[fldname][2] + vc[fldname][3]).astype(np.float32)
        fld[:,self.landmask] = np.nan
        self.__dict__[fldname] = fld
        return tpos
开发者ID:brorfred,项目名称:njord,代码行数:31,代码来源:bem.py


示例5: get_data

    def get_data(forecast_index, file_id):
        datafile = DataFile.objects.get(pk=file_id)
        file = netcdf_file(os.path.join(settings.MEDIA_ROOT, settings.WAVE_WATCH_DIR, datafile.file.name))
        variable_names_in_file = file.variables.keys()
        print variable_names_in_file

        all_day_height = file.variables['HTSGW_surface'][:, :, :]
        all_day_direction = file.variables['DIRPW_surface'][:,:,:]
        all_day_lat = file.variables['latitude'][:, :]
        all_day_long = file.variables['longitude'][:, :]
        all_day_times = file.variables['time'][:]
        #print "times: "
        #for each in all_day_times:
            #print each

        basetime = datetime.datetime(1970,1,1,0,0,0)

        # Check the first value of the forecast
        forecast_zero = basetime + datetime.timedelta(all_day_times[0]/3600.0/24.0,0,0)
        print(forecast_zero)

        directions = all_day_direction[forecast_index, ::10, :]
        directions_mod = 90.0 - directions + 180.0
        index = directions_mod > 180
        directions_mod[index] = directions_mod[index] - 360;

        index = directions_mod < -180;
        directions_mod[index] = directions_mod[index] + 360;

        U = 10.*np.cos(np.deg2rad(directions_mod))
        V = 10.*np.sin(np.deg2rad(directions_mod))

        print "height:", all_day_height[:10, :10]
开发者ID:seacast,项目名称:SharkEyes,代码行数:33,代码来源:models.py


示例6: get_data

    def get_data(file_id):
        datafile = DataFile.objects.get(pk=file_id)
        file = netcdf_file(os.path.join(settings.MEDIA_ROOT, settings.WAVE_WATCH_DIR, datafile.file.name))
        variable_names_in_file = file.variables.keys()
        print variable_names_in_file


        # longs = [item for sublist in file.variables['longitude'][:1] for item in sublist]
        # print "longs:"
        # for each in longs:
        #     print each
        # lats = file.variables['latitude'][:, 0]
        # print "lats:"
        # for each in lats:
        #     print each

        all_day_height = file.variables['HTSGW_surface'][:, :, :]
        all_day_lat = file.variables['latitude'][:, :]
        all_day_long = file.variables['longitude'][:, :]

        just_this_forecast_height = all_day_height[0][:1, :]
        just_this_forecast_lat = all_day_lat[ :,0]
        just_this_forecast_long= all_day_long[0][ :]
        print "\n\n\nWAVE HEIGHTS "
        for each in just_this_forecast_height:
            print each

        print "\n\n LATS:"
        print just_this_forecast_lat

        print "\n\n LONGS:"
        print just_this_forecast_long
开发者ID:avaleske,项目名称:SharkEyes,代码行数:32,代码来源:models.py


示例7: getVarData

	def getVarData(fn,var):
		def getMembers(tfh):
			names = sorted(tfh.getnames())
			names.remove('.')
			names.remove('./input.cfg')
			names.remove('./output.log')
			
			return [tfh.getmember(n) for n in names]

		def getPassCount(fl):
			fh = netcdf_file(fl)
			S = fh.variables['u'].shape
			fh.close()
			return S[0]
		
		tfh = tarfile.open(fn)
		members = getMembers(tfh)
		Nf = len(members)
		Np = getPassCount(tfh.extractfile(members[0]))
		
		data = pl.empty( (Nf,Np) )
		for k in range(len(members)):
			fl = tfh.extractfile(members[k])
			fh = netcdf_file(fl)
			data[k,:] = fh.variables[var][:,0,0]
			fh.close()
		tfh.close()
		return data
开发者ID:hornekyle,项目名称:AD-PIV,代码行数:28,代码来源:post-shear.py


示例8: _default_cache_entry_factory

    def _default_cache_entry_factory(self, key):
        """Called on a DataCache access __missing__() call.
        Gets all (step, row, col) entries for the file indexed by key and reads all data
        returning the entry for the requested key

        Arguments:
        key - (pixel_step, row, col) tuple

        """
        # A cache miss will generate a file lookup, read and cache of the associated data.
        path, _, _, _ = self._get_data_location(*key)   # path of file containing our data

        # Generate all the entries like the following for data in the file path
        # {(step, row, col): [module_data object reference, 0-3], ... }
        # First, enumerate data indices in current file.
        indices = self._enumerate_all_data_indices_in_file(os.path.basename(path))

        # OK, now read everything from the file
        f = netcdf_file(path, 'r')
        # buffer_ix, module_ix
        for pixel_step, row, col, channel, buffer_ix, module_ix in indices:
            self.module_data_cache[(pixel_step, row, col)] = \
                [self._get_mode1_pixel_data(f, buffer_ix, module_ix), channel]
        f.close()

        return self.module_data_cache[key]
开发者ID:AustralianSynchrotron,项目名称:Sakura,代码行数:26,代码来源:xmap_netcdf_reader.py


示例9: load

 def load(self,fldname, **kwargs):
     """ Load velocity fields for a given day"""
     self._timeparams(**kwargs)
     if fldname == "uv":
         self.load('u',**kwargs)
         self.load('v',**kwargs)
         self.uv = np.sqrt(self.u[:,1:,:]**2 + self.v[:,:,1:]**2)
         return
     
     if self.opendap:
         tpos = int(self.jd) - 714800
         k1   = kwargs.get("k1", getattr(self, "k1", self.klev)) 
         k2   = kwargs.get("k2", getattr(self, "k2", k1+1))
         dapH = open_url(self.dapurl)
         fld  = dapH[fldname][tpos,k1:k2,self.j1:self.j2,self.i1:self.i2] 
     else:
         filename = self.jd2filename(self.jd)
         if not os.path.isfile(filename):
             print "File missing"
             url = urlparse.urljoin(self.dataurl, os.path.basename(filename))
             self.retrive_file(url, filename)
         with netcdf_file(filename) as nc:
             fld =  nc.variables[fldname][:].copy()
             self.ssh =  np.squeeze(nc.variables['zeta'][:])
             self.zlev = ((self.depth + self.ssh)[np.newaxis,:,:] *
                           self.Cs_r[:,np.newaxis,np.newaxis])
     
     fld[fld>9999] = np.nan
     setattr(self, fldname, np.squeeze(fld))
开发者ID:raphaeldussin,项目名称:njord,代码行数:29,代码来源:rutgers.py


示例10: read_woce_netcdf

def read_woce_netcdf(fnm):
    """ Read a CTD cast from a WOCE NetCDF file. """

    def getvariable(nc, key):
        return nc.variables[key].data.copy()

    nc = netcdf_file(fnm)
    coords = (getvariable(nc, "longitude")[0], getvariable(nc, "latitude")[0])

    pres = getvariable(nc, "pressure")
    sal = getvariable(nc, "salinity")
    salqc = getvariable(nc, "salinity_QC")
    sal[salqc!=2] = np.nan
    temp = getvariable(nc, "temperature")
    # tempqc = getvariable(nc, "temperature_QC")
    # temp[tempqc!=2] = np.nan
    oxy = getvariable(nc, "oxygen")
    oxyqc = getvariable(nc, "oxygen_QC")
    oxy[oxyqc!=2] = np.nan

    date = getvariable(nc, "woce_date")
    time = getvariable(nc, "woce_time")
    return narwhal.CTDCast(pres, sal, temp, oxygen=oxy,
                           coords=coords,
                           properties={"woce_time":time, "woce_date":date})
开发者ID:arnaldorusso,项目名称:narwhal,代码行数:25,代码来源:cast.py


示例11: test_netcdf_wave_format

    def test_netcdf_wave_format(self):
        print("Running Wave NetCDF Format Test: ")
        #directory of where files will be saved at
        destination_directory = os.path.join(settings.MEDIA_ROOT, settings.WAVE_WATCH_DIR)

        print "Downloading File"
        #file names might need to be created dynamically in the future if ftp site changes
        file_name = "outer.nc"

        #Connect to FTP site to get the file modification data
        ftp = FTP('cil-www.oce.orst.edu')
        ftp.login()

        #retrieve the ftp modified datetime format
        ftp_dtm = ftp.sendcmd('MDTM' + " /pub/outgoing/ww3data/" + file_name)

        #convert ftp datetime format to a string datetime
        modified_datetime = datetime.strptime(ftp_dtm[4:], "%Y%m%d%H%M%S").strftime("%Y-%m-%d")

        #Create File Name and Download actual File into media folder
        url = urljoin(settings.WAVE_WATCH_URL, file_name)
        filename = "{0}_{1}_{2}.nc".format("OuterGrid", modified_datetime, uuid4())
        urllib.urlretrieve(url=url, filename=os.path.join(destination_directory, filename))

        datafile_read_object = netcdf_file(os.path.join(settings.MEDIA_ROOT, settings.WAVE_WATCH_DIR, filename))
        print "Checking Variables: latitude, longitude, HTSGW_surface"
        surface = datafile_read_object.variables['HTSGW_surface'][:, :, :]
        long = datafile_read_object.variables['longitude'][:]
        lat = datafile_read_object.variables['latitude'][:]
        ftp.quit()
        self.assertIsNotNone(surface)
        self.assertIsNotNone(long)
        self.assertIsNotNone(lat)
开发者ID:MiCurry,项目名称:SharkEyes,代码行数:33,代码来源:tests.py


示例12: __init__

 def __init__(self, projname, casename="", **kwargs):
     super(Partsat,self).__init__(projname, casename, *kwargs)
     postgresql.DB.__init__(self, projname, casename, database='partsat')
     self.flddict = {'par':('L3',),'chl':('box8',)}
     if projname == 'oscar':
         import pysea.MODIS
         self.sat = pysea.NASA.nasa(res='4km',
                                    ijarea=(700,1700,2000,4000))
         def calc_jd(ints,intstart):
             return self.base_iso + float(ints)/6-1
     elif projname=="casco":
         self.sat = casco.Sat(res='500m')
         def calc_jd(ints,intstart):
             return (self.base_iso +(ints-(intstart)*10800)/150 +
                     intstart/8)
     elif projname=="gompom":
         n = netcdf_file('/Users/bror/svn/modtraj/box8_gompom.cdf')
         self.gomi = n.variables['igompom'][:]
         self.gomj = n.variables['jgompom'][:]
         self.sati = n.variables['ibox8'][:]
         self.satj = n.variables['jbox8'][:]
     elif projname=="jplSCB":
         from njord import mati
         self.sat = mati.Cal()
     elif projname=="jplNow":
         from njord import mati
         self.sat = mati.Cal()
开发者ID:brorfred,项目名称:pytraj,代码行数:27,代码来源:partsat.py


示例13: load

 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
开发者ID:raphaeldussin,项目名称:njord,代码行数:7,代码来源:mldclim.py


示例14: setup_grid

 def setup_grid(self):
     """Define lat and lon matrices for njord"""
     gc = netcdf_file(self.gridfile)
     self.lat = gc.variables['lat'][:].copy()
     self.gmt = gmtgrid.Shift(gc.variables['lon'][:].copy())
     self.lon = self.gmt.lonvec         
     self.llon,self.llat = np.meshgrid(self.lon,self.lat)
开发者ID:brorfred,项目名称:njord,代码行数:7,代码来源:mldclim.py


示例15: setup_grid

 def setup_grid(self):
     gc = netcdf_file(self.gridfile)
     print self.gridfile
     self.llat  = gc.variables['y'][:]
     self.llon  = gc.variables['x'][:]
     self.depth = gc.variables['depth'][:].copy()
     self.depth[self.depth<0] = np.nan
开发者ID:brorfred,项目名称:njord,代码行数:7,代码来源:gompom.py


示例16: __init__

    def __init__(self, fname, variables=None, use_tmpfile=True):
        # try to figure out what we got
        #assert isinstance(fobj, file)
        assert isinstance(fname, str)
        if fname[:4]=='http':
            # it's an OpenDAP url
            self.ncf = netCDF4.Dataset(fname)
        elif os.path.exists(fname):
            if fnmatch(fname, '*.bz2') and use_tmpfile:
                fobj = tempfile.TemporaryFile('w+b', suffix='nc')
                subprocess.call(["bzcat", fname], stdout=fobj)
                fobj.seek(0)
            elif fnmatch(fname, '*.bz2'):
                fobj = bz2.BZ2File(fname, 'rb')
            else:
                fobj = file(fname, 'rb')            
            self.ncf = netcdf_file(fobj)
            #self.ncf = netCDF4.Dataset(fobj)
        else:
            raise IOError("Couldn't figure out how to open " + fname)

        self.fname = fname
        if variables is None:
            variables = self.ncf.variables.keys()
        for varname in variables:
            self._get_and_scale_variable(varname)
开发者ID:rabernat,项目名称:satdatatools,代码行数:26,代码来源:ghrsst_L2P_dataset.py


示例17: get_searise

  def get_searise(thklim = 0.0):
    
    filename = inspect.getframeinfo(inspect.currentframe()).filename
    home     = os.path.dirname(os.path.abspath(filename))
 
    direc = home + "/greenland/searise/Greenland_5km_dev1.2.nc"
    data  = netcdf_file(direc, mode = 'r')
    vara  = dict()
    
    # retrieve data :
    x     = array(data.variables['x1'][:])
    y     = array(data.variables['y1'][:])
    h     = array(data.variables['usrf'][:][0])
    adot  = array(data.variables['smb'][:][0])
    b     = array(data.variables['topg'][:][0])
    T     = array(data.variables['surftemp'][:][0]) + 273.15
    q_geo = array(data.variables['bheatflx'][:][0]) * 60 * 60 * 24 * 365
    lat   = array(data.variables['lat'][:][0])
    lon   = array(data.variables['lon'][:][0])
    U_sar = array(data.variables['surfvelmag'][:][0])
    dhdt  = array(data.variables['dhdt'][:][0])
 
    direc = home + "/greenland/searise/smooth_target.mat" 
    U_ob  = loadmat(direc)['st']
    
    H             = h - b
    h[H < thklim] = b[H < thklim] + thklim
    H[H < thklim] = thklim

    Tn            = 41.83 - 6.309e-3*h - 0.7189*lat - 0.0672*lon + 273
    
    # extents of domain :
    east  = max(x)
    west  = min(x)
    north = max(y)
    south = min(y)

    #projection info :
    proj   = 'stere'
    lat_0  = '90'
    lat_ts = '71'
    lon_0  = '-39'
 
    names = ['H', 'S', 'adot', 'B', 'T', 'q_geo','U_sar', \
             'U_ob', 'lat', 'lon', 'Tn','dhdt']
    ftns  = [H, h, adot, b, T, q_geo,U_sar, U_ob, lat, lon, Tn, dhdt]

    vara['dataset'] = 'searise'
    for n, f in zip(names, ftns):
      vara[n] = {'map_data'          : f,
                 'map_western_edge'  : west, 
                 'map_eastern_edge'  : east, 
                 'map_southern_edge' : south, 
                 'map_northern_edge' : north,
                 'projection'        : proj,
                 'standard lat'      : lat_0,
                 'standard lon'      : lon_0,
                 'lat true scale'    : lat_ts}
    return vara
开发者ID:douglas-brinkerhoff,项目名称:VarGlaS,代码行数:59,代码来源:data_factory.py


示例18: setup_grid

 def setup_grid(self):
     gc = netcdf_file(self.gridfile)
     dlon, dlat = gc.variables["spacing"][:]
     lon1, lon2 = gc.variables["x_range"][:]
     lat1, lat2 = gc.variables["y_range"][:]
     self.lon = np.arange(lon1, lon2, dlon)
     self.lat = np.arange(lat1, lat2, dlat)
     self.llon, self.llat = np.meshgrid(self.lon, self.lat)
开发者ID:raphaeldussin,项目名称:njord,代码行数:8,代码来源:gebco.py


示例19: get_currents_data

    def get_currents_data(forecast_index, file_id):
        datafile = DataFile.objects.get(pk=file_id)
        data_file = netcdf_file(os.path.join(settings.MEDIA_ROOT, settings.NETCDF_STORAGE_DIR, datafile.file.name))
        currents_u = data_file.variables['u'][forecast_index][39]
        currents_v = data_file.variables['v'][forecast_index][39]

        print "currents u:", 10.0*currents_u
        print "\n\n\ncurrents v:", 10.0*currents_v
开发者ID:seacast,项目名称:SharkEyes,代码行数:8,代码来源:models.py


示例20: dev_to_gmt

    def dev_to_gmt(self):
        """
        Should write grid to a NetCDF file
        """
        values = np.random.rand(10, 20, 30)
        grd = CartesianGrid3D(values)

        fname = 'temp.grd'
        if os.path.isfile(fname):
            os.remove(fname)

        # should create a NetCDF file 
        grd.to_gmt(fname)
        nc = netcdf_file(fname, 'r')
        for k in ['x_range', 'spacing', 'z', 'y_range',
                'dimension', 'z_range']:
            self.assertTrue(k in nc.variables)

        # default should write values[:, :, 0]
        # Note swapped ordering here
        self.assertEqual(nc.variables['dimension'][0], values.shape[1])
        self.assertEqual(nc.variables['dimension'][1], values.shape[0])

        zz = np.reshape(nc.variables['z'][::].copy(),
                (nc.variables['dimension'][1],
                    nc.variables['dimension'][0]))

        for ix in range(values.shape[0]):
            for iy in range(values.shape[1]):
                self.assertEqual(zz[ix, iy], values[ix, iy, 0])


        # should write values[:, iy, :]
        iy0 = 3
        grd.to_gmt(fname, iy=iy0)
        nc = netcdf_file(fname, 'r')
        self.assertEqual(nc.variables['dimension'][1], values.shape[0])
        self.assertEqual(nc.variables['dimension'][0], values.shape[2])
        
        zz = np.reshape(nc.variables['z'][::].copy(),
                (nc.variables['dimension'][1],
                    nc.variables['dimension'][0]))
        
        for ix in range(values.shape[0]):
            for iy in range(values.shape[2]):
                self.assertEqual(zz[ix, iy], values[ix, iy0, iy])
开发者ID:ekmyers,项目名称:PyVM,代码行数:46,代码来源:test_grids.py



注:本文中的scipy.io.netcdf_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python io.readsav函数代码示例发布时间:2022-05-27
下一篇:
Python io.mmwrite函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap