예제 #1
0
    def __init__(self, cdf, path):
        
        self.attr_only = False
        if (cdf is None ):
            self.noncd = True
            self.file = {}
            self.path = path
        else:
            # load config and set it based on 
            config = getConfig()
            projectSection = 'project:dream'
            variables_none = config.get(projectSection, "variables_none", default="false")

            if variables_none == "false":
                self.noncd = False
                CdunifFormatHandler.__init__(self, cdf, path)
            elif variables_none == "attr":
                CdunifFormatHandler.__init__(self, cdf, path)
                self.attr_only = True
                self.noncd = True
            else:  # assume "true"
                self.noncd = True
                self.file = {}
                self.path = path
                self.attr_only = False
    def __init__(self, cdf, path):

        if (cdf is None):
            self.noncd = True
            self.file = {}
            self.path = path
        else:
            # load config and set it based on
            config = getConfig()
            projectSection = 'project:input4mips'
            variables_none = config.get(projectSection,
                                        "variables_none",
                                        default="false")

            if variables_none == "false":
                self.noncd = False
                CdunifFormatHandler.__init__(self, cdf, path)
            elif variables_none == "attr":
                CdunifFormatHandler.__init__(self, cdf, path)
                self.attr_only = True
                self.noncd = True
            else:  # assume "true"
                self.noncd = True
                self.file = {}
                self.path = path
                self.attr_only = False
    def __init__(self, cdf):

        if cdf is None:
            self.noncd = True
        else:
            self.noncd = False
            CdunifFormatHandler.__init__(self, cdf)
예제 #4
0
 def __init__(self, cdf):
     
     if (cdf is None ):
         self.noncd = True
     else:
         self.noncd = False
         CdunifFormatHandler.__init__(self, cdf)
예제 #5
0
    def __init__(self, cdf, path):

        if (cdf is None):
            self.noncd = True
            self.file = {}
            self.path = path
        else:
            self.noncd = False
            CdunifFormatHandler.__init__(self, cdf, path)
 def __init__(self, cdf, path):
     
     if (cdf is None ):
         self.noncd = True
         self.file = {}
         self.path = path
     else:
         self.noncd = False
         CdunifFormatHandler.__init__(self, cdf, path)
예제 #7
0
    def inquireVariableList(self):
        """
        Inquire the variable names.

        Returns a list of string variable names.
        """
        if (self.noncd):
            return []
        else:
            return CdunifFormatHandler.inquireVariableList(self)
    def inquireVariableList(self):
        """
        Inquire the variable names.

        Returns a list of string variable names.
        """
        if (self.noncd):
            return []
        else:
            return CdunifFormatHandler.inquireVariableList(self)
    def inquireVariableDimensions(self, variableName):
        """
        Inquire the dimension names of a variable.

        Returns a list of string dimension names of the variable.
        """
        if (self.noncd):
            return []
        else:
            return CdunifFormatHandler.inquireVariableDimensions(self, variableName)
예제 #10
0
    def inquireVariableDimensions(self, variableName):
        """
        Inquire the dimension names of a variable.

        Returns a list of string dimension names of the variable.
        """
        if (self.noncd):
            return []
        else:
            return CdunifFormatHandler.inquireVariableDimensions(self, variableName)
예제 #11
0
    def __init__(self, cdf, path):
        
        if (cdf is None ):
            self.noncd = True
            self.file = {}
            self.path = path
        else:
            # load config and set it based on 
            config = getConfig()
            projectSection = 'project:'
            variables_none = config.get(projectSection, "variables_none", default="false")

            if variables_none == "false":
                self.noncd = False
                CdunifFormatHandler.__init__(self, cdf, path)
            else:
                self.noncd = True
                self.file = {}
                self.path = path
예제 #12
0
    def hasVariable(self, variableName):
        """
        Returns True iff a file has the given variable.

        variableName:
          String name of the variable.
        """
        if (self.noncd):
            return False
        else:
            return CdunifFormatHandler.hasVariable(self, variableName)
    def hasVariable(self, variableName):
        """
        Returns True iff a file has the given variable.

        variableName:
          String name of the variable.
        """
        if (self.noncd):
            return False
        else:
            return CdunifFormatHandler.hasVariable(self, variableName)
예제 #14
0
    def inquireAttributeList(self, variableName=None):
        """
        Inquire global or variable attribute names.

        Returns a list of attribute names.

        variableName
          String variable name. If None, return the global attribute list.
        """
        if (self.noncd):
            return []
        else:
            return CdunifFormatHandler.inquireAttributeList(self, variableName=variableName)
    def inquireAttributeList(self, variableName=None):
        """
        Inquire global or variable attribute names.

        Returns a list of attribute names.

        variableName
          String variable name. If None, return the global attribute list.
        """
        if (self.noncd):
            return []
        else:
            return CdunifFormatHandler.inquireAttributeList(self, variableName=variableName)
    def inquireVariableShape(self, variableName):
        """
        Get the shape of the variable multidimensional array.

        Returns a tuple of ints.

        variableName
          String name of the variable.
        """
        if (self.noncd):
            return []
        else:
            return CdunifFormatHandler.inquireVariableShape(self, variableName)
예제 #17
0
    def inquireVariableShape(self, variableName):
        """
        Get the shape of the variable multidimensional array.

        Returns a tuple of ints.

        variableName
          String name of the variable.
        """
        if (self.noncd):
            return []
        else:
            return CdunifFormatHandler.inquireVariableShape(self, variableName)
예제 #18
0
    def hasAttribute(self, attributeName, variableName=None):
        """
        Returns True iff a file or variable has an attribute.

        attributeName
          String name of the attribute.

        variableName:
          String name of the variable. If None, check a global attribute.
        """
        if (self.noncd):
            return False
        else:
            return CdunifFormatHandler.hasAttribute(self, attributeName, variableName=variableName)
    def hasAttribute(self, attributeName, variableName=None):
        """
        Returns True iff a file or variable has an attribute.

        attributeName
          String name of the attribute.

        variableName:
          String name of the variable. If None, check a global attribute.
        """
        if (self.noncd):
            return False
        else:
            return CdunifFormatHandler.hasAttribute(self, attributeName, variableName=variableName)
예제 #20
0
    def getVariable(self, variableName, index=None):
        """
        Get the value of the variable.

        Returns a numpy array.

        variableName
          String name of the variable.

        index
          Integer index to select along the first dimension. If None, return all values.
          
        """
        if (self.noncd or ):
            return []
        else:
            return CdunifFormatHandler.getVariable(self, variableName, index=index)
    def getVariable(self, variableName, index=None):
        """
        Get the value of the variable.

        Returns a numpy array.

        variableName
          String name of the variable.

        index
          Integer index to select along the first dimension. If None, return all values.
          
        """
        if (self.noncd):
            return []
        else:
            return CdunifFormatHandler.getVariable(self, variableName, index=index)
예제 #22
0
    def getAttribute(self, attributeName, variableName, *args):
        """
        Get the value of a global or variable attribute.

        Returns the attribute value, as an int, float, or 1-d numpy array.

        attributeName
          String name of the attribute.

        variableName:
          String name of the variable. If None, get a global attribute.

        args
          optional default value if the attribute is not found.
        """
        if (self.noncd):
            return None
        else:
            return CdunifFormatHandler.getAttribute(self, attributeName, variableName, *args)
    def getAttribute(self, attributeName, variableName, *args):
        """
        Get the value of a global or variable attribute.

        Returns the attribute value, as an int, float, or 1-d numpy array.

        attributeName
          String name of the attribute.

        variableName:
          String name of the variable. If None, get a global attribute.

        args
          optional default value if the attribute is not found.
        """
        if (self.noncd):
            return None
        else:
            return CdunifFormatHandler.getAttribute(self, attributeName, variableName, *args)
예제 #24
0
    def open(path, mode='r'):
        """
        Open a file.

        Returns an instance of the format handler. 

        path
          String path name.

        mode
          String mode. Since only mode='r' (read-only) is currently used, it is optional.
          """
        f = None
        
        if (path[-3:] == ".nc"):  
            cd = CdunifFormatHandler.open(path, mode=mode)

            f = AcmeMultiFormatHandler(cd.file)
        else:
            f = AcmeMultiFormatHandler(None)
        return f
    def open(path, mode="r"):
        """
        Open a file.

        Returns an instance of the format handler. 

        path
          String path name.

        mode
          String mode. Since only mode='r' (read-only) is currently used, it is optional.
          """
        f = None

        if path[-3:] == ".nc":
            cd = CdunifFormatHandler.open(path, mode=mode)

            f = AcmeMultiFormatHandler(cd.file)
        else:
            f = AcmeMultiFormatHandler(None)
        return f
 def close(self):
     """
     Close the file.
     """
     if self.noncd == False:
         CdunifFormatHandler.close(self)
예제 #27
0
 def close(self):
     """
     Close the file.
     """
     if self.noncd == False:
         CdunifFormatHandler.close(self)