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