-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path2d-histplot_from-pickle.py
More file actions
113 lines (92 loc) · 2.8 KB
/
2d-histplot_from-pickle.py
File metadata and controls
113 lines (92 loc) · 2.8 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
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 17 13:10:30 2013
@author: dashamstyr
"""
import site
site.addsitedir('C:\Users\User\Dropbox\Python_Scripts\GIT_Repos\MPLcode\hist2d')
#site.addsitedir('/Users/phil/repos/MPLcode')
#site.addsitedir('/Users/phil/lib/python')
import MPLtools as mtools
import os
import numpy as np
import pandas as pan
import matplotlib.pyplot as plt
import pickle
from matplotlib.colors import Normalize
from matplotlib import cm
#from plot_fields import loadvars
## import fasthist as fh
## from binit import fastin
from matplotlib.colors import Normalize
from matplotlib import cm
#os.chdir('C:\Program Files (x86)\SigmaMPL\DATA')
#
#filepath = mtools.get_files('Select MPL file', filetype = ('.h5', '*.h5'))
#
#MPLfile = mtools.MPL()
#
#MPLfile.fromHDF(filepath[0])
#
#altrange = np.arange(150,4000,10)
#
#MPLfile.alt_resample(altrange)
#copol = MPLfile.data[0]
#crosspol = MPLfile.data[1]
MPLdat = pickle.load(open('201304222100-201304222300_proc.pickle','rb'))
copol = MPLdat[0]
crosspol = MPLdat[1]
copolvals = np.hstack(copol.values).astype('float32')
crosspolvals = np.hstack(crosspol.values).astype('float32')
depolMPL = crosspolvals/copolvals
depolvals = depolMPL/(depolMPL+1)
copol_mean = np.mean(copolvals)
copol_std = np.std(copolvals)
copol_min = copol_mean-copol_std
copol_max = copol_mean+copol_std
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.canvas.draw()
fig.savefig('plot1.png')
#plt.close(fig)
import fasthist as h2d
## depolhist=h2d.fullhist(depolvals,20,0.24,0.42,-9999.,-8888.)
## copolhist=h2d.fullhist(copolvals,20,0.,1.6e-3,-9999.,-8888.)
depolhist=h2d.fullhist(depolvals,200,0.24,0.42,-9999.,-8888.)
copolhist=h2d.fullhist(copolvals,200,0.,1.6e-3,-9999.,-8888.)
theOut=h2d.hist2D(copolhist['fullbins'],depolhist['fullbins'],copolhist['numBins'],\
depolhist['numBins'])
cmap=cm.bone
cmap.set_over('r')
cmap.set_under('b')
fig=plt.figure(2)
fig.clf()
axis1=fig.add_subplot(111)
counts=theOut['coverage']
counts[counts < 1] = 1
logcounts=np.log10(counts)
im=axis1.pcolormesh(depolhist['centers'],copolhist['centers'],logcounts,
cmap=cmap)
cb=plt.colorbar(im,extend='both')
title="2-d histogram"
colorbar="log10(counts)"
the_label=cb.ax.set_ylabel(colorbar,rotation=270)
axis1.set_xlabel('depolvals')
axis1.set_ylabel('copolvals')
axis1.set_title(title)
fig.canvas.draw()
fig.savefig('plot2.png')
fig=plt.figure(3)
fig.clf()
axis3=fig.add_subplot(111)
im=axis3.imshow(logcounts,cmap=cmap)
plt.colorbar(im,extend='both')
plt.show()
plt.savefig('plot3.png')
#plt.close(fig)