本文整理汇总了Python中ocgis.RequestDataset.load方法的典型用法代码示例。如果您正苦于以下问题:Python RequestDataset.load方法的具体用法?Python RequestDataset.load怎么用?Python RequestDataset.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ocgis.RequestDataset
的用法示例。
在下文中一共展示了RequestDataset.load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: smm
# 需要导入模块: from ocgis import RequestDataset [as 别名]
# 或者: from ocgis.RequestDataset import load [as 别名]
def smm(index_path, wd=None, data_variables='auto'):
"""
Run a chunked sparse matrix multiplication.
:param str index_path: Path to chunked operation's index file.
:param str wd: Path to the directory containing the chunk files.
:param list data_variables: Optional list of data variables. Otherwise, auto-discovery is used.
"""
# Assume the current working directory
if wd is None:
wd = ''
# Turn on auto-discovery
if data_variables == 'auto':
v = None
else:
v = data_variables
# Get the attribute host
index_field = RequestDataset(index_path).get()
gs_index_v = index_field[GridChunkerConstants.IndexFile.NAME_INDEX_VARIABLE]
# Collect the source filenames
src_filenames = gs_index_v.attrs[GridChunkerConstants.IndexFile.NAME_SOURCE_VARIABLE]
src_filenames = index_field[src_filenames]
src_filenames = src_filenames.join_string_value()
# Collect the destination file names
dst_filenames = gs_index_v.attrs[GridChunkerConstants.IndexFile.NAME_DESTINATION_VARIABLE]
dst_filenames = index_field[dst_filenames]
dst_filenames = dst_filenames.join_string_value()
# Collect the weight filenames
wgt_filenames = gs_index_v.attrs[GridChunkerConstants.IndexFile.NAME_WEIGHTS_VARIABLE]
wgt_filenames = index_field[wgt_filenames]
wgt_filenames = wgt_filenames.join_string_value()
# Main loop for executing the SMM
for ii in range(src_filenames.size):
ocgis_lh(msg="Running SMM {} of {}".format(ii + 1, src_filenames.size), level=10, logger='regrid.base')
src_path = os.path.join(wd, src_filenames[ii])
src_field = RequestDataset(src_path, variable=v, decomp_type=DecompositionType.ESMF).create_field()
src_field.load()
dst_path = os.path.join(wd, dst_filenames[ii])
dst_field = RequestDataset(dst_path, decomp_type=DecompositionType.ESMF).create_field()
dst_field.load()
from ocgis.regrid.base import RegridOperation
from ESMF.api.constants import RegridMethod
# HACK: Note that weight filenames are stored with their full path.
# HACK: Always use a bilinear regridding method to allows for the identity sparse matrix in the case of
# equal grids.
regrid_options = {'split': False, 'weights_in': wgt_filenames[ii], 'regrid_method': RegridMethod.BILINEAR}
ro = RegridOperation(src_field, dst_field, regrid_options=regrid_options)
regridded = ro.execute()
regridded.write(dst_path)