diff --git a/schainpy/model/graphics/jroplot_spectra.py b/schainpy/model/graphics/jroplot_spectra.py index edec97c..7af4a08 100644 --- a/schainpy/model/graphics/jroplot_spectra.py +++ b/schainpy/model/graphics/jroplot_spectra.py @@ -48,18 +48,13 @@ class SpectraPlot(Plot): if self.CODE == 'spc_moments': data['moments'] = dataOut.moments - # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) if self.CODE == 'gaussian_fit': - # data['moments'] = dataOut.moments data['gaussfit'] = dataOut.DGauFitParams - # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) return data, meta def plot(self): - #print(self.xaxis) - #exit(1) if self.xaxis == "frequency": x = self.data.xrange[0] self.xlabel = "Frequency (kHz)" @@ -90,7 +85,6 @@ class SpectraPlot(Plot): if self.CODE == 'spc_moments': mean = data['moments'][n, 1] if self.CODE == 'gaussian_fit': - # mean = data['moments'][n, 1] gau0 = data['gaussfit'][n][2,:,0] gau1 = data['gaussfit'][n][2,:,1] if ax.firsttime: @@ -98,7 +92,6 @@ class SpectraPlot(Plot): self.xmin = self.xmin if self.xmin else -self.xmax self.zmin = self.zmin if self.zmin else numpy.nanmin(z) self.zmax = self.zmax if self.zmax else numpy.nanmax(z) - #print(numpy.shape(x)) ax.plt = ax.pcolormesh(x, y, z[n].T, vmin=self.zmin, vmax=self.zmax, @@ -132,7 +125,7 @@ class SpectraObliquePlot(Plot): Plot for Spectra data ''' - CODE = 'spc' + CODE = 'spc_oblique' colormap = 'jet' plot_type = 'pcolor' @@ -150,10 +143,25 @@ class SpectraObliquePlot(Plot): self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) self.ylabel = 'Range [km]' + def update(self, dataOut): + + data = {} + meta = {} + spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) + data['spc'] = spc + data['rti'] = dataOut.getPower() + data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) + meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) + + data['shift1'] = dataOut.Oblique_params[0][1] + data['shift2'] = dataOut.Oblique_params[0][4] + data['shift1_error'] = dataOut.Oblique_param_errors[0][1] + data['shift2_error'] = dataOut.Oblique_param_errors[0][4] + + return data, meta + def plot(self): - #print(self.xaxis) - #exit(1) if self.xaxis == "frequency": x = self.data.xrange[0] self.xlabel = "Frequency (kHz)" @@ -164,35 +172,23 @@ class SpectraObliquePlot(Plot): x = self.data.xrange[2] self.xlabel = "Velocity (m/s)" - if self.CODE == 'spc_moments': - x = self.data.xrange[2] - self.xlabel = "Velocity (m/s)" - self.titles = [] - #self.xlabel = "Velocidad (m/s)" - #self.ylabel = 'Rango (km)' - - y = self.data.heights + y = self.data.yrange self.y = y z = self.data['spc'] - self.CODE2 = 'spc_oblique' - - for n, ax in enumerate(self.axes): noise = self.data['noise'][n][-1] - if self.CODE == 'spc_moments': - mean = self.data['moments'][n, :, 1, :][-1] - if self.CODE2 == 'spc_oblique': - shift1 = self.data.shift1 - shift2 = self.data.shift2 + shift1 = self.data['shift1'] + shift2 = self.data['shift2'] + err1 = self.data['shift1_error'] + err2 = self.data['shift2_error'] if ax.firsttime: self.xmax = self.xmax if self.xmax else numpy.nanmax(x) self.xmin = self.xmin if self.xmin else -self.xmax self.zmin = self.zmin if self.zmin else numpy.nanmin(z) self.zmax = self.zmax if self.zmax else numpy.nanmax(z) - #print(numpy.shape(x)) ax.plt = ax.pcolormesh(x, y, z[n].T, vmin=self.zmin, vmax=self.zmax, @@ -204,15 +200,9 @@ class SpectraObliquePlot(Plot): self.data['rti'][n][-1], y)[0] ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, color="k", linestyle="dashed", lw=1)[0] - if self.CODE == 'spc_moments': - ax.plt_mean = ax.plot(mean, y, color='k')[0] - - if self.CODE2 == 'spc_oblique': - #ax.plt_shift1 = ax.plot(shift1, y, color='k', marker='x', linestyle='None', markersize=0.5)[0] - #ax.plt_shift2 = ax.plot(shift2, y, color='m', marker='x', linestyle='None', markersize=0.5)[0] - 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) - 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) - + + 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) + 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) else: self.ploterr1.remove() self.ploterr2.remove() @@ -220,17 +210,11 @@ class SpectraObliquePlot(Plot): if self.showprofile: ax.plt_profile.set_data(self.data['rti'][n][-1], y) ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) - if self.CODE == 'spc_moments': - ax.plt_mean.set_data(mean, y) - if self.CODE2 == 'spc_oblique': - #ax.plt_shift1.set_data(shift1, y) - #ax.plt_shift2.set_data(shift2, y) - #ax.clf() - 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) - 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) + 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) + 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) self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) - #self.titles.append('{}'.format('Velocidad Doppler')) + class CrossSpectraPlot(Plot): @@ -733,8 +717,6 @@ class SpectrogramPlot(Plot): self.ncols = 1 self.nrows = len(self.data.channels) self.nplots = len(self.data.channels) - #print(self.dataOut.heightList) - #self.ylabel = 'Range [km]' self.xlabel = 'Time' self.cb_label = 'dB' self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95}) @@ -742,18 +724,11 @@ class SpectrogramPlot(Plot): 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)] def plot(self): + self.x = self.data.times - #self.y = self.data.heights self.z = self.data[self.CODE] self.y = self.data.xrange[0] - #import time - #print(time.ctime(self.x)) - - ''' - print(numpy.shape(self.x)) - print(numpy.shape(self.y)) - print(numpy.shape(self.z)) - ''' + self.ylabel = "Frequency (kHz)" self.z = numpy.ma.masked_invalid(self.z) diff --git a/schainpy/model/graphics/jroplot_voltage_lags.py b/schainpy/model/graphics/jroplot_voltage_lags.py index d831bb4..040cff8 100644 --- a/schainpy/model/graphics/jroplot_voltage_lags.py +++ b/schainpy/model/graphics/jroplot_voltage_lags.py @@ -1,5 +1,7 @@ import os +import time +import math import datetime import numpy from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG @@ -13,27 +15,18 @@ from schainpy.model.graphics.jroplot_base import Plot, plt import matplotlib.pyplot as plt import matplotlib.colors as colors - -import time -import math - - from matplotlib.ticker import MultipleLocator - class RTIDPPlot(RTIPlot): - ''' - Plot for RTI Double Pulse Experiment + '''Plot for RTI Double Pulse Experiment ''' CODE = 'RTIDP' colormap = 'jro' plot_name = 'RTI' - #cb_label = 'Ne Electron Density (1/cm3)' - def setup(self): self.xaxis = 'time' self.ncols = 1 @@ -49,30 +42,25 @@ class RTIDPPlot(RTIPlot): self.cb_label = 'Intensity (dB)' - - #self.cb_label = cb_label - self.titles = ['{} Channel {}'.format( self.plot_name.upper(), '0x1'),'{} Channel {}'.format( self.plot_name.upper(), '0'),'{} Channel {}'.format( self.plot_name.upper(), '1')] + def update(self, dataOut): - def plot(self): - - self.data.normalize_heights() - self.x = self.data.times - self.y = self.data.heights[0:self.data.NDP] + data = {} + meta = {} + data[self.CODE] = dataOut.data_for_RTI_DP + data['NRANGE'] = dataOut.NDP - if self.showSNR: - self.z = numpy.concatenate( - (self.data[self.CODE], self.data['snr']) - ) - else: + return data, meta - self.z = self.data[self.CODE] - #print(numpy.max(self.z[0,0:])) + def plot(self): + self.x = self.data.times + self.y = self.data.yrange[0: self.data['NRANGE']] + self.z = self.data[self.CODE] self.z = numpy.ma.masked_invalid(self.z) if self.decimation is None: @@ -82,26 +70,21 @@ class RTIDPPlot(RTIPlot): for n, ax in enumerate(self.axes): - self.zmax = self.zmax if self.zmax is not None else numpy.max( self.z[1][0,12:40]) self.zmin = self.zmin if self.zmin is not None else numpy.min( self.z[1][0,12:40]) - - if ax.firsttime: if self.zlimits is not None: self.zmin, self.zmax = self.zlimits[n] - ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], vmin=self.zmin, vmax=self.zmax, cmap=self.cmaps[n] ) - #plt.tight_layout() else: if self.zlimits is not None: self.zmin, self.zmax = self.zlimits[n] @@ -111,7 +94,6 @@ class RTIDPPlot(RTIPlot): vmax=self.zmax, cmap=self.cmaps[n] ) - #plt.tight_layout() class RTILPPlot(RTIPlot): @@ -124,8 +106,6 @@ class RTILPPlot(RTIPlot): colormap = 'jro' plot_name = 'RTI LP' - #cb_label = 'Ne Electron Density (1/cm3)' - def setup(self): self.xaxis = 'time' self.ncols = 1 @@ -140,10 +120,6 @@ class RTILPPlot(RTIPlot): self.cb_label = 'Intensity (dB)' - - - #self.cb_label = cb_label - self.titles = ['{} Channel {}'.format( self.plot_name.upper(), '0'),'{} Channel {}'.format( self.plot_name.upper(), '1'),'{} Channel {}'.format( @@ -175,7 +151,6 @@ class RTILPPlot(RTIPlot): for n, ax in enumerate(self.axes): - self.zmax = self.zmax if self.zmax is not None else numpy.max( self.z[1][0,12:40]) self.zmin = self.zmin if self.zmin is not None else numpy.min( @@ -917,36 +892,37 @@ class CrossProductsPlot(Plot): plot_name = 'Cross Products' plot_type = 'scatterbuffer' - def setup(self): self.ncols = 3 self.nrows = 1 self.nplots = 3 self.ylabel = 'Range [km]' - self.width = 3.5*self.nplots self.height = 5.5 self.colorbar = False self.titles = [] - def plot(self): - - self.x = self.data['crossprod'][:,-1,:,:,:,:] - + def update(self, dataOut): + data = {} + meta = {} + data['crossprod'] = dataOut.crossprods + data['NDP'] = dataOut.NDP - self.y = self.data.heights[0:self.data.NDP] + return data, meta + def plot(self): + self.x = self.data['crossprod'][:,-1,:,:,:,:] + self.y = self.data.heights[0:self.data['NDP']] for n, ax in enumerate(self.axes): 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]))) 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]))) - if ax.firsttime: self.autoxticks=False @@ -969,7 +945,6 @@ class CrossProductsPlot(Plot): label4='kaxby' self.xlimits.append((self.xmin,self.xmax)) - ax.plotline1 = ax.plot(self.x[n][0,:,0,0], self.y, color='r',linewidth=2.0, label=label1) ax.plotline2 = ax.plot(self.x[n][1,:,0,0], self.y, color='k',linewidth=2.0, label=label2) 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): ax.legend(loc='upper right') ax.set_xlim(self.xmin, self.xmax) self.titles.append('{}'.format(self.plot_name.upper())) - #plt.tight_layout() - else: @@ -989,14 +962,11 @@ class CrossProductsPlot(Plot): ax.set_xlim(self.xmin, self.xmax) - ax.plotline1[0].set_data(self.x[n][0,:,0,0],self.y) ax.plotline2[0].set_data(self.x[n][1,:,0,0],self.y) ax.plotline3[0].set_data(self.x[n][2,:,0,0],self.y) ax.plotline4[0].set_data(self.x[n][3,:,0,0],self.y) self.titles.append('{}'.format(self.plot_name.upper())) - #plt.tight_layout() - class CrossProductsLPPlot(Plot): diff --git a/schainpy/model/proc/__init__.py b/schainpy/model/proc/__init__.py index c780bb2..6acb5cb 100644 --- a/schainpy/model/proc/__init__.py +++ b/schainpy/model/proc/__init__.py @@ -19,4 +19,4 @@ from .pxproc_parameters import * ###########DP########### from .jroproc_voltage_lags import * ###########DP########### -from .jroproc_spectra_lags_faraday import * +# from .jroproc_spectra_lags_faraday import * diff --git a/schainpy/model/proc/jroproc_voltage.py b/schainpy/model/proc/jroproc_voltage.py index 38c8391..a38e644 100644 --- a/schainpy/model/proc/jroproc_voltage.py +++ b/schainpy/model/proc/jroproc_voltage.py @@ -1,12 +1,21 @@ + +import os import sys -import numpy,math +import numpy, math from scipy import interpolate +from scipy.optimize import nnls from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator from schainpy.model.data.jrodata import Voltage,hildebrand_sekhon from schainpy.utils import log from time import time, mktime, strptime, gmtime, ctime -import os +try: + from schainpy.model.proc import fitacf_guess + from schainpy.model.proc import fitacf_fit_short + from schainpy.model.proc import fitacf_acf2 + from schainpy.model.proc import full_profile_profile +except: + log.warning('Missing Faraday fortran libs') class VoltageProc(ProcessingUnit): @@ -1979,8 +1988,6 @@ class suppress_stdout_stderr(object): os.close(fd) -from schainpy.model.proc import fitacf_guess -from schainpy.model.proc import fitacf_fit_short class DPTemperaturesEstimation(Operation): """Operation to estimate temperatures for Double Pulse data. @@ -2184,7 +2191,6 @@ class NeTeTiRecal(NormalizeDPPower,DPTemperaturesEstimation): return dataOut -from schainpy.model.proc import fitacf_acf2 class DenCorrection(Operation): def __init__(self, **kwargs): @@ -5366,8 +5372,6 @@ class SumFlipsHP(SumFlips): return dataOut -from schainpy.model.proc import full_profile_profile -from scipy.optimize import nnls class LongPulseAnalysis(Operation): """Operation to estimate ACFs, temperatures, total electron density and Hydrogen/Helium fractions from the Long Pulse data.