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


Python Dataset.featureType方法代码示例

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


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

示例1: tamoc_nc_file

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import featureType [as 别名]
def tamoc_nc_file(fname, title, summary, source):
    """
    Write the header meta data to an netCDF file for a TAMOC output
    
    The TAMOC suite stores its output by detaul in a netCDF dataset file.  
    This function writes the standard TAMOC metadata to the header of the 
    netCDF file.  
    
    Parameters
    ----------
    fname : str
        File name of the file to write
    title:  str
        String stating the TAMOC module where the data originated and the 
        type of data contained.  
    summary : str
        String summarizing what is contained in the dataset or information
        needed to interpret the dataset
    source : str
        String describing the source of the data in the dataset or of related
        datasets
    
    Returns
    -------
    nc : `netCDF4.Dataset` object
        The `netCDF4.Dataset` object containing the open netCDF4 file where
        the data should be stored.
    
    """
    
    # Create the netCDF dataset object
    nc = Dataset(fname, 'w', format='NETCDF4_CLASSIC')
    
    # Write the netCDF header data for a TAMOC suite output
    nc.Conventions = 'TAMOC Modeling Suite Output File'
    nc.Metadata_Conventions = 'TAMOC Python Model'
    nc.featureType = 'profile'
    nc.cdm_data_type = 'Profile'
    nc.nodc_template_version = \
        'NODC_NetCDF_Profile_Orthogonal_Template_v1.0'
    nc.title = title
    nc.summary = summary
    nc.source = source
    nc.creator_url = 'http://github.com/socolofs/tamoc'
    nc.date_created = datetime.today().isoformat(' ')
    nc.date_modified = datetime.today().isoformat(' ')
    nc.history = 'Creation'
    
    # Return the netCDF dataset
    return nc
开发者ID:socolofs,项目名称:tamoc,代码行数:52,代码来源:model_share.py

示例2: write_param_file

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import featureType [as 别名]
def write_param_file(
    file_name,
    nc_format="NETCDF3_CLASSIC",
    glob_atts=NcGlobals(),
    full_time_length=None,
    subset_length=None,
    unit_hydrograph_dt=None,
    outlet_lon=None,
    outlet_lat=None,
    outlet_x_ind=None,
    outlet_y_ind=None,
    outlet_decomp_ind=None,
    outlet_number=None,
    outlet_mask=None,
    outlet_name=None,
    outlet_upstream_gridcells=None,
    outlet_upstream_area=None,
    source_lon=None,
    source_lat=None,
    source_x_ind=None,
    source_y_ind=None,
    source_decomp_ind=None,
    source_time_offset=None,
    source2outlet_ind=None,
    unit_hydrograph=None,
    zlib=True,
    complevel=4,
    least_significant_digit=None,
):

    """Write a standard RVIC Parameter file """

    # ---------------------------------------------------------------- #
    # netCDF variable options
    ncvaropts = {"zlib": zlib, "complevel": complevel, "least_significant_digit": least_significant_digit}
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # Open file
    f = Dataset(file_name, "w", format=nc_format)
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # Time Variables

    # Timesteps
    timesteps = f.createDimension("timesteps", subset_length)
    timesteps = f.createVariable("timesteps", NC_DOUBLE, ("timesteps",), **ncvaropts)
    timesteps[:] = np.arange(subset_length)
    for key, val in iteritems(share.timesteps):
        if val:
            setattr(timesteps, key, val.encode())
    timesteps.timestep_length = b"unit_hydrograph_dt"

    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # write global attributes
    glob_atts.update()
    for key, val in iteritems(glob_atts.atts):
        if val:
            setattr(f, key, val.encode())
    f.featureType = b"timeSeries"
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # 0-D variables

    # Full time length (size of ring)
    ftl = f.createVariable("full_time_length", NC_INT, (), **ncvaropts)
    ftl[:] = full_time_length
    for key, val in iteritems(share.full_time_length):
        if val:
            setattr(ftl, key, val.encode())

    # Subset Length
    sl = f.createVariable("subset_length", NC_INT, (), **ncvaropts)
    sl[:] = subset_length
    for key, val in iteritems(share.subset_length):
        if val:
            setattr(sl, key, val.encode())

    # UH timestep
    uh_dt = f.createVariable("unit_hydrograph_dt", NC_DOUBLE, (), **ncvaropts)
    uh_dt[:] = unit_hydrograph_dt
    for key, val in iteritems(share.unit_hydrograph_dt):
        if val:
            setattr(uh_dt, key, val.encode())
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # Outlet Dimensions
    if outlet_y_ind.ndim == 0:
        numoutlets = 1
        outlet_name = np.array([outlet_name])
    else:
        numoutlets = len(outlet_lon)
    ocoords = ("outlets",)
    f.createDimension(ocoords[0], numoutlets)

#.........这里部分代码省略.........
开发者ID:mbaptiste,项目名称:RVIC,代码行数:103,代码来源:write.py

示例3: __write_array

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

#.........这里部分代码省略.........
                                **self.ncvaropts)
        time[:] = self._out_times[:self._out_data_i+1]
        for key, val in share.time.__dict__.iteritems():
            if val:
                setattr(time, key, val)
        time.calendar = self._calendar

        if self._avgflag != 'I':
            nv = f.createDimension('nv', 2)

            time.bounds = 'time_bnds'

            time_bnds = f.createVariable('time_bnds', self._ncprec,
                                         ('time', 'nv',), **self.ncvaropts)
            time_bnds[:, :] = self._out_time_bnds[:self._out_data_i+1]
        # ------------------------------------------------------------ #

        # ------------------------------------------------------------ #
        # Setup Coordinate Variables
        coords = ('outlets',)

        outlets = f.createDimension('outlets', self._num_outlets)

        nocoords = coords + ('nc_chars',)
        char_names = stringtochar(self._outlet_name)
        chars = f.createDimension(nocoords[1], char_names.shape[1])
        # ------------------------------------------------------------ #

        # ------------------------------------------------------------ #
        # Variables
        outlet_lon = f.createVariable('lon', self._ncprec, coords,
                                      **self.ncvaropts)
        outlet_lat = f.createVariable('lat', self._ncprec, coords,
                                      **self.ncvaropts)
        outlet_x_ind = f.createVariable('outlet_x_ind', NC_INT, coords,
                                        **self.ncvaropts)
        outlet_y_ind = f.createVariable('outlet_y_ind', NC_INT, coords,
                                        **self.ncvaropts)
        outlet_decomp_ind = f.createVariable('outlet_decomp_ind', NC_INT,
                                             coords, **self.ncvaropts)
        onm = f.createVariable('outlet_name', NC_CHAR, nocoords,
                               **self.ncvaropts)

        outlet_lon[:] = self._outlet_lon
        outlet_lat[:] = self._outlet_lat
        outlet_x_ind[:] = self._outlet_x_ind
        outlet_y_ind[:] = self._outlet_y_ind
        outlet_decomp_ind[:] = self._outlet_decomp_ind
        onm[:, :] = char_names

        for key, val in share.outlet_lon.__dict__.iteritems():
            if val:
                setattr(outlet_lon, key, val)

        for key, val in share.outlet_lat.__dict__.iteritems():
            if val:
                setattr(outlet_lat, key, val)

        for key, val in share.outlet_y_ind.__dict__.iteritems():
            if val:
                setattr(outlet_y_ind, key, val)

        for key, val in share.outlet_x_ind.__dict__.iteritems():
            if val:
                setattr(outlet_x_ind, key, val)

        for key, val in share.outlet_decomp_ind.__dict__.iteritems():
            if val:
                setattr(outlet_decomp_ind, key, val)

        for key, val in share.outlet_name.__dict__.iteritems():
            if val:
                setattr(onm, key, val)
        # ------------------------------------------------------------ #

        # ------------------------------------------------------------ #
        # Write Fields
        tcoords = ('time',) + coords

        for field in self._fincl:
            var = f.createVariable(field, self._ncprec, tcoords,
                                   **self.ncvaropts)
            var[:, :] = self._out_data[field][:self._out_data_i+1]

            for key, val in getattr(share, field).__dict__.iteritems():
                if val:
                    setattr(var, key, val)
            var.units = self._units
        # ------------------------------------------------------------ #

        # ------------------------------------------------------------ #
        # write global attributes
        self._glob_ats.update()
        for key, val in self._glob_ats.atts.iteritems():
            if val:
                setattr(f, key, val)
        f.featureType = "timeSeries"
        # ------------------------------------------------------------ #
        f.close()
        log.info('Finished writing %s', self.filename)
开发者ID:bartnijssen,项目名称:RVIC,代码行数:104,代码来源:history.py

示例4: charCounter

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import featureType [as 别名]
		numchars = charCounter(list[i])
		newList.append(stringtoarr(list[i], numchars))
	return newList

station_list = ["S001", "S002", "S003", "S004", "S005", "S006", "S007", "S008","S009", "S010", "S011", "S012"]
lat_list = [-150.0, -120.0, -90.0, -60.0, -30.0, 0.0, 30.0, 60.0, 90.0, 120.0, 150.0, 180.0]
lon_list = [-150.0, -120.0, -90.0, -60.0, -30.0, 0.0, 30.0, 60.0, 90.0, 120.0, 150.0, 180.0]
data_values = [17.0, 26.0, 58.0, 37.0, 45.0, 66.0, 27.0, -2.0, 7.0, 9.0, 23.0, 14.0]

# Main
try: 
    # global
    root_grp.description = "Test"
    root_grp.cdm_datatype = "Station"
    root_grp.stationDimension = "station_nm";
    root_grp.featureType = "TimeSeries";
    root_grp.conventions= "CF-1.6";
    baseDate = datetime(2001,3,1)
    root_grp.time_coverage_start = "2001-03-01 12:00:00";

    # dimensions
    root_grp.createDimension('time', None)
    root_grp.createDimension('station_nm', None) # stations unlimited = http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html#idp8314368
    # variables
    times = root_grp.createVariable('time', 'f8', ('time',))
    times.units = 'hours since 2001-03-01 12:00:00'
    #times.units = 'hours since 0001-01-01 00:00:00.0'
    times.calendar = 'gregorian'
    times.standard_name= 'time'
    data = root_grp.createVariable('data', 'f4', ('station_nm','time',))
    data.coordinates='time lat lon'
开发者ID:andreasdjokic,项目名称:wml2-ncdf,代码行数:33,代码来源:createNCDF.py

示例5: write_param_file

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import featureType [as 别名]
def write_param_file(file_name,
                     nc_format='NETCDF3_CLASSIC',
                     glob_atts=NcGlobals(),
                     full_time_length=None,
                     subset_length=None,
                     unit_hydrograph_dt=None,
                     outlet_lon=None,
                     outlet_lat=None,
                     outlet_x_ind=None,
                     outlet_y_ind=None,
                     outlet_decomp_ind=None,
                     outlet_number=None,
                     outlet_mask=None,
                     outlet_name=None,
                     outlet_upstream_gridcells=None,
                     outlet_upstream_area=None,
                     source_lon=None,
                     source_lat=None,
                     source_x_ind=None,
                     source_y_ind=None,
                     source_decomp_ind=None,
                     source_time_offset=None,
                     source2outlet_ind=None,
                     source_tracer=None,
                     unit_hydrograph=None):

    """ Write a standard RVIC Parameter file """

    # ---------------------------------------------------------------- #
    # Open file
    f = Dataset(file_name, 'w', format=nc_format)
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # Time Variables

    # Timesteps
    timesteps = f.createDimension('timesteps', subset_length)
    timesteps = f.createVariable('timesteps', NC_DOUBLE, ('timesteps',))
    timesteps[:] = np.arange(subset_length)
    for key, val in share.timesteps.__dict__.iteritems():
        if val:
            setattr(timesteps, key, val)
    timesteps.timestep_length = 'unit_hydrograph_dt'

    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # write global attributes
    glob_atts.update()
    for key, val in glob_atts.atts.iteritems():
        if val:
            setattr(f, key, val)
    f.featureType = "timeSeries"
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # 0-D variables

    # Full time length (size of ring)
    ftl = f.createVariable('full_time_length', NC_INT, ())
    ftl[:] = full_time_length
    for key, val in share.full_time_length.__dict__.iteritems():
        if val:
            setattr(ftl, key, val)

    # Subset Length
    sl = f.createVariable('subset_length', NC_INT, ())
    sl[:] = subset_length
    for key, val in share.subset_length.__dict__.iteritems():
        if val:
            setattr(sl, key, val)

    # UH timestep
    uh_dt = f.createVariable('unit_hydrograph_dt', NC_DOUBLE, ())
    uh_dt[:] = unit_hydrograph_dt
    for key, val in share.unit_hydrograph_dt.__dict__.iteritems():
        if val:
            setattr(uh_dt, key, val)
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # Outlet Dimensions
    if outlet_y_ind.ndim == 0:
        numoutlets = 1
        outlet_name = np.array([outlet_name])
    else:
        numoutlets = len(outlet_lon)
    ocoords = ('outlets',)
    outlets = f.createDimension(ocoords[0], numoutlets)

    nocoords = ocoords + ('nc_chars',)
    char_names = stringtochar(outlet_name)
    chars = f.createDimension(nocoords[1], char_names.shape[1])
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # 1-D Outlet Variables

    # Outlet Cell Longitudes
#.........这里部分代码省略.........
开发者ID:tcchiao,项目名称:RVIC,代码行数:103,代码来源:write.py

示例6: initialize_output

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import featureType [as 别名]
def initialize_output(filename, id_dim_name, time_len,
                      id_len, time_step_seconds):
    """Creates netCDF file with CF dimensions and variables, but no data.

    Arguments:
        filename -- full path and filename for output netCDF file
        id_dim_name -- name of Id dimension and variable, e.g., COMID
        time_len -- (integer) length of time dimension (number of time steps)
        id_len -- (integer) length of Id dimension (number of time series)
        time_step_seconds -- (integer) number of seconds per time step
    """

    cf_nc = Dataset(filename, 'w', format='NETCDF3_CLASSIC')

    # Create global attributes
    log('    globals', 'DEBUG')
    cf_nc.featureType = 'timeSeries'
    cf_nc.Metadata_Conventions = 'Unidata Dataset Discovery v1.0'
    cf_nc.Conventions = 'CF-1.6'
    cf_nc.cdm_data_type = 'Station'
    cf_nc.nodc_template_version = (
        'NODC_NetCDF_TimeSeries_Orthogonal_Template_v1.1')
    cf_nc.standard_name_vocabulary = ('NetCDF Climate and Forecast (CF) ' +
                                      'Metadata Convention Standard Name ' +
                                      'Table v28')
    cf_nc.title = 'RAPID Result'
    cf_nc.summary = ("Results of RAPID river routing simulation. Each river " +
                     "reach (i.e., feature) is represented by a point " +
                     "feature at its midpoint, and is identified by the " +
                     "reach's unique NHDPlus COMID identifier.")
    cf_nc.time_coverage_resolution = 'point'
    cf_nc.geospatial_lat_min = 0.0
    cf_nc.geospatial_lat_max = 0.0
    cf_nc.geospatial_lat_units = 'degrees_north'
    cf_nc.geospatial_lat_resolution = 'midpoint of stream feature'
    cf_nc.geospatial_lon_min = 0.0
    cf_nc.geospatial_lon_max = 0.0
    cf_nc.geospatial_lon_units = 'degrees_east'
    cf_nc.geospatial_lon_resolution = 'midpoint of stream feature'
    cf_nc.geospatial_vertical_min = 0.0
    cf_nc.geospatial_vertical_max = 0.0
    cf_nc.geospatial_vertical_units = 'm'
    cf_nc.geospatial_vertical_resolution = 'midpoint of stream feature'
    cf_nc.geospatial_vertical_positive = 'up'
    cf_nc.project = 'National Flood Interoperability Experiment'
    cf_nc.processing_level = 'Raw simulation result'
    cf_nc.keywords_vocabulary = ('NASA/Global Change Master Directory ' +
                                 '(GCMD) Earth Science Keywords. Version ' +
                                 '8.0.0.0.0')
    cf_nc.keywords = 'DISCHARGE/FLOW'
    cf_nc.comment = 'Result time step (seconds): ' + str(time_step_seconds)

    timestamp = datetime.utcnow().isoformat() + 'Z'
    cf_nc.date_created = timestamp
    cf_nc.history = (timestamp + '; added time, lat, lon, z, crs variables; ' +
                     'added metadata to conform to NODC_NetCDF_TimeSeries_' +
                     'Orthogonal_Template_v1.1')

    # Create dimensions
    log('    dimming', 'DEBUG')
    cf_nc.createDimension('time', time_len)
    cf_nc.createDimension(id_dim_name, id_len)

    # Create variables
    log('    timeSeries_var', 'DEBUG')
    timeSeries_var = cf_nc.createVariable(id_dim_name, 'i4', (id_dim_name,))
    timeSeries_var.long_name = (
        'Unique NHDPlus COMID identifier for each river reach feature')
    timeSeries_var.cf_role = 'timeseries_id'

    log('    time_var', 'DEBUG')
    time_var = cf_nc.createVariable('time', 'i4', ('time',))
    time_var.long_name = 'time'
    time_var.standard_name = 'time'
    time_var.units = 'seconds since 1970-01-01 00:00:00 0:00'
    time_var.axis = 'T'

    log('    lat_var', 'DEBUG')
    lat_var = cf_nc.createVariable('lat', 'f8', (id_dim_name,),
                                   fill_value=-9999.0)
    lat_var.long_name = 'latitude'
    lat_var.standard_name = 'latitude'
    lat_var.units = 'degrees_north'
    lat_var.axis = 'Y'

    log('    lon_var', 'DEBUG')
    lon_var = cf_nc.createVariable('lon', 'f8', (id_dim_name,),
                                   fill_value=-9999.0)
    lon_var.long_name = 'longitude'
    lon_var.standard_name = 'longitude'
    lon_var.units = 'degrees_east'
    lon_var.axis = 'X'

    log('    z_var', 'DEBUG')
    z_var = cf_nc.createVariable('z', 'f8', (id_dim_name,),
                                 fill_value=-9999.0)
    z_var.long_name = ('Elevation referenced to the North American ' +
                       'Vertical Datum of 1988 (NAVD88)')
    z_var.standard_name = 'surface_altitude'
    z_var.units = 'm'
#.........这里部分代码省略.........
开发者ID:CI-WATER,项目名称:erfp_era_interim_process,代码行数:103,代码来源:make_CF_RAPID_output.py


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