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


Python Dataset.project方法代码示例

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


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

示例1: generate_nc

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import project [as 别名]
def generate_nc(parser_context):
    parser = XLSParser()
    with open(parser_context.filepath, 'r') as f:
        doc = f.read()
    info = parser.extract_worksheets(doc)
    nccl = info[parser_context.worksheet]
    #header_line = 3
    #columns = nccl[header_line]
    #data_range = (4, 66)
    data_rows = nccl[parser_context.data_range[0]:parser_context.data_range[1]]
    print 'Generating',parser_context.output_file
    nc = Dataset(parser_context.output_file, 'w')
    nc.createDimension('time', len(data_rows)*12)
    nc.GDAL = "GDAL 1.9.2, released 2012/10/08"
    nc.history = "Created dynamically in IPython Notebook 2013-11-14"
    nc.title = nccl[0][0]
    nc.summary = nccl[1][0]
    nc.naming_authority = 'GLOS'
    nc.source = 'GLERL'
    nc.standard_name_vocabulary = "http://www.cgd.ucar.edu/cms/eaton/cf-metadata/standard_name.html"
    nc.project = 'GLOS'
    nc.Conventions = "CF-1.6"
    time = nc.createVariable('time', 'f8', ('time',))
    time.standard_name = 'time'
    time.units = 'seconds since 1970-01-01'
    time.long_name = 'Time'
    time.axis = 'T'
    precip = nc.createVariable(parser_context.variable, 'f8', ('time',), fill_value=parser_context.fill_value)
    #precip.standard_name = 'precipitation_amount'
    precip.standard_name = parser_context.standard_name

    precip.units = parser_context.units
    for i,row in enumerate(data_rows):
        for j in xrange(12):
            the_date = datetime(row[0], j+1, 1)
            timestamp = calendar.timegm(the_date.utctimetuple())
            time[i*12 + j] = timestamp
            try:
                value = float(row[j+1])
            except ValueError:
                continue
            except TypeError:
                continue

            precip[i*12 + j] = value
    nc.close() 
开发者ID:lukecampbell,项目名称:glos,代码行数:48,代码来源:hydro.py

示例2: write_nc_file

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import project [as 别名]
def write_nc_file(daily_results, filename, nc, anom_mode=False):
    #Grab every 4th time value to represent daily
    daily_time_var = nc.variables['time'][::4]

    nc_out = Dataset(filename, mode='w', format='NETCDF4') 
    nc_out.createDimension('lon', LONS)
    nc_out.createDimension('lat', LATS)
    nc_out.createDimension('time', None) #UNLIMITED
    nc_out.createDimension('month', MONTHS_YEAR)
    nc_out.title = ''
    nc_out.institution = ''
    nc_out.project = ''
    nc_out.contact = '[email protected]'
    nc_out.Conventions = "CF-1.6"
    
    longitude = nc_out.createVariable('lon', 'f8', ('lon',))
    longitude.standard_name = 'longitude'
    longitude.long_name = 'longitude'
    longitude.units = 'degrees_east'
    longitude.modulo = 360.0
    longitude.axis = 'X'
    longitude[:] = np.arange(0, 360.0, 2.0)
    
    latitude = nc_out.createVariable('lat', 'f8', ('lat',))
    latitude.standard_name = 'latitude'
    latitude.long_name = 'latitude'
    latitude.units = 'degrees_north'
    latitude.axis = 'Y'
    latitude[:] = np.arange(-90.0, 92.0, 2.0)
    
    time = nc_out.createVariable('time', 'f8', ('time',))
    time.units = 'hours since 1-1-1 0:0:0' 
    time.calendar = 'standard' #Gregorian
    time[:] = daily_time_var 
    
    if anom_mode:
        daily_mean = nc_out.createVariable('daily_anom', 'f8', ('time', 'lat', 'lon'))
        daily_mean.long_name = 'z500 daily anomaly vs 1981-2010'
    else:
        daily_mean = nc_out.createVariable('daily_mean', 'f8', ('time', 'lat', 'lon'))
        daily_mean.long_name = 'z500 daily mean'

    daily_mean[:] = daily_results
    nc_out.close()
开发者ID:abuddenb,项目名称:agu2015,代码行数:46,代码来源:calc_daily_mean_current.py

示例3: corrected

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import project [as 别名]
    dataset.title='Daily global radiation'
    dataset.comment='Daily global radiation bias corrected (scaled distribution mapping) data of the EURO-CORDEX model. The reference period is 1981-2010, the years 2006-2010 are taken from the corresponding rcp4.5 scenario.'
    
var.grid_mapping = 'latitude_longitude'

# projection information
crs.longitude_of_prime_meridian = 0.0 
crs.semi_major_axis = 6378137.0
crs.inverse_flattening = 298.257223563
crs.comment = 'Latitude and longitude on the WGS 1984 datum'

# write data to netCDF variable
var[:] = ds[param].data
lats[:] = lat1d
lons[:] = lon1d

# fill in times
dates = [startdate+k*timedelta(days=1) for k in range(ds[param].data.shape[0])]
times[:] = date2num(dates, units=times.units, calendar=times.calendar)

# global attributes

dataset.project= "Climaproof, funded by the Austrian Development Agency (ADA) and co-funded by the United Nations Environmental Programme (UNEP)"
dataset.source = 'Bias Correction Method: Switanek et al., 2017, doi.org/10.5194/hess-21-2649-2017, Regridding Method: Higher-order patch recovery (patch) by Earth System Modelling Framework (ESMF) software ESMF_RegridWeightGen (http://www.earthsystemmodeling.org/esmf_releases/public/last/ESMF_refdoc/)'
dataset.contact = 'Maria Wind <[email protected]>, Herbert Formayer <[email protected]>'
dataset.institution = 'Institute of Meteorology, University of Natural Resources and Life Sciences, Vienna, Austria'
dataset.referencees = 'https://data.ccca.ac.at/group/climaproof'
dataset.conventions = 'CF-1.6'

# close dataset        
dataset.close()
开发者ID:wasserblum,项目名称:met,代码行数:33,代码来源:read_write_netcdf_MARIA.py

示例4: modify_aims_netcdf

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import project [as 别名]
def modify_aims_netcdf(netcdf_file_path, channel_id_info):
    """ Modify the downloaded netCDF file so it passes both CF and IMOS checker
    input:
       netcdf_file_path(str)    : path of netcdf file to modify
       channel_id_index(dict) : information from xml for the channel
    """
    imos_env_path = os.path.join(os.environ.get('DATA_SERVICES_DIR'), 'lib', 'netcdf', 'imos_env')
    if not os.path.isfile(imos_env_path):
        logger = logging_aims()
        logger.error('%s is not accessible' % imos_env_path)
        close_logger(logger)
        sys.exit(1)

    dotenv.load_dotenv(imos_env_path)
    netcdf_file_obj = Dataset(netcdf_file_path, 'a', format='NETCDF4')
    netcdf_file_obj.naming_authority = 'IMOS'

    # add gatts to NetCDF
    netcdf_file_obj.aims_channel_id = int(channel_id_info['channel_id'])

    if not (channel_id_info['metadata_uuid'] == 'Not Available'):
        netcdf_file_obj.metadata_uuid = channel_id_info['metadata_uuid']

    if not netcdf_file_obj.instrument_serial_number:
        del(netcdf_file_obj.instrument_serial_number)

    # add CF gatts, values stored in lib/netcdf/imos_env
    netcdf_file_obj.Conventions            = os.environ.get('CONVENTIONS')
    netcdf_file_obj.data_centre_email      = os.environ.get('DATA_CENTRE_EMAIL')
    netcdf_file_obj.data_centre            = os.environ.get('DATA_CENTRE')
    netcdf_file_obj.project                = os.environ.get('PROJECT')
    netcdf_file_obj.acknowledgement        = os.environ.get('ACKNOWLEDGEMENT')
    netcdf_file_obj.distribution_statement = os.environ.get('DISTRIBUTION_STATEMENT')

    netcdf_file_obj.date_created           = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
    netcdf_file_obj.quality_control_set    = 1
    imos_qc_convention                     = 'IMOS standard set using the IODE flags'
    netcdf_file_obj.author                 = 'laurent besnard'
    netcdf_file_obj.author_email           = '[email protected]'

    rename_netcdf_attribute(netcdf_file_obj, 'geospatial_LAT_max', 'geospatial_lat_max')
    rename_netcdf_attribute(netcdf_file_obj, 'geospatial_LAT_min', 'geospatial_lat_min')
    rename_netcdf_attribute(netcdf_file_obj, 'geospatial_LON_max', 'geospatial_lon_max')
    rename_netcdf_attribute(netcdf_file_obj, 'geospatial_LON_min', 'geospatial_lon_min')

    # variables modifications
    time           = netcdf_file_obj.variables['time']
    time.calendar  = 'gregorian'
    time.axis      = 'T'
    time.valid_min = 0.0
    time.valid_max = 9999999999.0
    netcdf_file_obj.renameDimension('time', 'TIME')
    netcdf_file_obj.renameVariable('time', 'TIME')

    netcdf_file_obj.time_coverage_start = num2date(time[:], time.units, time.calendar).min().strftime('%Y-%m-%dT%H:%M:%SZ')
    netcdf_file_obj.time_coverage_end   = num2date(time[:], time.units, time.calendar).max().strftime('%Y-%m-%dT%H:%M:%SZ')

    # latitude longitude
    latitude                  = netcdf_file_obj.variables['LATITUDE']
    latitude.axis             = 'Y'
    latitude.valid_min        = -90.0
    latitude.valid_max        = 90.0
    latitude.reference_datum  = 'geographical coordinates, WGS84 projection'
    latitude.standard_name    = 'latitude'
    latitude.long_name        = 'latitude'

    longitude                 = netcdf_file_obj.variables['LONGITUDE']
    longitude.axis            = 'X'
    longitude.valid_min       = -180.0
    longitude.valid_max       = 180.0
    longitude.reference_datum = 'geographical coordinates, WGS84 projection'
    longitude.standard_name   = 'longitude'
    longitude.long_name       = 'longitude'

    # handle masked arrays
    lon_array = longitude[:]
    lat_array = latitude[:]
    if type(lon_array) != numpy.ma.core.MaskedArray or len(lon_array) == 1:
        netcdf_file_obj.geospatial_lon_min = min(lon_array)
        netcdf_file_obj.geospatial_lon_max = max(lon_array)
    else:
        netcdf_file_obj.geospatial_lon_min = numpy.ma.MaskedArray.min(lon_array)
        netcdf_file_obj.geospatial_lon_max = numpy.ma.MaskedArray.max(lon_array)

    if type(lat_array) != numpy.ma.core.MaskedArray or len(lat_array) == 1:
        netcdf_file_obj.geospatial_lat_min = min(lat_array)
        netcdf_file_obj.geospatial_lat_max = max(lat_array)
    else:
        numpy.ma.MaskedArray.min(lat_array)
        netcdf_file_obj.geospatial_lat_min = numpy.ma.MaskedArray.min(lat_array)
        netcdf_file_obj.geospatial_lat_max = numpy.ma.MaskedArray.max(lat_array)

    # Change variable name, standard name, longname, untis ....
    if 'Seawater_Intake_Temperature' in netcdf_file_obj.variables.keys():
        var                     = netcdf_file_obj.variables['Seawater_Intake_Temperature']
        var.units               = 'Celsius'
        netcdf_file_obj.renameVariable('Seawater_Intake_Temperature', 'TEMP')
        netcdf_file_obj.renameVariable('Seawater_Intake_Temperature_quality_control', 'TEMP_quality_control')
        var.ancillary_variables = 'TEMP_quality_control'

#.........这里部分代码省略.........
开发者ID:aodn,项目名称:data-services,代码行数:103,代码来源:aims_realtime_util.py

示例5: Table

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import project [as 别名]
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"
fid.keywords = "EARTH SCIENCE > SPECTRAL/ENGINEERING > MICROWAVE > BRIGHTNESS TEMPERATURE" 
fid.keywords_vocabulary = "NASA Global Change Master Directory (GCMD) Earth Science Keywords, Version 8.1"
fid.platform = "TBD"
fid.sensor = "TBD"
fid.naming_authority = "org.doi.dx"
fid.id = "10.5067/MEASURES/CRYOSPHERE/nsidc-0630.001"
fid.date_created = "TBD"
fid.acknowledgement = ["This data set was created with funding from NASA MEaSUREs Grant #NNX13AI23A.\n",
                       "Data archiving and distribution is supported by the NASA NSIDC Distributed Active Archive Center (DAAC)."]
fid.license = "No constraints on data access or use"
fid.processing_level = "Level 3"
fid.creator_name = "Mary J. Brodzik"
fid.creator_email = "[email protected]"
开发者ID:mjbrodzik,项目名称:ipython_notebooks,代码行数:33,代码来源:make_MODICEv04_min05yr_netcdf.py

示例6: range

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import project [as 别名]
# projection information
crs.longitude_of_prime_meridian = 0.0 
crs.semi_major_axis = 6378137.0
crs.inverse_flattening = 298.257223563
crs.comment = 'Latitude and longitude on the WGS 1984 datum'

# write data to netCDF variable
#print ds[param]
#print var
#exit()
var[:] = ds[param].data
lats[:] = lat1d
lons[:] = lon1d


# fill in times
dates = [startdate+k*timedelta(days=1) for k in range(ds[param].data.shape[0])]
times[:] = date2num(dates, units=times.units, calendar=times.calendar)

# global attributes

dataset.project= "URBANIA, funded by KLIEN"
dataset.source = 'WRF-TEB' #Bias Correction Method: Switanek et al., 2017, doi.org/10.5194/hess-21-2649-2017, Regridding Method: Higher-order patch recovery (patch) by Earth System Modelling Framework (ESMF) software ESMF_RegridWeightGen (http://www.earthsystemmodeling.org/esmf_releases/public/last/ESMF_refdoc/)'
dataset.contact = '[email protected]' #Maria Wind <[email protected]>, Herbert Formayer <[email protected]>'
dataset.institution = 'Institute of Meteorology, University of Natural Resources and Life Sciences, Vienna, Austria'
dataset.referencees = 'http://urbania.boku.ac.at'
dataset.conventions = 'CF-1.6'

# close dataset        
dataset.close()
开发者ID:wasserblum,项目名称:met,代码行数:32,代码来源:Fig15_write_CFconform_WRFImrandata.py

示例7: range

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import project [as 别名]
	nc_lon_var.long_name = 'Longitude'
	#nc_lon_var.standard_name = 'longitude'
	
	# Create ncdf attributes
	nc_file.WML_Conventions = 'CF-1.6'
	nc_file.WML_featureType = 'timeSeries'
	nc_file.WML_cdm_data_type = 'Station'
	nc_file.WML_standard_name_vocabulary = 'CF-1.6'
	nc_file.title = nc_title
	nc_file.summary = nc_summary
	nc_file.id = 'testing_id'
	nc_file.naming_authory = 'testing_authority'
	nc_file.WML_date_created = nc_date_create
	nc_file.WML_creator_name = nc_creator_name
	nc_file.creator_email = nc_creator_email
	nc_file.project = nc_project
	nc_file.processing_level = nc_proc_level
	nc_file.WML_profile = 'single variable'
	
	# data
	dates = [datetime(2001,3,1)+n*timedelta(hours=12) for n in range(12)]
	nc_time[:] = date2num(dates,units=nc_time.units,calendar=nc_time.calendar)
	#nc_station_names[:] = [stringtoarr("aaaa",4),stringtoarr("bbbb",4)]
	dummy = [stringtoarr("aaaa",4),stringtoarr("bbbb",4)]
	nc_station_names[:] = dummy
	nc_lat_var[:] = [35.0, 70.0]
	nc_lon_var[:] = [-120.0, 120.0]
	#for i in range(len(nc_station_names)):
		#data[i,:] = np.random.uniform(len(nc_time))
	
except:
开发者ID:andreasdjokic,项目名称:wml2-ncdf,代码行数:33,代码来源:practiceGagesHardCode.py

示例8: initialize_output

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import project [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.project方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。