1 |
#!/usr/bin/python |
---|
2 |
""" |
---|
3 |
Module to process sodar data. |
---|
4 |
""" |
---|
5 |
|
---|
6 |
def _main(): |
---|
7 |
import optparse |
---|
8 |
from sodar.utils import openAnything |
---|
9 |
from sodar import arrayData as a |
---|
10 |
import pylab as p |
---|
11 |
import os |
---|
12 |
|
---|
13 |
parser = optparse.OptionParser() |
---|
14 |
(values, args) = parser.parse_args() |
---|
15 |
(filein, pathout) = tuple(args) |
---|
16 |
|
---|
17 |
if not os.path.exists(pathout): |
---|
18 |
os.makedirs(pathout, mode=0775) |
---|
19 |
|
---|
20 |
|
---|
21 |
try: |
---|
22 |
rawDataHandle = openAnything.openAnything(filein) |
---|
23 |
rawDataString = rawDataHandle.read() |
---|
24 |
rawDataHandle.close() |
---|
25 |
except: |
---|
26 |
raise IOError("Failure to read raw data.") |
---|
27 |
|
---|
28 |
rawDataObject = a.rawData.RawData(rawDataString) |
---|
29 |
formattedDataObject = a.formattedData.FormattedData(rawDataObject) |
---|
30 |
arrayDataObject = a.ArrayData(formattedDataObject) |
---|
31 |
|
---|
32 |
fig = p.figure() |
---|
33 |
p.pcolor(arrayDataObject.uComponents.T) |
---|
34 |
p.colorbar() |
---|
35 |
fig.savefig(os.path.join(pathout, 'uComponents.png')) |
---|
36 |
|
---|
37 |
fig = p.figure() |
---|
38 |
p.pcolor(arrayDataObject.vComponents.T) |
---|
39 |
p.colorbar() |
---|
40 |
fig.savefig(os.path.join(pathout, 'vComponents.png')) |
---|
41 |
|
---|
42 |
fig = p.figure() |
---|
43 |
p.pcolor(arrayDataObject.wComponents.T) |
---|
44 |
p.colorbar() |
---|
45 |
fig.savefig(os.path.join(pathout, 'wComponents.png')) |
---|
46 |
|
---|
47 |
fig = p.figure() |
---|
48 |
p.pcolor(arrayDataObject.echoStrengths.T) |
---|
49 |
p.colorbar() |
---|
50 |
fig.savefig(os.path.join(pathout, 'echoStrengths.png')) |
---|
51 |
|
---|
52 |
fig = p.figure() |
---|
53 |
p.quiver(arrayDataObject.uComponents, |
---|
54 |
arrayDataObject.vComponents, |
---|
55 |
arrayDataObject.wComponents) |
---|
56 |
p.colorbar() |
---|
57 |
xmin,xmax,ymin,ymax = p.axis() |
---|
58 |
dx,dy = xmax-xmin, ymax-ymin |
---|
59 |
p.axis([xmin-0.1*dx, xmax+0.1*dx, ymin-0.1*dy, ymax+0.1*dy]) |
---|
60 |
p.title('Horizontal wind vectors: time vs. altitude') |
---|
61 |
fig.savefig(os.path.join(pathout, 'quiver.png')) |
---|
62 |
|
---|
63 |
if __name__ == "__main__": |
---|
64 |
_main() |
---|