本文整理汇总了Python中nansat.Nansat.export2thredds方法的典型用法代码示例。如果您正苦于以下问题:Python Nansat.export2thredds方法的具体用法?Python Nansat.export2thredds怎么用?Python Nansat.export2thredds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nansat.Nansat
的用法示例。
在下文中一共展示了Nansat.export2thredds方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_export2thredds_stere_one_band
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import export2thredds [as 别名]
def test_export2thredds_stere_one_band(self):
# skip the test if anaconda is used
if IS_CONDA:
return
n = Nansat(self.test_file_stere, logLevel=40)
tmpfilename = os.path.join(ntd.tmp_data_path,
'nansat_export2thredds_1b.nc')
n.export2thredds(tmpfilename, ['L_469'])
self.assertTrue(os.path.exists(tmpfilename))
示例2: test_export2thredds_longlat_list
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import export2thredds [as 别名]
def test_export2thredds_longlat_list(self):
d = Domain("+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs",
"-te 27 70 31 72 -ts 200 200")
n = Nansat(domain=d)
n.add_band(np.ones(d.shape(), np.float32),
parameters={'name': 'L_469'})
n.set_metadata('time_coverage_start', '2016-01-19')
tmpfilename = os.path.join(ntd.tmp_data_path,
'nansat_export2thredds_longlat.nc')
n.export2thredds(tmpfilename, ['L_469'])
ncI = netcdf_file(tmpfilename, 'r')
ncIVar = ncI.variables['L_469']
self.assertTrue(ncIVar.grid_mapping in ncI.variables.keys())
示例3: test_export2thredds_stere_many_bands
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import export2thredds [as 别名]
def test_export2thredds_stere_many_bands(self):
# skip the test if anaconda is used
if IS_CONDA:
return
n = Nansat(self.test_file_stere, logLevel=40)
tmpfilename = os.path.join(ntd.tmp_data_path,
'nansat_export2thredds_3b.nc')
bands = {
'L_645' : {'type': '>i1'},
'L_555' : {'type': '>i1'},
'L_469' : {'type': '>i1'},
}
n.export2thredds(tmpfilename, bands)
self.assertTrue(os.path.exists(tmpfilename))
示例4: test_export2thredds_arctic_long_lat
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import export2thredds [as 别名]
def test_export2thredds_arctic_long_lat(self):
n = Nansat(self.test_file_arctic, logLevel=40)
tmpfilename = os.path.join(ntd.tmp_data_path,
'nansat_export2thredds_arctic.nc')
bands = {
'Bristol': {'type': '>i2'},
'Bootstrap': {'type': '>i2'},
'UMass_AES': {'type': '>i2'},
}
n.export2thredds(tmpfilename, bands,
time=datetime.datetime(2016, 1, 20))
self.assertTrue(os.path.exists(tmpfilename))
g = gdal.Open(tmpfilename)
metadata = g.GetMetadata_Dict()
# Test that the long/lat values are set aproximately correct
ncg = 'NC_GLOBAL#'
easternmost_longitude = metadata.get(ncg + 'easternmost_longitude')
self.assertTrue(float(easternmost_longitude) > 179,
'easternmost_longitude is wrong:' +
easternmost_longitude)
westernmost_longitude = metadata.get(ncg + 'westernmost_longitude')
self.assertTrue(float(westernmost_longitude) < -179,
'westernmost_longitude is wrong:' +
westernmost_longitude)
northernmost_latitude = metadata.get(ncg + 'northernmost_latitude')
self.assertTrue(float(northernmost_latitude) > 89.999,
'northernmost_latitude is wrong:' +
northernmost_latitude)
southernmost_latitude = metadata.get(ncg + 'southernmost_latitude')
self.assertTrue(float(southernmost_latitude) < 54,
'southernmost_latitude is wrong:' +
southernmost_latitude)
self.assertTrue(float(southernmost_latitude) > 53,
'southernmost_latitude is wrong:' +
southernmost_latitude)
示例5: test_export2thredds_arctic_long_lat
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import export2thredds [as 别名]
def test_export2thredds_arctic_long_lat(self):
n = Nansat(self.test_file_arctic, mapper=self.default_mapper, log_level=40)
tmpfilename = os.path.join(self.tmp_data_path,
'nansat_export2thredds_arctic.nc')
bands = {
'Bristol': {'type': '>i2'},
'Bootstrap': {'type': '>i2'},
'UMass_AES': {'type': '>i2'},
}
n.export2thredds(tmpfilename, bands, time=datetime.datetime(2016, 1, 20))
self.assertTrue(os.path.exists(tmpfilename))
g = gdal.Open(tmpfilename)
metadata = g.GetMetadata_Dict()
# GDAL behaves differently:
# Windows: nc-attributes are accessible without 'NC_GLOBAL#' prefix
# Linux: nc-attributes are accessible only with 'NC_GLOBAL#' prefix
# OSX: ?
# Therefore we have to add NC_GLOBAL# and test if such metadata exists
nc_prefix = 'NC_GLOBAL#'
if not nc_prefix + 'easternmost_longitude' in metadata:
nc_prefix = ''
self.assertIn(nc_prefix + 'easternmost_longitude', metadata)
# Test that the long/lat values are set correctly
test_metadata_keys = ['easternmost_longitude', 'westernmost_longitude',
'northernmost_latitude', 'southernmost_latitude']
test_metadata_min = [179, -180, 89.9, 53]
test_metadata_max = [180, -179, 90, 54]
for i, test_metadata_key in enumerate(test_metadata_keys):
medata_value = float(metadata[nc_prefix + test_metadata_key])
self.assertTrue(medata_value >= test_metadata_min[i],
'%s is wrong: %f'%(test_metadata_key, medata_value))
self.assertTrue(medata_value <= test_metadata_max[i],
'%s is wrong: %f'%(test_metadata_key, medata_value))
示例6: test_export2thredds_rmmetadata
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import export2thredds [as 别名]
def test_export2thredds_rmmetadata(self):
n = Nansat(self.test_file_arctic, mapper=self.default_mapper, log_level=40)
n.export2thredds(self.tmp_filename, {'Bristol': {'type': '>i2'}},
time=datetime.datetime(2016, 1, 20),
rm_metadata=['description'])
示例7: test_export2thredds_longlat_list
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import export2thredds [as 别名]
def test_export2thredds_longlat_list(self):
n = Nansat(self.test_file_gcps, log_level=40, mapper=self.default_mapper)
with self.assertRaises(ValueError):
n.export2thredds('aa', ['L_469'])