Changeset 3005


Ignore:
Timestamp:
08/11/07 18:17:40 (12 years ago)
Author:
astephen
Message:

Consolidation of titania version under DX with proper source in trunk of SVN.

Location:
nappy/trunk
Files:
3 added
1 deleted
8 edited
4 moved

Legend:

Unmodified
Added
Removed
  • nappy/trunk/KNOWN_BUGS.txt

    r366 r3005  
    33which is a problem. 
    44 
     5There is a problem with the NXDEF NX XNAME definitions in FFIs 4010 as written at present. 
     6 NEED TO INVESTIGATE! 
     7 
  • nappy/trunk/bin/nc2na

    r368 r3005  
    2525    varlist     - a comma separated list of variables to include in the output file. 
    2626    -r          - provide rule arguments for calling additional routines held in nappy/rules sub-package. 
    27                   example call would be "-r aircraft,av,1,1f,2f,3f" telling nappy to call rules/aircraftData.py 
    28                   and interpret the rest of the arguments when called. 
     27                  example call would be "-r aircraft,av,flag,1,0,1" telling nappy to call rules/aircraftData.py 
     28                  and interpret the rest of the arguments when called (in this case sub-sampling by averaging. 
     29                  Or "-r aircraft,ss,flag,1,0,1" to sub-sample by selection using the flag variable at 
     30                  a sampling rate of 1Hz using valid flags of 0 and 1 only. 
    2931    limitFFI1001Rows - if format FFI is 1001 then chop files up into <limitFFI1001Rows> rows of data. 
    3032    -j          - just display file names that would be produced - without creating files. 
  • nappy/trunk/cdms2na.py

    r368 r3005  
    261261 
    262262def cdms2na(infilename, outfilenames, naVars={}, variables=None, nFilesOnly="no",  
    263             rule=None, ffi="automatic", spacer="    ", floatFormat="%8.3f",  
     263            rule=None, ffi="automatic", spacer="    ", floatFormat="%g",  
    264264            rules=None, sizeLimit=None): 
    265265    """ 
     
    430430        else:            
    431431            general.openNAFile(newname, 'w', builtNADict, spacer=spacer, floatFormat=floatFormat) 
    432         #nlhead=fixHeaderLength(newname)   
    433432 
    434433        msg="\nWrote the following variables:"+"\n\t"+("\n\t".join(i[1][0])) 
     
    528527 
    529528            # Deal with specific datasets with special rules 
    530             if self.rule[0]=="aircraft": 
     529            if self.rule!=None and self.rule[0]=="aircraft": 
    531530                var=self._useLocalRule(var, self.rule) 
    532531                if type(var)==type(None):  
     
    578577        for var in self.vars[:bestVarIndex-1]+self.vars[bestVarIndex:]: 
    579578            # Deal with specific datasets with special rules 
    580             if self.rule[0]=="aircraft": 
     579            if self.rule!=None and self.rule[0]=="aircraft": 
    581580                if var.rank()==2: 
    582581                    var=self._useLocalRule(var, self.rule) 
  • nappy/trunk/doc/INSTALL.txt

    r349 r3005  
    29291. Download the gzipped tar file from: 
    3030 
    31 <http://home.badc.rl.ac.uk/astephens/downloads/nappy-latest.tar.gz> 
     31???? 
    3232 
    33332. De-compress and untar the files: 
  • nappy/trunk/general.py

    r366 r3005  
    107107            naDict['FFI']=FFI 
    108108            print "\nFormat identified as:", FFI     
    109         return apply(classMap[FFI], (filename, mode, naDict, spacer, floatFormat)) 
     109        return apply(classMap[FFI], (filename,), {"mode":mode, "naDict":naDict, "spacer":spacer, "floatFormat":floatFormat}) 
    110110    else: 
    111111        raise "File mode not recognised '%s'." % mode 
  • nappy/trunk/localRules/aircraftData.py

    r368 r3005  
    5151                    samplingRate, flagsToUse) 
    5252        elif samplingMethod=="selection": 
    53             self.subSampledVarself._subSampleBySelection(var, timeVar, flagVar, 
     53            self.subSampledVar=self._subSampleBySelection(var, timeVar, flagVar, 
    5454                    samplingRate, flagsToUse) 
    5555 
    5656 
     57    def _subSampleBySelection(self, var, timeVar, flagVar, samplingRate, flagsToUse): 
     58        """ 
     59        Returns a new variable which is 'var' sub-sampled by selecting the value 
     60        at the given samplingRate with data selected according to flagVar 
     61        including the flag values  specified in flagsToUse (defaults are 0 and 1). 
     62        """ 
     63        if samplingRate!=1: 
     64            raise "Sampling rates of values other than 1Hz are not yet supported." 
     65        maskedArray=self._getMaskedArray(var[:,0](squeeze=1), flagVar[:,0](squeeze=1), flagsToUse) 
     66        # Now re-construct variable axes etc 
     67        newTimeAxis=self._flatten2DTimeAxis(timeVar, samplingRate) 
     68        newVar=self._recreateVariable(var, maskedArray, newTimeAxis, flagVar, max(flagsToUse), missingValue=maskedArray.fill_value(), sampleBy="selection") 
     69        return newVar 
     70 
     71         
    5772    def _subSampleByAveraging(self, var, timeVar, flagVar, samplingRate, flagsToUse): 
    5873        """ 
     
    86101        # Now re-construct variable axes etc 
    87102        newTimeAxis=self._flatten2DTimeAxis(timeVar, samplingRate) 
    88         newVar=self._recreateVariable(var, newArray, newTimeAxis, flagVar, max(flagsToUse), missingValue=maskedArray.fill_value())  
     103        newVar=self._recreateVariable(var, newArray, newTimeAxis, flagVar, max(flagsToUse), missingValue=maskedArray.fill_value(), sampleBy="averaging")  
    89104        return newVar 
    90105 
     
    114129 
    115130 
    116     def _recreateVariable(self, var, newArray, timeAxis, flagVar, flagMax, missingValue): 
     131    def _recreateVariable(self, var, newArray, timeAxis, flagVar, flagMax, missingValue, sampleBy="averaging"): 
    117132        """ 
    118133        Rebuilds a variable using new array and new time axis. 
     
    133148        newvar=cdms.createVariable(data, id=var.id, fill_value=missing, axes=[timeAxis], attributes=newAtts) 
    134149        newvar.frequency=1 
    135         newvar.comment="Data re-sampled to 1Hz frequency by averaging. " 
    136         if flagVar: 
    137             newvar.comment=newvar.comment+"Values were included where the flag variable were less than %s and where both the flag value and actual data value were present (i.e. not missing values)." % (flagMax+1) 
    138         else: 
    139             newvar.comment=newvar.comment+"The flag variable was not used in creating this variable." 
    140         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." 
     150        if sampleBy=="averaging": 
     151            newvar.comment="Data averaged to give a pseudo sampling frequency of 1 Hz. " 
     152            if flagVar: 
     153                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) 
     154                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." 
     155            else: 
     156                newvar.comment=newvar.comment+"The flag variable was not used in creating this variable." 
     157                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." 
     158        elif sampleBy=="selection": 
     159            newvar.comment="Data sub-sampled to give a pseudo sampling frequency of 1 Hz by selecting only the per-second frequency values. " 
     160            if flagVar: 
     161                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)." 
     162            else: 
     163                newvar.comment=newvar.comment+" The flag variable was not used in creating this variable."  
    141164        return newvar 
    142165   
  • nappy/trunk/test/testCdmsWrite.py

    r349 r3005  
    1515    print "Read file OK." 
    1616 
    17     outfile=os.path.join("..", "output", "out%s.nc" % ffi) 
     17    outfile=os.path.join("output", "out%s.nc" % ffi) 
    1818    print "Writing output NetCDF file %s" % outfile  
    1919    x.toCdmsFile(outfile) 
  • nappy/trunk/test/testWrites.py

    r366 r3005  
    2626    del d["FFI"] 
    2727 
    28     outfile=os.path.join("..", "output", "out%s.na" % ffi) 
     28    outfile=os.path.join("output", "out%s.na" % ffi) 
    2929    print "Writing output ", outfile 
    3030    y=nappy.openNAFile(outfile, 'w', d) 
Note: See TracChangeset for help on using the changeset viewer.