NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/sodar/trunk/sodar/arrayData.py

Revision 87 (checked in by cbc, 17 years ago)

Results of working/debug session with Harvey to look at quiver, NaN, orientation, and ground truthing.

Line 
1 #!/usr/bin/python
2 """
3 Module to handle sodar data samples as arrays.
4 """
5
6 __author__ = 'Chris Calloway'
7 __email__ = 'cbc@unc.edu'
8 __copyright__ = 'Copyright 2007 UNC-CH Department of Marine Science'
9 __license__ = 'GPL2'
10
11 import rawData
12 import formattedData
13 import numpy as n
14 from numpy import matrix
15 import datetime
16
17 class ArrayData(object):
18    
19     """Class to handle Daily sodar file data as arrays."""
20    
21     def __init__(self, data):
22         """Create arrays from formatted data."""
23         super(ArrayData, self).__init__()
24         self.timeInterval = data.timeInterval
25         self.altInterval = data.altInterval
26         self.numAltitudes = data.numAltitudes
27         self.minAltitude = data.minAltitude
28         self.maxAltitude = data.maxAltitude
29         self._thetas(data)
30         self._uComponents(data)
31         self._vComponents(data)
32         self._wComponents(data)
33         self._echoStrengths(data)
34         a=1
35    
36     def _thetas(self, data):
37         """Convert direction to polar azimuth in radians CW from North"""
38         self.thetas = n.pi * (n.array(data.thetas()) / 180.0)
39    
40     def _uComponents(self,data):
41         """Compute u component array"""
42         self.uComponents = n.array(data.radials()) * n.sin(self.thetas)
43    
44     def _vComponents(self,data):
45         """Compute v component array"""
46         self.vComponents = n.array(data.radials()) * n.cos(self.thetas)
47    
48     def _wComponents(self,data):
49         """Create w component array"""
50         self.wComponents = n.array(data.wComponents())
51    
52     def _echoStrengths(self,data):
53         """Create an echo strength array"""
54         self.echoStrengths = n.array(data.echoStrengths())
55
56
57 def _main():
58     """Process as script from command line."""
59     import urllib2
60     try:
61         rawDataHandle = urllib2.urlopen('http://nemo.isis.unc.edu/'\
62                                         'data/nccoos/level0/dukeforest/sodar/'\
63                                         'store/2007-06/20070603.dat')
64         rawDataString = rawDataHandle.read()
65         rawDataHandle.close()
66     except:
67         raise IOError("Failure to read raw test data")
68     rawDataObject = rawData.RawData(rawDataString)
69     formattedDataObject = formattedData.FormattedData(rawDataObject)
70     arrayDataObject = ArrayData(formattedDataObject)
71     import pylab as p
72     p.figure()
73     p.pcolor(matrix(arrayDataObject.uComponents).T)
74     p.colorbar()
75     p.figure()
76     p.pcolor(matrix(arrayDataObject.vComponents).T)
77     p.colorbar()
78     p.figure()
79     p.pcolor(matrix(arrayDataObject.wComponents).T)
80     p.colorbar()
81     p.figure()
82     p.pcolor(matrix(arrayDataObject.echoStrengths).T)
83     p.colorbar()
84     # p.quiver2(arrayDataObject.uComponents,
85     #           arrayDataObject.vComponents,
86     #           arrayDataObject.wComponents)
87     # p.colorbar()
88     # xmin,xmax,ymin,ymax = p.axis()
89     # dx,dy = xmax-xmin, ymax-ymin
90     # p.axis([xmin-0.1*dx, xmax+0.1*dx, ymin-0.1*dy, ymax+0.1*dy])
91     # p.title('Horizontal wind vectors: time vs. altitude')
92     p.show()
93
94 if __name__ == "__main__":
95     _main()
Note: See TracBrowser for help on using the browser.