Ejemplo n.º 1
0
    def __init__(self, sites_file_path, values_file_path):
        #self.sites_file_path = sites_file_path
        #self.values_file_path = values_file_path

        self.sites_file_path = os.path.abspath(sites_file_path)
        self.values_file_path = os.path.abspath(values_file_path)

        # Build a dictionary of variables indexed by code
        variable_dict = {}

        stage = csv_model.Variable()
        stage.VariableCode = 'Stage_ft'
        stage.VariableName = 'Stage'
        stage_units = wof_base.BaseUnits()
        stage_units.UnitsName = 'international foot'
        stage_units.UnitsType = 'Length'
        stage_units.UnitsAbbreviation = 'ft'
        stage.VariableUnits = stage_units
        variable_dict['Stage_ft'] = stage

        flow = csv_model.Variable()
        flow.VariableCode = 'Discharge_cfs'
        flow.VariableName = 'Discharge'
        flow_units = wof_base.BaseUnits()
        flow_units.UnitsName = 'cubic feet per second'
        flow_units.UnitsType = 'Flow'
        flow_units.UnitsAbbreviation = 'cfs'
        flow.VariableUnits = flow_units
        variable_dict['Discharge_cfs'] = flow

        self.variable_dict = variable_dict
Ejemplo n.º 2
0
 def append_units(self,get_variables_response):
     r = get_variables_response
     for i in range(len(get_variables_response)):
         #Declare a new instance of BaseUnits for each VariableUnits object of
         #each item in get_all_variables response.
         #If you don't do this all items will end up referencing the same
         #memory location for VariableUnits.            
         r[i].VariableUnits = wof_base.BaseUnits()
         
         r[i].VariableUnits.UnitsID = r[i].VariableUnits_UnitsID
         r[i].VariableUnits.UnitsName = r[i].VariableUnits_UnitsName
         r[i].VariableUnits.UnitsAbbreviation = r[i].VariableUnits_UnitsAbbreviation    
     
     return r
Ejemplo n.º 3
0
class Variable(wof_base.BaseVariable):
    # Properties common to all variables in this example
    SampleMedium = wof_base.SampleMediumTypes.SURFACE_WATER
    IsRegular = True
    ValueType = 'Field Observation'
    DataType = 'Average'
    NoDataValue = -9999
    TimeSupport = 1
    TimeUnitsID = 1
    GeneralCategory = wof_base.GeneralCategoryTypes.HYDROLOGY
    TimeUnits = wof_base.BaseUnits()
    TimeUnits.UnitsID = 1
    TimeUnits.UnitsName = 'day'
    TimeUnits.UnitsType = 'Time'
    TimeUnits.UnitsAbbreviation = 'd'
Ejemplo n.º 4
0
variableResultArr = dao.get_all_variables()
print variableResultArr
#for variableResult in variableResultArr:
#    print variableResult.VariableCode # This worked yay
#    #variableResult.VariableUnits.UnitsID = variableResult.VariableUnits_UnitsID
#    #variableResult.VariableUnits.UnitsName = variableResult.VariableUnits_UnitsName
#    #variableResult.VariableUnits.UnitsType = variableResult.VariableUnits_UnitsName
#    print variableResult.VariableUnits_UnitsAbbreviation
#    print variableResult.VariableUnits.UnitsAbbreviation

r = variableResultArr
for i in range(len(r)):
    print i
    print r[i].VariableName

    r[i].VariableUnits = wof_base.BaseUnits()
    r[i].VariableUnits.UnitsAbbreviation = str(
        r[i].VariableUnits_UnitsAbbreviation)
    r[0].VariableUnits.UnitsAbbreviation = "monkey"
    print r[0].VariableUnits.UnitsAbbreviation
    print r[1].VariableUnits.UnitsAbbreviation
    print r[2].VariableUnits.UnitsAbbreviation
    print r[3].VariableUnits.UnitsAbbreviation
    print r[4].VariableUnits.UnitsAbbreviation
    print "Next i"

print "let's see what happens after the loop assignment"
for re in r:
    print re.VariableName
    print re.VariableUnits.UnitsAbbreviation