本文整理汇总了Python中nansat.vrt.VRT._remove_strings_in_metadata_keys方法的典型用法代码示例。如果您正苦于以下问题:Python VRT._remove_strings_in_metadata_keys方法的具体用法?Python VRT._remove_strings_in_metadata_keys怎么用?Python VRT._remove_strings_in_metadata_keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nansat.vrt.VRT
的用法示例。
在下文中一共展示了VRT._remove_strings_in_metadata_keys方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from nansat.vrt import VRT [as 别名]
# 或者: from nansat.vrt.VRT import _remove_strings_in_metadata_keys [as 别名]
def __init__(self, *args, **kwargs):
filename = args[0]
gdal_metadata = VRT._remove_strings_in_metadata_keys(args[2],
['NC_GLOBAL#', 'NANSAT_', 'GDAL_'])
gcmd_keywords_mapping = get_gcmd_keywords_mapping()
for key, val in list(gcmd_keywords_mapping.items()):
if 'source' in list(gdal_metadata.keys()) and key in gdal_metadata['source']:
instrument = gcmd_keywords_mapping[key]['instrument']
platform = gcmd_keywords_mapping[key]['platform']
if not 'instrument' in locals():
raise WrongMapperError
super(Mapper, self).__init__(*args, **kwargs)
time_coverage_start, time_coverage_end = self.time_coverage()
self.dataset.SetMetadataItem('time_coverage_start',
(time_coverage_start.isoformat()))
self.dataset.SetMetadataItem('time_coverage_end',
(time_coverage_end.isoformat()))
self.dataset.SetMetadataItem('instrument', instrument)
self.dataset.SetMetadataItem('platform', platform)
示例2: __init__
# 需要导入模块: from nansat.vrt import VRT [as 别名]
# 或者: from nansat.vrt.VRT import _remove_strings_in_metadata_keys [as 别名]
def __init__(self, filename, gdal_dataset, gdal_metadata, *args, **kwargs):
if not filename.endswith('nc'):
raise WrongMapperError
self.input_filename = filename
if not gdal_metadata:
raise WrongMapperError
if 'NC_GLOBAL#GDAL_NANSAT_GCPY_000' in list(gdal_metadata.keys()) or \
'NC_GLOBAL#GDAL_NANSAT_GCPProjection' in list(gdal_metadata.keys()):
# Probably Nansat generated netcdf of swath data - see issue #192
raise WrongMapperError
metadata = VRT._remove_strings_in_metadata_keys(gdal_metadata,
['NC_GLOBAL#', 'NANSAT_', 'GDAL_'])
# Set origin metadata (TODO: agree on keyword...)
origin = ''
nans = 'NANSAT'
if 'origin' in list(metadata.keys()):
origin = metadata['origin'] + ' '
for key in list(metadata.keys()):
if nans in key:
metadata['origin'] = origin + nans
# else: Nothing needs to be done, origin stays the same...
# Check conventions metadata
if 'Conventions' not in list(metadata.keys()) or 'CF' not in metadata['Conventions']:
raise WrongMapperError
# OBS: at this point, generic mapper fails...
#if metadata.has_key('GCPProjection'):
# # Probably Nansat generated netcdf of swath data - see issue #192
# raise WrongMapperError
# Create empty VRT dataset with geo-reference
self._create_empty(gdal_dataset, metadata)
# Add bands with metadata and corresponding values to the empty VRT
self.create_bands(self._band_list(gdal_dataset, metadata, *args, **kwargs))
# Check size?
#xsize, ysize = self.ds_size(sub0)
# Create complex bands from *_real and *_imag bands (the function is in
# vrt.py)
self._create_complex_bands(self._get_sub_filenames(gdal_dataset))
# Set GCMD/DIF compatible metadata if available
self._set_time_coverage_metadata(metadata)
示例3: test_remove_strings_in_metadata_keys
# 需要导入模块: from nansat.vrt import VRT [as 别名]
# 或者: from nansat.vrt.VRT import _remove_strings_in_metadata_keys [as 别名]
def test_remove_strings_in_metadata_keys(self):
gdal_metadata = {'aaa': 'bbb', 'NC_GLOBAL#ccc': 'ddd', 'NANSAT_eee': 'fff'}
rm_strings = ['NC_GLOBAL#', 'NANSAT_']
new_metadata = VRT._remove_strings_in_metadata_keys(gdal_metadata, rm_strings)
self.assertEqual(new_metadata, {'aaa': 'bbb', 'ccc': 'ddd', 'eee': 'fff'})