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


Python Dataset.comment方法代码示例

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


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

示例1: new

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [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

示例2: writenc

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def writenc(var, lat, lon, fname, itime, iyear):

    foo = Dataset(fname, 'w', format='NETCDF4_CLASSIC')

    foo.createDimension('M', 20)
    foo.createDimension('L', None)
    foo.createDimension('Y', 64)
    foo.createDimension('X', 128)
    foo.createDimension('S', 1)

    foo.institution = 'FUNCEME'
    foo.comment = 'ECHAM4.6 MODEL'

    lats = foo.createVariable('Y', 'f4', ('Y'))
    lats.units = 'degrees_north'
    lats.long_name = 'latitude'
    lats.axis = "Y"
    lats[:] = lat[:]

    lons = foo.createVariable('X', 'f4', ('X'))
    lons.units = 'degrees_east'
    lons.long_name = 'longitude'
    lons.axis = "X"
    lons[:] = lon[:]

    ensemble = foo.createVariable('M', 'f4', ('M'))
    ensemble.units = 'unitless'
    ensemble.long_name = 'Ensemble Member'
    ensemble.axis = "M"
    ensemble[:] = range(20)

    lead = foo.createVariable('L', 'f4', ('L'))
    lead.units = 'months'
    lead.long_name = 'Lead'
    lead.axis = "L"
    lead[:] = [0.5, 1.5, 2.5]

    times = foo.createVariable('S', 'f4', ('S'))
    times.units = 'months since 1981-01-15'
    times.calendar = '365'
    times.standard_name = "forecast_reference_time"
    times.axis = "S"
    times[:] = 1

    precip = foo.createVariable('pr', float, ('S', 'M', 'L', 'Y', 'X'))
    precip.units = 'mm'
    precip.long_name = 'precipitation'
    precip.missing_value = -999.
    precip[:] = var[:]

    foo.close()

    print '\nWrite file:', fname, '\n'
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:55,代码来源:writenc4d.old.py

示例3: writenc4

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def writenc4(pcp, lat, lon, fname, itime, nmon):

    foo = Dataset(fname, 'w', format='NETCDF4_CLASSIC')

    foo.createDimension('ensemble', 20)
    foo.createDimension('time', None)
    foo.createDimension('lat', 72)
    foo.createDimension('lon', 109)

    foo.institution = 'FUNCEME'
    foo.comment = 'RSM97 forced by ECHAM46'

    lats = foo.createVariable('lat', 'f4', ('lat'), zlib=True)
    lats.units = 'degrees_north'
    lats.long_name = 'latitude'
    lats.axis = "Y"
    lats[:] = lat[:]

    lons = foo.createVariable('lon', 'f4', ('lon'), zlib=True)
    lons.units = 'degrees_east'
    lons.long_name = 'longitude'
    lons.axis = "X"
    lons[:] = lon[:]

    ensemble = foo.createVariable('ensemble', 'f4', ('ensemble'), zlib=True)
    ensemble.units = 'unitless'
    ensemble.long_name = 'ensemble'
    ensemble[:] = range(20)

    # lead = foo.createVariable('lead', 'f4', ('lead'),)
    # lead.units = 'unitless'
    # lead.long_name = 'Lead'
    # lead[:] = range(int(lead))

    times = foo.createVariable('time', 'f4', ('time'), zlib=True)
    # d = 'months since 1900-02-01 00:00:00'.format(iyear)
    d = 'years since 1981-{0}-15 00:00:00'.format(nmon)
    times.units = d
    times.calendar = 'standard'
    times.standard_name = "time"
    times[:] = range(itime)

    precip = foo.createVariable('pcp', float,
    ('ensemble', 'time', 'lat', 'lon'), zlib=True )
    # print precip
    precip.units = 'mm'
    precip.long_name = 'Precipitation'
    precip.missing_value = -999
    precip[:] = pcp[:]

    foo.close()

    print '\nWrite file:', fname, '\n'
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:55,代码来源:nc4rsm97tri.py

示例4: writenc4

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def writenc4(pcp, lat, lon, fname, itime):

    foo = Dataset(fname, 'w', format='NETCDF4_CLASSIC')

    foo.createDimension('ensemble', 10)
    foo.createDimension('time', None)
    foo.createDimension('lat', 110)
    foo.createDimension('lon', 129)

    foo.institution = 'FUNCEME'
    foo.comment = 'RSM2008 forced by ECHAM46'

    lats = foo.createVariable('lat', 'f4', ('lat'), zlib=True)
    lats.units = 'degrees_north'
    lats.long_name = 'latitude'
    lats.axis = "Y"
    lats[:] = lat[:]

    lons = foo.createVariable('lon', 'f4', ('lon'), zlib=True)
    lons.units = 'degrees_east'
    lons.long_name = 'longitude'
    lons.axis = "X"
    lons[:] = lon[:]

    ensemble = foo.createVariable('ensemble', 'f4', ('ensemble'), zlib=True)
    ensemble.units = 'unitless'
    ensemble.long_name = 'ensemble'
    ensemble[:] = range(10)

    times = foo.createVariable('time', 'f4', ('time'), zlib=True)
    d = 'years since {0}-{1:02d}-15 00:00:00'.format(1981, 02)
    times.units = d
    times.calendar = 'standard'
    times.standard_name = "time"
    times[:] = range(itime)

    precip = foo.createVariable('pcp', float, ('ensemble', 'time', 'lat', 'lon'), zlib=True )
    precip.units = 'mm'
    precip.long_name = 'Precipitation'
    precip.missing_value = -999
    print(pcp.shape)
    precip[:] = pcp[:]

    foo.close()

    print '\nWrite file:', fname, '\n'
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:48,代码来源:nc4rsm2008.py

示例5: create_mhl_sst_ncfile

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def create_mhl_sst_ncfile(txtfile, site_code_short, data,
                          time, dtime, spatial_data):
    """
    create NetCDF file for MHL Wave data
    """
    site_code = site_list[site_code_short][0]
    netcdf_filename = create_netcdf_filename(site_code, data, dtime)
    netcdf_filepath = os.path.join(
        output_folder, "%s.nc") % netcdf_filename
    ncfile = Dataset(netcdf_filepath, "w", format="NETCDF4")


    # generate site and deployment specific attributes
    ncfile.title = ("IMOS - ANMN New South Wales(NSW) %s "
                    "Sea water temperature (%s) -"
                    "Deployment No. %s %s to %s") % (
            site_list[site_code_short][1], site_code,
            spatial_data[0], min(dtime).strftime("%d-%m-%Y"),
            max(dtime).strftime("%d-%m-%Y"))
    ncfile.institution = 'Manly Hydraulics Laboratory'
    ncfile.keywords = ('Oceans | Ocean temperature |'
                           'Sea Surface Temperature')
    ncfile.principal_investigator = 'Mark Kulmar'
    ncfile.cdm_data_type = 'Station'
    ncfile.platform_code = site_code

    abstract_default = ("The sea water temperature is measured by a thermistor mounted in the "
                        "buoy hull approximately 400 mm below the water "
                        "surface.  The thermistor has a resolution of 0.05 "
                        "Celsius and an accuracy of 0.2 Celsius.  The "
                        "measurements are transmitted to a shore station "
                        "where it is stored on a PC before routine transfer "
                        "to Manly Hydraulics Laboratory via email.")

    if site_code_short in ['COF', 'CRH', 'EDE', 'PTK']:

        abstract_specific = ("This dataset contains sea water temperature "
                             "data collected by a wave monitoring buoy moored off %s. ") % site_list[site_code_short][1]
    else:
        abstract_specific = ("This dataset contains sea water temperature "
                             "data collected by a wave monitoring buoy moored off %s "
                             "approximately %s kilometres from the coastline. ") % (

                          site_list[site_code_short][1], site_list[site_code_short][2])

    ncfile.abstract = abstract_specific + abstract_default
    ncfile.comment = ("The sea water temperature data (SST) is routinely quality controlled (usually twice per week) "
                      "using a quality control program developed by Manly Hydraulics Laboratory.  The SST data gathered "
                      "by the buoy is regularly compared to the latest available satellite derived sea SST images available "
                      "from the Bluelink ocean forecasting web pages to ensure the integrity of the dataset.  Erroneous SST "
                      "records are removed and good quality data is flagged as \'Quality Controlled\' in the "
                      "Manly Hydraulics Laboratory SST database.") 
    ncfile.sourceFilename = os.path.basename(txtfile)
    ncfile.date_created = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
    ncfile.time_coverage_start = min(dtime).strftime("%Y-%m-%dT%H:%M:%SZ")
    ncfile.time_coverage_end = max(dtime).strftime("%Y-%m-%dT%H:%M:%SZ")
    ncfile.geospatial_lat_min = spatial_data[1]
    ncfile.geospatial_lat_max = spatial_data[1]
    ncfile.geospatial_lon_min = spatial_data[2]
    ncfile.geospatial_lon_max = spatial_data[2]
    ncfile.geospatial_vertical_max = 0.
    ncfile.geospatial_vertical_min = 0.
    ncfile.deployment_number = str(spatial_data[0])

    # add dimension and variables
    ncfile.createDimension('TIME', len(time))

    TIME = ncfile.createVariable('TIME', "d", 'TIME')
    TIMESERIES = ncfile.createVariable('TIMESERIES', "i")
    LATITUDE = ncfile.createVariable(
        'LATITUDE', "d", fill_value=99999.)
    LONGITUDE = ncfile.createVariable(
        'LONGITUDE', "d", fill_value=99999.)
    TEMP = ncfile.createVariable('TEMP', "f", 'TIME', fill_value=99999.)

    # add global attributes and variable attributes stored in config files
    config_file = os.path.join(os.getcwd(), 'global_att_sst.att')
    generate_netcdf_att(ncfile, config_file,
                        conf_file_point_of_truth=False)
    
    # replace nans with fillvalue in dataframe
    data = data.fillna(value=float(99999.))

    TIME[:] = time
    TIMESERIES[:] = 1
    LATITUDE[:] = spatial_data[1]
    LONGITUDE[:] = spatial_data[2]
    TEMP[:] = data['SEA_TEMP'].values
    ncfile.close()
开发者ID:aodn,项目名称:data-services,代码行数:91,代码来源:process_MHLsst_from_txt.py

示例6: writenchind

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def writenchind(var, lat, lon, fname, season, mon):

    foo = Dataset(fname, 'w', format='NETCDF4_CLASSIC')

    foo.createDimension('S', var.shape[0])
    foo.createDimension('M', 20)
    foo.createDimension('L', None)
    foo.createDimension('Y', lat.size)
    foo.createDimension('X', lon.size)

    foo.institution = 'FUNCEME - ECHAM46'
    foo.comment = '{0} Mon Hind - {1} - 1981-2010'.format(mon, season)

    M = foo.createVariable('M', 'f4', ('M'),)
    L = foo.createVariable('L', 'f4', ('L'),)
    Y = foo.createVariable('Y', 'f4', ('Y'),)
    X = foo.createVariable('X', 'f4', ('X'),)
    S = foo.createVariable('S', 'f4', ('S'), )
    pr = foo.createVariable('pr', float, ('S', 'M', 'L', 'Y', 'X'),)

    months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
              'Oct', 'Nov', 'Dec']

    S.units = 'years since 1981-{:02d}-15'.format(months.index(mon) + 1)
    M.units = 'unitless'
    L.units = 'months'
    X.units = 'degrees_east'
    Y.units = 'degrees_north'
    pr.units = 'mm'

    S.standard_name = 'forecast_reference_time'
    M.standard_name = 'realization'
    L.standard_name = 'forecast_period'
    X.standard_name = 'longitude'
    Y.standard_name = 'latitude'
    pr.standard_name = 'precipitation'

    S.long_name = 'Forecast Start time'
    M.long_name = 'Ensemble Member'
    L.long_name = 'Lead'
    X.long_name = 'longitude'
    Y.long_name = 'latitude'
    pr.long_name = 'precipitation'

    S.calendar = 'standard'

    X.axis = 'X'
    Y.axis = 'Y'
    M.axis = 'M'
    L.axis = 'L'
    S.axis = 'N'

    pr.missing_value = -999.

    S[:] = range(0, 30)
    M[:] = range(1, 21)
    L[:] = range(1, 4)
    X[:] = lon[:]
    Y[:] = lat[:]
    pr[:] = var[:]

    foo.close()
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:64,代码来源:writenc4dpcp.py

示例7: SeasonAccum

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
myfile = "\n => rsm97.hind8110.jan.1981-2010.JJA.nc"

print myfile

pcp, lat, lon = SeasonAccum()
print pcp.shape

foo = Dataset(myfile, "w", format="NETCDF3_CLASSIC")

foo.createDimension("time", None)
foo.createDimension("lat", pcp.shape[1])
foo.createDimension("lon", pcp.shape[2])

foo.institution = "FUNCEME"
foo.comment = "RSM97 forced by ECHAM46 - Jan Forecast"

lats = foo.createVariable("lat", "f4", ("lat"), zlib=True)
lats.units = "degrees_north"
lats.long_name = "latitude"
lats.axis = "Y"
lats[:] = lat[:]

lons = foo.createVariable("lon", "f4", ("lon"), zlib=True)
lons.units = "degrees_east"
lons.long_name = "longitude"
lons.axis = "X"
lons[:] = lon[:]

times = foo.createVariable("time", "f4", ("time"), zlib=True)
times.units = "years since 1981-01-01 00:00:00"
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:32,代码来源:rsm.py

示例8: cloneUM4

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [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

示例9: write_netcdf_file

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def write_netcdf_file(data, output_file):
    """Writes the resulting data to a NetCDF file"""
    dataset = Dataset(output_file, "w", format="NETCDF4_CLASSIC")

    # Dimensions
    dataset.createDimension("time")

    dataset.setncattr('g.General.SiteWmoId', '93' + str(data.station))
    dataset.setncattr('g.MeasuringSystem.Longitude', str(data.longitude) + ' degree east')
    dataset.setncattr('g.MeasuringSystem.Latitude', str(data.latitude) + ' degree north')
    dataset.setncattr('g.MeasuringSystem.Altitude', str(data.altitude) + ' m')
    #dataset.setncattr('g.SurfaceObs.Pressure', str(ident['surface_pressure']) + ' hPa')
    #dataset.setncattr('g.SurfaceObs.Temperature', str(ident['surface_temperature']) + ' °C')
    #dataset.setncattr('g.SurfaceObs.RelativeHumidity', str(ident['surface_humidity']) + ' %')
    dataset.setncattr('g.General.SiteCode', "INVRCRGL")
    dataset.setncattr('g.General.SiteName', "Invercargill")
    dataset.setncattr('g.General.SiteInstitution', "MetService New Zealand")
    dataset.setncattr('g.Product.Producer', "National Institute of Water and Atmospheric Research (New Zealand)")
    dataset.setncattr('g.Product.References', "https://github.com/kinow/pccora")

    #dataset.station_type = ident['station_type']
    #dataset.region_number = ident['region_number']
    #dataset.wmo_block_number = ident['wmo_block_number']
    dataset.wmo_block_number = 93
    dataset.wmo_station_number = data.station
    #dataset.wind_speed_unit = str(ident['wind_speed_unit']) + ', comment: 0 = m/s 1 = knots'
    #dataset.telecommunications_headings = str(ident['telecommunications_headings']) + ', comment: 0 = No 1 = Yes'
    #dataset.res = ident['reserved']
    #dataset.sounding_type = str(ident['sounding_type']) + ', comment: 0 = PTU 1 = Only pressure 2 = No PTU (Radar'
    #dataset.start_mode = str(ident['start_mode']) + ', comment: 0 = Auto 1 = Manual'
    #dataset.time_elapsed = ident['time_elapsed']
    #dataset.ptu_rate = ident['ptu_rate']
    #dataset.spu_serial_number = ident['spu_serial_number']
    #dataset.year = ident['year']
    #dataset.month = ident['month']
    #dataset.day = ident['day']
    #dataset.julian_date = ident['julian_date']
    #dataset.hour = ident['hour']
    #dataset.minute = ident['minute']
    #dataset.message_year = ident['message_year']
    #dataset.message_month = ident['message_month']
    #dataset.message_day = ident['message_day']
    #dataset.message_hour = ident['message_hour']
    #dataset.cloud_group = ident['cloud_group']
    #dataset.weather_group = ident['weather_group']
    #dataset.napp = ident['napp']
    #dataset.humidity_correction = ident['humidity_correction']
    #dataset.success_of_signal = ident['success_of_signal']
    #dataset.pressure_accept_level = ident['pressure_accept_level']
    #dataset.pressure_replace_level = ident['pressure_replace_level']
    #dataset.pressure_reject_level = ident['pressure_reject_level']
    #dataset.temperature_accept_level = ident['temperature_accept_level']
    #dataset.temperature_replace_level = ident['temperature_replace_level']
    #dataset.temperature_reject_level = ident['temperature_reject_level']
    #dataset.humidity_accept_level = ident['humidity_accept_level']
    #dataset.humidity_replace_level = ident['humidity_replace_level']
    #dataset.humidity_reject_level = ident['humidity_reject_level']
    #dataset.total_omega_count = ident['total_omega_count']
    #dataset.reason_temination = ident['reason_temination']
    #dataset.omega_count = ident['omega_count']
    #dataset.wind_computing_mode = str(ident['wind_computing_mode']) + ', comment: 0 = Remote 1 = Local 2 = Differential'
    #dataset.wind_mode = str(ident['wind_mode']) + ', comment: 0 = Omega 1 = Loran-C 2 = Radar 255 = Only PTU'
    #dataset.stations_used = str(ident['stations_used']) + ', comment: One bit for each station 1 = Used 0 = Not used'
    #dataset.loranc_chains_used = ident['loranc_chains_used']
    #dataset.gri_chain_1 = ident['gri_chain_1']
    #dataset.gri_chain_2 = ident['gri_chain_2']
    #dataset.exclude_loran_transmitters = str(ident['exclude_loran_transmitters']) + ', comment: One bit for each in the chain; and chain 2 transmitted'
    #dataset.phase_integration_time = str(ident['phase_integration_time']) + ', comment: 0 = time (s) 1 = Altitude (m/MSI'
    #dataset.phase_integration_time_1 = ident['phase_integration_time_1']
    #dataset.phase_integration_time_2 = ident['phase_integration_time_2']
    #dataset.phase_integration_time_3 = ident['phase_integration_time_3']
    #dataset.phase_integration_time_4 = ident['phase_integration_time_4']
    #dataset.phase_integration_time_5 = ident['phase_integration_time_5']
    #dataset.phase_integration_time_6 = ident['phase_integration_time_6']
    #dataset.phase_integration_change_level_1 = ident['phase_integration_change_level_1']
    #dataset.phase_integration_change_level_2 = ident['phase_integration_change_level_2']
    #dataset.phase_integration_change_level_3 = ident['phase_integration_change_level_3']
    #dataset.phase_integration_change_level_4 = ident['phase_integration_change_level_4']
    #dataset.phase_integration_change_level_5 = ident['phase_integration_change_level_5']
    #dataset.phase_integration_change_level_6 = ident['phase_integration_change_level_6']
    #dataset.reference_pressure = str(ident['reference_pressure']) + ' hPa'
    #dataset.reference_temperature = str(ident['reference_temperature']) + ' °C'
    #dataset.reference_humidity = str(ident['reference_humidity']) + ' %'

    dataset.institution = "MetService New Zealand"
    dataset.datetime = str(data.started_at)
    dataset.comment = 'For more information about the variables see: https://badc.nerc.ac.uk/data/ukmo-rad-hires/pc-coradata.html'

    elapsed_time = []
    #logarithmic_pressure = []
    temperature = []
    relative_humidity = []
    #north_wind = []
    #east_wind = []
    altitude = []
    pressure = []
    dew_point = []
    #mixing_ratio = []
    wind_direction = []
    wind_speed = []
#.........这里部分代码省略.........
开发者ID:kinow,项目名称:pccora,代码行数:103,代码来源:spltext2netcdf4.py

示例10: corrected

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
times.axis = 'T'

lats.units = 'degrees_north'
lats.long_name = 'latitude'
lats.standard_name = 'latitude'

lons.units = 'degrees_east'
lons.long_name = 'longitude'
lons.standard_name = 'longitude'

if param == 'pr':
    var.units = 'mm'
    var.long_name = 'total daily precipitation'
    var.stnadard_nbame = 'precipitation amount'
    dataset.title='Total daily precipitation'
    dataset.comment='Total daily precipitation 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[:] = var_array
    
elif param == 'tasmax':
    var.units = 'degree_Celsius'
    var.long_name = 'daily maximum near-surface air temperature'
    var.standard_name = 'air_temperature'
    dataset.title='Daily maximum near-surface air temperature'
    dataset.comment='Daily maximum near-surface air temperature 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.'
    
elif param == 'tasmin':
    var.units = 'degree_Celsius'
    var.long_name = 'daily minimum near-surface air temperature'
    var.standard_name = 'air_temperature'       
    dataset.title='Daily minimum near-surface air temperature'
    dataset.comment='Daily minimum near-surface air temperature 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.'
开发者ID:wasserblum,项目名称:met,代码行数:33,代码来源:read_write_netcdf_MARIA.py

示例11: ConvertNCCF

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def ConvertNCCF(TheFileIn,TheFileOut,TheTimes,TheDaysArray,TheCLats,TheCLongs,TheClimPeriod,TheMissing,TheType):
    ''' Discover what is in the file '''
    ''' Open and read in all bits '''
    ''' Write out in cf compliant style '''

    ncf=Dataset(TheFileIn,'r')
    nc_dims = list(ncf.dimensions)	# list of dimensions [dim for dim in ncf.dimensions]
    nc_vars = list(ncf.variables)  # list of nc variables [var for var in ncf.variables]
    nc_attrs = ncf.ncattrs()		# list of global attributes

    ndims=len(nc_dims)
    nvars=len(nc_vars)
    ngatts=len(nc_attrs)

# Get all global attributes
    TheGAtts=np.empty(ngatts,dtype=object)	# an empty array with the right number of string elements
    for (noo,att) in enumerate(nc_attrs):	# enumerate and use elements of the list
        TheGAtts[noo]=ncf.getncattr(att)	# get each global attribute and populate array

# Get all dimensions
    TheDims=np.empty(ndims)	# an empty array with the right number of string elements
    for (noo,dim) in enumerate(nc_dims):	# enumerate and use elements of the list
        TheDims[noo]=len(ncf.dimensions[dim])	# get length of each dimension
# NO DIMENSION ATTRIBUTES - 
#    TheDimAttrNames=[[] for i in xrange(ndims)]		# create list of lists - one for the attribute names of each dimension
#    TheDimAttrs=[[] for i in xrange(ndims)]		# create list of lists - one for the attributes of each dimension
#    for (noo,dim) in enumerate(nc_dims):	# enumerate and use elements of the list
#        TheDimAttrNames[noo]=ncf.dimensions[dim].ncattrs()	# fill names
#        for (nee,nats) in enumerate(TheDimAttrNames[noo]):      # loop through each name and get the attribute   
#            TheDimAttrs[noo][nee]=f.dimensions[dim].getncattr(nats)	

# Get all variables, and their attributes
    TheVarAttrNames=[[] for i in xrange(nvars)]		# create list of lists - one for the attribute names of each dimension
    TheVarAttrs=[[] for i in xrange(nvars)]		# create list of lists - one for the attributes of each dimension
    TheVars=[[] for i in xrange(nvars)]		# create list of lists - one for the attributes of each dimension
    for (noo,var) in enumerate(nc_vars):	# enumerate and use elements of the list
        TheVarAttrNames[noo]=ncf.variables[var].ncattrs()	# fill names
        for (nee,nats) in enumerate(TheVarAttrNames[noo]):      # loop through each name and get the attribute   
            TheVarAttrs[noo].append(ncf.variables[var].getncattr(nats))	
        TheVars[noo]=ncf.variables[nc_vars[noo]][:]


# Now write out, checking if the standard stuff is not there, and if not, then add in
    ncfw=Dataset(TheFileOut,'w',format='NETCDF3_CLASSIC')
    
# Set up the global attributes
# Is there a description?
    moo=np.where(np.array(nc_attrs) == 'description')
    if (moo[0] >= 0):
        ncfw.description=TheGAtts[moo[0]]
    else:
        ncfw.description="HadISDH monthly mean land surface "+TheType+" climate monitoring product from 1973 onwards. Quality control, homogenisation, uncertainty estimation, averaging over gridboxes (no smoothing or interpolation)."
# Is there a title?
    moo=np.where(np.array(nc_attrs) == 'title')
    if (moo[0] >= 0):
        ncfw.title=TheGAtts[moo[0]]
    else:
        ncfw.title="HadISDH monthly mean land surface "+TheType+" climate monitoring product from 1973 onwards."
# Is there an institution?
    moo=np.where(np.array(nc_attrs) == 'institution')
    if (moo[0] >= 0):
        ncfw.institution=TheGAtts[moo[0]]
    else:
        ncfw.institution="Met Office Hadley Centre (UK), National Climatic Data Centre (USA), Climatic Research Unit (UK), National Physical Laboratory (UK), Bjerknes Centre for Climate Research (Norway)"
# Is there a history?
    moo=np.where(np.array(nc_attrs) == 'history')
    if (moo[0] >= 0):
        ncfw.history=TheGAtts[moo[0]]
    else:
        ncfw.history="Updated 4 February 2014"
# Is there a source?
    moo=np.where(np.array(nc_attrs) == 'source')
    if (moo[0] >= 0):
        ncfw.source=TheGAtts[moo[0]]
    else:
        ncfw.source="HadISD.1.0.2.2013f (Dunn et al., 2012)"
# Is there a comment?
    moo=np.where(np.array(nc_attrs) == 'comment')
    if (moo[0] >= 0):
        ncfw.comment=TheGAtts[moo[0]]
    else:
        ncfw.comment=""
# Is there a reference?
    moo=np.where(np.array(nc_attrs) == 'reference')
    if (moo[0] >= 0):
        ncfw.reference=TheGAtts[moo[0]]
    else:
        ncfw.reference="Willett, K. M., Dunn, R. J. H., Thorne, P. W., Bell, S., de Podesta, M., Parker, D. E., Jones, P. D., and Williams Jr., C. N.: HadISDH land surface multi-variable humidity and temperature record for climate monitoring, Clim. Past, 10, 1983-2006, doi:10.5194/cp-10-1983-2014, 2014."
# Is there a version?
    moo=np.where(np.array(nc_attrs) == 'version')
    if (moo[0] >= 0):
        ncfw.version=TheGAtts[moo[0]]
    else:
        ncfw.version="HadISDH.2.0.0.2013p"
# Is there a Conventions?
    moo=np.where(np.array(nc_attrs) == 'Conventions')
    if (moo[0] >= 0):
        ncfw.Conventions=TheGAtts[moo[0]]
    else:
        ncfw.Conventions="CF-1.0"
#.........这里部分代码省略.........
开发者ID:Kate-Willett,项目名称:Climate_Explorer,代码行数:103,代码来源:Convert_cfnc_AUG2014.py

示例12: Dataset

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

# 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)"
开发者ID:mjbrodzik,项目名称:ipython_notebooks,代码行数:33,代码来源:make_MODICEv04_min05yr_netcdf.py

示例13: writenc

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def writenc(var1, var2, var3, lat, lon, fname, iyear, season, mon):

    foo = Dataset(fname, 'w', format='NETCDF4_CLASSIC')

    foo.createDimension('S', 1)
    foo.createDimension('M', 20)
    foo.createDimension('L', None)
    foo.createDimension('Y', lat.size)
    foo.createDimension('X', lon.size)

    foo.institution = 'FUNCEME- ECHAM46'
    foo.comment = '{0} Mon Fcst - {1} - {2}'.format(mon, season, iyear)

    M = foo.createVariable('M', 'f4', ('M'),)
    L = foo.createVariable('L', 'f4', ('L'),)
    Y = foo.createVariable('Y', 'f4', ('Y'),)
    X = foo.createVariable('X', 'f4', ('X'),)
    S = foo.createVariable('S', 'f4', ('S'), )
    t2mmax = foo.createVariable('t2mmax', float, ('S', 'M', 'L', 'Y', 'X'), )
    t2m = foo.createVariable('t2m', float, ('S', 'M', 'L', 'Y', 'X'),)
    t2mmin = foo.createVariable('t2mmin', float, ('S', 'M', 'L', 'Y', 'X'),)

    months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
              'Oct', 'Nov', 'Dec']

    S.units = 'months since {0}-{1}-15'\
        .format(iyear, str(months.index(mon) + 1).zfill(2))
    M.units = 'unitless'
    L.units = 'months'
    X.units = 'degrees_east'
    Y.units = 'degrees_north'
    t2mmax.units = 'K'
    t2m.units = 'K'
    t2mmin.units = 'K'

    S.standard_name = 'forecast_reference_time'
    M.standard_name = 'realization'
    L.standard_name = 'forecast_period'
    X.standard_name = 'longitude'
    Y.standard_name = 'latitude'
    t2m.standard_name = 'temperature max'
    t2mmax.standard_name = 'temperature 2m'
    t2mmin.standard_name = 'temperature min'

    S.long_name = 'Forecast Start time'
    M.long_name = 'Ensemble Member'
    L.long_name = 'Lead'
    X.long_name = 'longitude'
    Y.long_name = 'latitude'
    t2mmax.long_name = 'temperature max'
    t2m.long_name = 'temperature 2m'
    t2mmin.long_name = 'temperature min'

    S.calendar = 'standard'

    X.axis = 'X'
    Y.axis = 'Y'
    M.axis = 'M'
    L.axis = 'L'
    S.axis = 'N'

    t2mmax.missing_value = -999.
    t2m.missing_value = -999.
    t2mmin.missing_value = -999.

    S[:] = 0
    M[:] = range(1, 21)
    L[:] = range(1, 4)
    X[:] = lon[:]
    Y[:] = lat[:]
    t2mmax[:] = var1[:]
    t2m[:] = var2[:]
    t2mmin[:] = var3[:]

    foo.close()
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:77,代码来源:writenc4dtemp.py

示例14: writenc4

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def writenc4(var, lat, lon, fname, itime, varname):

    foo = Dataset(fname, 'w', format='NETCDF4_CLASSIC')

    foo.createDimension('ensemble', 20)
    foo.createDimension('time', None)
    foo.createDimension('lat', 72)
    foo.createDimension('lon', 109)

    foo.institution = 'FUNCEME'
    foo.comment = 'RSM97 forced by ECHAM46 - Jan Forecast'

    lats = foo.createVariable('lat', 'f4', ('lat'), zlib=True)
    lats.units = 'degrees_north'
    lats.long_name = 'latitude'
    lats.axis = "Y"
    lats[:] = lat[:]

    lons = foo.createVariable('lon', 'f4', ('lon'), zlib=True)
    lons.units = 'degrees_east'
    lons.long_name = 'longitude'
    lons.axis = "X"
    lons[:] = lon[:]

    ensemble = foo.createVariable('ensemble', 'f4', ('ensemble'), zlib=True)
    ensemble.units = 'unitless'
    ensemble.long_name = 'ensemble'
    ensemble[:] = range(20)

    # levels = foo.createVariable('levels', 'f4', ('lead'),)
    # levels.units = 'unitless'
    # levels.long_name = 'Levels'
    # levels[:] = range(int(levels))

    times = foo.createVariable('time', 'f4', ('time'), zlib=True)
    times.units = 'months since 1900-01-01 00:00:00'
    times.calendar = 'standard'
    times.standard_name = "time"
    times[:] = range(itime)

    if varname == "pcp":
        varlongname, varunits = 'Precipitation', 'mm'
    elif varname == "u":
        varlongname, varunits = 'U-Wind', 'm/s'
    elif varname == "v":
        varlongname, varunits = 'V-Wind', 'm/s'
    elif varname == "t":
        varlongname, varunits = 'Temperature', 'k'
    elif varname == "q":
        varlongname, varunits = 'Specific_Humidity', 'kg/kg'
    elif varname == "h":
        varlongname, varunits = 'Geopotential_Height', 'm'
    elif varname == "w":
        varlongname, varunits = 'Vertical_Velocity', 'm/s'
    else:
        print "no var..."
        exit()

    v = foo.createVariable(str(varname), float, ('ensemble', 'time', 'lat', 'lon',), zlib=True)
    print v
    v.units = varunits
    v.long_name = varlongname
    v.missing_value = -999
    v[:] = var[:]

    foo.close()

    print '\nWrite file:', fname, '\n'
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:70,代码来源:nc4rsm97.py

示例15: writenc4

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import comment [as 别名]
def writenc4(var, lat, lon, fname, itime, iyear, namevar):

    foo = Dataset(fname, 'w', format='NETCDF4_CLASSIC')

    foo.createDimension('ensemble', 20)
    foo.createDimension('time', None)
    foo.createDimension('lat', 72)
    foo.createDimension('lon', 109)

    foo.institution = 'FUNCEME'
    foo.comment = 'RSM97 forced by ECHAM46 - Jan Forecast'

    lats = foo.createVariable('lat', 'f4', ('lat'), zlib=True)
    lats.units = 'degrees_north'
    lats.long_name = 'latitude'
    lats.axis = "Y"
    lats[:] = lat[:]

    lons = foo.createVariable('lon', 'f4', ('lon'), zlib=True)
    lons.units = 'degrees_east'
    lons.long_name = 'longitude'
    lons.axis = "X"
    lons[:] = lon[:]

    ensemble = foo.createVariable('ensemble', 'f4', ('ensemble'), zlib=True)
    ensemble.units = 'unitless'
    ensemble.long_name = 'ensemble'
    ensemble[:] = range(20)

    # lead = foo.createVariable('lead', 'f4', ('lead'),)
    # lead.units = 'unitless'
    # lead.long_name = 'Lead'
    # lead[:] = range(int(lead))

    times = foo.createVariable('time', 'f4', ('time'), zlib=True)
    d = 'months since {0}-01-01 00:00:00'.format(iyear)
    times.units = d
    times.calendar = 'standard'
    times.standard_name = "time"
    times[:] = range(itime)

    if namevar == 'tmphag':
        lname = '2m TEMPERATURE'
        iunits = 'K'
    elif namevar == 'tmaxhag':
        lname = 'MAXIMUM TEMPERATURE'
        iunits = 'K'
    elif namevar == 'tminhag':
        lname = 'MINIMUM TEMPERATURE'
        iunits = 'K'
    else:
        print 'Saindo...'
        exit()

    vvar = foo.createVariable(namevar, float, ('ensemble', 'time', 'lat', 'lon'), zlib=True )
    print vvar
    vvar.units = iunits
    vvar.long_name = lname
    vvar.missing_value = -999
    vvar[:] = var[:]

    foo.close()

    print '\nWrite file:', fname, '\n'
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:66,代码来源:nc4rsm97.v2.py


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