From 2ff4b873399e2684851f1d7bdfc88ca60dc16687 Mon Sep 17 00:00:00 2001 From: Quentin Rodier <quentin.rodier@meteo.fr> Date: Wed, 14 Aug 2024 14:58:41 +0200 Subject: [PATCH] Quentin 14/08/2024: update to MNHPy 0.3.3, bugfix for Reunion interpol --- .../004_Reunion/005_python/plot_004_Reunion.py | 5 ++--- src/LIB/Python/Panel_Plot.py | 11 ++++++----- src/LIB/Python/misc_functions.py | 16 ++++++++++------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/MY_RUN/KTEST/004_Reunion/005_python/plot_004_Reunion.py b/MY_RUN/KTEST/004_Reunion/005_python/plot_004_Reunion.py index 99bcf6ff0..d1deb6c44 100644 --- a/MY_RUN/KTEST/004_Reunion/005_python/plot_004_Reunion.py +++ b/MY_RUN/KTEST/004_Reunion/005_python/plot_004_Reunion.py @@ -97,13 +97,12 @@ Dvar['f1']['THT-LSTHM'] = copy.deepcopy(Dvar['f1']['THT']) Dvar['f1']['THT-LSTHM'] = Dvar['f1']['THT'] - Dvar['f2']['LSTHM'] Dvar['f1']['VT-LSVM'] = copy.deepcopy(Dvar['f1']['VM']) Dvar['f1']['VT-LSVM'] = Dvar['f1']['VM'] - Dvar['f2']['LSVM'] - Lplot = [ Dvar['f1']['THT'][:,:,i_slice], Dvar['f1']['THT-LSTHM'][:,:,i_slice],Dvar['f1']['VT-LSVM'][:,:,i_slice],Dvar['f1']['WT'][:,:,i_slice]] Ltitle = ['Potential Temperature', 'Anomalie de théta (THT-LSTHM)', 'Anomalie de V (VT-LSVM)', 'WT vertical velocity'] LaxeZ = [Dvar['f1']['altitude'][:,:,i_slice], Dvar['f1']['altitude'][:,:,i_slice],Dvar['f1']['altitude'][:,:,i_slice],Dvar['f1']['altitude_w'][:,:,i_slice]] LaxeX = [Dvar['f1']['ny_3D'][:,:,i_slice]]*len(Lplot) Lcbarlabel = ['K', 'K','m/s', 'm/s'] -Lxlab = ['longitude']*len(Lplot) +Lxlab = ['latitude']*len(Lplot) Lylab = ['altitude (m)']*len(Lplot) Lylim = [(0,16000)]*len(Lplot) Lminval = [300, -1.9, -10.5, -6.75] @@ -123,7 +122,7 @@ Lplot2 = [ Dvar['f1']['WM'][:,:,i_slice]] Ltitle = ['Wind'] Llegendval = [15] Llegendlabel = ['m/s']*len(Lplot) -Lxlab = ['longitude']*len(Lplot) +Lxlab = ['latitude']*len(Lplot) Lylab = ['altitude (m)']*len(Lplot) Larrowstep = [1]*len(Lplot) Lwidth = [0.002]*len(Lplot) diff --git a/src/LIB/Python/Panel_Plot.py b/src/LIB/Python/Panel_Plot.py index a34ab6f26..b5050347e 100644 --- a/src/LIB/Python/Panel_Plot.py +++ b/src/LIB/Python/Panel_Plot.py @@ -74,7 +74,7 @@ class PanelPlot(): self.iplt += 1 return self.iplt - def draw_Backmap(self, drawCoastLines, ax, projo): + def draw_Backmap(self, drawCoastLines, ax, projo, gridLines=True): """ Handle drawing of the background plot (coastlines, departements, grid lines and labels) """ @@ -87,8 +87,8 @@ class PanelPlot(): from cartopy.mpl.ticker import (LatitudeLocator, LongitudeLocator,LongitudeFormatter, LatitudeFormatter) gl.top_labels = False gl.right_labels = False - gl.xlines = True - gl.ylines = True + gl.xlines = gridLines + gl.ylines = gridLines gl.xlocator = LongitudeLocator() gl.ylocator = LatitudeLocator() gl.xformatter = LongitudeFormatter() @@ -544,7 +544,7 @@ class PanelPlot(): def psectionH(self, lon=[], lat=[], Lvar=[], Lcarte=[], Llevel=[], Lxlab=[], Lylab=[], Ltitle=[], Lminval=[], Lmaxval=[], Lstep=[], Lstepticks=[], Lcolormap=[], LcolorLine=[], Lcbarlabel=[], Lproj=[], Lfacconv=[], coastLines=True, ax=[], Lid_overlap=[], colorbar=True, Ltime=[], LaddWhite_cm=[], LwhiteTop=[], Lpltype=[], Lcbformatlabel=[], Llinewidth=[], - Lextendcolorbar=[], PrintMinMaxText=True): + Lextendcolorbar=[], PrintMinMaxText=True,gridLines=True): """ Horizontal cross section plot Parameters : @@ -577,6 +577,7 @@ class PanelPlot(): - Lcbformatlabel: List of boolean to reduce the format to exponential 1.1E+02 format colorbar label - Lextendcolorbar : List of boolean to extend the colorbar in both directions - PrintMinMaxText: Boolean, True to add a min/max values of the plotted variables on top of the graph + - gridLines : Boolean, True to add the horizontal and vertical grid lines in cartopy """ self.ax = ax @@ -707,7 +708,7 @@ class PanelPlot(): # Coastlines / Grid lines and labels if Lproj: - self.draw_Backmap(coastLines, self.ax[iax], Lproj[i]) + self.draw_Backmap(coastLines, self.ax[iax], Lproj[i], gridLines) # X/Y Axis self.set_XYaxislab(self.ax, iax, Lxlab[i], Lylab[i]) diff --git a/src/LIB/Python/misc_functions.py b/src/LIB/Python/misc_functions.py index c5b29258e..a5d8ec762 100644 --- a/src/LIB/Python/misc_functions.py +++ b/src/LIB/Python/misc_functions.py @@ -193,10 +193,10 @@ def comp_altitude2DVar(oneVar3D, orography, ztop, level, n_y, n_x): level : array 1D 1D level variable (level or level_w) - n_x : array 1D + n_x : array 1D (or 2D if LCARTESIAN=F) 1D directionnal grid variable along i (ni_u, or ni_v) - n_y : array 1D + n_y : array 1D (or 2D if LCARTESIAN=F) 1D directionnal grid variable along j (nj_u, or nj_v) Returns @@ -214,10 +214,14 @@ def comp_altitude2DVar(oneVar3D, orography, ztop, level, n_y, n_x): n_y3D = copy.deepcopy(oneVar3D) altitude = copy.deepcopy(oneVar3D) for k in range(len(level)): - for j in range(oneVar3D.shape[2]): - n_y3D[k,:,j] = n_y - for i in range(oneVar3D.shape[1]): - n_x3D[k,i,:] = n_x + if n_x.ndim == 2: + n_y3D[k,:,:] = n_y + n_x3D[k,:,:] = n_x + else: + for j in range(oneVar3D.shape[2]): + n_y3D[k,:,j] = n_y + for i in range(oneVar3D.shape[1]): + n_x3D[k,i,:] = n_x for i in range(oneVar3D.shape[2]): for j in range(oneVar3D.shape[1]): if ztop == 0: -- GitLab