nappy/contrib/aircraft/aircraftData.py
def _recreateVariable(self, var, newArray, timeAxis, flagVar, flagMax, missingValue, sampleBy="averaging"):
        """
        Rebuilds a variable using new array and new time axis.
        """
        atts=var.attributes
        newAtts={}
        for att,value in atts.items():
            if type(value) in (type((1,1)), type([1,2]), type(Numeric.array([1.]))) and len(value)==1:
                value=value[0]
            if type(value) in (type(1), type(1.), type(long(1))):
                newAtts[att]=value
            elif type(value)==type(""):
                newAtts[att]=value.strip()

        # Now create the variable
        missing=missingValue
        data=newArray
        newvar=cdms.createVariable(data, id=var.id, fill_value=missing, axes=[timeAxis], attributes=newAtts)
        newvar.frequency=1
        if sampleBy=="averaging":
            newvar.comment="Data averaged to give a pseudo sampling frequency of 1 Hz. "
            if flagVar:
                newvar.comment=newvar.comment+"Values were included where the flag variable was less than %s and where both the flag value and actual data value were present (i.e. not missing values)." % (flagMax+1)
                newvar.comment=newvar.comment+" Average data values were set to missing where more than half the values in any one second period were already missing. Missing value was also used where more than half the flags were either missing value or values of 2 or greater."
            else:
                newvar.comment=newvar.comment+"The flag variable was not used in creating this variable."
                newvar.comment=newvar.comment+" Average data values were set to missing where more than half the values in any one second period were already missing."
        elif sampleBy=="selection":
            newvar.comment="Data sub-sampled to give a pseudo sampling frequency of 1 Hz by selecting only the per-second frequency values. "
            if flagVar:
                newvar.comment=newvar.comment+" Values were included where the flag variable was less than 2 and where both the flag value and actual data value were present (i.e. not missing values)."
            else:
                newvar.comment=newvar.comment+" The flag variable was not used in creating this variable." 
        return newvar

        Rebuilds a variable using new array and new time axis.
        
Rebuilds a variable using new array and new time axis.
Rebuilds a variable using new array and new time axis .
def _recreateVariable(self, var, newArray, timeAxis, flagVar, flagMax, missingValue, sampleBy="averaging"):
        atts=var.attributes
        newAtts={}
        for att,value in atts.items():
            if type(value) in (type((1,1)), type([1,2]), type(Numeric.array([1.]))) and len(value)==1:
                value=value[0]
            if type(value) in (type(1), type(1.), type(long(1))):
                newAtts[att]=value
            elif type(value)==type(""):
                newAtts[att]=value.strip()
        missing=missingValue
        data=newArray
        newvar=cdms.createVariable(data, id=var.id, fill_value=missing, axes=[timeAxis], attributes=newAtts)
        newvar.frequency=1
        if sampleBy=="averaging":
            newvar.comment="Data averaged to give a pseudo sampling frequency of 1 Hz. "
            if flagVar:
                newvar.comment=newvar.comment+"Values were included where the flag variable was less than %s and where both the flag value and actual data value were present (i.e. not missing values)." % (flagMax+1)
                newvar.comment=newvar.comment+" Average data values were set to missing where more than half the values in any one second period were already missing. Missing value was also used where more than half the flags were either missing value or values of 2 or greater."
            else:
                newvar.comment=newvar.comment+"The flag variable was not used in creating this variable."
                newvar.comment=newvar.comment+" Average data values were set to missing where more than half the values in any one second period were already missing."
        elif sampleBy=="selection":
            newvar.comment="Data sub-sampled to give a pseudo sampling frequency of 1 Hz by selecting only the per-second frequency values. "
            if flagVar:
                newvar.comment=newvar.comment+" Values were included where the flag variable was less than 2 and where both the flag value and actual data value were present (i.e. not missing values)."
            else:
                newvar.comment=newvar.comment+" The flag variable was not used in creating this variable." 
        return newvar
def _recreateVariable ( self , var , newArray , timeAxis , flagVar , flagMax , missingValue , sampleBy = "averaging" ) : atts = var . attributes newAtts = { } for att , value in atts . items ( ) : if type ( value ) in ( type ( ( 1 , 1 ) ) , type ( [ 1 , 2 ] ) , type ( Numeric . array ( [ 1. ] ) ) ) and len ( value ) == 1 : value = value [ 0 ] if type ( value ) in ( type ( 1 ) , type ( 1. ) , type ( long ( 1 ) ) ) : newAtts [ att ] = value elif type ( value ) == type ( "" ) : newAtts [ att ] = value . strip ( ) missing = missingValue data = newArray newvar = cdms . createVariable ( data , id = var . id , fill_value = missing , axes = [ timeAxis ] , attributes = newAtts ) newvar . frequency = 1 if sampleBy == "averaging" : newvar . comment = "Data averaged to give a pseudo sampling frequency of 1 Hz. " if flagVar : newvar . comment = newvar . comment + "Values were included where the flag variable was less than %s and where both the flag value and actual data value were present (i.e. not missing values)." % ( flagMax + 1 ) newvar . comment = newvar . comment + " Average data values were set to missing where more than half the values in any one second period were already missing. Missing value was also used where more than half the flags were either missing value or values of 2 or greater." else : newvar . comment = newvar . comment + "The flag variable was not used in creating this variable." newvar . comment = newvar . comment + " Average data values were set to missing where more than half the values in any one second period were already missing." elif sampleBy == "selection" : newvar . comment = "Data sub-sampled to give a pseudo sampling frequency of 1 Hz by selecting only the per-second frequency values. " if flagVar : newvar . comment = newvar . comment + " Values were included where the flag variable was less than 2 and where both the flag value and actual data value were present (i.e. not missing values)." else : newvar . comment = newvar . comment + " The flag variable was not used in creating this variable." return newvar
Rebuilds a variable using new array and new time axis.
Rebuilds a variable using new array and new time axis .
"""
        Rebuilds a variable using new array and new time axis.
        """ # Now create the variable
self
var
newArray
timeAxis
flagVar
flagMax
missingValue
sampleBy