当前位置: 首页>>代码示例>>Python>>正文


Python IonObject.slice方法代码示例

本文整理汇总了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
开发者ID:ooici-eoi,项目名称:pydap-handlers-ion,代码行数:57,代码来源:__init__.py


注:本文中的pyon.public.IonObject.slice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。