Пример #1
0
    def create_variable_element(self, variableResult):
        variable = WaterML.VariableInfoType(
            variableName=variableResult.VariableName,
            valueType=variableResult.ValueType,
            dataType=variableResult.DataType,
            generalCategory=variableResult.GeneralCategory,
            sampleMedium=variableResult.SampleMedium,
            NoDataValue=variableResult.NoDataValue,
            variableDescription=variableResult.VariableDescription)

        variableCode = WaterML.variableCode()
        variableCode.vocabulary = self.vocabulary
        #TODO: What is this, should it always be true?
        variableCode.default = "true"
        variableCode.variableID = variableResult.VariableID
        variableCode.valueOf_ = variableResult.VariableCode

        variable.add_variableCode(variableCode)

        if variableResult.VariableUnits:
            units = WaterML.units(
                unitsAbbreviation=variableResult.VariableUnits.
                UnitsAbbreviation,
                unitsCode=variableResult.VariableUnitsID,
                unitsType=variableResult.VariableUnits.UnitsType,
                valueOf_=variableResult.VariableUnits.UnitsName)

            variable.set_units(units)

        timeSupport = WaterML.timeSupport()
        timeSupport.isRegular = variableResult.IsRegular

        if variableResult.TimeUnits:
            timeUnits = WaterML.UnitsType(
                UnitID=variableResult.TimeUnits.UnitsID,
                UnitName=variableResult.TimeUnits.UnitsName,
                UnitDescription=variableResult.TimeUnits.UnitsName,
                UnitType=variableResult.TimeUnits.UnitsType,
                UnitAbbreviation=variableResult.TimeUnits.UnitsAbbreviation)

            timeSupport.set_unit(timeUnits)

        # TODO: time interval is not the same as time support.
        # Time interval refers to a spacing between values for regular data,
        # which isn't stored in ODM.
        if variableResult.TimeSupport:
            # integer in WaterML 1.0
            timeSupport.timeInterval = str(int(variableResult.TimeSupport))
        variable.set_timeSupport(timeSupport)
        return variable
Пример #2
0
    def create_offset_element(self, offsetTypeResult):
        #TODO: where does offsetIsVertical come from
        #TODO: where does offsetHorizDirectionDegrees come from?
        offset = WaterML.OffsetType(
            offsetTypeID=offsetTypeResult.OffsetTypeID,
            offsetValue=None,
            offsetDescription=offsetTypeResult.OffsetDescription,
            offsetIsVertical='true',
            offsetHorizDirectionDegrees=None)

        if offsetTypeResult.OffsetUnits:
            units = WaterML.UnitsType(
                UnitID=offsetTypeResult.OffsetUnits.UnitsID,
                UnitAbbreviation=offsetTypeResult.OffsetUnits.
                UnitsAbbreviation,
                UnitName=offsetTypeResult.OffsetUnits.UnitsName,
                UnitType=offsetTypeResult.OffsetUnits.UnitsType)

            offset.units = units

        return offset