@@ -662,6 +662,7 class getNoiseB(Operation): | |||||
662 |
|
662 | |||
663 | self.minIndex, self.maxIndex, self.minIndexFFT, self.maxIndexFFT = minIndex, maxIndex, minIndexFFT, maxIndexFFT |
|
663 | self.minIndex, self.maxIndex, self.minIndexFFT, self.maxIndexFFT = minIndex, maxIndex, minIndexFFT, maxIndexFFT | |
664 | self.isConfig = True |
|
664 | self.isConfig = True | |
|
665 | self.offset = 1 | |||
665 | if offset!=None: |
|
666 | if offset!=None: | |
666 | self.offset = 10**(offset/10) |
|
667 | self.offset = 10**(offset/10) | |
667 | #print("config getNoiseB Done") |
|
668 | #print("config getNoiseB Done") | |
@@ -705,7 +706,7 class getNoiseB(Operation): | |||||
705 | #print("2: ",10*numpy.log10(self.dataOut.noise_estimation/64)) |
|
706 | #print("2: ",10*numpy.log10(self.dataOut.noise_estimation/64)) | |
706 |
|
707 | |||
707 | #print(self.dataOut.flagNoData) |
|
708 | #print(self.dataOut.flagNoData) | |
708 | print("getNoise Done", noise) |
|
709 | #print("getNoise Done", noise) | |
709 | return self.dataOut |
|
710 | return self.dataOut | |
710 |
|
711 | |||
711 | def getNoiseByMean(self,data): |
|
712 | def getNoiseByMean(self,data): | |
@@ -1400,12 +1401,11 class IntegrationFaradaySpectra(Operation): | |||||
1400 | buffer=None |
|
1401 | buffer=None | |
1401 | buffer1=None |
|
1402 | buffer1=None | |
1402 | buffer_cspc=None |
|
1403 | buffer_cspc=None | |
|
1404 | #print("aes: ", self.__buffer_cspc) | |||
1403 | self.__buffer_spc=numpy.array(self.__buffer_spc) |
|
1405 | self.__buffer_spc=numpy.array(self.__buffer_spc) | |
1404 | try: |
|
1406 | if self.__buffer_cspc != None: | |
1405 | self.__buffer_cspc=numpy.array(self.__buffer_cspc) |
|
1407 | self.__buffer_cspc=numpy.array(self.__buffer_cspc) | |
1406 | except : |
|
1408 | ||
1407 | #print("No cpsc",e) |
|
|||
1408 | pass |
|
|||
1409 | #print("FREQ_DC",self.__buffer_spc.shape,self.__buffer_cspc.shape) |
|
1409 | #print("FREQ_DC",self.__buffer_spc.shape,self.__buffer_cspc.shape) | |
1410 |
|
1410 | |||
1411 | freq_dc = int(self.__buffer_spc.shape[2] / 2) |
|
1411 | freq_dc = int(self.__buffer_spc.shape[2] / 2) | |
@@ -1414,11 +1414,9 class IntegrationFaradaySpectra(Operation): | |||||
1414 | self.dataOutliers = numpy.zeros((self.nChannels,self.nHeights)) # --> almacen de outliers |
|
1414 | self.dataOutliers = numpy.zeros((self.nChannels,self.nHeights)) # --> almacen de outliers | |
1415 |
|
1415 | |||
1416 | for k in range(self.minHei_ind,self.maxHei_ind): |
|
1416 | for k in range(self.minHei_ind,self.maxHei_ind): | |
1417 | try: |
|
1417 | if self.__buffer_cspc != None: | |
1418 | buffer_cspc=numpy.copy(self.__buffer_cspc[:,:,:,k]) |
|
1418 | buffer_cspc=numpy.copy(self.__buffer_cspc[:,:,:,k]) | |
1419 | except: |
|
1419 | ||
1420 | #print("No cpsc",e) |
|
|||
1421 | pass |
|
|||
1422 | outliers_IDs_cspc=[] |
|
1420 | outliers_IDs_cspc=[] | |
1423 | cspc_outliers_exist=False |
|
1421 | cspc_outliers_exist=False | |
1424 | for i in range(self.nChannels):#dataOut.nChannels): |
|
1422 | for i in range(self.nChannels):#dataOut.nChannels): | |
@@ -1484,14 +1482,17 class IntegrationFaradaySpectra(Operation): | |||||
1484 |
|
1482 | |||
1485 | self.dataOutliers[i,k] = len(outliers_IDs) |
|
1483 | self.dataOutliers[i,k] = len(outliers_IDs) | |
1486 |
|
1484 | |||
|
1485 | ||||
1487 | self.__buffer_spc[:,i,:,k]=numpy.copy(buffer1) |
|
1486 | self.__buffer_spc[:,i,:,k]=numpy.copy(buffer1) | |
1488 |
|
1487 | |||
1489 | outliers_IDs_cspc=numpy.append(outliers_IDs_cspc,outliers_IDs) |
|
|||
1490 |
|
1488 | |||
|
1489 | if self.__buffer_cspc != None: | |||
|
1490 | outliers_IDs_cspc=numpy.append(outliers_IDs_cspc,outliers_IDs) | |||
1491 |
|
1491 | |||
1492 |
|
1492 | |||
1493 | outliers_IDs_cspc=outliers_IDs_cspc.astype(numpy.dtype('int64')) |
|
1493 | if self.__buffer_cspc != None: | |
1494 | if cspc_outliers_exist : |
|
1494 | outliers_IDs_cspc=outliers_IDs_cspc.astype(numpy.dtype('int64')) | |
|
1495 | if cspc_outliers_exist: | |||
1495 |
|
1496 | |||
1496 | lt=outliers_IDs_cspc |
|
1497 | lt=outliers_IDs_cspc | |
1497 |
|
1498 | |||
@@ -1500,13 +1501,9 class IntegrationFaradaySpectra(Operation): | |||||
1500 | #buffer_cspc[p,:]=avg |
|
1501 | #buffer_cspc[p,:]=avg | |
1501 | buffer_cspc[p,:] = numpy.NaN |
|
1502 | buffer_cspc[p,:] = numpy.NaN | |
1502 |
|
1503 | |||
1503 | try: |
|
1504 | if self.__buffer_cspc != None: | |
1504 | self.__buffer_cspc[:,:,:,k]=numpy.copy(buffer_cspc) |
|
1505 | self.__buffer_cspc[:,:,:,k]=numpy.copy(buffer_cspc) | |
1505 | except: |
|
1506 | ||
1506 | #print("No cpsc",e) |
|
|||
1507 | pass |
|
|||
1508 | #else: |
|
|||
1509 | #break |
|
|||
1510 |
|
1507 | |||
1511 |
|
1508 | |||
1512 |
|
1509 | |||
@@ -1522,14 +1519,11 class IntegrationFaradaySpectra(Operation): | |||||
1522 |
|
1519 | |||
1523 | #data_spc = numpy.sum(self.__buffer_spc,axis=0) |
|
1520 | #data_spc = numpy.sum(self.__buffer_spc,axis=0) | |
1524 | data_spc = numpy.nansum(self.__buffer_spc,axis=0) |
|
1521 | data_spc = numpy.nansum(self.__buffer_spc,axis=0) | |
1525 | try: |
|
1522 | if self.__buffer_cspc != None: | |
1526 | #data_cspc = numpy.sum(self.__buffer_cspc,axis=0) |
|
1523 | #data_cspc = numpy.sum(self.__buffer_cspc,axis=0) | |
1527 | data_cspc = numpy.nansum(self.__buffer_cspc,axis=0) |
|
1524 | data_cspc = numpy.nansum(self.__buffer_cspc,axis=0) | |
1528 |
e |
|
1525 | else: | |
1529 | #print("No cpsc",e) |
|
1526 | data_cspc = None | |
1530 | pass |
|
|||
1531 |
|
||||
1532 |
|
||||
1533 | data_dc = self.__buffer_dc |
|
1527 | data_dc = self.__buffer_dc | |
1534 | #(CH, HEIGH) |
|
1528 | #(CH, HEIGH) | |
1535 | self.maxProfilesInt = self.__profIndex |
|
1529 | self.maxProfilesInt = self.__profIndex | |
@@ -1539,7 +1533,7 class IntegrationFaradaySpectra(Operation): | |||||
1539 | self.__buffer_cspc = [] |
|
1533 | self.__buffer_cspc = [] | |
1540 | self.__buffer_dc = 0 |
|
1534 | self.__buffer_dc = 0 | |
1541 | self.__profIndex = 0 |
|
1535 | self.__profIndex = 0 | |
1542 |
|
1536 | #print("cleaned ",data_cspc) | ||
1543 | return data_spc, data_cspc, data_dc, n |
|
1537 | return data_spc, data_cspc, data_dc, n | |
1544 |
|
1538 | |||
1545 | def byProfiles(self, *args): |
|
1539 | def byProfiles(self, *args): | |
@@ -1589,6 +1583,7 class IntegrationFaradaySpectra(Operation): | |||||
1589 | if not self.__dataReady: |
|
1583 | if not self.__dataReady: | |
1590 | return None, None, None, None |
|
1584 | return None, None, None, None | |
1591 |
|
1585 | |||
|
1586 | #print("integrate", avgdata_cspc) | |||
1592 | return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc |
|
1587 | return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc | |
1593 |
|
1588 | |||
1594 | def run(self, dataOut, n=None, DPL = None,timeInterval=None, overlapping=False, minHei=None, maxHei=None, avg=1, factor=0.75): |
|
1589 | def run(self, dataOut, n=None, DPL = None,timeInterval=None, overlapping=False, minHei=None, maxHei=None, avg=1, factor=0.75): | |
@@ -1596,10 +1591,10 class IntegrationFaradaySpectra(Operation): | |||||
1596 | if n == 1: |
|
1591 | if n == 1: | |
1597 | return self.dataOut |
|
1592 | return self.dataOut | |
1598 |
|
1593 | |||
1599 |
|
1594 | #print("nchannels", self.dataOut.nChannels) | ||
1600 | if self.dataOut.nChannels == 1: |
|
1595 | if self.dataOut.nChannels == 1: | |
1601 | self.dataOut.data_cspc = None #si es un solo canal no vale la pena acumular DATOS |
|
1596 | self.dataOut.data_cspc = None #si es un solo canal no vale la pena acumular DATOS | |
1602 | #print(self.dataOut.data_spc.shape, self.dataOut.data_cspc) |
|
1597 | #print("IN spc:", self.dataOut.data_spc.shape, self.dataOut.data_cspc) | |
1603 | if not self.isConfig: |
|
1598 | if not self.isConfig: | |
1604 | self.setup(self.dataOut, n, timeInterval, overlapping,DPL ,minHei, maxHei, avg, factor) |
|
1599 | self.setup(self.dataOut, n, timeInterval, overlapping,DPL ,minHei, maxHei, avg, factor) | |
1605 | self.isConfig = True |
|
1600 | self.isConfig = True | |
@@ -1627,7 +1622,7 class IntegrationFaradaySpectra(Operation): | |||||
1627 | if self.nChannels == 1: |
|
1622 | if self.nChannels == 1: | |
1628 | #print("f int", avgdata_spc.shape) |
|
1623 | #print("f int", avgdata_spc.shape) | |
1629 | self.dataOut.data_spc = avgdata_spc |
|
1624 | self.dataOut.data_spc = avgdata_spc | |
1630 |
self.dataOut.data_cspc = |
|
1625 | self.dataOut.data_cspc = None | |
1631 | else: |
|
1626 | else: | |
1632 | self.dataOut.data_spc = numpy.squeeze(avgdata_spc) |
|
1627 | self.dataOut.data_spc = numpy.squeeze(avgdata_spc) | |
1633 | self.dataOut.data_cspc = numpy.squeeze(avgdata_cspc) |
|
1628 | self.dataOut.data_cspc = numpy.squeeze(avgdata_cspc) | |
@@ -1649,7 +1644,7 class IntegrationFaradaySpectra(Operation): | |||||
1649 | #print(self.dataOut.max_nIncohInt) |
|
1644 | #print(self.dataOut.max_nIncohInt) | |
1650 | self.dataOut.utctime = avgdatatime |
|
1645 | self.dataOut.utctime = avgdatatime | |
1651 | self.dataOut.flagNoData = False |
|
1646 | self.dataOut.flagNoData = False | |
1652 | #print("Faraday Integration DONE...") |
|
1647 | #print("Faraday Integration DONE...", self.dataOut.data_cspc) | |
1653 | #print(self.dataOut.flagNoData) |
|
1648 | #print(self.dataOut.flagNoData) | |
1654 | return self.dataOut |
|
1649 | return self.dataOut | |
1655 |
|
1650 | |||
@@ -1683,8 +1678,9 class removeInterference(Operation): | |||||
1683 | jspectra = self.dataOut.data_spc |
|
1678 | jspectra = self.dataOut.data_spc | |
1684 | jcspectra = self.dataOut.data_cspc |
|
1679 | jcspectra = self.dataOut.data_cspc | |
1685 | jnoise = self.dataOut.getNoise() |
|
1680 | jnoise = self.dataOut.getNoise() | |
1686 | num_incoh = self.dataOut.nIncohInt |
|
1681 | #num_incoh = self.dataOut.nIncohInt | |
1687 |
|
1682 | num_incoh = self.dataOut.max_nIncohInt | ||
|
1683 | #print("spc: ", jspectra.shape, jcspectra) | |||
1688 | num_channel = jspectra.shape[0] |
|
1684 | num_channel = jspectra.shape[0] | |
1689 | num_prof = jspectra.shape[1] |
|
1685 | num_prof = jspectra.shape[1] | |
1690 | num_hei = jspectra.shape[2] |
|
1686 | num_hei = jspectra.shape[2] | |
@@ -1694,6 +1690,7 class removeInterference(Operation): | |||||
1694 | count_hei = int(num_hei / 2) |
|
1690 | count_hei = int(num_hei / 2) | |
1695 | hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei |
|
1691 | hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei | |
1696 | hei_interf = numpy.asarray(hei_interf)[0] |
|
1692 | hei_interf = numpy.asarray(hei_interf)[0] | |
|
1693 | #print(hei_interf) | |||
1697 | # nhei_interf |
|
1694 | # nhei_interf | |
1698 | if (nhei_interf == None): |
|
1695 | if (nhei_interf == None): | |
1699 | nhei_interf = 5 |
|
1696 | nhei_interf = 5 | |
@@ -1737,12 +1734,10 class removeInterference(Operation): | |||||
1737 | jspc_interf = junkspc_interf.sum(axis=0) / nhei_interf |
|
1734 | jspc_interf = junkspc_interf.sum(axis=0) / nhei_interf | |
1738 | jspc_interf = jspc_interf.transpose() |
|
1735 | jspc_interf = jspc_interf.transpose() | |
1739 | # Calculando el espectro de interferencia promedio |
|
1736 | # Calculando el espectro de interferencia promedio | |
1740 | noiseid = numpy.where( |
|
1737 | noiseid = numpy.where(jspc_interf <= tmp_noise / numpy.sqrt(num_incoh)) | |
1741 | jspc_interf <= tmp_noise / numpy.sqrt(num_incoh)) |
|
|||
1742 | noiseid = noiseid[0] |
|
1738 | noiseid = noiseid[0] | |
1743 | cnoiseid = noiseid.size |
|
1739 | cnoiseid = noiseid.size | |
1744 | interfid = numpy.where( |
|
1740 | interfid = numpy.where(jspc_interf > tmp_noise / numpy.sqrt(num_incoh)) | |
1745 | jspc_interf > tmp_noise / numpy.sqrt(num_incoh)) |
|
|||
1746 | interfid = interfid[0] |
|
1741 | interfid = interfid[0] | |
1747 | cinterfid = interfid.size |
|
1742 | cinterfid = interfid.size | |
1748 |
|
1743 |
@@ -2023,6 +2023,7 class removeProfileByFaradayHS(Operation): | |||||
2023 | def cleanOutliersByBlock(self): |
|
2023 | def cleanOutliersByBlock(self): | |
2024 | import matplotlib.pyplot as plt |
|
2024 | import matplotlib.pyplot as plt | |
2025 | import datetime |
|
2025 | import datetime | |
|
2026 | import cv2 | |||
2026 | #print(self.__buffer_data[0].shape) |
|
2027 | #print(self.__buffer_data[0].shape) | |
2027 | data = self.__buffer_data#.copy() |
|
2028 | data = self.__buffer_data#.copy() | |
2028 | print("cleaning shape inpt: ",data.shape) |
|
2029 | print("cleaning shape inpt: ",data.shape) | |
@@ -2034,59 +2035,154 class removeProfileByFaradayHS(Operation): | |||||
2034 | (nch,nsamples, nh) = spectrum.shape |
|
2035 | (nch,nsamples, nh) = spectrum.shape | |
2035 | data2 = None |
|
2036 | data2 = None | |
2036 | #print(data.shape) |
|
2037 | #print(data.shape) | |
|
2038 | cleanedBlock = None | |||
2037 | spectrum2 = spectrum.copy() |
|
2039 | spectrum2 = spectrum.copy() | |
2038 | for ch in range(nch): |
|
2040 | for ch in range(nch): | |
2039 | dh = self.__dh |
|
2041 | dh = self.__dh | |
2040 | dt1 = (dh*1.0e-6)/(0.15) |
|
2042 | dt1 = (dh*1.0e-6)/(0.15) | |
2041 | dt2 = self.__buffer_times[1]-self.__buffer_times[0] |
|
2043 | dt2 = self.__buffer_times[1]-self.__buffer_times[0] | |
|
2044 | ||||
2042 | freqv = numpy.fft.fftfreq(nh, d=dt1) |
|
2045 | freqv = numpy.fft.fftfreq(nh, d=dt1) | |
2043 | freqh = numpy.fft.fftfreq(self.n, d=dt2) |
|
2046 | freqh = numpy.fft.fftfreq(self.n, d=dt2) | |
2044 | #print("spc loop: ") |
|
2047 | ||
|
2048 | # freqv = numpy.fft.fftshift(numpy.fft.fftfreq(nh, d=dt1)) | |||
|
2049 | # freqh = numpy.fft.fftshift(numpy.fft.fftfreq(self.n, d=dt2)) | |||
|
2050 | # | |||
|
2051 | ||||
|
2052 | ||||
|
2053 | ||||
2045 |
|
2054 | |||
2046 |
|
2055 | |||
2047 |
|
2056 | |||
2048 | x, y = numpy.meshgrid(numpy.sort(freqh),numpy.sort(freqv)) |
|
|||
2049 | z = numpy.abs(spectrum[ch,:,:]) |
|
2057 | z = numpy.abs(spectrum[ch,:,:]) | |
2050 | phase = numpy.angle(spectrum[ch,:,:]) |
|
2058 | phase = numpy.angle(spectrum[ch,:,:]) | |
|
2059 | ||||
|
2060 | print("shape z: ", z.shape) | |||
|
2061 | ||||
|
2062 | ||||
2051 | # Find all peaks higher than the 98th percentile |
|
2063 | # Find all peaks higher than the 98th percentile | |
2052 | peaks = z < numpy.percentile(z, 99) |
|
2064 | peaks = z < numpy.percentile(z, 99) | |
2053 | #print(peaks) |
|
2065 | #print(peaks) | |
2054 | # Set those peak coefficients to zero |
|
2066 | # Set those peak coefficients to zero | |
2055 |
spectrum2 = spectrum |
|
2067 | #spectrum2 = spectrum * peaks.astype(int) | |
2056 | data2 = numpy.fft.ifft2(spectrum2,axes=(0,2)) |
|
2068 | #data2 = numpy.fft.ifft2(spectrum2,axes=(0,2)) | |
2057 |
|
2069 | |||
2058 | dat = numpy.log10(z.T) |
|
2070 | dat = numpy.log10(z.T) | |
2059 | pdat = numpy.log10(phase.T) |
|
2071 | pdat = numpy.log10(phase.T) | |
2060 | dat2 = numpy.log10(numpy.abs(spectrum2.T)) |
|
2072 | ||
|
2073 | ||||
|
2074 | min, max = dat.min(), dat.max() | |||
|
2075 | #img = ((dat-min)*255/(max-min)).astype(numpy.uint8) | |||
|
2076 | img = ((dat-min)*200/(max-min)).astype(numpy.uint8) | |||
|
2077 | #img = 255 - ((dat-min)*255/max).astype(numpy.uint8) | |||
|
2078 | ||||
|
2079 | #print(img.shape) | |||
|
2080 | # cv2.imshow('image', numpy.fft.fftshift(img)) | |||
|
2081 | # cv2.waitKey(0) | |||
|
2082 | ||||
|
2083 | spikes = numpy.where(img > 230, True, False) | |||
|
2084 | #print("spikes: ", spikes.sum()) | |||
|
2085 | ||||
|
2086 | #img = cv2.medianBlur(img,3) | |||
|
2087 | ||||
|
2088 | #cv2.imshow('image', cv2.resize(img.astype('float32'), (600, 600))) | |||
|
2089 | kernel3 = numpy.zeros((3,15)) | |||
|
2090 | kernel3[0, :] = -1 | |||
|
2091 | kernel3[1, :] = 2 | |||
|
2092 | kernel3[2, :] = -1 | |||
|
2093 | sharp_img = cv2.filter2D(src=img, ddepth=-1, kernel=kernel3) | |||
|
2094 | ||||
|
2095 | ||||
|
2096 | # cv2.imshow('sharp image', numpy.fft.fftshift(sharp_img)) | |||
|
2097 | # cv2.waitKey(0) | |||
|
2098 | ||||
|
2099 | ret, thresh = cv2.threshold(sharp_img, 127, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) | |||
|
2100 | # #thresh = cv2.adaptiveThreshold(sharp_img,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY_INV,21,0) | |||
|
2101 | # cv2.imshow('binary img', numpy.fft.fftshift(thresh)) | |||
|
2102 | # cv2.waitKey(0) | |||
|
2103 | # #Remove horizontal | |||
|
2104 | horizontal_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (10,1)) | |||
|
2105 | detected_lines = cv2.morphologyEx(sharp_img, cv2.MORPH_OPEN, horizontal_kernel, iterations=8) | |||
|
2106 | cnts, h = cv2.findContours(detected_lines, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) | |||
|
2107 | # print(cnts) | |||
|
2108 | # cv2.imshow('lines ', numpy.fft.fftshift(detected_lines)) | |||
|
2109 | # cv2.waitKey(0) | |||
|
2110 | #cnts = cnts[0] if len(cnts) == 2 else cnts[1] | |||
|
2111 | y_line_index = numpy.asarray([ [c[0][0][0],c[1][0][0], c[0][0][1]] for c in cnts ]) | |||
|
2112 | ||||
|
2113 | # print(y_line_index) | |||
|
2114 | u, index, counts = numpy.unique(y_line_index[:,2], return_index=True, return_counts=True) | |||
|
2115 | print(u, index, counts) | |||
|
2116 | readed_lines = [] | |||
|
2117 | for x1, x2, y, YY, n in zip(y_line_index, u, counts): | |||
|
2118 | if y in readed_lines: | |||
|
2119 | pass | |||
|
2120 | if n > 1: | |||
|
2121 | len_line = self.n | |||
|
2122 | else: | |||
|
2123 | len_line = len(z[x1:x2,y]) | |||
|
2124 | #print(y, nh, self.n) | |||
|
2125 | if y != (nh-1): | |||
|
2126 | list = [ ((z[n, y-1] + z[n,y+1])/2) for n in range(len_line)] | |||
|
2127 | else: | |||
|
2128 | list = [ ((z[n, y-1] + z[n,0])/2) for n in range(len_line)] | |||
|
2129 | if n > 1: | |||
|
2130 | z[:,y] = numpy.asarray(list) | |||
|
2131 | else: | |||
|
2132 | z[x1:x2,y] = numpy.asarray(list) | |||
|
2133 | ||||
|
2134 | readed_lines.append(y) | |||
|
2135 | ||||
|
2136 | dat2 = numpy.log10(z.T) | |||
|
2137 | img = ((dat2-min)*255/(max-min)).astype(numpy.uint8) | |||
|
2138 | ||||
|
2139 | for c in cnts: | |||
|
2140 | #print(c) | |||
|
2141 | cv2.drawContours(img, [c], -1, (255,255,255), 2) | |||
|
2142 | #print("C: ",c[0][1]) | |||
|
2143 | ||||
|
2144 | spcCleaned = z * numpy.exp(1j*phase) | |||
|
2145 | #print(spcCleaned) | |||
|
2146 | ||||
|
2147 | ||||
|
2148 | cv2.imshow('image2', numpy.fft.fftshift(img)) | |||
|
2149 | cv2.waitKey(0) | |||
|
2150 | cv2.destroyAllWindows() | |||
2061 |
|
2151 | |||
2062 | m = numpy.mean(dat) |
|
2152 | m = numpy.mean(dat) | |
2063 | o = numpy.std(dat) |
|
2153 | o = numpy.std(dat) | |
|
2154 | ||||
2064 | fig, ax = plt.subplots(1,2,figsize=(12, 6)) |
|
2155 | fig, ax = plt.subplots(1,2,figsize=(12, 6)) | |
|
2156 | #X, Y = numpy.meshgrid(numpy.sort(freqh),numpy.sort(freqv)) | |||
|
2157 | X, Y = numpy.meshgrid(numpy.fft.fftshift(freqh),numpy.fft.fftshift(freqv)) | |||
2065 |
|
2158 | |||
2066 | colormap = 'jet' |
|
2159 | colormap = 'jet' | |
2067 | #c = ax[0].pcolormesh(x, y, dat, cmap =colormap, vmin = (m-2*o)/2, vmax = (m+2*o)) |
|
2160 | #c = ax[0].pcolormesh(x, y, dat, cmap =colormap, vmin = (m-2*o)/2, vmax = (m+2*o)) | |
2068 |
c = ax[0].pcolormesh( |
|
2161 | c = ax[0].pcolormesh(X, Y, numpy.fft.fftshift(dat), cmap =colormap, vmin = 4.2, vmax = 5.0) | |
2069 | fig.colorbar(c, ax=ax[0]) |
|
2162 | fig.colorbar(c, ax=ax[0]) | |
2070 | #print("aqui estoy", dat.shape) |
|
2163 | ||
|
2164 | ||||
2071 | #c = ax.pcolor( z.T , cmap ='gray', vmin = (m-2*o), vmax = (m+2*o)) |
|
2165 | #c = ax.pcolor( z.T , cmap ='gray', vmin = (m-2*o), vmax = (m+2*o)) | |
2072 | date_time = datetime.datetime.fromtimestamp(self.__buffer_times[0]).strftime('%Y-%m-%d %H:%M:%S.%f') |
|
2166 | #date_time = datetime.datetime.fromtimestamp(self.__buffer_times[0]).strftime('%Y-%m-%d %H:%M:%S.%f') | |
2073 | #strftime('%Y-%m-%d %H:%M:%S') |
|
2167 | #strftime('%Y-%m-%d %H:%M:%S') | |
2074 | #ax[0].set_title('Spectrum magnitude '+date_time) |
|
2168 | #ax[0].set_title('Spectrum magnitude '+date_time) | |
2075 | fig.canvas.set_window_title('Spectrum magnitude {} '.format(self.n)+date_time) |
|
2169 | #fig.canvas.set_window_title('Spectrum magnitude {} '.format(self.n)+date_time) | |
2076 | #print("aqui estoy2",dat2[:,:,0].shape) |
|
2170 | #print("aqui estoy2",dat2[:,:,0].shape) | |
2077 |
c = ax[1].pcolormesh( |
|
2171 | c = ax[1].pcolormesh(X, Y, numpy.fft.fftshift(dat2), cmap =colormap, vmin = 4.2, vmax = 5.0) | |
2078 | #c = ax[1].pcolormesh(x, y, dat2[:,:,0], cmap =colormap, vmin = (m-2*o)/2, vmax = (m+2*o)-1) |
|
2172 | #c = ax[1].pcolormesh(x, y, dat2[:,:,0], cmap =colormap, vmin = (m-2*o)/2, vmax = (m+2*o)-1) | |
2079 | #print("aqui estoy3") |
|
2173 | #print("aqui estoy3") | |
2080 | fig.colorbar(c, ax=ax[1]) |
|
2174 | fig.colorbar(c, ax=ax[1]) | |
2081 | plt.show() |
|
2175 | plt.show() | |
2082 |
|
2176 | |||
|
2177 | spectrum[ch,:,:] = spcCleaned | |||
|
2178 | ||||
2083 | #print(data2.shape) |
|
2179 | #print(data2.shape) | |
2084 |
|
2180 | |||
2085 | #data = data2 |
|
|||
2086 |
|
2181 | |||
2087 | #cleanBlock = numpy.fft.ifft2(data, axes=(0,2)).reshape() |
|
|||
2088 |
|
2182 | |||
2089 | #print("cleanOutliersByBlock Done") |
|
2183 | data[:,:,self.minHei_idx:] = numpy.fft.ifft2(spectrum, axes=(0,2)) | |
|
2184 | ||||
|
2185 | #print("cleanOutliersByBlock Done", data.shape) | |||
2090 |
|
2186 | |||
2091 | return data |
|
2187 | return data | |
2092 |
|
2188 |
General Comments 0
You need to be logged in to leave comments.
Login now