コード例 #1
0
ファイル: ncml.py プロジェクト: AZed/uvcdat
 def toCDML(self, forcedata=0):
     "Translate to a CDML tree. Returns a cdms.cdmsNode.AxisNode."
     axisnode = AxisNode(self.name, self.length, CdFloat) # Only for virtual axes
     axisnode.setExternalAttr("isvar", "false", CdString)
     if forcedata:
         axisnode.setData(Numeric.arrayrange(float(self.length)))
     return axisnode
コード例 #2
0
    def toCDML(self, ncnode, forcedata=0):
        "Translate to a CDML tree. Returns a cdms.cdmsNode.VariableNode or cdms.cdmsNode.AxisNode."
        dimdict = ncnode.dimensions
        if self.name in dimdict.keys() and self.shape is not None and len(
                self.shape) == 1:
            dimnode = dimdict[self.name]
            varnode = AxisNode(self.name, dimnode.length,
                               NCToCdType[self.datatype])
            if self.values is not None:
                varnode.setData(self.values.values)
            elif forcedata:
                varnode.setData(Numeric.arrayrange(float(dimnode.length)))
        else:
            domnode = DomainNode()
            if self.shape is not None:
                for dimid in self.shape:
                    dimncnode = dimdict[dimid]
                    domelemnode = DomElemNode(dimid, 0, dimncnode.length)
                    domnode.add(domelemnode)
            varnode = cdmsNode.VariableNode(self.name,
                                            NCToCdType[self.datatype], domnode)

        attkeys = self.attributes.keys()
        attkeys.sort()
        for attkey in attkeys:
            attncnode = self.attributes[attkey]
            value = attncnode.value
            if isinstance(value, Numeric.ArrayType):
                value = value[0]
            varnode.setExternalAttr(attncnode.name, value,
                                    NCToCdType[attncnode.datatype])
        return varnode
コード例 #3
0
ファイル: ncml.py プロジェクト: AZed/uvcdat
    def toCDML(self, ncnode, forcedata=0):
        "Translate to a CDML tree. Returns a cdms.cdmsNode.VariableNode or cdms.cdmsNode.AxisNode."
        dimdict = ncnode.dimensions
        if self.name in dimdict.keys() and self.shape is not None and len(self.shape)==1:
            dimnode = dimdict[self.name]
            varnode = AxisNode(self.name, dimnode.length, NCToCdType[self.datatype])
            if self.values is not None:
                varnode.setData(self.values.values)
            elif forcedata:
                varnode.setData(Numeric.arrayrange(float(dimnode.length)))
        else:
            domnode = DomainNode()
            if self.shape is not None:
                for dimid in self.shape:
                    dimncnode = dimdict[dimid]
                    domelemnode = DomElemNode(dimid, 0, dimncnode.length)
                    domnode.add(domelemnode)
            varnode = cdmsNode.VariableNode(self.name, NCToCdType[self.datatype], domnode)

        attkeys = self.attributes.keys()
        attkeys.sort()
        for attkey in attkeys:
            attncnode = self.attributes[attkey]
            value = attncnode.value
            if isinstance(value, Numeric.ArrayType):
                value = value[0]
            varnode.setExternalAttr(attncnode.name, value, NCToCdType[attncnode.datatype])
        return varnode
コード例 #4
0
 def toCDML(self, forcedata=0):
     "Translate to a CDML tree. Returns a cdms.cdmsNode.AxisNode."
     axisnode = AxisNode(self.name, self.length,
                         CdFloat)  # Only for virtual axes
     axisnode.setExternalAttr("isvar", "false", CdString)
     if forcedata:
         axisnode.setData(Numeric.arrayrange(float(self.length)))
     return axisnode