source: qesdi/data_processing/convertPre.py @ 5406

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/qesdi/data_processing/convertPre.py@5406
Revision 5406, 1.1 KB checked in by dgrant, 11 years ago (diff)

Classes for reading basic data plus precipetation implementation

Line 
1import netCDF4
2import sys
3from TMCReader import TMCReader
4
5class PrecipetationReader(TMCReader):
6    """A class to read the ascii text from the precipetation data file"""
7
8    def storeLine(self, line):
9        precipDataPt = PrecipetationDataPt(line.split())
10        self._coordTable.insert(precipDataPt, precipDataPt.lat, precipDataPt.lon)
11
12
13
14class PrecipetationDataPt:
15    """Class to store data for a specific point"""
16
17    def __init__(self,preVals):
18        self.lat=preVals[0]
19        self.lon=preVals[1]
20        self.jan=preVals[2]
21        self.feb=preVals[3]
22        self.mar=preVals[4]
23        self.apr=preVals[5]
24        self.may=preVals[6]
25        self.jun=preVals[7]
26        self.jul=preVals[8]
27        self.aug=preVals[9]
28        self.sep=preVals[10]
29        self.oct=preVals[11]
30        self.nov=preVals[12]
31        self.dec=preVals[13]
32
33
34def main():
35    precipetationReader = PrecipetationReader()
36    precipetationReader.readData(sys.argv[1])
37    lookupTable = precipetationReader.getLookupTable()
38    print lookupTable.lookup('-59.083', '-26.583').jan
39
40if __name__ == "__main__":
41    main()
Note: See TracBrowser for help on using the repository browser.