本文整理汇总了Python中nansat.Nansat.from_domain方法的典型用法代码示例。如果您正苦于以下问题:Python Nansat.from_domain方法的具体用法?Python Nansat.from_domain怎么用?Python Nansat.from_domain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nansat.Nansat
的用法示例。
在下文中一共展示了Nansat.from_domain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_export_gcps_complex_to_netcdf
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import from_domain [as 别名]
def test_export_gcps_complex_to_netcdf(self):
""" Should export file with GCPs and write correct complex bands"""
n0 = Nansat(self.test_file_gcps, log_level=40, mapper=self.default_mapper)
b0 = n0['L_469']
n1 = Nansat.from_domain(n0)
n1.add_band(b0.astype('complex64'), parameters={'name': 'L_469'})
tmpfilename = os.path.join(self.tmp_data_path, 'nansat_export_gcps_complex.nc')
n1.export(tmpfilename)
ncf = Dataset(tmpfilename)
self.assertTrue(os.path.exists(tmpfilename))
self.assertTrue('GCPX' in ncf.variables)
self.assertTrue('GCPY' in ncf.variables)
self.assertTrue('GCPPixel' in ncf.variables)
self.assertTrue('GCPLine' in ncf.variables)
n2 = Nansat(tmpfilename, mapper=self.default_mapper)
b2 = n2['L_469']
lon0, lat0 = n0.get_geolocation_grids()
lon2, lat2 = n1.get_geolocation_grids()
np.testing.assert_allclose(lon0, lon2)
np.testing.assert_allclose(lat0, lat2)
示例2: test_dont_export2thredds_gcps
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import from_domain [as 别名]
def test_dont_export2thredds_gcps(self):
n = Nansat(self.test_file_gcps, log_level=40, mapper=self.default_mapper)
n2 = Nansat.from_domain(n)
n.add_band(np.ones(n2.shape(), np.float32))
tmpfilename = os.path.join(self.tmp_data_path,
'nansat_export2thredds.nc')
self.assertRaises(ValueError, n2.export2thredds, tmpfilename,
['L_645'])
示例3: test_export2thredds_longlat_dict
# 需要导入模块: from nansat import Nansat [as 别名]
# 或者: from nansat.Nansat import from_domain [as 别名]
def test_export2thredds_longlat_dict(self):
d = Domain("+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs",
"-te 27 70 31 72 -ts 200 200")
n = Nansat.from_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(self.tmp_data_path,
'nansat_export2thredds_longlat.nc')
n.export2thredds(tmpfilename, {'L_469': {'type': '>i1'}})
ncI = Dataset(tmpfilename, 'r')
ncIVar = ncI.variables['L_469']
self.assertTrue(ncIVar.grid_mapping in ncI.variables.keys())
self.assertEqual(ncIVar[:].dtype, np.int8)