diff --git a/schainpy/model/graphics/jroplot_base.py b/schainpy/model/graphics/jroplot_base.py index f692966..8af5b31 100644 --- a/schainpy/model/graphics/jroplot_base.py +++ b/schainpy/model/graphics/jroplot_base.py @@ -20,7 +20,7 @@ import matplotlib,re if 'BACKEND' in os.environ: matplotlib.use(os.environ['BACKEND']) elif 'linux' in sys.platform: - matplotlib.use("Agg") + matplotlib.use("TkAgg") elif 'darwin' in sys.platform: matplotlib.use('MacOSX') else: @@ -33,18 +33,17 @@ from matplotlib.patches import Polygon from mpl_toolkits.axes_grid1 import make_axes_locatable from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator -from .plotting_codes import * +from .plotting_codes import register_cmap from schainpy.model.data.jrodata import PlotterData from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator from schainpy.utils import log -for name, cb_table in sophy_cb_tables: - ncmap = matplotlib.colors.ListedColormap(cb_table, name=name) - matplotlib.pyplot.register_cmap(cmap=ncmap) EARTH_RADIUS = 6.3710e3 +register_cmap() + def ll2xy(lat1, lon1, lat2, lon2): p = 0.017453292519943295 @@ -293,7 +292,7 @@ class Plot(Operation): fig_p = plt.figure(figsize=(self.width, self.height), edgecolor='k', facecolor='w') - fig_r = plt.figure(figsize=(self.width, self.height), + fig_r = plt.figure(figsize=(self.width, 4), edgecolor='k', facecolor='w') self.figures['PPI'].append(fig_p) @@ -342,13 +341,13 @@ class Plot(Operation): cax.tick_params(labelsize=8) self.pf_axes.append(cax) - for n in range(self.nrows): - if self.colormaps is not None: - cmap = plt.get_cmap(self.colormaps[n]) - else: - cmap = plt.get_cmap(self.colormap) - cmap.set_bad(self.bgcolor, 1.) - self.cmaps.append(cmap) + # for n in range(self.nrows): + # if self.colormaps is not None: + # cmap = plt.get_cmap(self.colormaps[n]) + # else: + # cmap = plt.get_cmap(self.colormap) + # cmap.set_bad(self.bgcolor, 1.) + # self.cmaps.append(cmap) def __add_axes(self, ax, size='30%', pad='8%'): ''' @@ -431,6 +430,8 @@ class Plot(Operation): if self.colorbar: ax.cbar = plt.colorbar( ax.plt, ax=ax, fraction=0.05, pad=0.06, aspect=10) + if self.colormap=='sophy_r': + ax.cbar.set_ticks([0.2, 0.73, 0.83, 0.93, 0.96, 0.99, 1.02, 1.05]) ax.cbar.ax.tick_params(labelsize=8) ax.cbar.ax.press = None if self.cb_label: diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index eabf3d4..6735771 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -11,6 +11,7 @@ import cartopy.io.shapereader as shpreader from schainpy.model.graphics.jroplot_base import Plot, plt from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot from schainpy.utils import log +from schainpy.model.graphics.plotting_codes import cb_tables EARTH_RADIUS = 6.3710e3 @@ -525,8 +526,8 @@ class WeatherParamsPlot(Plot): self.ncols = 1 self.nrows = 1 self.nplots= 1 - self.ylabel= 'Range [km]' - self.xlabel= 'Range [km]' + self.ylabel= 'Height [km]' + self.xlabel= 'Distance from radar [km]' if self.channels is not None: self.nplots = len(self.channels) @@ -546,7 +547,7 @@ class WeatherParamsPlot(Plot): self.len_azi =0 self.buffer_ini = None self.buffer_ele = None - self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) + self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.1}) self.flag =0 self.indicador= 0 self.last_data_ele = None @@ -649,11 +650,19 @@ class WeatherParamsPlot(Plot): else: axes = self.axes['RHI'] + if self.colormap in cb_tables: + norm = cb_tables[self.colormap]['norm'] + else: + norm = None + for i, ax in enumerate(axes): if data['mode_op'] == 'PPI': ax.set_extent([-75.745893, -74.845893, -12.490436, -11.590436]) - - ax.plt = ax.pcolormesh(x, y, z[i], cmap=self.colormap, vmin=self.zmin, vmax=self.zmax) + + if norm is None: + ax.plt = ax.pcolormesh(x, y, z[i], cmap=self.colormap, vmin=self.zmin, vmax=self.zmax) + else: + ax.plt = ax.pcolormesh(x, y, z[i], cmap=self.colormap, norm=norm) if data['mode_op'] == 'RHI': len_aux = int(data['azi'].shape[0]/4) @@ -691,7 +700,7 @@ class WeatherParamsPlot(Plot): provs = [x for x in reader_p.records() if x.attributes["NAME"] in ("Junín", "Lima")] vias = [x for x in reader_v.records() if x.attributes["DEP"] in ("JUNIN", "LIMA")] - # Display Kenya's shape + # Display limits and streets shape_feature = ShapelyFeature([x.geometry for x in districts], ccrs.PlateCarree(), facecolor="none", edgecolor='grey', lw=0.5) ax.add_feature(shape_feature) shape_feature = ShapelyFeature([x.geometry for x in provs], ccrs.PlateCarree(), facecolor="none", edgecolor='white', lw=1) diff --git a/schainpy/model/graphics/plotting_codes.py b/schainpy/model/graphics/plotting_codes.py index d69c658..b31c594 100644 --- a/schainpy/model/graphics/plotting_codes.py +++ b/schainpy/model/graphics/plotting_codes.py @@ -1,6 +1,9 @@ ''' @author: roj-idl71 ''' + +import matplotlib + #USED IN jroplot_spectra.py RTI_CODE = 0 #Range time intensity (RTI). SPEC_CODE = 1 #Spectra (and Cross-spectra) information. @@ -30,48 +33,81 @@ EWDRIFT_CODE = 28 #COLOR TABLES -reflectivity = [ - "#000000", # -30 - "#15191d", # -25 - "#2a323b", # -20 - "#3f4c59", # -15 - "#556576", # -10 - "#6a7f94", # -5 - "#7f99b2", # 0 - "#00ffff", # 5 - "#007fff", # 10 - "#0000ff", # 15 - "#00ff00", # 20 - "#00bf00", # 25 - "#007f00", # 30 - "#ffff00", # 35 - "#ffbf00", # 40 - "#ff7f00", # 45 - "#ff0000", # 50 - "#bf0000", # 55 - "#7f0000", # 60 - "#fe00fe", # 65 - "#8e59ff", # 70 - "#f0f0f0", # 75 +refl = [ + "#2a323b", "#3f4c59", "#556576", "#6a7f94", "#7f99b2", + "#00ffff", "#007fff", "#0000ff", "#00ff00", "#00bf00", + "#007f00", "#ffff00", "#ffbf00", "#ff7f00", "#ff0000", + "#bf0000", "#7f0000", "#fe00fe", "#8e59ff", "#f0f0f0", ] -velocity = [ +refl_bounds = [-20, -15, -10, -5, 0, 5, 10 ,15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80] + +doppler = [ "#003300", "#005500", "#007700", "#009900", "#00bb00", "#24ce24", "#6cd26c", "#b4d6b4", "#d6b4b4", "#d26c6c", "#ce2424", "#bb0000", "#980000", "#760000", "#540000", "#330000", ] -spc_width = [ +width = [ "#00ffff", "#00aaf2", "#0055e5", "#0000d8", "#007f00", "#00aa00", "#00d400", "#00ff00", "#ffff00", "#ffd400", "#ffaa00", "#ff7f00", "#ff0000", "#d40000", "#aa0000", "#7f0000", "#ff00ff", "#d400d4", "#aa00aa", "#7f007f", "#9938ff", "#832ed8", "#6e25b2", "#591c8c", - "#aaaaaa", "#8e8e8e" ] -sophy_cb_tables = [ - ('sophy_r', reflectivity), - ('sophy_v', velocity), - ('sophy_w', spc_width), -] \ No newline at end of file +zdr = [ + "#7333cc", "#7e3cd5", "#8945de", "#944ee7", "#9f57f0", "#aa5ff8", + "#82345c", "#984272", "#ae4f88", "#c55c9f", "#db6ab5", "#db6ab5", + "#b5842d", "#c29a4c", "#d0b16b", "#ddc78a", "#ebddaa", "#f8f4c9", + "#f0f5ff", "#c4d8ff", "#97bbff", "#6a9eff", "#3e81ff", "#1164ff", + "#17f576", "#13df60", "#0ec949", "#0ab233", "#059c1d", "#018606", + "#fff300", "#ffdd00", "#ffc700", "#ffb000", "#ff9a00", "#ff8400", + "#f10000", "#db0000", "#c40000", "#ae0000", "#980000", "#810000", +] + +phi = [ + "#ff3f40", "#ec3b6d", "#bf2f7e", "#92247c", "#7b1f7f", "#732492", "#782fbf", "#6f3bec", + "#513fff", "#3b4bec", "#2f57bf", "#245592", "#1f5a7f", "#247992", "#2fb4bf", "#3bece0", + "#3fffd8", "#3becb1", "#2fbf7d", "#249253", "#1f7f3d", "#24923b", "#2fbf3e", "#3bec3b", + "#50ff3f", "#5aec3b", "#55bf2f", "#4a9224", "#487f1f", "#5a9224", "#80bf2f", "#aaec3b", + "#c4ff3f", "#c0ec3b", "#a4bf2f", "#839224", "#777f1f", "#8e9224", "#bfbc2f", "#ece03b", + "#ffea3f", "#ecd13b", "#bfa42f", "#927924", "#7f661f", "#927124", "#bf8f2f", "#ecac3b", + "#ffb43f", "#eca23b", "#bf7f2f", "#925e24", "#7f501f", "#925924", "#bf712f", "#ec883b", + "#ff8f3f", "#ec813b", "#bf662f", "#924c24", "#7f401f", "#924824", "#bf5c2f", "#ec6f3b", +] + +rho = [ + "#2a323b", "#3f4c59", "#556576", "#6a7f94", "#7f99b2", + "#00ffff", "#00bff5", "#007feb", "#003fe2", "#0000d8", + "#00ff00", "#00df00", "#00bf00", "#009f00", "#007f00", + "#ffff00", "#ffdf00", "#ffbf00", "#ff9f00", "#ff7f00", + "#ff0000", "#df0000", "#bf0000", "#9f0000", "#7f0000", + "#ff00ff", "#df00df", "#bf00bf", "#9f009f", "#7f007f", + "#9938ff", "#8931e2", "#792ac5", "#6923a8", "#591c8c", +] + +rho_bounds = [0.2, 0.306, 0.412, 0.518, 0.624, 0.73, + 0.75, 0.77, 0.79, 0.81, 0.83, + 0.85, 0.87, 0.89, 0.91, 0.93, + 0.936, 0.942, 0.948, 0.954, 0.96, + 0.966, 0.972, 0.978, 0.984, 0.99, + 0.996, 1.002, 1.008, 1.014, 1.02, + 1.026, 1.032, 1.038, 1.044, 1.05, 1.056] + +cb_tables = { + 'sophy_z': {'colors': refl, 'norm': None }, + 'sophy_v': {'colors': doppler, 'norm': None }, + 'sophy_w': {'colors': width, 'norm': None }, + 'sophy_d': {'colors': zdr, 'norm': None }, + 'sophy_p': {'colors': phi, 'norm': None }, + 'sophy_r': {'colors': rho, 'norm': matplotlib.colors.BoundaryNorm(rho_bounds, 37), 'extremes': ['#15191d', '#333899']}, +} + +def register_cmap(): + + for colormap in cb_tables: + cmap = matplotlib.colors.ListedColormap(cb_tables[colormap]['colors'], name=colormap) + if 'extremes' in cb_tables[colormap]: + cmap = cmap.with_extremes(under=cb_tables[colormap]['extremes'][0], over=cb_tables[colormap]['extremes'][1]) + matplotlib.pyplot.register_cmap(cmap=cmap) diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py index 54f7706..a8474e7 100644 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -4027,12 +4027,8 @@ class WeatherRadar(Operation): Pr = dataOut.data_param[:,0,:] '''---------------------------- Calculo de Noise y threshold para Reflectividad---------''' - # noise = numpy.zeros(self.nCh) - # for i in range(self.nCh): - # noise[i] = hildebrand_sekhon(Pr[i,:], 1) - # window = numpy.where(Pr[i,:]<1.3*noise[i]) - # Pr[i,window]= 1e-10 - Pr = Pr/1000.0 # Conversion Watt + + Pr = Pr/1000.0 # Conversion Watt '''-----------2 Reflectividad del Radar y Factor de Reflectividad------''' self.n_radar = numpy.zeros((self.nCh,self.nHeis)) self.Z_radar = numpy.zeros((self.nCh,self.nHeis)) @@ -4044,12 +4040,7 @@ class WeatherRadar(Operation): '''----------- Factor de Reflectividad Equivalente lamda_ < 10 cm , lamda_= 3.2cm-------''' Zeh = self.Z_radar - #print("---------------------------------------------------------------------") - #print("RangedBz",10*numpy.log10((self.Range[0,-10:]*(10**3))**2)) - #print("CTE",10*numpy.log10(self.RadarConstant)) - #print("Pr first10",10*numpy.log10(Pr[0,:20])) - #print("Pr last10",10*numpy.log10(Pr[0,-20:])) - #print("LCTE",10*numpy.log10(self.lambda_**4/( numpy.pi**5 * self.Km**2))) + if self.Pt<0.3: factor=10.072 else: @@ -4164,45 +4155,6 @@ class PedestalInformation(Operation): log.error('No new position files found in {}'.format(path)) raise IOError('No new position files found in {}'.format(path)) - - def find_mode(self, index): - sample_max = 20 - start = index - flag_mode = None - - while True: - print(start, sample_max, numpy.shape(self.ele)) - if start+sample_max > numpy.shape(self.ele)[0]: - if sample_max == 10: - print("CANNOT KNOW IF MODE IS PPI OR RHI, ANALIZE NEXT FILE") - break - else: - sample_max = 10 - continue - sigma_ele = numpy.nanstd(self.ele[start:start+sample_max]) - sigma_azi = numpy.nanstd(self.azi[start:start+sample_max]) - print("ele",self.ele[start-sample_max:start+sample_max]) - print("azi",self.azi[start-sample_max:start+sample_max]) - print(sigma_azi, sigma_ele) - - if sigma_ele<.5 and sigma_azi<.5: - if sigma_ele