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


Python Dataset.institution方法代码示例

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


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

示例1: new

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

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import institution [as 别名]
def fix_netcdf(infile,outfile):
    """
    Write a new netcdf but this time do the coordinate vars correctly
    """
    rootgrp = Dataset(outfile,'w', format='NETCDF3_64BIT')

    data, targetAttrs = read_netcdf(infile,vars=('Prec','Wind','Tmax','Tmin','time','nav_lat','nav_lon'))
    res = 0.5
    # set dimensions
    lon = rootgrp.createDimension('lon',data['Prec'].shape[2])
    lat = rootgrp.createDimension('lat',data['Prec'].shape[1])
    time = rootgrp.createDimension('time',data['Prec'].shape[0])

    # do vars
    
    times = rootgrp.createVariable('time','f8',('time',))
    times[:] = np.arange(data['Prec'].shape[0])*86400
    times.units = targetAttrs['time']['units']
    times.long_name = targetAttrs['time']['long_name']
    
    lat = rootgrp.createVariable('lat','f8',('lat',))
    lat[:] = np.arange(data['nav_lat'].min(),data['nav_lat'].max()+res,res)
    lat.units = 'degrees_north'
    lat.long_name = 'Latitude'
    
    lon = rootgrp.createVariable('lon','f8',('lon',))
    lon[:] = np.arange(data['nav_lon'].min(),data['nav_lon'].max()+res,res)
    lon.units = 'degrees_east'
    lon.long_name = 'Longitude'
    
    Precip = rootgrp.createVariable('Precip','f8',('time','lat','lon',),fill_value=data['Prec'].fill_value)
    Precip[:,:,:] = data['Prec']
    Precip.units = targetAttrs['Prec']['units']
    Precip.long_name = targetAttrs['Prec']['long_name']
    
    Tmax = rootgrp.createVariable('Tmax','f8',('time','lat','lon',),fill_value=data['Tmax'].fill_value)
    Tmax[:,:,:] = data['Tmax']
    Tmax.units = targetAttrs['Tmax']['units']
    Tmax.long_name = targetAttrs['Tmax']['long_name']

    Tmin = rootgrp.createVariable('Tmin','f8',('time','lat','lon',),fill_value=data['Tmin'].fill_value)
    Tmin[:,:,:] = data['Tmin']
    Tmin.units = targetAttrs['Tmin']['units']
    Tmin.long_name = targetAttrs['Tmin']['long_name']    

    Wind = rootgrp.createVariable('Wind','f8',('time','lat','lon',),fill_value=data['Wind'].fill_value)
    Wind[:,:,:] = data['Wind']
    Wind.units = targetAttrs['Wind']['units']
    Wind.long_name = targetAttrs['Wind']['long_name']
    
    rootgrp.description = 'Global 1/2 Degree Gridded Meteorological VIC Forcing Data Set '
    rootgrp.history = 'Created: {}\n'.format(tm.ctime(tm.time()))
    rootgrp.source = sys.argv[0] # prints the name of script used
    rootgrp.institution = "University of Washington Dept. of Civil and Environmental Engineering"
    rootgrp.sources = "UDel (Willmott and Matsuura 2007), CRU (Mitchell et al., 2004), NCEP/NCAR (Kalnay et al. 1996)"
    rootgrp.projection = "Geographic"
    rootgrp.surfSng_convention = "Traditional"

    rootgrp.close()
开发者ID:orianac,项目名称:tonic,代码行数:61,代码来源:fix_global_forcings.py

示例3: writenc4

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

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

示例5: writenc4

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

示例6: write_nc_file

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

示例7: prepare_nc

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import institution [as 别名]
def prepare_nc(FileIn, FileRef, FileOut, x, y, stream_thres, relevant_T):
    """
    Prepares a target NetCDF, following the attributes of a source NetCDF file, but using the
    x-axis, y-axis of a certain projection. If the projection is lat-lon, then only a lat-lon axis
    is prepared. Otherwise an x, y axis is prepared, a projection variable is defined, and grids for
    latitude and longitude values are written to the NetCDF file.
    input:
        FileIn:         string      -- Path to NetCDF case file
        FileRef:        string      -- Path to NetCDF reference file
        FileOut:        string      -- Path to target result NetCDF file
        x:              array float -- Vector with x axis
        y:              array float -- Vector with y axis
        stream_thres:   int         -- Stream threshold, above which floods are taken into account
        relevant_T:     int         -- Return period, above which floods are taken into account
        y:              array float -- Vector with y axis
    output:
        No output from this function. The result is a prepared NetCDF file at FileOut

    """
    # if projStr.lower() == 'epsg:4326':
#    if srs.IsProjected() == 0:
#        logger.info('Found lat-lon coordinate system, preparing lat, lon axis')
#        x_dim      = 'lon';             y_dim     = 'lat'
#        x_name     = 'longitude';       y_name = 'latitude'
#        x_longname = 'Longitude values';y_longname = 'Latitude values'
#        x_unit     = 'degrees_east';       y_unit     = 'degrees_north'
#        gridmap    = 'latitude_longitude'
#    else:
#        logger.info('Found a Cartesian projection coordinate system, preparing x, y axis')
#        x_dim = 'x';                                    y_dim = 'y'
#        x_name = 'projection_x_coordinate';             y_name = 'projection_x_coordinate'
#        x_longname = 'x-coordinate in Cartesian system';y_longname = 'y-coordinate in Cartesian system'
#        x_unit     = 'm';                               y_unit     = 'm'
#        gridmap    = ''
    y_dim = 'lat'
    x_dim = 'lon'
    y_unit = 'degrees_north'
    x_unit = 'degrees_east'
    y_name = 'latitude'
    x_name = 'longitude'
    y_longname = 'Latitude values'
    x_longname = 'Longitude values'
    gridmap = 'latitude_longitude'
    logger.info('Preparing ' + FileOut)
    nc_src = Dataset(FileIn,'r')
    nc_trg = Dataset(FileOut,'w') # format='NETCDF3_CLASSIC'
    # Create dimensions
    nc_trg.createDimension("time", 0) #NrOfDays*8
    nc_trg.createDimension(y_dim, len(y))
    nc_trg.createDimension(x_dim, len(x))
    # create axes

    DateHour = nc_trg.createVariable('time','f8',('time',))
    DateHour.units = 'Years since 0001-01-01 00:00:00'
    DateHour.calendar = 'gregorian'
    DateHour.standard_name = 'time'
    DateHour.long_name = 'time'
    DateHour_src = nc_src.variables['time'][:]
    DateHour[:] = np.arange(0,len(DateHour_src))
    # DateHour[:] = nc4.date2num(datetimeObj,units=nc_src.variables['time'].units,calendar=DateHour.calendar)
    y_var = nc_trg.createVariable(y_dim,'f4',(y_dim,))
    y_var.standard_name = y_name
    y_var.long_name = y_longname
    y_var.units = y_unit
    x_var = nc_trg.createVariable(x_dim,'f4',(x_dim,))
    x_var.standard_name = x_name
    x_var.long_name = x_longname
    x_var.units = x_unit
    y_var[:] = y
    x_var[:] = x

    # Set attributes
    # Change some of the attributes, add some
    all_attrs = nc_src.ncattrs()
    for attr in all_attrs:
        try:
            attr_val = eval('nc_src.' + attr)
            exec("nc_trg." + attr + " = '" + attr_val + "'")
        except:
            logger.warning('Could not write attribute')
    nc_trg.institution     = 'Deltares\nPBL\nUtrecht University'
    nc_trg.history         = "File generated from Deltares' GLOFRIS_downscale v1.0. Original file details given in global attributes"
    nc_trg.source_case     = FileIn
    nc_trg.reference_case  = FileRef
    nc_trg.stream_threshold= str(stream_thres)
    nc_trg.return_period_threshold = str(relevant_T)
    nc_trg.disclaimer      = 'The availability and quality of these data is in no way guaranteed by Deltares'
    # write projection info to file
    wgs84 = nc_trg.createVariable('wgs84','c')
    wgs84.long_name = 'wgs84'
    wgs84.EPSG_code = 'EPSG:4326'
    wgs84.proj4_params = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
    wgs84.grid_mapping_name = 'latitude_longitude'

    # create water level variable
    variab               = nc_trg.createVariable('water_level','f4',('time',y_dim,x_dim,),chunksizes=(1,len(y),len(x)),fill_value=-9999)
    variab.units         = 'm'
    variab.standard_name = 'water_surface_height_above_reference_datum'
    variab.long_name     = 'Water level above surface elevation'

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

示例8: SeasonAccum

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import institution [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)
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:32,代码来源:rsm.py

示例9: writenc

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

示例10: writenc4

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

示例11: create_mhl_sst_ncfile

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

示例12: Dataset

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import institution [as 别名]
latli = np.argmin(np.abs(lataux - latbounds[0]))
latui = np.argmin(np.abs(lataux - latbounds[1]))
lonli = np.argmin(np.abs(lonaux - lonbounds[0]))
lonui = np.argmin(np.abs(lonaux - lonbounds[1]))
lat = data.variables['latitude'][latli:latui+1]
lon = data.variables['longitude'][lonli:lonui+1]
pcp = data.variables['precip'][:, latli:latui+1 , lonli:lonui+1]
data.close()

foo = Dataset('chirps-v2.0.monthly.as.nc', 'w', format='NETCDF3_CLASSIC')

foo.createDimension('time', None)
foo.createDimension('latitude', pcp.shape[1])
foo.createDimension('longitude', pcp.shape[2])

foo.institution = 'Climate Hazards Group.  University of California at Santa Barbara'
foo.creator_name = 'Pete Peterson'
foo.history = 'created by Climate Hazards Group - Modified by Funceme (NetCDF3 - South America)'
foo.title = 'CHIRPS Version 2.0'
foo.creator_email = '[email protected]'
foo.documentation = 'http://pubs.usgs.gov/ds/832/'
foo.comments = 'time variable denotes the first day of the given month.'
foo.ftp_url = 'ftp://chg-ftpout.geog.ucsb.edu/pub/org/chg/products/CHIRPS-latest/'
foo.website = 'http://chg.geog.ucsb.edu/data/chirps/index.html'
foo.faq = 'http://chg-wiki.geog.ucsb.edu/wiki/CHIRPS_FAQ'
foo.version = 'Version 2.0'
foo.date_created = '2015-12-02'

lats = foo.createVariable('latitude', 'f4', ('latitude'))
lats.units = 'degrees_north'
lats.long_name = 'latitude'
开发者ID:marcelorodriguesss,项目名称:FCST,代码行数:33,代码来源:nc4.to.nc3.py

示例13: corrected

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

示例14: ConvertNCCF

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

示例15: Dataset

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import institution [as 别名]
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"
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"
开发者ID:mjbrodzik,项目名称:ipython_notebooks,代码行数:34,代码来源:make_MODICEv04_min05yr_netcdf.py


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