##// END OF EJS Templates
First faraday ops review #TODO: fix plots
jespinoza -
r1381:3afd912ddcce
parent child
Show More
@@ -48,18 +48,13 class SpectraPlot(Plot):
48 48
49 49 if self.CODE == 'spc_moments':
50 50 data['moments'] = dataOut.moments
51 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
52 51 if self.CODE == 'gaussian_fit':
53 # data['moments'] = dataOut.moments
54 52 data['gaussfit'] = dataOut.DGauFitParams
55 # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor)
56 53
57 54 return data, meta
58 55
59 56 def plot(self):
60 57
61 #print(self.xaxis)
62 #exit(1)
63 58 if self.xaxis == "frequency":
64 59 x = self.data.xrange[0]
65 60 self.xlabel = "Frequency (kHz)"
@@ -90,7 +85,6 class SpectraPlot(Plot):
90 85 if self.CODE == 'spc_moments':
91 86 mean = data['moments'][n, 1]
92 87 if self.CODE == 'gaussian_fit':
93 # mean = data['moments'][n, 1]
94 88 gau0 = data['gaussfit'][n][2,:,0]
95 89 gau1 = data['gaussfit'][n][2,:,1]
96 90 if ax.firsttime:
@@ -98,7 +92,6 class SpectraPlot(Plot):
98 92 self.xmin = self.xmin if self.xmin else -self.xmax
99 93 self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
100 94 self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
101 #print(numpy.shape(x))
102 95 ax.plt = ax.pcolormesh(x, y, z[n].T,
103 96 vmin=self.zmin,
104 97 vmax=self.zmax,
@@ -132,7 +125,7 class SpectraObliquePlot(Plot):
132 125 Plot for Spectra data
133 126 '''
134 127
135 CODE = 'spc'
128 CODE = 'spc_oblique'
136 129 colormap = 'jet'
137 130 plot_type = 'pcolor'
138 131
@@ -150,10 +143,25 class SpectraObliquePlot(Plot):
150 143 self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18})
151 144 self.ylabel = 'Range [km]'
152 145
146 def update(self, dataOut):
147
148 data = {}
149 meta = {}
150 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
151 data['spc'] = spc
152 data['rti'] = dataOut.getPower()
153 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
154 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
155
156 data['shift1'] = dataOut.Oblique_params[0][1]
157 data['shift2'] = dataOut.Oblique_params[0][4]
158 data['shift1_error'] = dataOut.Oblique_param_errors[0][1]
159 data['shift2_error'] = dataOut.Oblique_param_errors[0][4]
160
161 return data, meta
162
153 163 def plot(self):
154 164
155 #print(self.xaxis)
156 #exit(1)
157 165 if self.xaxis == "frequency":
158 166 x = self.data.xrange[0]
159 167 self.xlabel = "Frequency (kHz)"
@@ -164,35 +172,23 class SpectraObliquePlot(Plot):
164 172 x = self.data.xrange[2]
165 173 self.xlabel = "Velocity (m/s)"
166 174
167 if self.CODE == 'spc_moments':
168 x = self.data.xrange[2]
169 self.xlabel = "Velocity (m/s)"
170
171 175 self.titles = []
172 #self.xlabel = "Velocidad (m/s)"
173 #self.ylabel = 'Rango (km)'
174
175 176
176 y = self.data.heights
177 y = self.data.yrange
177 178 self.y = y
178 179 z = self.data['spc']
179 180
180 self.CODE2 = 'spc_oblique'
181
182
183 181 for n, ax in enumerate(self.axes):
184 182 noise = self.data['noise'][n][-1]
185 if self.CODE == 'spc_moments':
186 mean = self.data['moments'][n, :, 1, :][-1]
187 if self.CODE2 == 'spc_oblique':
188 shift1 = self.data.shift1
189 shift2 = self.data.shift2
183 shift1 = self.data['shift1']
184 shift2 = self.data['shift2']
185 err1 = self.data['shift1_error']
186 err2 = self.data['shift2_error']
190 187 if ax.firsttime:
191 188 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
192 189 self.xmin = self.xmin if self.xmin else -self.xmax
193 190 self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
194 191 self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
195 #print(numpy.shape(x))
196 192 ax.plt = ax.pcolormesh(x, y, z[n].T,
197 193 vmin=self.zmin,
198 194 vmax=self.zmax,
@@ -204,15 +200,9 class SpectraObliquePlot(Plot):
204 200 self.data['rti'][n][-1], y)[0]
205 201 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
206 202 color="k", linestyle="dashed", lw=1)[0]
207 if self.CODE == 'spc_moments':
208 ax.plt_mean = ax.plot(mean, y, color='k')[0]
209
210 if self.CODE2 == 'spc_oblique':
211 #ax.plt_shift1 = ax.plot(shift1, y, color='k', marker='x', linestyle='None', markersize=0.5)[0]
212 #ax.plt_shift2 = ax.plot(shift2, y, color='m', marker='x', linestyle='None', markersize=0.5)[0]
213 self.ploterr1 = ax.errorbar(shift1, y, xerr=self.data.shift1_error,fmt='k^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2)
214 self.ploterr2 = ax.errorbar(shift2, y, xerr=self.data.shift2_error,fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2)
215 203
204 self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=0.2, marker='x', linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2)
205 self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2)
216 206 else:
217 207 self.ploterr1.remove()
218 208 self.ploterr2.remove()
@@ -220,17 +210,11 class SpectraObliquePlot(Plot):
220 210 if self.showprofile:
221 211 ax.plt_profile.set_data(self.data['rti'][n][-1], y)
222 212 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
223 if self.CODE == 'spc_moments':
224 ax.plt_mean.set_data(mean, y)
225 if self.CODE2 == 'spc_oblique':
226 #ax.plt_shift1.set_data(shift1, y)
227 #ax.plt_shift2.set_data(shift2, y)
228 #ax.clf()
229 self.ploterr1 = ax.errorbar(shift1, y, xerr=self.data.shift1_error,fmt='k^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2)
230 self.ploterr2 = ax.errorbar(shift2, y, xerr=self.data.shift2_error,fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2)
213 self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2)
214 self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2)
231 215
232 216 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
233 #self.titles.append('{}'.format('Velocidad Doppler'))
217
234 218
235 219 class CrossSpectraPlot(Plot):
236 220
@@ -733,8 +717,6 class SpectrogramPlot(Plot):
733 717 self.ncols = 1
734 718 self.nrows = len(self.data.channels)
735 719 self.nplots = len(self.data.channels)
736 #print(self.dataOut.heightList)
737 #self.ylabel = 'Range [km]'
738 720 self.xlabel = 'Time'
739 721 self.cb_label = 'dB'
740 722 self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95})
@@ -742,18 +724,11 class SpectrogramPlot(Plot):
742 724 self.CODE.upper(), x, self.data.heightList[self.data.hei], self.data.heightList[self.data.hei],self.data.heightList[self.data.hei]+(self.data.DH*self.data.nProfiles)) for x in range(self.nrows)]
743 725
744 726 def plot(self):
727
745 728 self.x = self.data.times
746 #self.y = self.data.heights
747 729 self.z = self.data[self.CODE]
748 730 self.y = self.data.xrange[0]
749 #import time
750 #print(time.ctime(self.x))
751 731
752 '''
753 print(numpy.shape(self.x))
754 print(numpy.shape(self.y))
755 print(numpy.shape(self.z))
756 '''
757 732 self.ylabel = "Frequency (kHz)"
758 733
759 734 self.z = numpy.ma.masked_invalid(self.z)
@@ -1,5 +1,7
1 1
2 2 import os
3 import time
4 import math
3 5 import datetime
4 6 import numpy
5 7 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG
@@ -13,27 +15,18 from schainpy.model.graphics.jroplot_base import Plot, plt
13 15
14 16 import matplotlib.pyplot as plt
15 17 import matplotlib.colors as colors
16
17 import time
18 import math
19
20
21 18 from matplotlib.ticker import MultipleLocator
22 19
23 20
24
25 21 class RTIDPPlot(RTIPlot):
26 22
27 '''
28 Plot for RTI Double Pulse Experiment
23 '''Plot for RTI Double Pulse Experiment
29 24 '''
30 25
31 26 CODE = 'RTIDP'
32 27 colormap = 'jro'
33 28 plot_name = 'RTI'
34 29
35 #cb_label = 'Ne Electron Density (1/cm3)'
36
37 30 def setup(self):
38 31 self.xaxis = 'time'
39 32 self.ncols = 1
@@ -49,30 +42,25 class RTIDPPlot(RTIPlot):
49 42
50 43 self.cb_label = 'Intensity (dB)'
51 44
52
53 #self.cb_label = cb_label
54
55 45 self.titles = ['{} Channel {}'.format(
56 46 self.plot_name.upper(), '0x1'),'{} Channel {}'.format(
57 47 self.plot_name.upper(), '0'),'{} Channel {}'.format(
58 48 self.plot_name.upper(), '1')]
59 49
50 def update(self, dataOut):
60 51
61 def plot(self):
52 data = {}
53 meta = {}
54 data[self.CODE] = dataOut.data_for_RTI_DP
55 data['NRANGE'] = dataOut.NDP
62 56
63 self.data.normalize_heights()
64 self.x = self.data.times
65 self.y = self.data.heights[0:self.data.NDP]
57 return data, meta
66 58
67 if self.showSNR:
68 self.z = numpy.concatenate(
69 (self.data[self.CODE], self.data['snr'])
70 )
71 else:
59 def plot(self):
72 60
61 self.x = self.data.times
62 self.y = self.data.yrange[0: self.data['NRANGE']]
73 63 self.z = self.data[self.CODE]
74 #print(numpy.max(self.z[0,0:]))
75
76 64 self.z = numpy.ma.masked_invalid(self.z)
77 65
78 66 if self.decimation is None:
@@ -82,26 +70,21 class RTIDPPlot(RTIPlot):
82 70
83 71 for n, ax in enumerate(self.axes):
84 72
85
86 73 self.zmax = self.zmax if self.zmax is not None else numpy.max(
87 74 self.z[1][0,12:40])
88 75 self.zmin = self.zmin if self.zmin is not None else numpy.min(
89 76 self.z[1][0,12:40])
90 77
91
92
93 78 if ax.firsttime:
94 79
95 80 if self.zlimits is not None:
96 81 self.zmin, self.zmax = self.zlimits[n]
97 82
98
99 83 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
100 84 vmin=self.zmin,
101 85 vmax=self.zmax,
102 86 cmap=self.cmaps[n]
103 87 )
104 #plt.tight_layout()
105 88 else:
106 89 if self.zlimits is not None:
107 90 self.zmin, self.zmax = self.zlimits[n]
@@ -111,7 +94,6 class RTIDPPlot(RTIPlot):
111 94 vmax=self.zmax,
112 95 cmap=self.cmaps[n]
113 96 )
114 #plt.tight_layout()
115 97
116 98
117 99 class RTILPPlot(RTIPlot):
@@ -124,8 +106,6 class RTILPPlot(RTIPlot):
124 106 colormap = 'jro'
125 107 plot_name = 'RTI LP'
126 108
127 #cb_label = 'Ne Electron Density (1/cm3)'
128
129 109 def setup(self):
130 110 self.xaxis = 'time'
131 111 self.ncols = 1
@@ -140,10 +120,6 class RTILPPlot(RTIPlot):
140 120
141 121 self.cb_label = 'Intensity (dB)'
142 122
143
144
145 #self.cb_label = cb_label
146
147 123 self.titles = ['{} Channel {}'.format(
148 124 self.plot_name.upper(), '0'),'{} Channel {}'.format(
149 125 self.plot_name.upper(), '1'),'{} Channel {}'.format(
@@ -175,7 +151,6 class RTILPPlot(RTIPlot):
175 151
176 152 for n, ax in enumerate(self.axes):
177 153
178
179 154 self.zmax = self.zmax if self.zmax is not None else numpy.max(
180 155 self.z[1][0,12:40])
181 156 self.zmin = self.zmin if self.zmin is not None else numpy.min(
@@ -917,36 +892,37 class CrossProductsPlot(Plot):
917 892 plot_name = 'Cross Products'
918 893 plot_type = 'scatterbuffer'
919 894
920
921 895 def setup(self):
922 896
923 897 self.ncols = 3
924 898 self.nrows = 1
925 899 self.nplots = 3
926 900 self.ylabel = 'Range [km]'
927
928 901 self.width = 3.5*self.nplots
929 902 self.height = 5.5
930 903 self.colorbar = False
931 904 self.titles = []
932 905
933 def plot(self):
934
935 self.x = self.data['crossprod'][:,-1,:,:,:,:]
936
906 def update(self, dataOut):
937 907
908 data = {}
909 meta = {}
938 910
911 data['crossprod'] = dataOut.crossprods
912 data['NDP'] = dataOut.NDP
939 913
940 self.y = self.data.heights[0:self.data.NDP]
914 return data, meta
941 915
916 def plot(self):
942 917
918 self.x = self.data['crossprod'][:,-1,:,:,:,:]
919 self.y = self.data.heights[0:self.data['NDP']]
943 920
944 921 for n, ax in enumerate(self.axes):
945 922
946 923 self.xmin=numpy.min(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0])))
947 924 self.xmax=numpy.max(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0])))
948 925
949
950 926 if ax.firsttime:
951 927
952 928 self.autoxticks=False
@@ -969,7 +945,6 class CrossProductsPlot(Plot):
969 945 label4='kaxby'
970 946 self.xlimits.append((self.xmin,self.xmax))
971 947
972
973 948 ax.plotline1 = ax.plot(self.x[n][0,:,0,0], self.y, color='r',linewidth=2.0, label=label1)
974 949 ax.plotline2 = ax.plot(self.x[n][1,:,0,0], self.y, color='k',linewidth=2.0, label=label2)
975 950 ax.plotline3 = ax.plot(self.x[n][2,:,0,0], self.y, color='b',linewidth=2.0, label=label3)
@@ -977,8 +952,6 class CrossProductsPlot(Plot):
977 952 ax.legend(loc='upper right')
978 953 ax.set_xlim(self.xmin, self.xmax)
979 954 self.titles.append('{}'.format(self.plot_name.upper()))
980 #plt.tight_layout()
981
982 955
983 956 else:
984 957
@@ -989,14 +962,11 class CrossProductsPlot(Plot):
989 962
990 963 ax.set_xlim(self.xmin, self.xmax)
991 964
992
993 965 ax.plotline1[0].set_data(self.x[n][0,:,0,0],self.y)
994 966 ax.plotline2[0].set_data(self.x[n][1,:,0,0],self.y)
995 967 ax.plotline3[0].set_data(self.x[n][2,:,0,0],self.y)
996 968 ax.plotline4[0].set_data(self.x[n][3,:,0,0],self.y)
997 969 self.titles.append('{}'.format(self.plot_name.upper()))
998 #plt.tight_layout()
999
1000 970
1001 971
1002 972 class CrossProductsLPPlot(Plot):
@@ -19,4 +19,4 from .pxproc_parameters import *
19 19 ###########DP###########
20 20 from .jroproc_voltage_lags import *
21 21 ###########DP###########
22 from .jroproc_spectra_lags_faraday import *
22 # from .jroproc_spectra_lags_faraday import *
@@ -1,12 +1,21
1
2 import os
1 3 import sys
2 4 import numpy, math
3 5 from scipy import interpolate
6 from scipy.optimize import nnls
4 7 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator
5 8 from schainpy.model.data.jrodata import Voltage,hildebrand_sekhon
6 9 from schainpy.utils import log
7 10 from time import time, mktime, strptime, gmtime, ctime
8 import os
9 11
12 try:
13 from schainpy.model.proc import fitacf_guess
14 from schainpy.model.proc import fitacf_fit_short
15 from schainpy.model.proc import fitacf_acf2
16 from schainpy.model.proc import full_profile_profile
17 except:
18 log.warning('Missing Faraday fortran libs')
10 19
11 20 class VoltageProc(ProcessingUnit):
12 21
@@ -1979,8 +1988,6 class suppress_stdout_stderr(object):
1979 1988 os.close(fd)
1980 1989
1981 1990
1982 from schainpy.model.proc import fitacf_guess
1983 from schainpy.model.proc import fitacf_fit_short
1984 1991 class DPTemperaturesEstimation(Operation):
1985 1992 """Operation to estimate temperatures for Double Pulse data.
1986 1993
@@ -2184,7 +2191,6 class NeTeTiRecal(NormalizeDPPower,DPTemperaturesEstimation):
2184 2191 return dataOut
2185 2192
2186 2193
2187 from schainpy.model.proc import fitacf_acf2
2188 2194 class DenCorrection(Operation):
2189 2195
2190 2196 def __init__(self, **kwargs):
@@ -5366,8 +5372,6 class SumFlipsHP(SumFlips):
5366 5372 return dataOut
5367 5373
5368 5374
5369 from schainpy.model.proc import full_profile_profile
5370 from scipy.optimize import nnls
5371 5375 class LongPulseAnalysis(Operation):
5372 5376 """Operation to estimate ACFs, temperatures, total electron density and Hydrogen/Helium fractions from the Long Pulse data.
5373 5377
General Comments 0
You need to be logged in to leave comments. Login now