-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathplot.py
141 lines (113 loc) · 4.27 KB
/
plot.py
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
#-------------------------------------------------
#-------------------------------------------------
#
# Class plot
#
#-------------------------------------------------
#-------------------------------------------------
# Import all
import matplotlib.pyplot as plt
import numpy as np
#--------------------
# Class definition
#--------------------
class plot(object):
'''
A class to plot.
Written by A. Benoit, B. Pinel-Puyssegur and R. Jolivet 2019
Licence:
PhaCo: Phase unwrapping errors Correction
Copyright (C) 2019 <Angelique Benoit, Beatrice Pinel-Puyssegur and Romain Jolivet>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
#--------------------
# Initialization
#--------------------
def __init__(self, trip):
'''
Initialize the class.
Args:
* trip : triplet
'''
# Get triplet class arguments
self.trip = trip
# All done
return
#--------------------
# Plot triplet misclosures
#--------------------
def plotMisclosures(self):
'''
Plot misclosures of the triplet.
'''
# Plot 0 with NaNs
self.trip.closure_unw[self.trip.closure_unw ==0.] = 'nan'
self.trip.closure_int[self.trip.closure_int ==0.] = 'nan'
self.trip.closure[self.trip.closure ==0.] = 'nan'
# Misclosures of the triplet
fig = plt.figure()
ax1=fig.add_subplot(1,4,1)
plt.imshow(self.trip.closure_int)
ax1.set_title('Misclosure from wrap igram')
ax2=fig.add_subplot(1,4,2, sharex=ax1, sharey=ax1)
plt.imshow(self.trip.closure_unw)
ax2.set_title('Closure of unwrap igram')
ax3=fig.add_subplot(1,4,3, sharex=ax1, sharey=ax1)
plt.imshow(self.trip.closure)
ax3.set_title('Total closure without misclosure')
#ax4=fig.add_subplot(1,4,4)
#plt.hist(self.trip.closure_int.flatten(), bins=200, log=True)
#ax4.set_title('Distrib of misclosure')
plt.show()
## Misclosure before and after regions size selection
#self.trip.closure_mod2pi_errors[abs(self.trip.closure_mod2pi_errors)==0] = np.nan
#fig = plt.figure()
#ax1=fig.add_subplot(1,2,1)
#plt.imshow(self.trip.closure_mod2pi_errors)
#ax1.set_title('Closure before size selection')
#ax2=fig.add_subplot(1,2,2, sharex=ax1, sharey=ax1)
#plt.imshow(self.trip.closure_mod2pi_errors_ok)
#ax2.set_title('Closure after size selection')
#plt.show()
# Redo NaN to 0
#self.trip.closure_mod2pi_errors_ok = np.nan_to_num(self.trip.closure_mod2pi_errors_ok)
self.trip.closure_unw = np.nan_to_num(self.trip.closure_unw)
self.trip.closure_int = np.nan_to_num(self.trip.closure_int)
self.trip.closure = np.nan_to_num(self.trip.closure)
# All done
return
#--------------------
# Plot error ref regions
#--------------------
def plotRegions(self):
'''
Plot error and reference regions.
'''
# Make the plot
fig = plt.figure()
ax1=fig.add_subplot(1,2,1)
plt.imshow(self.trip.labels_errors)
ax1.set_title('All error regions labels')
ax2=fig.add_subplot(1,2,2, sharex=ax1, sharey=ax1)
plt.imshow(self.trip.labels_ref)
ax2.set_title('All reference regions labels')
plt.show()
# All done
return
#--------------------
# Plot triplet mean closure
#--------------------
# def plotMeanClosure(self):
#plt.figure()
#plt.imshow(self.igram_meanClosure)
#plt.title('igram mean closure')
#plt.show()