当前位置: 首页>>代码示例>>Python>>正文


Python Dataset.type方法代码示例

本文整理汇总了Python中netCDF4.Dataset.type方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.type方法的具体用法?Python Dataset.type怎么用?Python Dataset.type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在netCDF4.Dataset的用法示例。


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

示例1: writeCMIP5File

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import type [as 别名]
def writeCMIP5File(modelName,scenario,myvarname,lon,lat,time,mydata,mydataanomaly,outfilename):
    
     myformat='NETCDF3_CLASSIC'
     
     if os.path.exists(outfilename):
          os.remove(outfilename)
     print "Results written to netcdf file: %s"%(outfilename)
     if myvarname=="sic": myvar="SIC"
     
     f1 = Dataset(outfilename, mode='w', format=myformat)
     f1.title       = "IPCC AR5 %s"%(myvar)
     f1.description = "IPCC AR5 running averages of %s for model %s for scenario %s"%(myvar,modelName,scenario)
     f1.history     = "Created " + str(datetime.now())
     f1.source      = "Trond Kristiansen ([email protected])"
     f1.type        = "File in NetCDF3 format created using iceExtract.py"
     f1.Conventions = "CF-1.0"

     """Define dimensions"""
     f1.createDimension('x',  len(lon))
     f1.createDimension('y', len(lat))
     f1.createDimension('time', None)
        
     vnc = f1.createVariable('longitude', 'd', ('x',),zlib=False)
     vnc.long_name = 'Longitude'
     vnc.units = 'degree_east'
     vnc.standard_name = 'longitude'
     vnc[:] = lon

     vnc = f1.createVariable('latitude', 'd', ('y',),zlib=False)
     vnc.long_name = 'Latitude'
     vnc.units = 'degree_north'
     vnc.standard_name = 'latitude'
     vnc[:] = lat

     v_time = f1.createVariable('time', 'd', ('time',),zlib=False)
     v_time.long_name = 'Years'
     v_time.units = 'Years'
     v_time.field = 'time, scalar, series'
     v_time[:]=time     
     
     v_temp=f1.createVariable('SIC', 'd', ('time', 'y', 'x',),zlib=False)
     v_temp.long_name = "Sea-ice area fraction (%)"
     v_temp.units = "%"
     v_temp.time = "time"
     v_temp.field="SIC, scalar, series"
     v_temp.missing_value = 1e20
     
    
     if myvarname=='sic':
          f1.variables['SIC'][:,:,:]  = mydata
          
     f1.close()
开发者ID:trondkr,项目名称:OceanLight,代码行数:54,代码来源:IOwrite.py

示例2: createBryFile

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import type [as 别名]
def createBryFile(confM2R):
    if (confM2R.myformat == 'NETCDF4'):
        myzlib = True
    else:
        myzlib = False
    grdROMS = confM2R.grdROMS

    if os.path.exists(confM2R.bryname):
        os.remove(confM2R.bryname)
    print(('\n=>Creating initial Boundary (BRY) file {}'.format(confM2R.bryname)))

    f1 = Dataset(confM2R.bryname, mode='w', format=confM2R.myformat)
    f1.title = "Boundary forcing file (BRY) used for forcing of the ROMS model"
    f1.description = "Created for the {} grid file".format(confM2R.romsgridpath)
    f1.grdFile = "{}".format(confM2R.romsgridpath)
    f1.history = 'Created ' + time.ctime(time.time())
    f1.source = "{} ({})".format(confM2R.authorname, confM2R.authoremail)
    f1.type = "File in {} format created using MODEL2ROMS".format(confM2R.myformat)
    f1.link = "https://github.com/trondkr/model2roms"
    f1.Conventions = "CF-1.0"

    """ Define dimensions """
    f1.createDimension('xi_rho', grdROMS.xi_rho)
    f1.createDimension('eta_rho', grdROMS.eta_rho)
    f1.createDimension('xi_u', grdROMS.xi_u)
    f1.createDimension('eta_u', grdROMS.eta_u)
    f1.createDimension('xi_v', grdROMS.xi_v)
    f1.createDimension('eta_v', grdROMS.eta_v)
    f1.createDimension('xi_psi', grdROMS.xi_psi)
    f1.createDimension('eta_psi', grdROMS.eta_psi)
    f1.createDimension('ocean_time', None)
    f1.createDimension('s_rho', len(grdROMS.s_rho))
    f1.createDimension('s_w', len(grdROMS.s_w))

    vnc = f1.createVariable('lon_rho', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = 'Longitude of RHO-points'
    vnc.units = 'degree_east'
    vnc.standard_name = 'longitude'
    vnc[:, :] = grdROMS.lon_rho

    vnc = f1.createVariable('lat_rho', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = 'Latitude of RHO-points'
    vnc.units = 'degree_north'
    vnc.standard_name = 'latitude'
    vnc[:, :] = grdROMS.lat_rho

    vnc = f1.createVariable('lon_u', 'd', ('eta_u', 'xi_u',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = 'Longitude of U-points'
    vnc.units = 'degree_east'
    vnc.standard_name = 'longitude'
    vnc[:, :] = grdROMS.lon_u

    vnc = f1.createVariable('lat_u', 'd', ('eta_u', 'xi_u',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = 'Latitude of U-points'
    vnc.units = 'degree_north'
    vnc.standard_name = 'latitude'
    vnc[:, :] = grdROMS.lat_u

    vnc = f1.createVariable('lon_v', 'd', ('eta_v', 'xi_v',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = 'Longitude of V-points'
    vnc.units = 'degree_east'
    vnc.standard_name = 'longitude'
    vnc[:, :] = grdROMS.lon_v

    vnc = f1.createVariable('lat_v', 'd', ('eta_v', 'xi_v',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = 'Latitude of V-points'
    vnc.units = 'degree_north'
    vnc.standard_name = 'latitude'
    vnc[:, :] = grdROMS.lat_v

    vnc = f1.createVariable('lat_psi', 'd', ('eta_psi', 'xi_psi',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = 'Latitude of PSI-points'
    vnc.units = 'degree_north'
    vnc.standard_name = 'latitude'
    vnc[:, :] = grdROMS.lat_psi

    vnc = f1.createVariable('lon_psi', 'd', ('eta_psi', 'xi_psi',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = 'Longitude of PSI-points'
    vnc.units = 'degree_east'
    vnc.standard_name = 'longitude'
    vnc[:, :] = grdROMS.lon_psi

    vnc = f1.createVariable('h', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = "Bathymetry at RHO-points"
    vnc.units = "meter"
    vnc.coordinates = "lat_rho lon_rho"
    vnc.field = "bath, scalar"
    vnc[:, :] = grdROMS.h

    vnc = f1.createVariable('s_rho', 'd', ('s_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
    vnc.long_name = "S-coordinate at RHO-points"
    vnc.valid_min = -1.
    vnc.valid_max = 0.

    if grdROMS.vtransform == 2:
        vnc.standard_name = "ocean_s_coordinate_g2"
        vnc.formula_terms = "s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc"
    if grdROMS.vtransform == 1:
        vnc.standard_name = "ocean_s_coordinate_g1"
        vnc.formula_terms = "s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc"
#.........这里部分代码省略.........
开发者ID:trondkr,项目名称:model2roms,代码行数:103,代码来源:IOBry.py

示例3: writeData

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import type [as 别名]
def writeData(outputFile,obs_lat,obs_lon,obs_value,Nobs,survey_time,obs_time,obs_Xgrid,obs_Ygrid,
                               firstIteration,lastIteration,
                               obs_flag,obs_type,obs_error,obs_Zgrid,obs_depth,obs_variance,
                               survey,is3d,Nstate,USENETCDF4):


   if USENETCDF4 is True:
      myZLIB=True
      myformat='NETCDF4'
   else:
      myZLIB=False
      myformat='NETCDF3_CLASSIC'

   if firstIteration is True:

      f1 = Dataset(outputFile, mode='w', format=myformat)
      f1.description="This is a obs file for SST"
      f1.history = 'Created ' + time.ctime(time.time())
      f1.source = 'Trond Kristiansen ([email protected])'
      f1.type='NetCDF4 using program createMapNS.py'

      f1.options='Program requires: getCortad.py and writeObsfile.py'

      """ Define dimensions """
      f1.createDimension('one', 1)
      f1.createDimension('state_variable', Nstate)
      f1.createDimension('datum', None)

      v_spherical = f1.createVariable('spherical', 'c', ('one',),zlib=myZLIB)
      v_spherical.long_name = 'grid type logical switch'
      v_spherical.option_T  = "spherical"
      v_spherical.option_F  = "Cartesian"
      v_spherical[:]        = "T"

      v_obs_type = f1.createVariable('obs_type', 'i', ('datum',),zlib=myZLIB)
      v_obs_type.long_name = 'model state variable associated with observation'
      v_obs_type.opt_1 ='free-surface'
      v_obs_type.opt_2 ='vertically integrated u-momentum component';
      v_obs_type.opt_3 ='vertically integrated v-momentum component';
      v_obs_type.opt_4 ='u-momentum component'
      v_obs_type.opt_5 ='v-momentum component'
      v_obs_type.opt_6 ='potential temperature'
      v_obs_type.opt_7 ='salinity'
      v_obs_type[:]    = obs_type

      v_time = f1.createVariable('obs_time', 'd', ('datum',),zlib=myZLIB)
      v_time.long_name = 'Time of observation'
      v_time.units     = 'days'
      v_time.field     = 'time, scalar, series'
      v_time.calendar  = 'standard'
      v_time[:]        = obs_time


      v_obs_lon = f1.createVariable('obs_lon', 'd', ('datum',),zlib=myZLIB)
      v_obs_lon.long_name = 'Longitude of observation'
      v_obs_lon.units     = 'degrees_east'
      v_obs_lon.min       = -180
      v_obs_lon.max       = 180
      v_obs_lon[:]        = obs_lon

      v_obs_lat = f1.createVariable('obs_lat', 'd', ('datum',),zlib=myZLIB)
      v_obs_lat.long_name = 'Latitude of observation'
      v_obs_lat.units     = 'degrees_north'
      v_obs_lat.min       = -90
      v_obs_lat.max       = 90
      v_obs_lat[:]        = obs_lat

      v_obs_depth = f1.createVariable('obs_depth', 'd', ('datum',),zlib=myZLIB)
      v_obs_depth.long_name = 'Depth of observation'
      v_obs_depth.units     = 'meter'
      v_obs_depth.minus     = 'downwards'
      v_obs_depth[:]        = obs_depth

      v_obs_error = f1.createVariable('obs_error', 'd', ('datum',),zlib=myZLIB)
      v_obs_error.long_name = 'Observation error covariance'
      v_obs_error.units     = 'squared state variable units'
      v_obs_error[:]        = obs_error

      v_obs_val = f1.createVariable('obs_value', 'd', ('datum',),zlib=myZLIB)
      v_obs_val.long_name = 'Observation value'
      v_obs_val.units     = 'state variable units'
      v_obs_val[:]        = obs_value

      v_obs_xgrid = f1.createVariable('obs_Xgrid', 'd', ('datum',),zlib=myZLIB)
      v_obs_xgrid.long_name = 'x-grid observation location'
      v_obs_xgrid.units     = 'nondimensional'
      v_obs_xgrid.left      = "INT(obs_Xgrid(datum))"
      v_obs_xgrid.right     = "INT(obs_Xgrid(datum))+1"
      v_obs_xgrid[:]        = obs_Xgrid

      v_obs_ygrid = f1.createVariable('obs_Ygrid', 'd', ('datum',),zlib=myZLIB)
      v_obs_ygrid.long_name = 'y-grid observation location'
      v_obs_ygrid.units     = 'nondimensional'
      v_obs_ygrid.top       = "INT(obs_Ygrid(datum))+1"
      v_obs_ygrid.bottom    = "INT(obs_Ygrid(datum))"
      v_obs_ygrid[:]        = obs_Ygrid

      v_obs_zgrid = f1.createVariable('obs_Zgrid', 'd', ('datum',),zlib=myZLIB)
      v_obs_zgrid.long_name = 'z-grid observation location'
      v_obs_zgrid.units     = 'nondimensional'
#.........这里部分代码省略.........
开发者ID:trondkr,项目名称:NS8KM-ROMS,代码行数:103,代码来源:writeObsfile.py

示例4: createinitfile

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import type [as 别名]
def createinitfile(confM2R, ntime, var, data1=None, data2=None, data3=None, data4=None):
    # Create initial file for use with ROMS. This is the same as extracting time 0 from
    # the climatology file.
    if (confM2R.myformat == 'NETCDF4'):
        myzlib = True
    else:
        myzlib = False

    grdROMS = confM2R.grdROMS

    if not grdROMS.ioInitInitialized:
        grdROMS.ioInitInitialized = True
        if os.path.exists(confM2R.initname):
            os.remove(confM2R.initname)

        f1 = Dataset(confM2R.initname, mode='w', format=confM2R.myformat)
        f1.title = "Initial forcing file (INIT) used for foring of the ROMS model"
        f1.description = "Created for the %s grid file" % (confM2R.romsgridpath)
        f1.grd_file = "Gridfile: %s" % (confM2R.romsgridpath)
        f1.history = "Created " + time.ctime(time.time())
        f1.source = "Trond Kristiansen ([email protected])"
        f1.type = "File in %s format created using MODEL2ROMS" % (confM2R.myformat)
        f1.link = "https://github.com/trondkr/model2roms"
        f1.Conventions = "CF-1.0"

        # Define dimensions
        f1.createDimension('xi_rho', grdROMS.xi_rho)
        f1.createDimension('eta_rho', grdROMS.eta_rho)
        f1.createDimension('xi_u', grdROMS.xi_u)
        f1.createDimension('eta_u', grdROMS.eta_u)
        f1.createDimension('xi_v', grdROMS.xi_v)
        f1.createDimension('eta_v', grdROMS.eta_v)
        f1.createDimension('xi_psi', grdROMS.xi_psi)
        f1.createDimension('eta_psi', grdROMS.eta_psi)
        f1.createDimension('ocean_time', None)
        f1.createDimension('s_rho', len(grdROMS.s_rho))
        f1.createDimension('s_w', len(grdROMS.s_w))

        vnc = f1.createVariable('lon_rho', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Longitude of RHO-points'
        vnc.units = 'degree_east'
        vnc.standard_name = 'longitude'
        vnc[:, :] = grdROMS.lon_rho

        vnc = f1.createVariable('lat_rho', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Latitude of RHO-points'
        vnc.units = 'degree_north'
        vnc.standard_name = 'latitude'
        vnc[:, :] = grdROMS.lat_rho

        vnc = f1.createVariable('lon_u', 'd', ('eta_u', 'xi_u',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Longitude of U-points'
        vnc.units = 'degree_east'
        vnc.standard_name = 'longitude'
        vnc[:, :] = grdROMS.lon_u

        vnc = f1.createVariable('lat_u', 'd', ('eta_u', 'xi_u',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Latitude of U-points'
        vnc.units = 'degree_north'
        vnc.standard_name = 'latitude'
        vnc[:, :] = grdROMS.lat_u

        vnc = f1.createVariable('lon_v', 'd', ('eta_v', 'xi_v',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Longitude of V-points'
        vnc.units = 'degree_east'
        vnc.standard_name = 'longitude'
        vnc[:, :] = grdROMS.lon_v

        vnc = f1.createVariable('lat_v', 'd', ('eta_v', 'xi_v',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Latitude of V-points'
        vnc.units = 'degree_north'
        vnc.standard_name = 'latitude'
        vnc[:, :] = grdROMS.lat_v

        vnc = f1.createVariable('lat_psi', 'd', ('eta_psi', 'xi_psi',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Latitude of PSI-points'
        vnc.units = 'degree_north'
        vnc.standard_name = 'latitude'
        vnc[:, :] = grdROMS.lat_psi

        vnc = f1.createVariable('lon_psi', 'd', ('eta_psi', 'xi_psi',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Longitude of PSI-points'
        vnc.units = 'degree_east'
        vnc.standard_name = 'longitude'
        vnc[:, :] = grdROMS.lon_psi

        vnc = f1.createVariable('h', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Final bathymetry at RHO points'
        vnc.units = 'meter'
        vnc.field = "bath, scalar"
        vnc[:, :] = grdROMS.h

        vnc = f1.createVariable('s_rho', 'd', ('s_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = "S-coordinate at RHO-points"
        vnc.valid_min = -1.
        vnc.valid_max = 0.
        vnc.positive = "up"
        if grdROMS.vtransform == 2:
            vnc.standard_name = "ocean_s_coordinate_g2"
            vnc.formula_terms = "s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc"
#.........这里部分代码省略.........
开发者ID:trondkr,项目名称:model2roms,代码行数:103,代码来源:IOinitial.py

示例5: createNetCDFFileUV

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import type [as 别名]
def createNetCDFFileUV(grdROMS, outfilename, myformat, mytype):

    if (myformat=='NETCDF4'):
        myzlib = True
    else:
        myzlib = False

    if os.path.exists(outfilename):
        os.remove(outfilename)
    print(('Creating atmospheric forcing file for UV wind - %s'%(outfilename)))

    f1 = Dataset(outfilename, mode='w', format=myformat)
    f1.title="Atmospheric frocing file used by the ROMS model"
    f1.description="Created for the %s grid file"%(grdROMS.grdName)
    f1.grdFile="%s"%(grdROMS.grdfilename)
    f1.history = 'Created ' + time.ctime(time.time())
    f1.source = 'Trond Kristiansen ([email protected])'
    f1.type = "File in %s format created using MODEL2ROMS"%(myformat)
    f1.link = "https://github.com/trondkr/model2roms"
    f1.Conventions = "CF-1.0"

    """ Define dimensions """
    f1.createDimension('xi_rho',  grdROMS.xi_rho)
    f1.createDimension('eta_rho', grdROMS.eta_rho)
    f1.createDimension('wind_time', None)
    
    vnc = f1.createVariable('lon_rho', 'd', ('eta_rho','xi_rho',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Longitude of RHO-points'
    vnc.units = 'degree_east'
    vnc.standard_name = 'longitude'
    vnc[:,:] = grdROMS.lon_rho

    vnc = f1.createVariable('lat_rho', 'd', ('eta_rho','xi_rho',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Latitude of RHO-points'
    vnc.units = 'degree_north'
    vnc.standard_name = 'latitude'
    vnc[:,:] = grdROMS.lat_rho

    v_time = f1.createVariable('wind_time', 'd', ('wind_time',),zlib=myzlib, fill_value=grdROMS.fill_value)
    
    if mytype == "NORESM":
        v_time.long_name = 'Days since 1800-01-01 00:00:00'
        v_time.units = 'Days since 1800-01-01 00:00:00'
    else:
        v_time.long_name = 'Days since 1948-01-01 00:00:00'
        v_time.units = 'Days since 1948-01-01 00:00:00'
    v_time.field = 'time, scalar, series'
    v_time.calendar='noleap'

    v_temp_west=f1.createVariable('Vwind', 'f', ('wind_time', 'eta_rho', 'xi_rho',),zlib=myzlib, fill_value=grdROMS.fill_value)
    v_temp_west.long_name = "Eta-component of wind"
    v_temp_west.units = "meter second-1"
    v_temp_west.field = "Vwind, scalar, series"
    v_temp_west.missing_value = grdROMS.fill_value
    v_temp_west.time = "wind_time"

    v_temp_west=f1.createVariable('Uwind', 'f', ('wind_time', 'eta_rho', 'xi_rho',),zlib=myzlib, fill_value=grdROMS.fill_value)
    v_temp_west.long_name = "Xi-component of wind"
    v_temp_west.units = "meter second-1"
    v_temp_west.field = "Uwind, scalar, series"
    v_temp_west.missing_value = grdROMS.fill_value
    v_temp_west.time = "wind_time"

    f1.close()
开发者ID:trondkr,项目名称:model2roms,代码行数:66,代码来源:IOatmos.py

示例6: writeclimfile

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import type [as 别名]
def writeclimfile(confM2R, ntime, myvar, data1=None, data2=None, data3=None, data4=None):
    if confM2R.myformat == 'NETCDF4':
        myzlib = True
    else:
        myzlib = False

    grdROMS = confM2R.grdROMS

    if confM2R.grdROMS.ioClimInitialized is False:
        confM2R.grdROMS.ioClimInitialized = True
        if os.path.exists(confM2R.climname):
            os.remove(confM2R.climname)

        f1 = Dataset(confM2R.climname, mode='w', format=confM2R.myformat)
        f1.title = "Climatology forcing file (CLIM) used for forcing the ROMS model"
        f1.description = "Created for grid file: %s" % (confM2R.romsgridpath)
        f1.grd_file = "Gridfile: %s" % (confM2R.romsgridpath)
        f1.history = "Created " + time.ctime(time.time())
        f1.source = "{} ({})".format(confM2R.authorname,confM2R.authoremail)
        f1.type = "File in %s format created using MODEL2ROMS" % (confM2R.myformat)
        f1.link = "https://github.com/trondkr/model2roms"
        f1.Conventions = "CF-1.0"

        # Define dimensions
        f1.createDimension('xi_rho', grdROMS.xi_rho)
        f1.createDimension('eta_rho', grdROMS.eta_rho)
        f1.createDimension('xi_u', grdROMS.xi_u)
        f1.createDimension('eta_u', grdROMS.eta_u)
        f1.createDimension('xi_v', grdROMS.xi_v)
        f1.createDimension('eta_v', grdROMS.eta_v)
        f1.createDimension('xi_psi', grdROMS.xi_psi)
        f1.createDimension('eta_psi', grdROMS.eta_psi)
        f1.createDimension('s_rho', len(grdROMS.s_rho))
        f1.createDimension('s_w', len(grdROMS.s_w))
        if confM2R.isclimatology:
            f1.createDimension('clim_time', 12)
        else:
            f1.createDimension('ocean_time', None)

        vnc = f1.createVariable('lon_rho', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Longitude of RHO-points'
        vnc.units = 'degree_east'
        vnc.standard_name = 'longitude'
        vnc[:, :] = grdROMS.lon_rho

        vnc = f1.createVariable('lat_rho', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Latitude of RHO-points'
        vnc.units = 'degree_north'
        vnc.standard_name = 'latitude'
        vnc[:, :] = grdROMS.lat_rho

        vnc = f1.createVariable('lon_u', 'd', ('eta_u', 'xi_u',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Longitude of U-points'
        vnc.units = 'degree_east'
        vnc.standard_name = 'longitude'
        vnc[:, :] = grdROMS.lon_u

        vnc = f1.createVariable('lat_u', 'd', ('eta_u', 'xi_u',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Latitude of U-points'
        vnc.units = 'degree_north'
        vnc.standard_name = 'latitude'
        vnc[:, :] = grdROMS.lat_u

        vnc = f1.createVariable('lon_v', 'd', ('eta_v', 'xi_v',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Longitude of V-points'
        vnc.units = 'degree_east'
        vnc.standard_name = 'longitude'
        vnc[:, :] = grdROMS.lon_v

        vnc = f1.createVariable('lat_v', 'd', ('eta_v', 'xi_v',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Latitude of V-points'
        vnc.units = 'degree_north'
        vnc.standard_name = 'latitude'
        vnc[:, :] = grdROMS.lat_v

        vnc = f1.createVariable('lat_psi', 'd', ('eta_psi', 'xi_psi',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Latitude of PSI-points'
        vnc.units = 'degree_north'
        vnc.standard_name = 'latitude'
        vnc[:, :] = grdROMS.lat_psi

        vnc = f1.createVariable('lon_psi', 'd', ('eta_psi', 'xi_psi',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Longitude of PSI-points'
        vnc.units = 'degree_east'
        vnc.standard_name = 'longitude'
        vnc[:, :] = grdROMS.lon_psi

        vnc = f1.createVariable('h', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Bathymetry at RHO-points'
        vnc.units = 'meter'
        vnc.field = "bath, scalar"
        vnc[:, :] = grdROMS.h

        vnc = f1.createVariable('f', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
        vnc.long_name = 'Coriolis parameter at RHO-points'
        vnc.units = 'second-1'
        vnc.field = "Coriolis, scalar"
        vnc[:, :] = grdROMS.f

        vnc = f1.createVariable('pm', 'd', ('eta_rho', 'xi_rho',), zlib=myzlib, fill_value=grdROMS.fillval)
#.........这里部分代码省略.........
开发者ID:trondkr,项目名称:model2roms,代码行数:103,代码来源:IOwrite.py

示例7: writeStationNETCDF4

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import type [as 别名]
def writeStationNETCDF4(t,s,uvel,vvel,ssh,taux,tauy,ntime,depth,lat,lon,outfilename):
       
    if os.path.exists(outfilename):
        os.remove(outfilename)
    print(('Writing first results to file %s'%(outfilename)))
    
    f1 = Dataset(outfilename, mode='w', format='NETCDF4')
    f1.description="This is a station (lat=%3.2f,lon=%3.2f) file from SODA data"%(lat,lon)
    f1.history = 'Created ' + time.ctime(time.time())
    f1.source = 'Trond Kristiansen ([email protected])'
    f1.type='NetCDF4 time-depth file created using SODA2ROMS' 
       
    f1.createDimension('time', len(ntime))
    f1.createDimension('z', len(depth))
  
    v=f1.createVariable('lon','d')
    v.long_name = "Longitude position of station" ;
    v.units = "Longitude"
    v[:]=lon
    
    v=f1.createVariable('lat','d', zlib=True)
    v.long_name = "Latitude position of station" ;
    v.units = "Latitude"
    v[:]=lat
    
    v=f1.createVariable('depth','d',('z',), zlib=True)
    v.long_name = "Z-depth matrix" ;
    v.units = "meter"
    v[:]=depth
     
    v_time = f1.createVariable('time', 'd', ('time',), zlib=True)
    v_time.long_name = 'Days since 1948-01-01 00:00:00'
    v_time.units = 'days'
    v_time.field = 'time, scalar, series'
    v_time.calendar='standard'
    v_time[:] = ntime
    
    v_temp=f1.createVariable('temp', 'f', ('time','z'), zlib=True)
    v_temp.long_name = "Ocean temperature"
    v_temp.units = "degrees Celsius"
    v_temp[:,:] = t
    
    v_salt=f1.createVariable('salt', 'f', ('time','z'), zlib=True)
    v_salt.long_name = "Ocean salinity"
    v_salt.units = "psu"
    v_salt[:,:]=s
    
    v_ssh=f1.createVariable('zeta','d',('time',), zlib=True)
    v_ssh.long_name = "Sea surface height (SSH)"
    v_ssh.units = "m"
    v_ssh[:] = ssh
    
    v_taux=f1.createVariable('taux','d',('time',), zlib=True)
    v_taux.long_name = "Wind stress in x direction"
    v_taux.units = "N/m^2"
    v_taux[:] = taux
    
    v_tauy=f1.createVariable('tauy','d',('time',), zlib=True)
    v_tauy.long_name = "Wind stress in y direction"
    v_tauy.units = "N/m^2"
    v_tauy[:] = tauy
    
    v_u=f1.createVariable('u', 'f', ('time','z'), zlib=True)
    v_u.long_name = "U-velocity, scalar, series"
    v_u.units = "m/s"
    v_u[:,:] = uvel
    
    v_v=f1.createVariable('v', 'f', ('time','z'), zlib=True)
    v_v.long_name = "V-velocity, scalar, series"
    v_v.units = "m/s"
    v_v[:,:] = vvel
        
    f1.close()
开发者ID:trondkr,项目名称:model2roms,代码行数:75,代码来源:IOstation.py

示例8: createBryFile

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import type [as 别名]
def createBryFile(grdROMS, outfilename, writeIce, mytype, myformat):

    if (myformat=='NETCDF4'):
        myzlib = True
    else:
        myzlib = False

    if os.path.exists(outfilename):
        os.remove(outfilename)
    print 'Creating initial Boundary (BRY) file %s'%(outfilename)

    f1 = Dataset(outfilename, mode='w', format=myformat)
    f1.title="Boundary forcing file (BRY) used for forcing of the ROMS model"
    f1.description="Created for the %s grid file"%(grdROMS.grdName)
    f1.grdFile="%s"%(grdROMS.grdfilename)
    f1.history = 'Created ' + time.ctime(time.time())
    f1.source = 'Trond Kristiansen ([email protected])'
    f1.type = "File in %s format created using MODEL2ROMS"%(myformat)
    f1.link = "https://github.com/trondkr/model2roms"
    f1.Conventions = "CF-1.0"

    """ Define dimensions """
    f1.createDimension('xi_rho',  grdROMS.xi_rho)
    f1.createDimension('eta_rho', grdROMS.eta_rho)
    f1.createDimension('xi_u',    grdROMS.xi_u)
    f1.createDimension('eta_u',   grdROMS.eta_u)
    f1.createDimension('xi_v',    grdROMS.xi_v)
    f1.createDimension('eta_v',   grdROMS.eta_v)
    f1.createDimension('xi_psi',    grdROMS.xi_psi)
    f1.createDimension('eta_psi',   grdROMS.eta_psi)
    f1.createDimension('ocean_time', None)
    f1.createDimension('s_rho', len(grdROMS.s_rho))
    f1.createDimension('s_w', len(grdROMS.s_w))

    vnc = f1.createVariable('lon_rho', 'd', ('eta_rho','xi_rho',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Longitude of RHO-points'
    vnc.units = 'degree_east'
    vnc.standard_name = 'longitude'
    vnc[:,:] = grdROMS.lon_rho

    vnc = f1.createVariable('lat_rho', 'd', ('eta_rho','xi_rho',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Latitude of RHO-points'
    vnc.units = 'degree_north'
    vnc.standard_name = 'latitude'
    vnc[:,:] = grdROMS.lat_rho

    vnc = f1.createVariable('lon_u', 'd', ('eta_u','xi_u',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Longitude of U-points'
    vnc.units = 'degree_east'
    vnc.standard_name = 'longitude'
    vnc[:,:] = grdROMS.lon_u

    vnc = f1.createVariable('lat_u', 'd', ('eta_u','xi_u',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Latitude of U-points'
    vnc.units = 'degree_north'
    vnc.standard_name = 'latitude'
    vnc[:,:] = grdROMS.lat_u

    vnc = f1.createVariable('lon_v', 'd', ('eta_v','xi_v',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Longitude of V-points'
    vnc.units = 'degree_east'
    vnc.standard_name = 'longitude'
    vnc[:,:] = grdROMS.lon_v

    vnc = f1.createVariable('lat_v', 'd', ('eta_v','xi_v',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Latitude of V-points'
    vnc.units = 'degree_north'
    vnc.standard_name = 'latitude'
    vnc[:,:] = grdROMS.lat_v

    vnc = f1.createVariable('lat_psi', 'd', ('eta_psi','xi_psi',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Latitude of PSI-points'
    vnc.units = 'degree_north'
    vnc.standard_name = 'latitude'
    vnc[:,:] = grdROMS.lat_psi

    vnc = f1.createVariable('lon_psi', 'd', ('eta_psi','xi_psi',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = 'Longitude of PSI-points'
    vnc.units = 'degree_east'
    vnc.standard_name = 'longitude'
    vnc[:,:] = grdROMS.lon_psi

    vnc = f1.createVariable('h', 'd', ('eta_rho','xi_rho',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = "Bathymetry at RHO-points"
    vnc.units = "meter"
    vnc.coordinates ="lat_rho lon_rho"
    vnc.field = "bath, scalar"
    vnc[:,:] = grdROMS.h

    vnc = f1.createVariable('s_rho', 'd', ('s_rho',),zlib=myzlib, fill_value=grdROMS.fill_value)
    vnc.long_name = "S-coordinate at RHO-points"
    vnc.valid_min = -1.
    vnc.valid_max = 0.

    if grdROMS.vtransform==2:
        vnc.standard_name = "ocean_s_coordinate_g2"
        vnc.formula_terms = "s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc"
    if grdROMS.vtransform==1:
        vnc.standard_name = "ocean_s_coordinate_g1"
        vnc.formula_terms = "s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc"
#.........这里部分代码省略.........
开发者ID:raytl,项目名称:model2roms,代码行数:103,代码来源:IOBry.py


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