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


Python Dataset.references方法代码示例

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


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

示例1: netcdfPiomas

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import references [as 别名]
def netcdfPiomas(lats,lons,var,directory):
    name = 'piomas_regrid_March_19792015.nc'
    filename = directory + name
    ncfile = Dataset(filename,'w',format='NETCDF4')
    ncfile.description = 'PIOMAS Sea ice thickness reanalysis from 1979-2015 ' \
                        'interpolated on a 180x180 grid (latxlon)' \
                        'of NSIDC EASE100' 
    
    ### Dimensions
    ncfile.createDimension('years',var.shape[0])
    ncfile.createDimension('lat',var.shape[1])
    ncfile.createDimension('lon',var.shape[2])
    
    ### Variables
    years = ncfile.createVariable('years','f4',('years'))
    latitude = ncfile.createVariable('lat','f4',('lat','lat'))
    longitude = ncfile.createVariable('lon','f4',('lon','lon'))
    varns = ncfile.createVariable('thick','f4',('years','lat','lon'))
    
    ### Metrics
    varns.units = 'meters'
    ncfile.title = 'PIOMAS March SIT'
    ncfile.instituion = 'Dept. ESS at University of California, Irvine'
    ncfile.source = 'University of Washington'
    ncfile.references = '[Zhang and Rothrock, 2003]'
    
    ### Data
    years[:] = list(xrange(var.shape[0]))
    latitude[:] = lats
    longitude[:] = lons
    varns[:] = var
    
    ncfile.close()
    print 'Completed: Created netCDF4 File!'
开发者ID:zmlabe,项目名称:SeaIceThickness,代码行数:36,代码来源:calc_MarchSIT_timeseries.py

示例2: netcdfSIT

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import references [as 别名]
def netcdfSIT(lats,lons,var):
    directory = '/home/zlabe/Surtsey/seaice_obs/Thk/March/'
    name = 'icesatG_regrid_March_20032008.nc'
    filename = directory + name
    ncfile = Dataset(filename,'w',format='NETCDF4')
    ncfile.description = 'Sea ice thickness processed by NASA-G and now' \
                         'regridded on an EASE2.0 100 km grid for the' \
                         'period of March 2003-2008'
    
    ### Dimensions
    ncfile.createDimension('years',var.shape[0])
    ncfile.createDimension('lat',var.shape[1])
    ncfile.createDimension('lon',var.shape[2])
    
    ### Variables
    years = ncfile.createVariable('years','f4',('years'))
    latitude = ncfile.createVariable('lat','f4',('lat','lat'))
    longitude = ncfile.createVariable('lon','f4',('lon','lon'))
    varns = ncfile.createVariable('sit','f4',('years','lat','lon'))
    
    ### Units
    varns.units = 'meters'
    ncfile.title = 'ICESat-G'
    ncfile.instituion = 'Dept. ESS at University of California, Irvine'
    ncfile.source = 'NASA-G'
    ncfile.references = 'Donghui Yi, H. Zwally'
    
    ### Data
    years[:] = list(xrange(var.shape[0]))
    latitude[:] = lats
    longitude[:] = lons
    varns[:] = var
    
    ncfile.close()
    print 'Completed: Created netCDF4 File!'
开发者ID:zmlabe,项目名称:SeaIceThickness,代码行数:37,代码来源:calc_IcesatG.py

示例3: new

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import references [as 别名]
    def new(self, secs):
        """
        Creates a new seNorge netCDF file.
        Convention: Climate and Forecast (CF) version 1.4
        
        @param secs: in seconds since 1970-01-01 00:00:00
        """
        # create new file
        rootgrp = Dataset(self.filename, 'w') # create new file using netcdf4
#        rootgrp = netcdf_file(self.filename, 'w') # create new file using scipy.IO
        
        # add root dimensions
        rootgrp.createDimension('time', size=self.default_senorge_time)
        rootgrp.createDimension('x', size=self.default_senorge_width)
        rootgrp.createDimension('y', size=self.default_senorge_height)
        
        # add root attributes
        rootgrp.Conventions = "CF-1.4"
        rootgrp.institution = "Norwegian Water Resources and Energy Directorate (NVE)"
        rootgrp.source = ""
        rootgrp.history = ""
        rootgrp.references = ""
        rootgrp.comment = "Data distributed via www.senorge.no"
        
        self.rootgrp = rootgrp
        
        # add coordinates
        time = self.rootgrp.createVariable('time', 'f8', ('time',))
        time.units = 'seconds since 1970-01-01 00:00:00 +00:00'
        time.long_name = 'time'
        time.standard_name = 'time'
        time[:] = secs
        
        self._set_utm()
        self._set_latlon()
开发者ID:Monte-Carlo,项目名称:pysenorge-1,代码行数:37,代码来源:_io.py

示例4: netcdfSatelliteG

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import references [as 别名]
def netcdfSatelliteG(lats,lons,var,directory):
    name = 'satelliteG_regrid_March_20032015.nc'
    filename = directory + name
    ncfile = Dataset(filename,'w',format='NETCDF4')
    ncfile.description = 'Satellite data for ICESat-G (2003-2008) and' \
                         'CryoSat-2 (2011-2015) that have been regridded' \
                         'on 180x180 EASE2.0 100km grids. Years 2009-2010 are' \
                         'available in the data but have been filled with' \
                         'nan values to be inclusive. Shape is therefore' \
                         '[13,180,180]'
    
    ### Dimensions
    ncfile.createDimension('years',var.shape[0])
    ncfile.createDimension('lat',var.shape[1])
    ncfile.createDimension('lon',var.shape[2])
    
    ### Variables
    years = ncfile.createVariable('years','f4',('years'))
    latitude = ncfile.createVariable('lat','f4',('lat','lat'))
    longitude = ncfile.createVariable('lon','f4',('lon','lon'))
    varns = ncfile.createVariable('thick','f4',('years','lat','lon'))
    
    ### Metrics
    varns.units = 'meters'
    ncfile.title = 'ICESat_G/CryoSat March SIT'
    ncfile.instituion = 'Dept. ESS at University of California, Irvine'
    ncfile.source = 'NASA-G/ESA Products'
    ncfile.references = 'Donghui Yi, H. Zwally, S. Laxon'
    
    ### Data
    years[:] = list(xrange(var.shape[0]))
    latitude[:] = lats
    longitude[:] = lons
    varns[:] = var
    
    ncfile.close()
    print 'Completed: Created netCDF4 File!'
开发者ID:zmlabe,项目名称:SeaIceThickness,代码行数:39,代码来源:calc_MarchSIT_timeseries.py

示例5: len

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import references [as 别名]
    conusmask[:] = conusmask_ccpa

    thrnumv[:] = xc[:]
    thrvalv[:] = thresh[:]
 
    rootgrp.latcorners = [lats_anal[0,0], lats_anal[0,-1], lats_anal[-1,0], lats_anal[-1,-1]]
    rootgrp.loncorners = [lons_anal[0,0], lons_anal[0,-1], lons_anal[-1,0], lons_anal[-1,-1]]

    rootgrp.stream = "s4" # ????
    rootgrp.title = "Reforecast V2 accum. ensemble-mean precip forecast and analyzed CDF + rank correlation"
    rootgrp.Conventions = "CF-1.0"  # ????
    rootgrp.history = "Revised Mar 2016 by Hamill" 
    rootgrp.institution = \
        "Reforecast from ERSL/PSD using NCEP/EMC GEFS, circa 2012"
    rootgrp.platform = "Model" 
    rootgrp.references = "http://www.esrl.noaa.gov/psd/forecasts/reforecast2/" 
    
    # ---- open ensemble data file for each year, read in data, and augment cdf 
    #      information for that year if the sample is within the month of interest
    #      or the neighboring month

    rankcorr_fa = -99.99*np.ones((nja,nia),dtype=np.float)    
    nyears = len(range(2002,2016))
    print 'nsamps = ',92*nyears
    precipa = np.zeros((nja,nia),dtype=np.float)
    precipf3d = np.zeros((92*nyears,njf,nif),dtype=np.float)
    precipa3d = np.zeros((92*nyears,nja,nia),dtype=np.float)
    ipktr = 0

    infilename = input_data_directory+'/refcstv2_precip_ccpav3_'+\
       cleadb+'_to_'+cleade+'.nc'
开发者ID:ThomasMoreHamill,项目名称:analog,代码行数:33,代码来源:compute_precip_CCPAgrid_cdfs.py

示例6: create_uGrid_ncdf

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import references [as 别名]
def create_uGrid_ncdf(filename,
                        nMesh2_node, nMesh2_edge, nMesh2_face, nMaxMesh2_face_nodes,
                        Mesh2_edge_nodes, Mesh2_edge_faces, Mesh2_face_nodes, Mesh2_face_edges,
                        Mesh2_node_x, Mesh2_node_y, Mesh2_edge_x, Mesh2_edge_y,
                        Mesh2_face_x, Mesh2_face_y, Mesh2_face_center_x, Mesh2_face_center_y,
                        Mesh2_face_area=None,
                        Mesh2_edge_x_bnd=None, Mesh2_edge_y_bnd=None,
                        Mesh2_face_x_bnd=None, Mesh2_face_y_bnd=None,
                        coord_type='geographic',
                        dim_nMesh2_layer2d=1, dim_nMesh2_layer3d=1, dim_nMesh2_class_names_strlen=20, dim_nMesh2_suspension_classes=1,
                        start_index=0,
                        log=True):
    '''
    Function creates a NETCDF4 file. Data is stored in accordance with
    BAW convention for 2D Unstructured Grid (http://www.baw.de/methoden/index.php5/NetCDF_Unstrukturiertes_Gitter)
    
    input:
        filename - string, containing filename of netcdf file to be created.
        nMesh2_node, nMesh2_edge, nMesh2_face - integers, indicating number of nodes/edges/faces in a grid
        nMaxMesh2_face_nodes - integer, showing maximum number of nodes/edges in a face (could be 3 or 4)

        Mesh2_edge_nodes, Mesh2_edge_faces, Mesh2_face_nodes, Mesh2_face_edges,     |
        Mesh2_node_x, Mesh2_node_y, Mesh2_edge_x, Mesh2_edge_y,                     | => 1D numpy arrays with data
        Mesh2_face_x, Mesh2_face_y, Mesh2_face_center_x, Mesh2_face_center_y,       |
        Mesh2_face_area                                                             |

        coord_type  - string indicating in which variable to store passed data, in x,y or in lon,lat
                by default - 'geographic'
                'cartesian' <> 'geographic'
    '''


    # --------------------------------------------------
    #                   Creating ncdf
    # --------------------------------------------------
    root_grp = Dataset(filename, mode='w', format='NETCDF4')

    root_grp.title = 'mossco >>> uGrid conversion'
    root_grp.history = 'Createded on ' + time.ctime(time.time())
    #root_grp.comment = 'WARNING! Latitude and longitude valueas are stored as X,Y coordinates. Therefore any calculations that involve length or area in X or Y dimension are wrong'
    root_grp.Conventions = 'CF-1.6'
    #root_grp.institution = 'Bundesanstalt fuer Wasserbau - Federal Waterways Engineering and Research Institute'
    root_grp.references = 'http://www.baw.de/ und http://www.baw.de/methoden/index.php5/NetCDF'
    #root_grp.source = ''



    # --------------------------------------------------
    #                   Creating dimensions
    # --------------------------------------------------
    root_grp.createDimension('nMesh2_node', nMesh2_node)
    root_grp.createDimension('nMesh2_edge', nMesh2_edge)
    root_grp.createDimension('nMesh2_face', nMesh2_face)
    root_grp.createDimension('nMaxMesh2_face_nodes', nMaxMesh2_face_nodes)
    root_grp.createDimension('two', 2)
    root_grp.createDimension('three', 3)
    root_grp.createDimension('nMesh2_time', 1)
    root_grp.createDimension('nMesh2_data_time', None)  # None stands for UNLIMITED
    if dim_nMesh2_layer2d is not None:
        root_grp.createDimension('nMesh2_layer_2d', dim_nMesh2_layer2d)
    if dim_nMesh2_layer3d is not None:
        root_grp.createDimension('nMesh2_layer_3d', dim_nMesh2_layer3d)
    root_grp.createDimension('nMesh2_class_names_strlen', dim_nMesh2_class_names_strlen)
    root_grp.createDimension('nMesh2_suspension_classes', dim_nMesh2_suspension_classes)

    if coord_type in ['cartesian', 'both'] :
        # **********************************************************************************************************************************************
        #
        #                  1) Local coordinates
        #
        # **********************************************************************************************************************************************
        # --------------------------------------------------
        #                                   1.1) NODES
        # --------------------------------------------------

        ncVar_Mesh2_node_x = root_grp.createVariable('Mesh2_node_x', 'f8', ('nMesh2_node'), fill_value=False)
        ncVar_Mesh2_node_x.long_name = 'x-Koordinate der Knoten eines 2D-Gitters'
        ncVar_Mesh2_node_x.units = 'm'
        ncVar_Mesh2_node_x.name_id = 1650
        ncVar_Mesh2_node_x.standard_name = 'projection_x_coordinate'
        ncVar_Mesh2_node_x[:] = Mesh2_node_x[:]

        ncVar_Mesh2_node_y = root_grp.createVariable('Mesh2_node_y', 'f8', ('nMesh2_node'), fill_value=False)
        ncVar_Mesh2_node_y.long_name = 'y-Koordinate der Knoten eines 2D-Gitters'
        ncVar_Mesh2_node_y.units = 'm'
        ncVar_Mesh2_node_y.name_id = 1651
        ncVar_Mesh2_node_y.standard_name = 'projection_y_coordinate'
        ncVar_Mesh2_node_y[:] = Mesh2_node_y[:]

        # --------------------------------------------------
        #                                   1.2) EDGES
        # --------------------------------------------------

        ncVar_Mesh2_edge_x = root_grp.createVariable('Mesh2_edge_x', 'f8', ('nMesh2_edge'), fill_value=False)
        ncVar_Mesh2_edge_x.long_name = 'x-Koordinate der Kanten eines 2D-Gitters, Kantenmitte'
        ncVar_Mesh2_edge_x.units = 'm'
        ncVar_Mesh2_edge_x.name_id = 1650
        ncVar_Mesh2_edge_x.bounds = 'Mesh2_edge_x_bnd'
        ncVar_Mesh2_edge_x.standard_name = 'projection_x_coordinate'
        ncVar_Mesh2_edge_x[:] = Mesh2_edge_x[:]
#.........这里部分代码省略.........
开发者ID:cdd1969,项目名称:convert2ugrid,代码行数:103,代码来源:process_davit_ncdf.py

示例7: cloneUM4

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import references [as 别名]
def cloneUM4(masterfile, newfile, startdate="copy", tn=24, dt=3600.0):
    """
    Creates a new UM4 netCDF file based on a master file.
    
    Convention: Climate and Forecast (CF) version 1.4
    
    @param secs: in seconds since 1970-01-01 00:00:00
    """
    print "Started cloning %s as %s" % (masterfile, newfile)

    # open master file
    master = Dataset(masterfile, "r")
    Mdimensions = master.dimensions.keys()

    # create new file
    rootgrp = Dataset(newfile, "w", format="NETCDF3_CLASSIC")

    # add root dimensions
    rootgrp.createDimension("time", size=tn)
    rootgrp.createDimension("rlon", size=default_UM4_width)
    rootgrp.createDimension("rlat", size=default_UM4_height)
    rootgrp.createDimension("sigma", size=1)

    # add root attributes
    rootgrp.Conventions = "CF-1.4"
    rootgrp.institution = "Norwegian Water Resources and Energy Directorate (NVE)"
    rootgrp.source = "Compiled from several +66 hour prognoses by the Norwegian Meteorological Institute (met.no)"
    rootgrp.history = "%s created" % time.ctime(time.time())
    rootgrp.references = "met.no"
    rootgrp.comment = "Progonosis data for www.senorge.no"

    # add time variable
    Mtime = master.variables["time"]
    # determine start date
    try:
        _end = date2num(iso2datetime(startdate), timeunit)
        _start = _end - ((tn - 1) * dt)
    except ValueError:
        # if the startdate is set to "copy" use the date of the last input file
        Mdate = num2date(Mtime[0], timeunit).date()
        utc6 = datetime.time(06, 00, 00)
        _end = date2num(datetime.datetime.combine(Mdate, utc6), timeunit)
        _start = _end - ((tn - 1) * dt)
        print (_end - _start) / dt
    _time = rootgrp.createVariable("time", "f8", ("time",))
    _time[:] = arange(_start, _end + dt, dt)  # ensures that _end is included
    for attr in Mtime.ncattrs():
        _time.setncattr(attr, Mtime.getncattr(attr))

    # add rlon variable
    Mrlon = master.variables["rlon"]
    _rlon = rootgrp.createVariable("rlon", "f4", ("rlon",))
    _rlon[:] = Mrlon[:]
    for attr in Mrlon.ncattrs():
        _rlon.setncattr(attr, Mrlon.getncattr(attr))

    # add rlat variable
    Mrlat = master.variables["rlat"]
    _rlat = rootgrp.createVariable("rlat", "f4", ("rlat",))
    _rlat[:] = Mrlat[:]
    for attr in Mrlat.ncattrs():
        _rlat.setncattr(attr, Mrlat.getncattr(attr))

    # add sigma variable
    try:
        Msigma = master.variables["sigma"]
        _sigma = rootgrp.createVariable("sigma", "i2", ("sigma",))
        _sigma[:] = Msigma[:]
        for attr in Msigma.ncattrs():
            _sigma.setncattr(attr, Msigma.getncattr(attr))
    except KeyError:
        print "No variable called 'sigma'!"

    for var in master.variables.keys():
        # exclude the variables referring to dimensions
        if var not in Mdimensions:
            exec ("M%s = master.variables['%s']" % (var, var))
            exec ("print 'Cloning %s', master.variables['%s'].dimensions" % (var, var))
            exec ("_%s = rootgrp.createVariable('%s', M%s.dtype, M%s.dimensions)" % (var, var, var, var))
            exec ("""for attr in M%s.ncattrs():\n\t_%s.setncattr(attr, M%s.getncattr(attr))""" % (var, var, var))

    rootgrp.close()
    master.close()
    print "Cloning completed!"
开发者ID:NVE,项目名称:pysenorge,代码行数:86,代码来源:clone_netCDF.py

示例8: Dataset

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import references [as 别名]
# Assume that /projects/CHARIS is sshfs mounted on this machine, and
# that the user has write permission
fid = Dataset('~/projects/CHARIS/snow_cover/modice.v0.4/min05yr_nc/MODICE.v0.4.1test.nc', 'w', format='NETCDF4')
fid.Conventions = "CF-1.6"
fid = Dataset('/home/vagrant/measures-byu/src/prod/cetb_file/templates/cetb_global_template.nc', 'w', format='NETCDF4')
fid.Conventions = "CF-1.6"
fid.title = "MODICE mask for a minimum number of years"
fid.product_version = "v0.4"
#fid.software_version_id = "TBD"
#fid.software_repository = "[email protected]:nsidc/measures-byu.git"
fid.source = "MODICE"
fid.source_version_id = "v04"
fid.history = ""
fid.comment = "Mask locations with 2 indicate MODICE for >= min_years."
fid.references = "Painter, T. H., Brodzik, M. J., A. Racoviteanu, R. Armstrong. 2012. Automated mapping of Earth's annual minimum exposed snow and ice with MODIS. Geophysical Research Letters, 39(20):L20501, doi:10.1029/2012GL053340."
fid.summary = ["An improved, enhanced-resolution, gridded passive microwave Earth System Data Record \n",
               "for monitoring cryospheric and hydrologic time series\n" ]fid.title = "MEaSUREs Calibrated Passive Microwave Daily EASE-Grid 2.0 Brightness Temperature ESDR"
fid.institution = ["National Snow and Ice Data Center\n",
                   "Cooperative Institute for Research in Environmental Sciences\n",
                   "University of Colorado at Boulder\n",
                   "Boulder, CO"]
fid.publisher = ["National Snow and Ice Data Center\n",
                   "Cooperative Institute for Research in Environmental Sciences\n",
                   "University of Colorado at Boulder\n",
                   "Boulder, CO"]
fid.publisher_url = "http://nsidc.org/charis"
fid.publisher_email = "[email protected]"
fid.project = "CHARIS"
fid.standard_name_vocabulary = "CF Standard Name Table (v27, 28 September 2013)"
fid.cdm_data_type = "grid"
开发者ID:mjbrodzik,项目名称:ipython_notebooks,代码行数:32,代码来源:make_MODICEv04_min05yr_netcdf.py

示例9: Dataset

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import references [as 别名]
        # --------------------------
        # Create output NetCDF file
        # --------------------------
        if os.path.exists(outfilename): os.remove(outfilename)
        f1 = Dataset(outfilename, mode='w', format='NETCDF4_CLASSIC')

        # Global attributes
        f1.Conventions = "CF-1.6"
        f1.title = "Monthly-mean (full water column) fields"
        f1.history = "Simulations were done using a 8x8 km polar stereographic grid projection, however the final " \
                     "data are presented using a reference grid. Conversion between grid " \
                     "projectionsby grid2lonlatZ.py"
        f1.source = "IMR, ROMSv3.7, IS4DVAR, NorthSea-8km reanalysis"
        f1.institution = "Institute of Marine Research, Norway"
        f1.references = "http://www.imr.no"
        f1.product_version = "1.0"
        f1.contact = "[email protected]"
        f1.netcdf_version_id = "netCDF-4 Classic"
        # Define dimensions
        f1.createDimension('time', None)
        f1.createDimension('depth', len(outlevels))
        f1.createDimension('longitude', len(lon))
        f1.createDimension('latitude', len(lat))

        v = f1.createVariable('time', 'd', ('time',))
        v0 = f0.variables['time']
        v.long_name = 'time'
        v.units = "Days since 1948-01-01 00:00:00"
        v.calendar = "Gregorian"
开发者ID:trondkr,项目名称:NS8KM-ROMS,代码行数:31,代码来源:grid2lonlatZ.py


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