-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2d-histplot-from-LNC.py
More file actions
145 lines (112 loc) · 3.59 KB
/
2d-histplot-from-LNC.py
File metadata and controls
145 lines (112 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 17 13:10:30 2013
@author: dashamstyr
"""
import LNC_tools as ltools
import os, sys
import numpy as np
import matplotlib.pyplot as plt
import slowhist as h2d
from matplotlib import cm
olddir = os.getcwd()
os.chdir('C:\Users\dashamstyr\Dropbox\PhD - General')
filepath = ltools.get_files('Select LNC file', filetype = ('.h5', '*.h5'))
datatypes = ['BR532','PR532']
header, data_dict = ltools.from_HDF(filepath[0], datatypes)
try:
BRdat = data_dict[datatypes[0]]
except KeyError:
sys.exit("No BR532 data available!")
try:
PRdat = data_dict[datatypes[1]]
except KeyError:
sys.exit("No PR532 data available!")
altrange = np.arange(150,10000,10)
BRdat = ltools.alt_resample(BRdat,altrange)
PRdat = ltools.alt_resample(PRdat,altrange)
altrange = BRdat.columns.values
copolvals = np.hstack(BRdat.values).astype('float32')
depolvals = np.hstack(PRdat.values).astype('float32')
numbins = 100
depolmin = 0.0
depolmax = 0.5
copolmin = 0.0
copolmax = 5.0
copolhist=h2d.fullhist(copolvals,numbins,copolmin,copolmax,-9999.,-8888.)
depolhist=h2d.fullhist(depolvals,numbins,depolmin,depolmax,-9999.,-8888.)
altOut = h2d.althist(PRdat.values,altrange,numbins,(depolmin,depolmax))
copolOut=h2d.hist2D(copolhist['fullbins'],depolhist['fullbins'],copolhist['numBins'],depolhist['numBins'])
altcounts=altOut['coverage']
copolcounts = copolOut['coverage']
altcounts[altcounts < 1] = 1
copolcounts[copolcounts < 1] = 1
altlogcounts=np.log10(altcounts)
copollogcounts=np.log10(copolcounts)
try:
os.chdir('Plots')
except WindowsError:
os.makedirs('Plots')
os.chdir('Plots')
startdate = BRdat.index[0].strftime("%Y-%m-%d")
enddate = BRdat.index[-1].strftime("%Y-%m-%d")
starttime = BRdat.index[0].strftime("%H")
endtime = BRdat.index[-1].strftime("%H")
if startdate == enddate:
if starttime == endtime:
savetime = startdate+'_'+starttime
else:
savetime = startdate+'_'+starttime+'-'+endtime
else:
savetime = startdate+'-'+enddate
fignum = 0
#fignum+=1
#fig=plt.figure(fignum)
#fig.clf()
#the_axis=fig.add_subplot(111)
#the_axis.plot(depolvals,copolvals,'b+')
#the_axis.set_xlabel('depolvals')
#the_axis.set_ylabel('copolvals')
#the_axis.set_title('raw scatterplot')
#fig.savefig('{0}_{1}-{2}m-copoldepolraw.png'.format(savetime,altrange[0],altrange[-1]))
#fig.canvas.draw()
cmap=cm.bone
cmap.set_over('r')
cmap.set_under('b')
fignum+=1
fig=plt.figure(fignum)
fig.clf()
axis=fig.add_subplot(111)
im=axis.pcolormesh(depolhist['centers'],altrange,altlogcounts.T, cmap = cmap)
cb=plt.colorbar(im,extend='both')
title="2-d histogram"
colorbar="log10(counts)"
the_label=cb.ax.set_ylabel(colorbar,rotation=270)
axis.set_xlabel('depolvals')
axis.set_ylabel('Altitude [m]')
axis.set_title(title)
fig.savefig('{0}_{1}-{2}m-althist.png'.format(savetime,altrange[0],altrange[-1]))
fig.canvas.draw()
fignum+=1
fig=plt.figure(fignum)
fig.clf()
axis=fig.add_subplot(111)
im=axis.pcolormesh(depolhist['centers'],copolhist['centers'],copollogcounts, cmap = cmap)
cb=plt.colorbar(im,extend='both')
title="2-d histogram"
colorbar="log10(counts)"
the_label=cb.ax.set_ylabel(colorbar,rotation=270)
axis.set_xlabel('Volume Depolarization Ratio')
axis.set_ylabel('Attenuated Backscatter')
axis.set_title(title)
fig.savefig('{0}_{1}-{2}m-copoldepol.png'.format(savetime,altrange[0],altrange[-1]))
fig.canvas.draw()
#fignum+=1
#fig = plt.figure(fignum)
#fig.clf()
#axis = fig.add_subplot(111)
#hist = axis.hist(depolvals, bins = 100)
#fig.savefig('{0}_{1}-{2}m-1Ddepolhist.png'.format(savetime,altrange[0],altrange[-1]))
#fig.canvas.draw()
plt.show()
os.chdir(olddir)