@@ -49,13 +49,12 static PyObject *hildebrand_sekhon(PyObject *self, PyObject *args) { | |||||
49 | // return PyLong_FromLong(lnoise); |
|
49 | // return PyLong_FromLong(lnoise); | |
50 | return PyFloat_FromDouble(lnoise); |
|
50 | return PyFloat_FromDouble(lnoise); | |
51 | } |
|
51 | } | |
52 | /* |
|
52 | ||
53 | static PyObject *hildebrand_sekhon2(PyObject *self, PyObject *args) { |
|
53 | static PyObject *hildebrand_sekhon2(PyObject *self, PyObject *args) { | |
54 | double navg; |
|
54 | double navg; | |
55 | double th; |
|
|||
56 | PyObject *data_obj, *data_array; |
|
55 | PyObject *data_obj, *data_array; | |
57 |
|
56 | |||
58 |
if (!PyArg_ParseTuple(args, "Od", &data_obj, &navg |
|
57 | if (!PyArg_ParseTuple(args, "Od", &data_obj, &navg)) { | |
59 | return NULL; |
|
58 | return NULL; | |
60 | } |
|
59 | } | |
61 |
|
60 | |||
@@ -68,7 +67,7 static PyObject *hildebrand_sekhon2(PyObject *self, PyObject *args) { | |||||
68 | } |
|
67 | } | |
69 | double *sortdata = (double*)PyArray_DATA(data_array); |
|
68 | double *sortdata = (double*)PyArray_DATA(data_array); | |
70 | int lenOfData = (int)PyArray_SIZE(data_array) ; |
|
69 | int lenOfData = (int)PyArray_SIZE(data_array) ; | |
71 |
double nums_min = lenOfData* |
|
70 | double nums_min = lenOfData*0.75; | |
72 | if (nums_min <= 5) nums_min = 5; |
|
71 | if (nums_min <= 5) nums_min = 5; | |
73 | double sump = 0; |
|
72 | double sump = 0; | |
74 | double sumq = 0; |
|
73 | double sumq = 0; | |
@@ -94,13 +93,14 static PyObject *hildebrand_sekhon2(PyObject *self, PyObject *args) { | |||||
94 |
|
93 | |||
95 | Py_DECREF(data_array); |
|
94 | Py_DECREF(data_array); | |
96 |
|
95 | |||
97 |
|
|
96 | return PyLong_FromLong(j); | |
98 | return PyFloat_FromDouble(j,sortID); |
|
97 | ||
99 | } |
|
98 | } | |
100 | */ |
|
99 | ||
101 |
|
100 | |||
102 | static PyMethodDef noiseMethods[] = { |
|
101 | static PyMethodDef noiseMethods[] = { | |
103 | { "hildebrand_sekhon", hildebrand_sekhon, METH_VARARGS, "Get noise with hildebrand_sekhon algorithm" }, |
|
102 | { "hildebrand_sekhon", hildebrand_sekhon, METH_VARARGS, "Get noise with hildebrand_sekhon algorithm" }, | |
|
103 | { "hildebrand_sekhon2", hildebrand_sekhon2, METH_VARARGS, "Get index for satellite cleaning" }, | |||
104 | { NULL, NULL, 0, NULL } |
|
104 | { NULL, NULL, 0, NULL } | |
105 | }; |
|
105 | }; | |
106 |
|
106 |
@@ -192,9 +192,9 class JROData(GenericData): | |||||
192 | data = None |
|
192 | data = None | |
193 | nmodes = None |
|
193 | nmodes = None | |
194 | metadata_list = ['heightList', 'timeZone', 'type'] |
|
194 | metadata_list = ['heightList', 'timeZone', 'type'] | |
195 |
codeList = |
|
195 | codeList = [] | |
196 |
azimuthList = |
|
196 | azimuthList = [] | |
197 |
elevationList = |
|
197 | elevationList = [] | |
198 |
|
198 | |||
199 | def __str__(self): |
|
199 | def __str__(self): | |
200 |
|
200 |
@@ -87,7 +87,10 class PowerPlot(RTIPlot): | |||||
87 | data = { |
|
87 | data = { | |
88 | 'pow': 10*numpy.log10(dataOut.data_pow) |
|
88 | 'pow': 10*numpy.log10(dataOut.data_pow) | |
89 | } |
|
89 | } | |
|
90 | try: | |||
90 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
91 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
|
92 | except: | |||
|
93 | pass | |||
91 | return data, {} |
|
94 | return data, {} | |
92 |
|
95 | |||
93 | class SpectralWidthPlot(RTIPlot): |
|
96 | class SpectralWidthPlot(RTIPlot): |
@@ -23,6 +23,8 class SpectraPlot(Plot): | |||||
23 | plot_type = 'pcolor' |
|
23 | plot_type = 'pcolor' | |
24 | buffering = False |
|
24 | buffering = False | |
25 | channelList = [] |
|
25 | channelList = [] | |
|
26 | elevationList = [] | |||
|
27 | azimuthList = [] | |||
26 |
|
28 | |||
27 | def setup(self): |
|
29 | def setup(self): | |
28 |
|
30 | |||
@@ -43,6 +45,10 class SpectraPlot(Plot): | |||||
43 | def update_list(self,dataOut): |
|
45 | def update_list(self,dataOut): | |
44 | if len(self.channelList) == 0: |
|
46 | if len(self.channelList) == 0: | |
45 | self.channelList = dataOut.channelList |
|
47 | self.channelList = dataOut.channelList | |
|
48 | if len(self.elevationList) == 0: | |||
|
49 | self.elevationList = dataOut.elevationList | |||
|
50 | if len(self.azimuthList) == 0: | |||
|
51 | self.azimuthList = dataOut.azimuthList | |||
46 |
|
52 | |||
47 | def update(self, dataOut): |
|
53 | def update(self, dataOut): | |
48 |
|
54 | |||
@@ -110,6 +116,9 class SpectraPlot(Plot): | |||||
110 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
116 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) | |
111 | if self.CODE == 'spc_moments': |
|
117 | if self.CODE == 'spc_moments': | |
112 | ax.plt_mean.set_data(mean, y) |
|
118 | ax.plt_mean.set_data(mean, y) | |
|
119 | if len(self.azimuthList) > 0 and len(self.elevationList) > 0: | |||
|
120 | self.titles.append('CH {}: {:2.1f}elv {:2.1f}az {:3.2f}dB'.format(self.channelList[n], noise, self.elevationList[n], self.azimuthList[n])) | |||
|
121 | else: | |||
113 | self.titles.append('CH {}: {:3.2f}dB'.format(self.channelList[n], noise)) |
|
122 | self.titles.append('CH {}: {:3.2f}dB'.format(self.channelList[n], noise)) | |
114 |
|
123 | |||
115 |
|
124 | |||
@@ -226,6 +235,8 class RTIPlot(Plot): | |||||
226 | plot_type = 'pcolorbuffer' |
|
235 | plot_type = 'pcolorbuffer' | |
227 | titles = None |
|
236 | titles = None | |
228 | channelList = [] |
|
237 | channelList = [] | |
|
238 | elevationList = [] | |||
|
239 | azimuthList = [] | |||
229 |
|
240 | |||
230 | def setup(self): |
|
241 | def setup(self): | |
231 | self.xaxis = 'time' |
|
242 | self.xaxis = 'time' | |
@@ -242,7 +253,12 class RTIPlot(Plot): | |||||
242 |
|
253 | |||
243 | def update_list(self,dataOut): |
|
254 | def update_list(self,dataOut): | |
244 |
|
255 | |||
|
256 | if len(self.channelList) == 0: | |||
245 | self.channelList = dataOut.channelList |
|
257 | self.channelList = dataOut.channelList | |
|
258 | if len(self.elevationList) == 0: | |||
|
259 | self.elevationList = dataOut.elevationList | |||
|
260 | if len(self.azimuthList) == 0: | |||
|
261 | self.azimuthList = dataOut.azimuthList | |||
246 |
|
262 | |||
247 |
|
263 | |||
248 | def update(self, dataOut): |
|
264 | def update(self, dataOut): | |
@@ -265,12 +281,18 class RTIPlot(Plot): | |||||
265 |
|
281 | |||
266 | try: |
|
282 | try: | |
267 | if self.channelList != None: |
|
283 | if self.channelList != None: | |
|
284 | if len(self.elevationList) > 0 and len(self.azimuthList) > 0: | |||
|
285 | self.titles = ['{} Channel {} ({:2.1f} Elev, {:2.1f} Azth)'.format( | |||
|
286 | self.CODE.upper(), x, self.elevationList[x], self.azimuthList[x]) for x in self.channelList] | |||
|
287 | else: | |||
268 | self.titles = ['{} Channel {}'.format( |
|
288 | self.titles = ['{} Channel {}'.format( | |
269 | self.CODE.upper(), x) for x in self.channelList] |
|
289 | self.CODE.upper(), x) for x in self.channelList] | |
270 | except: |
|
290 | except: | |
271 | if self.channelList.any() != None: |
|
291 | if self.channelList.any() != None: | |
|
292 | ||||
272 | self.titles = ['{} Channel {}'.format( |
|
293 | self.titles = ['{} Channel {}'.format( | |
273 | self.CODE.upper(), x) for x in self.channelList] |
|
294 | self.CODE.upper(), x) for x in self.channelList] | |
|
295 | ||||
274 | if self.decimation is None: |
|
296 | if self.decimation is None: | |
275 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
297 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
276 | else: |
|
298 | else: | |
@@ -879,6 +901,8 class NoiselessRTIPlot(Plot): | |||||
879 | plot_type = 'pcolorbuffer' |
|
901 | plot_type = 'pcolorbuffer' | |
880 | titles = None |
|
902 | titles = None | |
881 | channelList = [] |
|
903 | channelList = [] | |
|
904 | elevationList = [] | |||
|
905 | azimuthList = [] | |||
882 |
|
906 | |||
883 | def setup(self): |
|
907 | def setup(self): | |
884 | self.xaxis = 'time' |
|
908 | self.xaxis = 'time' | |
@@ -894,9 +918,12 class NoiselessRTIPlot(Plot): | |||||
894 | self.CODE.upper(), x) for x in range(self.nplots)] |
|
918 | self.CODE.upper(), x) for x in range(self.nplots)] | |
895 |
|
919 | |||
896 | def update_list(self,dataOut): |
|
920 | def update_list(self,dataOut): | |
897 |
|
921 | if len(self.channelList) == 0: | ||
898 | self.channelList = dataOut.channelList |
|
922 | self.channelList = dataOut.channelList | |
899 |
|
923 | if len(self.elevationList) == 0: | ||
|
924 | self.elevationList = dataOut.elevationList | |||
|
925 | if len(self.azimuthList) == 0: | |||
|
926 | self.azimuthList = dataOut.azimuthList | |||
900 |
|
927 | |||
901 | def update(self, dataOut): |
|
928 | def update(self, dataOut): | |
902 | if len(self.channelList) == 0: |
|
929 | if len(self.channelList) == 0: | |
@@ -906,9 +933,15 class NoiselessRTIPlot(Plot): | |||||
906 |
|
933 | |||
907 | n0 = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
934 | n0 = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
908 | (nch, nff, nh) = dataOut.data_spc.shape |
|
935 | (nch, nff, nh) = dataOut.data_spc.shape | |
|
936 | #print(nch, nff, nh) | |||
|
937 | if nch != 1: | |||
|
938 | aux = [] | |||
|
939 | for c in self.channelList: | |||
|
940 | aux.append(n0[c]) | |||
|
941 | n0 = numpy.asarray(aux) | |||
909 | noise = numpy.repeat(n0,nh, axis=0).reshape((nch,nh)) |
|
942 | noise = numpy.repeat(n0,nh, axis=0).reshape((nch,nh)) | |
910 |
|
943 | #print(dataOut.elevationList, dataOut.azimuthList) | ||
911 |
|
944 | #print(dataOut.channelList) | ||
912 | data['noiseless_rti'] = dataOut.getPower() - noise |
|
945 | data['noiseless_rti'] = dataOut.getPower() - noise | |
913 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
946 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
914 | return data, meta |
|
947 | return data, meta | |
@@ -923,10 +956,15 class NoiselessRTIPlot(Plot): | |||||
923 |
|
956 | |||
924 | try: |
|
957 | try: | |
925 | if self.channelList != None: |
|
958 | if self.channelList != None: | |
|
959 | if len(self.elevationList) > 0 and len(self.azimuthList) > 0: | |||
|
960 | self.titles = ['{} Channel {} ({:2.1f} Elev, {:2.1f} Azth)'.format( | |||
|
961 | self.CODE.upper(), x, self.elevationList[x], self.azimuthList[x]) for x in self.channelList] | |||
|
962 | else: | |||
926 | self.titles = ['{} Channel {}'.format( |
|
963 | self.titles = ['{} Channel {}'.format( | |
927 | self.CODE.upper(), x) for x in self.channelList] |
|
964 | self.CODE.upper(), x) for x in self.channelList] | |
928 | except: |
|
965 | except: | |
929 | if self.channelList.any() != None: |
|
966 | if self.channelList.any() != None: | |
|
967 | ||||
930 | self.titles = ['{} Channel {}'.format( |
|
968 | self.titles = ['{} Channel {}'.format( | |
931 | self.CODE.upper(), x) for x in self.channelList] |
|
969 | self.CODE.upper(), x) for x in self.channelList] | |
932 | if self.decimation is None: |
|
970 | if self.decimation is None: |
@@ -17,6 +17,8 import math | |||||
17 | from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation |
|
17 | from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation | |
18 | from schainpy.model.data.jrodata import Spectra |
|
18 | from schainpy.model.data.jrodata import Spectra | |
19 | from schainpy.model.data.jrodata import hildebrand_sekhon |
|
19 | from schainpy.model.data.jrodata import hildebrand_sekhon | |
|
20 | from schainpy.model.data import _noise | |||
|
21 | ||||
20 | from schainpy.utils import log |
|
22 | from schainpy.utils import log | |
21 |
|
23 | |||
22 | from scipy.optimize import curve_fit |
|
24 | from scipy.optimize import curve_fit | |
@@ -1092,6 +1094,7 class IntegrationFaradaySpectra(Operation): | |||||
1092 | n = None |
|
1094 | n = None | |
1093 | minHei_ind = None |
|
1095 | minHei_ind = None | |
1094 | maxHei_ind = None |
|
1096 | maxHei_ind = None | |
|
1097 | avg = 1.0 | |||
1095 | factor = 0.0 |
|
1098 | factor = 0.0 | |
1096 |
|
1099 | |||
1097 | def __init__(self): |
|
1100 | def __init__(self): | |
@@ -1184,10 +1187,10 class IntegrationFaradaySpectra(Operation): | |||||
1184 |
|
1187 | |||
1185 | return |
|
1188 | return | |
1186 |
|
1189 | |||
1187 | def hildebrand_sekhon_Integration(self,data,navg, factor): |
|
1190 | def hildebrand_sekhon_Integration(self,sortdata,navg, factor): | |
1188 |
|
1191 | #data debe estar ordenado | ||
1189 | sortdata = numpy.sort(data, axis=None) |
|
1192 | #sortdata = numpy.sort(data, axis=None) | |
1190 | sortID=data.argsort() |
|
1193 | #sortID=data.argsort() | |
1191 | lenOfData = len(sortdata) |
|
1194 | lenOfData = len(sortdata) | |
1192 | nums_min = lenOfData*factor |
|
1195 | nums_min = lenOfData*factor | |
1193 | if nums_min <= 5: |
|
1196 | if nums_min <= 5: | |
@@ -1209,7 +1212,9 class IntegrationFaradaySpectra(Operation): | |||||
1209 | j += 1 |
|
1212 | j += 1 | |
1210 | #lnoise = sump / j |
|
1213 | #lnoise = sump / j | |
1211 | #print("H S done") |
|
1214 | #print("H S done") | |
1212 | return j,sortID |
|
1215 | #return j,sortID | |
|
1216 | return j | |||
|
1217 | ||||
1213 |
|
1218 | |||
1214 | def pushData(self): |
|
1219 | def pushData(self): | |
1215 | """ |
|
1220 | """ | |
@@ -1256,7 +1261,11 class IntegrationFaradaySpectra(Operation): | |||||
1256 | # if i==1 and j==0: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 |
|
1261 | # if i==1 and j==0: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
1257 | # continue |
|
1262 | # continue | |
1258 | buffer=buffer1[:,j] |
|
1263 | buffer=buffer1[:,j] | |
1259 | index,sortID=self.hildebrand_sekhon_Integration(buffer,1,self.factor) |
|
1264 | sortdata = numpy.sort(buffer, axis=None) | |
|
1265 | sortID=buffer.argsort() | |||
|
1266 | index = _noise.hildebrand_sekhon2(sortdata,self.navg) | |||
|
1267 | ||||
|
1268 | #index,sortID=self.hildebrand_sekhon_Integration(buffer,1,self.factor) | |||
1260 |
|
1269 | |||
1261 | indexes.append(index) |
|
1270 | indexes.append(index) | |
1262 | #sortIDs.append(sortID) |
|
1271 | #sortIDs.append(sortID) | |
@@ -1272,7 +1281,7 class IntegrationFaradaySpectra(Operation): | |||||
1272 | if indexmin != buffer1.shape[0]: |
|
1281 | if indexmin != buffer1.shape[0]: | |
1273 | if self.nChannels > 1: |
|
1282 | if self.nChannels > 1: | |
1274 | cspc_outliers_exist= True |
|
1283 | cspc_outliers_exist= True | |
1275 |
print("outliers c |
|
1284 | #print("outliers cspc") | |
1276 | ###sortdata=numpy.sort(buffer1,axis=0) |
|
1285 | ###sortdata=numpy.sort(buffer1,axis=0) | |
1277 | ###avg2=numpy.mean(sortdata[:indexmin,:],axis=0) |
|
1286 | ###avg2=numpy.mean(sortdata[:indexmin,:],axis=0) | |
1278 | lt=outliers_IDs |
|
1287 | lt=outliers_IDs |
General Comments 0
You need to be logged in to leave comments.
Login now