本文整理汇总了Python中pyon.public.IonObject.slice方法的典型用法代码示例。如果您正苦于以下问题:Python IonObject.slice方法的具体用法?Python IonObject.slice怎么用?Python IonObject.slice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.public.IonObject
的用法示例。
在下文中一共展示了IonObject.slice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_constraints
# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import slice [as 别名]
def parse_constraints(self, environ):
# print ">> Start parse_constraints"
# import pprint
# pprint.pprint("")
# pprint.pprint(environ)
ds_name, ds_id, ds_url, buf_size = get_dataset_info(self)
# print "DS Info: name=%s ds_id=%s ds_url=%s buf_size=%s" % (ds_name, ds_id, ds_url, buf_size)
# TODO: Call the "damsP" module to retrieve a BaseDatasetHandler based on the ds_id
dsh = self.damsP.get_data_handlers(ds_id=ds_id)
#DSH WAY
dataset_type = DatasetType(name=ds_name, attributes={'NC_GLOBAL': dsh.get_attributes()})
fields, queries = environ['pydap.ce']
fields = fields or [[(name, ())] for name in dsh.ds.variables]
# print "CE Fields: %s" % fields
# print "CE Queries: %s" % queries
pdr_obj = IonObject("PydapVarDataRequest", name="p_req")
for fvar in fields:
target = dataset_type
while fvar:
name, slice_ = fvar.pop(0)
pdr_obj.name = name
pdr_obj.slice = slice_
if (name in dsh.ds.dimensions or not dsh.ds.variables[name].dimensions or target is not dataset_type):
# print "==> if"
nm, dat, tc, di, at = dsh.acquire_data(request=pdr_obj)
target[name] = BaseType(name=nm, data=dat, shape=dat.shape, type=tc, dimensions=di, attributes=at)
elif fvar:
# print "==> elif"
attrs = dsh.get_attributes(name)
target.setdefault(name, StructureType(name=name, attributes=attrs))
target = target[name]
else:
# print "==> else"
attrs = dsh.get_attributes(name)
grid = target[name] = GridType(name=name, attributes=attrs)
nm, dat, tc, di, at = dsh.acquire_data(request=pdr_obj)
grid[name] = BaseType(name=nm, data=dat, shape=dat.shape, type=tc, dimensions=di, attributes=at)
slice_ = list(slice_) + [slice(None)] * (len(grid.array.shape) - len(slice_))
for dim, dimslice in zip(dsh.ds.variables[name].dimensions, slice_):
pdr_obj.name=dim
pdr_obj.slice=dimslice
nm, dat, tc, di, at = dsh.acquire_data(request=pdr_obj)
grid[dim] = BaseType(name=nm, data=dat, shape=dat.shape, type=tc, dimensions=di, attributes=at)
dataset_type._set_id()
dataset_type.close = dsh.ds.close
# print ">> End parse_constraints"
return dataset_type