diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..df8da8d --- /dev/null +++ b/_config.yml @@ -0,0 +1,3 @@ +theme: jekyll-theme-cayman +title: [MNHPy] +description: [Gallery from MNHPy library.] diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 0000000..9a59901 --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,42 @@ + + + + + +{% seo %} + + + + + + + {% include head-custom.html %} + + + Skip to the content. + + + +
+ {{ content }} + + +
+ + diff --git a/gallery/figures/3D_mayavi.png b/gallery/figures/3D_mayavi.png new file mode 100644 index 0000000..f6520c8 Binary files /dev/null and b/gallery/figures/3D_mayavi.png differ diff --git a/gallery/figures/XY_budget_terms.png b/gallery/figures/XY_budget_terms.png new file mode 100644 index 0000000..b4945bf Binary files /dev/null and b/gallery/figures/XY_budget_terms.png differ diff --git a/gallery/figures/XY_lines_001_2Drelief.png b/gallery/figures/XY_lines_001_2Drelief.png new file mode 100644 index 0000000..0ea30ce Binary files /dev/null and b/gallery/figures/XY_lines_001_2Drelief.png differ diff --git a/gallery/figures/XY_lines_tseries_aircraft_AZF2M.png b/gallery/figures/XY_lines_tseries_aircraft_AZF2M.png new file mode 100644 index 0000000..0a0fb0f Binary files /dev/null and b/gallery/figures/XY_lines_tseries_aircraft_AZF2M.png differ diff --git a/gallery/figures/XY_multisimple_GABLS1.png b/gallery/figures/XY_multisimple_GABLS1.png new file mode 100644 index 0000000..548a890 Binary files /dev/null and b/gallery/figures/XY_multisimple_GABLS1.png differ diff --git a/gallery/figures/histogramm_009ICARTT_full.png b/gallery/figures/histogramm_009ICARTT_full.png new file mode 100644 index 0000000..d433aa6 Binary files /dev/null and b/gallery/figures/histogramm_009ICARTT_full.png differ diff --git a/gallery/figures/horizontal_oasis_coupling.png b/gallery/figures/horizontal_oasis_coupling.png new file mode 100644 index 0000000..04906a5 Binary files /dev/null and b/gallery/figures/horizontal_oasis_coupling.png differ diff --git a/gallery/figures/sectionH_004_Reunion.png b/gallery/figures/sectionH_004_Reunion.png new file mode 100644 index 0000000..b13353e Binary files /dev/null and b/gallery/figures/sectionH_004_Reunion.png differ diff --git a/gallery/figures/sectionH_2dom_front_AZF_full.png b/gallery/figures/sectionH_2dom_front_AZF_full.png new file mode 100644 index 0000000..191844d Binary files /dev/null and b/gallery/figures/sectionH_2dom_front_AZF_full.png differ diff --git a/gallery/figures/sectionH_OCEAN.png b/gallery/figures/sectionH_OCEAN.png new file mode 100644 index 0000000..0b0ccc2 Binary files /dev/null and b/gallery/figures/sectionH_OCEAN.png differ diff --git a/gallery/figures/sectionH_vectors_007janvier_full.png b/gallery/figures/sectionH_vectors_007janvier_full.png new file mode 100644 index 0000000..dae99ea Binary files /dev/null and b/gallery/figures/sectionH_vectors_007janvier_full.png differ diff --git a/gallery/figures/sectionV_KW78_full.png b/gallery/figures/sectionV_KW78_full.png new file mode 100644 index 0000000..253fe1b Binary files /dev/null and b/gallery/figures/sectionV_KW78_full.png differ diff --git a/gallery/figures/sectionV_Reunion_full.png b/gallery/figures/sectionV_Reunion_full.png new file mode 100644 index 0000000..01dfc13 Binary files /dev/null and b/gallery/figures/sectionV_Reunion_full.png differ diff --git a/gallery/figures/timeseries_FIRE_full.png b/gallery/figures/timeseries_FIRE_full.png new file mode 100644 index 0000000..311591e Binary files /dev/null and b/gallery/figures/timeseries_FIRE_full.png differ diff --git a/gallery/view/3D_mayavi.md b/gallery/view/3D_mayavi.md new file mode 100644 index 0000000..456e16f --- /dev/null +++ b/gallery/view/3D_mayavi.md @@ -0,0 +1,84 @@ +## Plot 2 + +![3D_mayavi.png](../figures/3D_mayavi.png) + +````python +# -------------------------------------------------------- +# +# G. Feger ( 06/02/2024 ) +# +# ~~~~~~~~~~~~~~~ +# Script used to visualize aerosol cloud interaction +# in the case of a dusty Saharan Air Layer at Cape Verde +# ~~~~~~~~~~~~~~~ +# +# -------------------------------------------------------- + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import matplotlib as mpl ; import matplotlib.pyplot as plt +from matplotlib import cm ; from matplotlib.colors import ListedColormap +import numpy as np ; import pandas as pd +import cartopy ; import cartopy.feature as cfeature +import xarray as xr ; import math ; import numpy.ma as ma +import datetime ; from netCDF4 import Dataset +import cftime ; import os +import datetime ; import cartopy.crs as ccrs +import scipy ; from scipy.stats import gmean +import fct ; from scipy.interpolate import interpn +import PyQt5 ; import mayavi ; from mayavi import mlab +import metpy ; import metpy.calc as mpcalc +from metpy.cbook import get_test_data +from metpy.interpolate import cross_section +from mpl_toolkits.basemap import Basemap, shiftgrid +import pandas as pd +from IPython.display import display, HTML +display(HTML("")) + +# MAYAVI 3D plot +%gui qt +# lecture fichier méso-nh +def process_data(directory, pattern, endwith): + nc_files = [os.path.join(directory, filename) for filename in os.listdir(directory) if filename.endswith(endwith) and filename.startswith(pattern)] + datasets = [xr.open_mfdataset(file,combine='by_coords') for file in nc_files] + ho = xr.concat(datasets, dim='time', join='override') + ho = ho.sortby('time') + ho = ho.assign_coords(nj=('nj', ho.latitude[:,0].values), ni=('ni', ho.longitude[0,:].values), nj_u=('nj_u', ho.latitude[:,0].values), ni_u=('ni_u', ho.longitude[0,:].values)).rename({'ni': 'lon', 'nj': 'lat', 'ni_u': 'lon_u', 'nj_u': 'lat_u'}) + return ho +m1 = process_data('.' , 'CMS01.1.SEG01.OUT.012', '.nc') +pgd = process_data('.' , 'AFCAV', '.nc') + +# prepare le domaine 3d +step = 0 +lon = m1.lon.values +lat = m1.lat.values +alt = m1.level_w.values/1000 # en km +topo = pgd.CLAY[0,:,:].values/1000 +Z_plot = 10 # Z_plot = alt[-1] si on veut visu tout le domaine sans zoomer +alt_reg = np.linspace(0,Z_plot,101) # altitude dz fixe pour interpolation et plot +x, y, z = np.meshgrid(lon, lat, alt_reg, indexing='ij') # grille 3D : dx dy dz constant +# selection des variables +var1 = m1.WT[step, :, :,:].values +var2 = m1.NIF01[step, :, :,:].values +var1 = np.transpose(var1, (2, 1, 0)) # Z en 3e position +var2 = np.transpose(var2, (2, 1, 0)) # Z en 3e position +var1 = interpn((lon, lat, alt), var1, (x, y, z), method='linear', bounds_error=False, fill_value=0) # interp variables sur domaine régulier +var2 = interpn((lon, lat, alt), var2, (x, y, z), method='linear', bounds_error=False, fill_value=0) + +# -- Figure -- +fig = mlab.figure(bgcolor=(1,1,1), fgcolor=(0.,0.,0.)) +ratio=2 +pltextent = (lon[0], lon[-1], lat[0], lat[-1], alt[0]/ratio, Z_plot/ratio) # rapport d'aspect de la fig pour lisibilité +contour1 = mlab.contour3d(x,y,z/ratio,var1, vmin=2, vmax=10 , contours=[2,5,10], transparent=True,opacity=0.7) +contour2 = mlab.contour3d(x,y,z/ratio,var2, vmin=20,vmax=40, contours=[20,30,40], transparent=False,opacity=0.99,colormap='Reds') +mlab.imshow(topo.T, colormap='gist_gray',figure=fig, extent=[lon[0], lon[-1], lat[0], lat[-1], alt[0]/ratio, alt[1]/ratio], opacity=0.5) +#mlab.surf(lon, lat, topo.T/ratio, colormap='gist_gray',figure=fig,opacity=0.7, vmin=alt[0]/ratio) +# setup figure +mlab.outline(contour1, color=(.1, .7, .7), extent=pltextent) +mlab.axes(xlabel='Lon', ylabel='Lat', zlabel='Alt (km)') +mlab.axes(nb_labels=5,ranges=(lon[0], lon[-1], lat[0], lat[-1], alt[0], Z_plot)) # valeurs reelles des coordonnees +mlab.gcf().scene.parallel_projection = True +mlab.orientation_axes() +mlab.colorbar(object=contour2, nb_colors=3, nb_labels=3, orientation='vertical', title='IFN FREE (#/cm3)') +mlab.title('Simulation Méso-NH', line_width=2.0, size=4, figure=fig) +mlab.text3d(lon[-104],lat[-44],alt[26]/ratio, 'Saharan air layer', scale=0.4, color=(0.6,0,0.3)) +```` diff --git a/gallery/view/XY_budget_terms.md b/gallery/view/XY_budget_terms.md new file mode 100644 index 0000000..fc8e45a --- /dev/null +++ b/gallery/view/XY_budget_terms.md @@ -0,0 +1,49 @@ +## Plot 2 + +![XY_budget_terms.png](../figures/XY_budget_terms.png) + +````python +Panel = PanelPlot(2,2, [20,20],'COPT81 avec Mask', titlepad=11, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=40) + +# Budget of potential temperature +nmask=0 #Convective mask, criteria in set_mask.f90 +ntime=7 # 8th hour + +Lplot = [Dvar['f1'][('/Budgets/TH','SFR')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','DEPS')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','DEPG')][nmask,ntime,:], + Dvar['f1'][('/Budgets/TH','REVA')][nmask,ntime,:], + Dvar['f1'][('/Budgets/TH','DEPI')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','IMLT')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','GMLT')][nmask,ntime,:], + Dvar['f1'][('/Budgets/TH','DRYG')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','ACC')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','RIM')][nmask,ntime,:], + Dvar['f1'][('/Budgets/TH','BERFI')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','CFRZ')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','WETG')][nmask,ntime,:] + ] +LaxeZ = [Dvar['f1']['mask_level']]*len(Lplot) +Ltitle = ['Bilan température potentielle : partie convective - MASK1']*len(Lplot) +Llinelabel = ['SFR','DEPS','DEPG','REVA','DEPI','IMLT','GMLT','DRYG','ACC','RIM','BERFI','CFRZ','WETG'] +Lxlim = [(-0.7E-2, 0.7E-2)]*len(Lplot) +Lxlab = ['Terme du bilan (K)']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,12000.0)]*len(Lplot) +LaxisColor = ['black']*len(Lplot) +Llinewidth = [3]*len(Lplot) +LfacconvX=[1]*len(Lplot) +Llinecolor = ['red','green','blue','cyan','indigo','bisque','brown','orange','yellow', + 'magenta','gray','lightblue','black'] + +fig = Panel.pXY_lines(Lxx=Lplot, Lyy=LaxeZ, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Llinewidth=Llinewidth, LfacconvX=LfacconvX, + Lylim=Lylim, Lxlim=Lxlim, Llinelabel=Llinelabel, Llinecolor=Llinecolor,LaxisColor=LaxisColor, + ax=fig.axes) + +nmask=1 #Convective mask, criteria in set_mask.f90 +Lplot = [Dvar['f1'][('/Budgets/TH','SFR')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','DEPS')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','DEPG')][nmask,ntime,:], + Dvar['f1'][('/Budgets/TH','REVA')][nmask,ntime,:], + Dvar['f1'][('/Budgets/TH','DEPI')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','IMLT')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','GMLT')][nmask,ntime,:], + Dvar['f1'][('/Budgets/TH','DRYG')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','ACC')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','RIM')][nmask,ntime,:], + Dvar['f1'][('/Budgets/TH','BERFI')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','CFRZ')][nmask,ntime,:], Dvar['f1'][('/Budgets/TH','WETG')][nmask,ntime,:] + ] +Lxlim = [(-0.7E-3, 0.7E-3)]*len(Lplot) +Ltitle = ['Bilan température potentielle : partie stratiforme - MASK2']*len(Lplot) + +fig = Panel.pXY_lines(Lxx=Lplot, Lyy=LaxeZ, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Llinewidth=Llinewidth, LfacconvX=LfacconvX, + Lylim=Lylim, Lxlim=Lxlim, Llinelabel=Llinelabel, Llinecolor=Llinecolor,LaxisColor=LaxisColor, + ax=fig.axes) +Panel.save_graph(1,fig) +```` diff --git a/gallery/view/XY_lines_001_2Drelief.md b/gallery/view/XY_lines_001_2Drelief.md new file mode 100644 index 0000000..9e04854 --- /dev/null +++ b/gallery/view/XY_lines_001_2Drelief.md @@ -0,0 +1,35 @@ +## Plot 2 + +![XY_lines_001_2Drelief.png](../figures/XY_lines_001_2Drelief.png) + +````python +Panel6 = PanelPlot(2,2, [20,20],'Profiles at the center (top of the topography)') + +Lplot = [ Dvar['f1']['WT'][:,127]] +LaxeZ = [Dvar['f1']['altitude'][:,127]]*len(Lplot) +Ltitle = ['WT and THT-LSTHM']*len(Lplot) +Llinelabel = ['WT'] +Lxlab = ['velocity (m/s)']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,15000.1)]*len(Lplot) +Lxlim = [(-0.3,0.3)] +Llinecolor = ['r'] +LaxisColor = Llinecolor +Llvl = [0]*len(Lplot) +Ltime = [Dvar['f1']['time']] +fig6 = Panel6.pXY_lines(Lyy=LaxeZ, Lxx=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, Llinelabel=Llinelabel, + Llinecolor=Llinecolor, LaxisColor=LaxisColor, Ltime=Ltime) + +Lplot = [ Dvar['f1']['THT-LSTHM'][:,127]] +Ltitle = [] +Llinelabel = ['THT - LSTHM '] +Lxlab = ['theta perturb (K)']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,15000.1)]*len(Lplot) +Lxlim = [(-0.8,0.1)] +Llinecolor = ['g'] +LaxisColor = Llinecolor +Llvl = [0]*len(Lplot) +fig7 = Panel6.pXY_lines(Lyy=LaxeZ, Lxx=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle,ax=fig6.axes, id_overlap=1, + Lylim=Lylim, Lxlim=Lxlim, Llinelabel=Llinelabel, Llinecolor=Llinecolor,LaxisColor=LaxisColor, Ltime=Ltime) +```` diff --git a/gallery/view/XY_lines_tseries_aircraft_AZF2M.md b/gallery/view/XY_lines_tseries_aircraft_AZF2M.md new file mode 100644 index 0000000..a4659a9 --- /dev/null +++ b/gallery/view/XY_lines_tseries_aircraft_AZF2M.md @@ -0,0 +1,61 @@ +## Plot 2 + +![XY_lines_tseries_aircraft_AZF2M.png](../figures/XY_lines_tseries_aircraft_AZF2M.png) + +````python +Panel = PanelPlot(8,2, [14,20],'Time series from Aircraft', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=18) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'ZS')]] +Ltime = [Dvar['f13'][(LG_AVION,'time_flyer')]/3600.0] +Ltitle = ['Orography'] +Lxlab = ['Time (h)'] +Lylab = ['ZS (m)'] +Lylim = [(0, 350)] +Lxlim = [(9.0, 9.2)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'P')]] +Ltitle = ['Pressure'] +Lylab = ['P (Pa)'] +Lylim = [(0, 95000)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'LON')]] +Ltitle = ['Longitude'] +Lylab = ['Longitude'] +Lylim = [(0, 2.5)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'ZON_WIND')]] +Ltitle = ['Zonal wind'] +Lylab = ['u (m/s)'] +Lylim = [(-1, 11)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'MER_WIND')]] +Ltitle = ['Meridional wind'] +Lylab = ['v (m/s)'] +Lylim = [(-3, 3)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'W')]] +Ltitle = ['Vertical velocity'] +Lylab = ['w (m/s)'] +Lylim = [(-0.1, 0.1)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'Th')]] +Ltitle = ['Potential Temperature'] +Lylab = [r'$\theta$ (K)'] +Lylim = [(290, 305)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'Rv')]] +Ltitle = ['Water vapor mixing ratio'] +Lylab = ['Rv (kg/kg))'] +Lylim = [(0, 0.01)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +fig.tight_layout() +Panel.save_graph(1,fig) +```` diff --git a/gallery/view/XY_multisimple_GABLS1.md b/gallery/view/XY_multisimple_GABLS1.md new file mode 100644 index 0000000..c0b3c84 --- /dev/null +++ b/gallery/view/XY_multisimple_GABLS1.md @@ -0,0 +1,40 @@ +## Plot 2 + +![XY_multisimple_GABLS1.png](../figures/XY_multisimple_GABLS1.png) + +````python +Panel = PanelPlot(3,3, [25,25],'8-9h time averaged vertical profiles', titlepad=11, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=40) + +Lplot = [np.mean(Dvar['f1'][(LG_MEAN,'MEAN_TH')][:,t_beg:t_end],axis=1), np.mean(Dvar['f2'][(LG_MEAN,'MEAN_TH')][:,t_beg:t_end],axis=1), + np.mean(Dvar['f3'][(LG_MEAN,'MEAN_TH')][:,t_beg:t_end],axis=1)] +LaxeZ = [Dvar['f1']['level_les'], Dvar['f2']['level_les'], Dvar['f3']['level_les']] +Ltitle = ['MEAN_TH']*len(Lplot) +Llinelabel = ['1D BL89','1D RM17', 'LES'] +Lxlab = ['theta (K)']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,400.1)]*len(Lplot) +Lxlim = [(262, 268)]*len(Lplot) +Llinecolor = ['red','blue', 'black'] +LaxisColor = ['black']*len(Lplot) +Llinewidth = [3]*len(Lplot) +fig = Panel.pXY_lines(Lxx=Lplot, Lyy=LaxeZ, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Llinewidth=Llinewidth, + Lylim=Lylim, Lxlim=Lxlim, Llinelabel=Llinelabel, Llinecolor=Llinecolor,LaxisColor=LaxisColor) + +Lplot = [np.mean(Dvar['f1']['WIND'][:,t_beg:t_end],axis=1), np.mean(Dvar['f2']['WIND'][:,t_beg:t_end],axis=1), np.mean(Dvar['f3']['WIND'][:,t_beg:t_end],axis=1)] +Ltitle = ['Wind speed']*len(Lplot) +Lxlab = ['Wind speed (m/s)']*len(Lplot) +Lxlim = [(0, 11)]*len(Lplot) +fig = Panel.pXY_lines(Lxx=Lplot, Lyy=LaxeZ, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, ax=fig.axes, Llinewidth=Llinewidth, + Lylim=Lylim, Lxlim=Lxlim, Llinelabel=Llinelabel, Llinecolor=Llinecolor,LaxisColor=LaxisColor) + +Lplot = [Dvar['f1']['SBL_H'][:], Dvar['f2']['SBL_H'][:], Dvar['f3']['SBL_H'][:]] + +Ltitle = ['Boundary layer height']*len(Lplot) +LaxeTime = [Dvar['f1']['time_les']/3600.0, Dvar['f2']['time_les']/3600.0, Dvar['f3']['time_les']/3600.0] +Lxlab = ['Time (h)']*len(Lplot) +Lxlim = [(0, 9)]*len(Lplot) +Lylim = [(0, 300.1)]*len(Lplot) +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=LaxeTime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, ax=fig.axes,Llinewidth=Llinewidth, + Lylim=Lylim, Lxlim=Lxlim, Llinelabel=Llinelabel, Llinecolor=Llinecolor,LaxisColor=LaxisColor) +Panel.save_graph(1,fig) +```` diff --git a/gallery/view/diachronic_file.md b/gallery/view/diachronic_file.md new file mode 100644 index 0000000..1948997 --- /dev/null +++ b/gallery/view/diachronic_file.md @@ -0,0 +1,22 @@ +## Read diachronic file + +````python +LnameFiles = ['RBL89.1.ECH01.000.nc','GABL1.1.ECH01.000.nc'] +LG_MEAN = '/LES_budgets/Mean/Cartesian/Not_time_averaged/Not_normalized/cart/' +LG_SBG = '/LES_budgets/Subgrid/Cartesian/Not_time_averaged/Not_normalized/cart/' +LG_RES = '/LES_budgets/Resolved/Cartesian/Not_time_averaged/Not_normalized/cart/' + +Dvar_input = { +'f1':[(LG_SBG,'SBG_TKE'),(LG_SBG,'SBG_WU'),(LG_SBG,'SBG_WV'),(LG_SBG,'SBG_KM'),(LG_SBG,'SBG_KH'),(LG_SBG,'SBG_WTHL'),(LG_SBG,'SBG_THL2'), + (LG_MEAN,'MEAN_U'),(LG_MEAN,'MEAN_V'),(LG_MEAN,'MEAN_TH'), + 'time_les','level_les'], +'f2':[(LG_SBG,'SBG_TKE'),(LG_SBG,'SBG_WU'),(LG_SBG,'SBG_WV'),(LG_SBG,'SBG_KM'),(LG_SBG,'SBG_KH'),(LG_SBG,'SBG_WTHL'),(LG_SBG,'SBG_THL2'), + (LG_RES,'RES_KE'),(LG_RES,'RES_WU'),(LG_RES,'RES_WV'),(LG_RES,'RES_WTH'),(LG_RES,'RES_TH2'), + (LG_MEAN,'MEAN_U'),(LG_MEAN,'MEAN_V'),(LG_MEAN,'MEAN_TH'), + 'time_les','level_les'] +} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path=path, removeHALO=False) +```` diff --git a/gallery/view/full_doc.md b/gallery/view/full_doc.md new file mode 100644 index 0000000..0e04587 --- /dev/null +++ b/gallery/view/full_doc.md @@ -0,0 +1,43 @@ +## Full documentation + +````python +def read_netcdf(LnameFiles, Dvar_input, path='.', get_data_only=True, del_empty_dim=True, removeHALO=True): + """Read a netCDF4 Meso-NH file + For each file, call functions to read diachronic or synchronous file + + Parameters + ---------- + LnameFiles : list of str + list of Meso-NH netCDF4 file (diachronic or synchronous) + + Dvar_input : Dict{'fileNumber' : 'var_name',('group_name','var_name')} + where + 'fileNumber' is a str corresponding to 'f' + the file number in LnameFiles (by order) + 'var_name' is the exact str of the netCDF4 variable name + ('group_name','var_name') is the exact tuple of the (sub-)groups name and the netCDF4 variable name + e.g. : {'f1':['ZS', 'WT','ni', 'level'], + 'f2':[('/LES_budgets/Cartesian/Not_time_averaged/Not_normalized/cart/',MEAN_TH'),('/Budgets/RI','AVEF')] + } + + path : str + unique path of the files + + get_data_only : bool, default: True + if True, the function returns Dvar as masked_array (only data) + if False, the function returns Dvar as netCDF4._netCDF4.Variable + + del_empty_dim : bool, default: True + if get_data_only=True and del_empty_dim=True, returns Dvar as an array without dimensions with size 1 and 0 + e.g. : an array of dimensions (time_budget, cart_level, cart_nj, cart_ni) with shape (180,1,50,1) is returned (180,50) + + removeHALO : bool, default: True + if True, remove first and last (NHALO=1) point [1:-1] if get_data_only=True on each + level, level_w, ni, ni_u, ni_v, nj, nj_u, nj_v dimensions + + Returns + ------- + Dvar : Dict + Dvar[ifile]['var_name'] if the group contains only one variable + Dvar[ifile][('group_name','var_name')] if the group contains more than one variable + """ +```` diff --git a/gallery/view/histogramm_009ICARTT_full.md b/gallery/view/histogramm_009ICARTT_full.md new file mode 100644 index 0000000..21b1965 --- /dev/null +++ b/gallery/view/histogramm_009ICARTT_full.md @@ -0,0 +1,122 @@ +## Plot 2 + +![histogramm_009ICARTT_full.png](../figures/histogramm_009ICARTT_full.png) + +````python +#!/usr/bin/env python3 +""" +@author: Quentin Rodier +Creation : 07/01/2021 + +Last modifications +""" +import matplotlib as mpl +mpl.use('Agg') +from read_MNHfile import read_netcdf +from Panel_Plot import PanelPlot +import cartopy.crs as ccrs +import os +import numpy as np + +os.system('rm -f tempgraph*') +# +# User's parameter / Namelist +# +path="" + +LnameFiles = ['ICART.1.SEG01.001dg.nc', 'ICART.1.SEG01.002dg.nc'] + +Dvar_input = { +'f1':['MRC','COT','O3T','O3_PROD','O3_LOSS','CO_PROD','CO_LOSS','level','ZTOP', 'longitude','latitude','level_w','time', + 'CO_BUDGET','O3_BUDGET','O3_CHREACLIST','CO_CHREACLIST'], +'f2':['MRC','COT','O3T','O3_PROD','O3_LOSS','CO_PROD','CO_LOSS','level','ZTOP', 'longitude','latitude','level_w','time', + 'CO_BUDGET','O3_BUDGET','O3_CHREACLIST','CO_CHREACLIST'] +} +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path=path, removeHALO=True) + +################################################################ +######### PANEL 1 # Horizontal cross-section +############################################################### +Panel1 = PanelPlot(3,3, [25,17],'Horizontal section at 1150m, 19h', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.01, colorbaraspect=40, labelcolorbarpad = 13) + +Lplot = [ Dvar['f1']['MRC'][:,:,:], Dvar['f1']['COT'][:,:,:], Dvar['f1']['O3T'][:,:,:], Dvar['f1']['O3_PROD'][:,:,:], + Dvar['f1']['O3_LOSS'][:,:,:], Dvar['f1']['CO_PROD'][:,:,:], Dvar['f1']['CO_LOSS'][:,:,:]] + +LaxeX = [Dvar['f1']['longitude']]*len(Lplot) +LaxeY = [Dvar['f1']['latitude']]*len(Lplot) +Ltitle = ['Cloud mixing ratio', 'Carbon monoxyde CO ','Ozone O3', 'Ozone production', 'Ozone destruction','Carbon monoxyde production','Carbon monoxyde destruction'] +Lcbarlabel = ['g/kg', 'ppbv','ppbv','ppbv/h','ppbv/h','ppbv/h','ppbv/h'] +Lylab = ['latitude']*len(Lplot) +Lminval = [ 0, 107.5, 0, 70, 70, 0.5, 0.5 ] +Lmaxval = [ 0.2, 137.5, 70, 130, 130, 1.7, 1.7 ] +Lstep = [ 0.01, 2.5, 5, 5, 5, 0.1, 0.1] +Lstepticks = Lstep +Lfacconv = [ 1, 1, 1, 1e9*3600, 1e9*3600,1e9*3600, 1e9*3600] +Lcolormap = ['gist_ncar']*len(Lplot) +Llvl = [14]*len(Lplot) +LaddWhite_cm = [True, False, False, False, False, False, False] +Lprojection = [ccrs.PlateCarree()]*len(Lplot) + +fig1 = Panel1.psectionH(lon=LaxeX, lat=LaxeY, Lvar=Lplot, Llevel=Llvl,Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + colorbar=True, LaddWhite_cm=LaddWhite_cm, Lproj=Lprojection) + +Panel1.save_graph(1,fig1) + +################################################################ +######### PANEL 2 # Horizontal cross-section +############################################################### +Panel2 = PanelPlot(3,3, [25,17],'Horizontal section at 1150m, 20h', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.01, colorbaraspect=40, labelcolorbarpad = 13) + +Lplot = [ Dvar['f2']['MRC'][:,:,:], Dvar['f2']['COT'][:,:,:], Dvar['f2']['O3T'][:,:,:], Dvar['f2']['O3_PROD'][:,:,:], + Dvar['f2']['O3_LOSS'][:,:,:], Dvar['f2']['CO_PROD'][:,:,:], Dvar['f2']['CO_LOSS'][:,:,:]] + +fig2 = Panel2.psectionH(lon=LaxeX, lat=LaxeY, Lvar=Lplot, Llevel=Llvl,Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + colorbar=True, LaddWhite_cm=LaddWhite_cm, Lproj=Lprojection) + +Panel2.save_graph(2,fig2) + +################################################################ +######### PANEL 3 # Bar plots Budget chemical reactions +############################################################### +Dvar['f1']['CO_BUDGET_mean'] = np.mean(Dvar['f1']['CO_BUDGET'][:,13,:,:],axis=(1,2)) # {x,y} Average on height = 1150m +Dvar['f1']['O3_BUDGET_mean'] = np.mean(Dvar['f1']['O3_BUDGET'][:,13,:,:],axis=(1,2)) # {x,y} Average on height = 1150m +Dvar['f2']['CO_BUDGET_mean'] = np.mean(Dvar['f2']['CO_BUDGET'][:,13,:,:],axis=(1,2)) # {x,y} Average on height = 1150m +Dvar['f2']['O3_BUDGET_mean'] = np.mean(Dvar['f2']['O3_BUDGET'][:,13,:,:],axis=(1,2)) # {x,y} Average on height = 1150m + +Panel3 = PanelPlot(2,2, [20,20],'Chemical budgets', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.01, colorbaraspect=40, labelcolorbarpad = 13) + +Lplot = [Dvar['f1']['CO_BUDGET_mean'], Dvar['f1']['O3_BUDGET_mean'], Dvar['f2']['CO_BUDGET_mean'], Dvar['f2']['O3_BUDGET_mean'] ] +Lbins=[Dvar['f1']['CO_CHREACLIST'], Dvar['f1']['O3_CHREACLIST'],Dvar['f2']['CO_CHREACLIST'], Dvar['f2']['O3_CHREACLIST']] +Ltitle = ['Carbon monoxyde CO chemical reactions', 'Ozone O3 chemical reactions']*2 +Lylab = ['Budget (ppbv/h)']*len(Lplot) +Ltime = [Dvar['f1']['time'], Dvar['f1']['time'], Dvar['f2']['time'], Dvar['f2']['time']] +Lylim=[(-1,1), (-100, 100)]*2 +Lfacconv = [1E9*3600]*len(Lplot) +Lwidth=[0.95]*len(Lplot) +Lcolors=[] +for var in Lplot: + cc=['']*len(var) + for n,val in enumerate(var): + if val<0: + cc[n]='blue' + elif val>=0: + cc[n]='red' + Lcolors.append(cc) + +fig3 = Panel3.pXY_bar(Lbins=Lbins, Lvar=Lplot, Lylim=Lylim, Lfacconv=Lfacconv, Ltitle=Ltitle, Lylab=Lylab, Lcolor=Lcolors, Lwidth=Lwidth, Ltime=Ltime) + +# Handle a new axis at y=0 for each graphs +for i,var in enumerate(Lplot): + ax2 = fig3.axes[i].twinx() # Clone the existing axis + ax2_x = ax2.get_xaxis() + ax2_x.set_label('Chemical reactions') + ax2_y = ax2.get_yaxis() # Get the new Y axe and hide it + ax2_y.set_visible(False) + fig3.axes[i].spines['bottom'].set_position('center') # Move the original axis to the center + +Panel3.save_graph(3,fig3) +```` diff --git a/gallery/view/horizontal_oasis_coupling.md b/gallery/view/horizontal_oasis_coupling.md new file mode 100644 index 0000000..7626cc0 --- /dev/null +++ b/gallery/view/horizontal_oasis_coupling.md @@ -0,0 +1,141 @@ +## Plot 2 + +![horizontal_oasis_coupling.png](../figures/horizontal_oasis_coupling.png) + +````python +#!/bin/python3 +# -------------------------------------------------------- +# +# Author ( date ) : +# J. Pianezze ( 29.09.2023 ) +# +# ~~~~~~~~~~~~~~~ +# Script used to verify OASIS exchanges between +# Meso-NH and toy models +# ~~~~~~~~~~~~~~~ +# +# -------------------------------------------------------- + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import os, glob +import netCDF4 +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.colors import BoundaryNorm +curdir_path = os.getcwd()+'/' +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ######################################################### +# ### To be defined by user ### +# ######################################################### + +name_file_send_mnh = glob.glob('*mesonh_01.nc')[0] +name_file_recv_mnh = glob.glob('*mesonh_02.nc')[0] +name_file_send_toy = glob.glob('*toyexe_02.nc')[0] +name_file_recv_toy = glob.glob('*toyexe_01.nc')[0] +name_var01 = name_file_send_mnh[5:8] +name_var02 = name_file_recv_mnh[5:8] + +# ######################################################### + +# --------------------------------------- +# Create directory to store figures +# --------------------------------------- +try : + os.mkdir(curdir_path+name_var01+'_'+name_var02+'/') +except OSError: + print('Directory already created') +else: + print('Making directory') + +# --------------------------------------- +# Open files +# --------------------------------------- +file_send_toy = netCDF4.Dataset(name_file_send_toy) +file_recv_mnh = netCDF4.Dataset(name_file_recv_mnh) +file_recv_toy = netCDF4.Dataset(name_file_recv_toy) +file_send_mnh = netCDF4.Dataset(name_file_send_mnh) +file_grids = netCDF4.Dataset('grids.nc') + +# --------------------------------------- +# Read lon/lat +# --------------------------------------- +lon_toy = file_grids.variables['toyt.lon'] ; nlon_toy = np.shape(lon_toy)[1] +lat_toy = file_grids.variables['toyt.lat'] ; nlat_toy = np.shape(lat_toy)[0] +lon_mnh = file_grids.variables['ssea.lon'] ; nlon_mnh = np.shape(lon_mnh)[1] +lat_mnh = file_grids.variables['ssea.lat'] ; nlat_mnh = np.shape(lat_mnh)[0] + +# --------------------------------------- +# Read variables +# --------------------------------------- +var_send_toy = file_send_toy.variables[name_file_send_toy[0:8]][-2,:,:]*1000.0 +var_recv_toy = file_recv_toy.variables[name_file_recv_toy[0:8]][-1,:,:] +var_send_mnh = file_send_mnh.variables[name_file_send_mnh[0:8]][-2,:,:] +var_recv_mnh = file_recv_mnh.variables[name_file_recv_mnh[0:8]][-1,:,:]*1000.0 + +mask_mnh = (var_send_mnh[:,:] > 1E10) +var_send_mnh = np.ma.MaskedArray(var_send_mnh, mask=mask_mnh) +var_recv_mnh = np.ma.MaskedArray(var_recv_mnh, mask=mask_mnh) + +mask_toy = (var_recv_toy[:,:] == 0.0) +var_send_toy = np.ma.MaskedArray(var_send_toy, mask=mask_toy) +var_recv_toy = np.ma.MaskedArray(var_recv_toy, mask=mask_toy) + +# ----------------------------------------------------------- +# Create figure +# ----------------------------------------------------------- +fig = plt.figure() + +# ----------------------------------------------------------- +# Define colormap and norm +# ----------------------------------------------------------- +cmap_wnd = plt.cm.RdBu_r +cmap_toy = plt.cm.RdBu_r + +levels_wnd = np.arange( 0.0, 0.26, 0.01) +levels_toy = np.arange(-10.0, 10.1, 0.1) + +norm_wnd = BoundaryNorm(levels_wnd, ncolors=cmap_wnd.N, clip=True) +norm_toy = BoundaryNorm(levels_toy, ncolors=cmap_toy.N, clip=True) + +#---------------------- +ax = fig.add_subplot(221) +plt.title('(a) Send by MNH') +cs = plt.pcolormesh(lon_mnh[:,:],lat_mnh[:,:],var_send_mnh[:,:],cmap=cmap_wnd,norm=norm_wnd) +cbar = plt.colorbar(cs,orientation='vertical',format='%.2f') +plt.tick_params(axis='x',which='both',labelbottom=False) +ax.set_xlim(( max(np.min(lon_mnh[1:-1,1:-1]),np.min(lon_toy[1:-1,1:-1])), min(np.max(lon_mnh[1:-1,1:-1]),np.max(lon_toy[1:-1,1:-1])) )) +ax.set_ylim(( max(np.min(lat_mnh[1:-1,1:-1]),np.min(lat_toy[1:-1,1:-1])), min(np.max(lat_mnh[1:-1,1:-1]),np.max(lat_toy[1:-1,1:-1])) )) + +#---------------------- +ax = fig.add_subplot(222) +plt.title('(b) Received by TOY') +cs = plt.pcolormesh(lon_toy[:,:],lat_toy[:,:],var_recv_toy[:,:],cmap=cmap_wnd,norm=norm_wnd) +cbar = plt.colorbar(cs,orientation='vertical',format='%.2f') +plt.tick_params(axis='x',which='both',labelbottom=False) +plt.tick_params(axis='y',which='both',labelleft =False) +ax.set_xlim(( max(np.min(lon_mnh[1:-1,1:-1]),np.min(lon_toy[1:-1,1:-1])), min(np.max(lon_mnh[1:-1,1:-1]),np.max(lon_toy[1:-1,1:-1])) )) +ax.set_ylim(( max(np.min(lat_mnh[1:-1,1:-1]),np.min(lat_toy[1:-1,1:-1])), min(np.max(lat_mnh[1:-1,1:-1]),np.max(lat_toy[1:-1,1:-1])) )) + +#---------------------- +ax = fig.add_subplot(223) +plt.title('(c) Send by TOY') +cs = plt.pcolormesh(lon_toy[:,:],lat_toy[:,:],var_send_toy[:,:],cmap=plt.cm.RdBu_r,vmin=np.min(var_send_toy), vmax=np.max(var_send_toy)) +cbar = plt.colorbar(cs,orientation='vertical',format='%.1f') +ax.set_xlim(( max(np.min(lon_mnh[1:-1,1:-1]),np.min(lon_toy[1:-1,1:-1])), min(np.max(lon_mnh[1:-1,1:-1]),np.max(lon_toy[1:-1,1:-1])) )) +ax.set_ylim(( max(np.min(lat_mnh[1:-1,1:-1]),np.min(lat_toy[1:-1,1:-1])), min(np.max(lat_mnh[1:-1,1:-1]),np.max(lat_toy[1:-1,1:-1])) )) + +#---------------------- +ax = fig.add_subplot(224) +plt.title('(d) Received by MNH') +cs = plt.pcolormesh(lon_mnh[:,:],lat_mnh[:,:],var_recv_mnh[:,:],cmap=plt.cm.RdBu_r,vmin=np.min(var_send_toy), vmax=np.max(var_send_toy)) +cbar = plt.colorbar(cs,orientation='vertical',format='%.1f') +plt.tick_params(axis='y',which='both',labelleft=False) +ax.set_xlim(( max(np.min(lon_mnh[1:-1,1:-1]),np.min(lon_toy[1:-1,1:-1])), min(np.max(lon_mnh[1:-1,1:-1]),np.max(lon_toy[1:-1,1:-1])) )) +ax.set_ylim(( max(np.min(lat_mnh[1:-1,1:-1]),np.min(lat_toy[1:-1,1:-1])), min(np.max(lat_mnh[1:-1,1:-1]),np.max(lat_toy[1:-1,1:-1])) )) + +#------------------------ +plt.savefig(curdir_path+name_var01+"_"+name_var02+"/"+name_var01+"_"+name_var02+".png", bbox_inches='tight', dpi=400) +plt.close() +#------------------------ +```` diff --git a/gallery/view/multiple_file.md b/gallery/view/multiple_file.md new file mode 100644 index 0000000..de3e522 --- /dev/null +++ b/gallery/view/multiple_file.md @@ -0,0 +1,14 @@ +## Read multiple file + +````python +LnameFiles = ['ICART.1.SEG01.001dg.nc', 'ICART.1.SEG01.002dg.nc'] +Lvariables = ['MRC','COT','O3T','O3_PROD','O3_LOSS','CO_PROD','CO_LOSS', + 'level','ZTOP', 'longitude','latitude','level_w','time', + 'CO_BUDGET','O3_BUDGET','O3_CHREACLIST','CO_CHREACLIST'] + +Dvar_input = {'f1':Lvariables, 'f2':Lvariables} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path="", removeHALO=True) +```` diff --git a/gallery/view/sectionH_004_Reunion.md b/gallery/view/sectionH_004_Reunion.md new file mode 100644 index 0000000..7b00f84 --- /dev/null +++ b/gallery/view/sectionH_004_Reunion.md @@ -0,0 +1,144 @@ +## Plot 2 + +![sectionH_004_Reunion.png](../figures/sectionH_004_Reunion.png) + +````python +#!/usr/bin/env python3 +""" + +@author: Quentin Rodier +Creation : 07/01/2021 + +Last modifications +""" +import matplotlib as mpl +mpl.use('Agg') +from read_MNHfile import read_netcdf +from Panel_Plot import PanelPlot +from misc_functions import comp_altitude2DVar, mean_operator +import cartopy.crs as ccrs +import numpy as np +import copy +import os + +os.system('rm -f tempgraph*') +# +# User's parameter / Namelist +# +LnameFiles = ['REUNI.1.00A20.004dia.nc', 'REUNI.1.00A20.004.nc'] + +Dvar_input = { +'f1':['ZS', 'UT', 'VT', 'WT', 'THT', 'ALT_PRESSURE','ALT_U','ALT_V','ALT_THETA','level','ZTOP', 'longitude','latitude','level_w','time'], +'f2':['LSTHM', 'LSVM']} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path="", removeHALO=True) + +################################################################ +######### PANEL 1 # Horizontal cross-section +############################################################### +Panel1 = PanelPlot(2,2, [20,20],'004_Reunion horizontal sections') + +Dvar['f1']['WIND'] = np.sqrt(Dvar['f1']['UT']**2 + Dvar['f1']['VT']**2) +Lplot = [ Dvar['f1']['ZS'][:,:], Dvar['f1']['WIND'][0,:,:], Dvar['f1']['ALT_THETA'][:,:], Dvar['f1']['ALT_PRESSURE'][:,:]] + +LaxeX = [Dvar['f1']['longitude']]*len(Lplot) +LaxeY = [Dvar['f1']['latitude']]*len(Lplot) +Ltitle = ['Orography', 'Wind speed ','Potential temperature at z = 1500m', 'Pressure'] +Lcbarlabel = ['m', 'm/s','K','hPa'] +Lxlab = ['longitude']*len(Lplot) +Lylab = ['latitude']*len(Lplot) +Lminval = [0, 8, 301.8, 831] +Lmaxval = [3000, 26, 305, 838] +Lstep = [50,1, 0.1, 0.1, 0.1] +Lstepticks = [500, 2,1,0.5] +Lfacconv = [1, 1, 1, 1./100.] +Lcolormap = ['gist_rainbow_r']*len(Lplot) +Ltime = [Dvar['f1']['time']]*len(Lplot) +Lpltype = ['cf']*len(Lplot) +LaddWhite_cm = [True, False, False, False] +Lprojection = [ccrs.PlateCarree()]*len(Lplot) + +fig1 = Panel1.psectionH(lon=LaxeX, lat=LaxeY, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + colorbar=True, Ltime=Ltime, LaddWhite_cm=LaddWhite_cm, Lproj=Lprojection) + +Lplot1 = [ Dvar['f1']['UT'], Dvar['f1']['ALT_U']] +Lplot2 = [ Dvar['f1']['VT'], Dvar['f1']['ALT_V']] +Ltitle = ['wind vectors at K=2', 'wind vectors at z = 1500m '] +Lxlab = ['longitude']*len(Lplot1) +Lylab = ['latitude']*len(Lplot1) +Llegendval = [25,25] +Lcbarlabel = ['(m/s)']*len(Lplot1) +Larrowstep = [4]*len(Lplot1) +Lwidth = [0.003]*len(Lplot1) +Lcolor = ['black']*len(Lplot1) +Lprojection = [ccrs.PlateCarree()]*len(Lplot1) +Llvl = [0]*len(Lplot1) +Lscale = [400]*len(Lplot1) +fig2 = Panel1.pvector(Lxx=LaxeX, Lyy=LaxeY, Llevel=Llvl, Lvar1=Lplot1, Lvar2=Lplot2, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lproj=Lprojection, Lid_overlap=[2,6], ax=fig1.axes, Lscale=Lscale) + +################################################################ +######### PANEL 2 # Vertical cross-section +############################################################### +# Compute wind into mass point +tomass = mean_operator() +Dvar['f1']['WM'] = tomass.MZM(Dvar['f1']['WT']) +Dvar['f1']['VM'] = tomass.MYM(Dvar['f1']['VT']) + +Panel2 = PanelPlot(2,2, [20,20],'004_Reunion vertical sections at i=35') +i_slice = 33 + +# Black line +Panel1.addLine(fig2.axes[0],[Dvar['f1']['longitude'][0,i_slice],Dvar['f1']['latitude'][0,i_slice]],[Dvar['f1']['longitude'][-1,i_slice],Dvar['f1']['latitude'][-1,i_slice]],'black',3) +Panel1.save_graph(1,fig2) + +# Compute altitude variable in 3D with a 2D topography +Dvar['f1']['altitude'] , Dvar['f1']['nx_3D'], Dvar['f1']['ny_3D'] = comp_altitude2DVar(Dvar['f2']['LSTHM'], Dvar['f1']['ZS'],Dvar['f1']['ZTOP'], Dvar['f1']['level'], Dvar['f1']['latitude'], Dvar['f1']['longitude']) +Dvar['f1']['altitude_w'], Dvar['f1']['nx_3D'], Dvar['f1']['ny_3D'] = comp_altitude2DVar(Dvar['f1']['WM'], Dvar['f1']['ZS'],Dvar['f1']['ZTOP'], Dvar['f1']['level_w'], Dvar['f1']['latitude'], Dvar['f1']['longitude']) +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) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,16000)]*len(Lplot) +Lminval = [300, -1.9, -10.5, -6.75] +Lmaxval = [355, 1.9, 10.5, 6.75] +Lstep = [2.5, 0.2, 1, 0.5] +Lstepticks = Lstep +Lcolormap=['gist_rainbow_r','seismic','seismic','seismic'] +orog = Dvar['f1']['ZS'][:,i_slice] + +fig3 = Panel2.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, Lylim=Lylim, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, + orog=orog, colorbar=True, Ltime=Ltime) + +# Wind vector on last panel +Lplot1 = [ Dvar['f1']['VM'][:,:,i_slice]] +Lplot2 = [ Dvar['f1']['WM'][:,:,i_slice]] +Ltitle = ['Wind'] +Llegendval = [15] +Lcbarlabel = ['m/s']*len(Lplot) +Lxlab = ['longitude']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Larrowstep = [1]*len(Lplot) +Lwidth = [0.002]*len(Lplot) +Lscale = [800]*len(Lplot) +Lylim=[(0,3000)] +Lxlim = [(-21.3,-20.9)]*len(Lplot) +Lcolor=['lightgray'] + +fig4 = Panel2.pvector(Lxx=LaxeX, Lyy=LaxeZ, Lvar1=Lplot1, Lvar2=Lplot2, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lid_overlap=[6], ax=fig3.axes, Lscale=Lscale, Lylim=Lylim, Lxlim=Lxlim, Lcolor=Lcolor) + +Panel2.save_graph(2,fig4) +```` diff --git a/gallery/view/sectionH_2dom_front_AZF_full.md b/gallery/view/sectionH_2dom_front_AZF_full.md new file mode 100644 index 0000000..ff49712 --- /dev/null +++ b/gallery/view/sectionH_2dom_front_AZF_full.md @@ -0,0 +1,390 @@ +## Plot 2 + +![sectionH_2dom_front_AZF_full.png](../figures/sectionH_2dom_front_AZF_full.png) + +````python +#!/usr/bin/env python3 +""" +@author: Quentin Rodier +Creation : 07/01/2021 + +Last modifications +""" +import matplotlib as mpl +mpl.use('Agg') +from read_MNHfile import read_netcdf +from Panel_Plot import PanelPlot +from misc_functions import mean_operator, convert_date +import cartopy.crs as ccrs +import numpy as np +import os +import cartopy.io.shapereader as shpreader +import matplotlib.patches as mpatches +os.system('rm -f tempgraph*') +# +# User's parameter / Namelist +# +path="" + +LnameFiles = ['AZF02.1.CEN4T.001.nc', 'AZF02.1.CEN4T.002.nc', 'AZF02.1.CEN4T.003.nc', + 'AZF02.1.CEN4T.004.nc', 'AZF02.1.CEN4T.005.nc', 'AZF02.1.CEN4T.007.nc', + 'AZF02.2.CEN4T.001.nc', 'AZF02.2.CEN4T.002.nc', 'AZF02.2.CEN4T.003.nc', + 'AZF02.2.CEN4T.004.nc', 'AZF02.2.CEN4T.005.nc', 'AZF02.2.CEN4T.007.nc', + 'AZF02.1.CEN4T.000.nc'] +LG_AVION='/Flyers/Aircrafts/AVION/' +LG_AVIONT='/Flyers/Aircrafts/AVION/Point/' +LG_AVIONZT='/Flyers/Aircrafts/AVION/Vertical_profile/' + +Dvar_input = { +'f1':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f2':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f3':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f4':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f5':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f6':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f7':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level','LONOR','LATOR','LAT','LON'], +'f8':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f9':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f10':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f11':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f12':['SVT001','SVT002','ATC001','ATC002','UT','VT','latitude','longitude','level'], +'f13':[(LG_AVION,'time_flyer'),(LG_AVIONT,'ZS'), (LG_AVIONT,'P'), (LG_AVIONT,'LON'),(LG_AVIONT,'MER_WIND'), + (LG_AVIONT,'ZON_WIND'),(LG_AVIONT,'W'), (LG_AVIONT,'Th'), (LG_AVIONT,'Rv'),(LG_AVIONT,'Tke'), + (LG_AVIONT,'H_FLUX'),(LG_AVIONT,'LE_FLUX'), (LG_AVIONT,'Tke_Diss'), (LG_AVIONT,'Tsrad')] +} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path=path, removeHALO=True) + +################################################################ +######### PANEL 1 +############################################################### +Panel = PanelPlot(2,3, [25,14],'Domaine 1 SV 001', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=22) +Lplot = [Dvar['f1']['SVT001'], Dvar['f2']['SVT001'], Dvar['f3']['SVT001'], + Dvar['f4']['SVT001'], Dvar['f5']['SVT001'], Dvar['f6']['SVT001']] + +lon = [Dvar['f1']['longitude']]*len(Lplot) +lat = [Dvar['f1']['latitude']]*len(Lplot) +Ltitle = ['SVT001']*len(Lplot) +Lcbarlabel = ['kg/kg']*len(Lplot) +Lxlab = ['longitude']*len(Lplot) +Lylab = ['latitude']*len(Lplot) +Lminval = [0]*len(Lplot) +Lmaxval = [0.15E-5]*len(Lplot) +Lstep = [0.05E-6]*len(Lplot) +Lstepticks = [0.2E-6]*len(Lplot) +Lcolormap = ['gist_rainbow_r']*len(Lplot) +Lprojection = [ccrs.PlateCarree()]*len(Lplot) +LaddWhite = [True]*len(Lplot) +Llevel = [0]*len(Lplot) +Ltime = [Dvar['f1']['date'], Dvar['f2']['date'], Dvar['f3']['date'], Dvar['f4']['date'], Dvar['f5']['date'], Dvar['f6']['date']] +Lcbformatlabel=[True]*len(Lplot) +fig = Panel.psectionH(lon=lon, lat=lat, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, + Ltime=Ltime, LaddWhite_cm=LaddWhite, Lproj=Lprojection, Llevel=Llevel, Lcbformatlabel=Lcbformatlabel) + +Lplot1 = [ Dvar['f1']['UT'], Dvar['f2']['UT'], Dvar['f3']['UT'], Dvar['f4']['UT'], Dvar['f5']['UT'], Dvar['f6']['UT']] +Lplot2 = [ Dvar['f1']['VT'], Dvar['f2']['VT'], Dvar['f3']['VT'], Dvar['f4']['VT'], Dvar['f5']['VT'], Dvar['f6']['VT']] +Ltitle = ['wind vectors at K=2']*len(Lplot) +Llegendval = [7.5]*len(Lplot) +Lcbarlabel = ['(m/s)']*len(Lplot1) +Larrowstep = [2]*len(Lplot1) +Lwidth = [0.002]*len(Lplot1) +Lcolor = ['black']*len(Lplot1) +Lscale = [100]*len(Lplot1) +fig = Panel.pvector(Lxx=lon, Lyy=lat, Llevel=Llevel, Lvar1=Lplot1, Lvar2=Lplot2, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lproj=Lprojection, Lid_overlap=[0,2,4,6,8,10], ax=fig.axes, Lscale=Lscale) + +# Departements francais +departements_shp='departements-20180101.shp' +adm1_shapes = list(shpreader.Reader(departements_shp).geometries()) + +# Add departements to each axes + scatter point of emission source +loncar, latcar = [1.439,1.5], [43.567, 43.9] +label=['AZF1','AZF2'] +for i in range(len(Lplot)): + fig.axes[i*2].add_geometries(adm1_shapes, ccrs.PlateCarree(),edgecolor='black', facecolor='white', alpha=0.2) + fig.axes[i*2].scatter(loncar,latcar) + for lab, txt in enumerate(label): + fig.axes[i*2].annotate(label[lab], (loncar[lab], latcar[lab]), color='black',size=10, weight="bold") + +# Add a Rectangle displaying the domain of the model 2 +for i in range(len(Lplot)): + fig.axes[i*2].add_patch(mpatches.Rectangle(xy=[Dvar['f7']['LONOR'], Dvar['f7']['LATOR']], width=Dvar['f7']['LON'][-1,-1]-Dvar['f7']['LONOR'], height=Dvar['f7']['LAT'][-1,-1]-Dvar['f7']['LATOR'], + facecolor='blue', alpha=0.15, transform=ccrs.PlateCarree())) + +fig.tight_layout() +Panel.save_graph(1,fig) + +################################################################ +######### PANEL 2 +############################################################### +Panel = PanelPlot(2,3, [25,14],'Domaine 1 SV 002', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=22) +Lplot = [Dvar['f1']['SVT002'], Dvar['f2']['SVT002'], Dvar['f3']['SVT002'], + Dvar['f4']['SVT002'], Dvar['f5']['SVT002'], Dvar['f6']['SVT002']] + +lon = [Dvar['f1']['longitude']]*len(Lplot) +lat = [Dvar['f1']['latitude']]*len(Lplot) +Ltitle = ['SVT001']*len(Lplot) +Lcbarlabel = ['kg/kg']*len(Lplot) +Lminval = [0]*len(Lplot) +Lmaxval = [0.15E-5]*len(Lplot) +Lstep = [0.05E-6]*len(Lplot) +Lstepticks = [0.2E-6]*len(Lplot) +Lcbformatlabel=[True]*len(Lplot) +fig = Panel.psectionH(lon=lon, lat=lat, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, + Ltime=Ltime, LaddWhite_cm=LaddWhite, Lproj=Lprojection, Llevel=Llevel, Lcbformatlabel=Lcbformatlabel) + +fig = Panel.pvector(Lxx=lon, Lyy=lat, Llevel=Llevel, Lvar1=Lplot1, Lvar2=Lplot2, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lproj=Lprojection, Lid_overlap=[0,2,4,6,8,10], ax=fig.axes, Lscale=Lscale) + +# Add departements to each axes + scatter point of emission source +for i in range(len(Lplot)): + fig.axes[i*2].add_geometries(adm1_shapes, ccrs.PlateCarree(),edgecolor='black', facecolor='white', alpha=0.2) + fig.axes[i*2].scatter(loncar,latcar) + for lab, txt in enumerate(label): + fig.axes[i*2].annotate(label[lab], (loncar[lab], latcar[lab]), color='black',size=10, weight="bold") + +# Add a Rectangle displaying the domain of the model 2 +for i in range(len(Lplot)): + fig.axes[i*2].add_patch(mpatches.Rectangle(xy=[Dvar['f7']['LONOR'], Dvar['f7']['LATOR']], width=Dvar['f7']['LON'][-1,-1]-Dvar['f7']['LONOR'], height=Dvar['f7']['LAT'][-1,-1]-Dvar['f7']['LATOR'], + facecolor='blue', alpha=0.15, transform=ccrs.PlateCarree())) + +fig.tight_layout() +Panel.save_graph(2,fig) + +################################################################ +######### PANEL 3 +############################################################### +Panel = PanelPlot(2,3, [25,14],'Domaine 1 ATC 001', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=22) +Lplot = [Dvar['f1']['ATC001'], Dvar['f2']['ATC001'], Dvar['f3']['ATC001'], + Dvar['f4']['ATC001'], Dvar['f5']['ATC001'], Dvar['f6']['ATC001']] + +Ltitle = ['ATC001']*len(Lplot) +Lcbarlabel = ['$m^{-3}$']*len(Lplot) +Lminval = [0]*len(Lplot) +Lmaxval = [0.15E-6]*len(Lplot) +Lstep = [0.05E-7]*len(Lplot) +Lstepticks = [0.2E-7]*len(Lplot) +fig = Panel.psectionH(lon=lon, lat=lat, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, + Ltime=Ltime, LaddWhite_cm=LaddWhite, Lproj=Lprojection, Llevel=Llevel, Lcbformatlabel=Lcbformatlabel) + +# Add departements to each axes + scatter point of emission source +for i in range(len(Lplot)): + fig.axes[i*2].add_geometries(adm1_shapes, ccrs.PlateCarree(),edgecolor='black', facecolor='white', alpha=0.2) + fig.axes[i*2].scatter(loncar,latcar) + for lab, txt in enumerate(label): + fig.axes[i*2].annotate(label[lab], (loncar[lab], latcar[lab]), color='black',size=10, weight="bold") + +# Add a Rectangle displaying the domain of the model 2 +for i in range(len(Lplot)): + fig.axes[i*2].add_patch(mpatches.Rectangle(xy=[Dvar['f7']['LONOR'], Dvar['f7']['LATOR']], width=Dvar['f7']['LON'][-1,-1]-Dvar['f7']['LONOR'], height=Dvar['f7']['LAT'][-1,-1]-Dvar['f7']['LATOR'], + facecolor='blue', alpha=0.15, transform=ccrs.PlateCarree())) + +fig.tight_layout() +Panel.save_graph(3,fig) + +################################################################ +######### PANEL 4 +############################################################### +Panel = PanelPlot(2,3, [25,14],'Domaine 1 ATC 002', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=22) +Lplot = [Dvar['f1']['ATC002'], Dvar['f2']['ATC002'], Dvar['f3']['ATC002'], + Dvar['f4']['ATC002'], Dvar['f5']['ATC002'], Dvar['f6']['ATC002']] + +Ltitle = ['ATC002']*len(Lplot) +Lcbarlabel = ['$m^{-3}$']*len(Lplot) +Lminval = [0]*len(Lplot) +Lmaxval = [0.15E-6]*len(Lplot) +Lstep = [0.05E-7]*len(Lplot) +Lstepticks = [0.2E-7]*len(Lplot) +fig = Panel.psectionH(lon=lon, lat=lat, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, + Ltime=Ltime, LaddWhite_cm=LaddWhite, Lproj=Lprojection, Llevel=Llevel, Lcbformatlabel=Lcbformatlabel) + +# Add departements to each axes + scatter point of emission source +for i in range(len(Lplot)): + fig.axes[i*2].add_geometries(adm1_shapes, ccrs.PlateCarree(),edgecolor='black', facecolor='white', alpha=0.2) + fig.axes[i*2].scatter(loncar,latcar) + for lab, txt in enumerate(label): + fig.axes[i*2].annotate(label[lab], (loncar[lab], latcar[lab]), color='black',size=10, weight="bold") + +# Add a Rectangle displaying the domain of the model 2 +for i in range(len(Lplot)): + fig.axes[i*2].add_patch(mpatches.Rectangle(xy=[Dvar['f7']['LONOR'], Dvar['f7']['LATOR']], width=Dvar['f7']['LON'][-1,-1]-Dvar['f7']['LONOR'], height=Dvar['f7']['LAT'][-1,-1]-Dvar['f7']['LATOR'], + facecolor='blue', alpha=0.15, transform=ccrs.PlateCarree())) + +fig.tight_layout() +Panel.save_graph(4,fig) +################################################################ +######### PANEL 5 : Domaine fils +############################################################### +Panel = PanelPlot(2,3, [25,14],'Domaine 2 SV 001', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=18) +Lplot = [Dvar['f7']['SVT001'], Dvar['f8']['SVT001'], Dvar['f9']['SVT001'], + Dvar['f10']['SVT001'], Dvar['f11']['SVT001'], Dvar['f12']['SVT001']] + +lon = [Dvar['f7']['longitude']]*len(Lplot) +lat = [Dvar['f7']['latitude']]*len(Lplot) +Ltitle = ['SVT001']*len(Lplot) +Lcbarlabel = ['kg/kg']*len(Lplot) +Lxlab = ['longitude']*len(Lplot) +Lylab = ['latitude']*len(Lplot) +Lminval = [0]*len(Lplot) +Lmaxval = [0.15E-5]*len(Lplot) +Lstep = [0.05E-6]*len(Lplot) +Lstepticks = [0.2E-6]*len(Lplot) +Lcolormap = ['gist_rainbow_r']*len(Lplot) +Lprojection = [ccrs.PlateCarree()]*len(Lplot) +LaddWhite = [True]*len(Lplot) +Llevel = [0]*len(Lplot) +Ltime = [Dvar['f7']['date'], Dvar['f8']['date'], Dvar['f9']['date'], Dvar['f10']['date'], Dvar['f11']['date'], Dvar['f12']['date']] +Lcbformatlabel=[True]*len(Lplot) +fig = Panel.psectionH(lon=lon, lat=lat, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, + Ltime=Ltime, LaddWhite_cm=LaddWhite, Lproj=Lprojection, Llevel=Llevel, Lcbformatlabel=Lcbformatlabel) + +Lplot1 = [ Dvar['f7']['UT'], Dvar['f8']['UT'], Dvar['f9']['UT'], Dvar['f10']['UT'], Dvar['f11']['UT'], Dvar['f12']['UT']] +Lplot2 = [ Dvar['f7']['VT'], Dvar['f8']['VT'], Dvar['f9']['VT'], Dvar['f10']['VT'], Dvar['f11']['VT'], Dvar['f12']['VT']] +Ltitle = ['wind vectors at K=2']*len(Lplot) +Llegendval = [7.5]*len(Lplot) +Lcbarlabel = ['(m/s)']*len(Lplot1) +Larrowstep = [4]*len(Lplot1) +Lwidth = [0.002]*len(Lplot1) +Lcolor = ['black']*len(Lplot1) +Lscale = [75]*len(Lplot1) +fig = Panel.pvector(Lxx=lon, Lyy=lat, Llevel=Llevel, Lvar1=Lplot1, Lvar2=Lplot2, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lproj=Lprojection, Lid_overlap=[0,2,4,6,8,10], ax=fig.axes, Lscale=Lscale) + +# Departements francais +departements_shp='departements-20180101.shp' +adm1_shapes = list(shpreader.Reader(departements_shp).geometries()) + +# Add departements to each axes + scatter point of emission source +loncar, latcar = [1.439,1.5], [43.567, 43.9] +label=['AZF1','AZF2'] +for i in range(len(Lplot)): + fig.axes[i*2].add_geometries(adm1_shapes, ccrs.PlateCarree(),edgecolor='black', facecolor='white', alpha=0.2) + fig.axes[i*2].scatter(loncar,latcar) + for lab, txt in enumerate(label): + fig.axes[i*2].annotate(label[lab], (loncar[lab], latcar[lab]), color='black',size=10, weight="bold") + +fig.tight_layout() +Panel.save_graph(5,fig) + +################################################################ +######### PANEL 6 +############################################################### +Panel = PanelPlot(2,3, [25,14],'Domaine 2 ATC 001', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=18) +Lplot = [Dvar['f7']['ATC001'], Dvar['f8']['ATC001'], Dvar['f9']['ATC001'], + Dvar['f10']['ATC001'], Dvar['f11']['ATC001'], Dvar['f12']['ATC001']] +Ltitle = ['ATC001']*len(Lplot) +Lcbarlabel = ['$m^{-3}$']*len(Lplot) +Lminval = [0]*len(Lplot) +Lmaxval = [0.6E-6]*len(Lplot) +Lstep = [0.01E-6]*len(Lplot) +Lstepticks = [0.1E-6]*len(Lplot) +fig = Panel.psectionH(lon=lon, lat=lat, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, + Ltime=Ltime, LaddWhite_cm=LaddWhite, Lproj=Lprojection, Llevel=Llevel, Lcbformatlabel=Lcbformatlabel) + +# Add departements to each axes + scatter point of emission source +for i in range(len(Lplot)): + fig.axes[i*2].add_geometries(adm1_shapes, ccrs.PlateCarree(),edgecolor='black', facecolor='white', alpha=0.2) + fig.axes[i*2].scatter(loncar,latcar) + for lab, txt in enumerate(label): + fig.axes[i*2].annotate(label[lab], (loncar[lab], latcar[lab]), color='black',size=10, weight="bold") + +fig.tight_layout() +Panel.save_graph(6,fig) + +################################################################ +######### PANEL 7 +############################################################### +Panel = PanelPlot(8,2, [14,20],'Time series from Aircraft', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=18) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'ZS')]] +Ltime = [Dvar['f13'][(LG_AVION,'time_flyer')]/3600.0] +Ltitle = ['Orography'] +Lxlab = ['Time (h)'] +Lylab = ['ZS (m)'] +Lylim = [(0, 350)] +Lxlim = [(9.0, 9.2)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'P')]] +Ltitle = ['Pressure'] +Lylab = ['P (Pa)'] +Lylim = [(0, 95000)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'LON')]] +Ltitle = ['Longitude'] +Lylab = ['Longitude'] +Lylim = [(0, 2.5)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'ZON_WIND')]] +Ltitle = ['Zonal wind'] +Lylab = ['u (m/s)'] +Lylim = [(-1, 11)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'MER_WIND')]] +Ltitle = ['Meridional wind'] +Lylab = ['v (m/s)'] +Lylim = [(-3, 3)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'W')]] +Ltitle = ['Vertical velocity'] +Lylab = ['w (m/s)'] +Lylim = [(-0.1, 0.1)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'Th')]] +Ltitle = ['Potential Temperature'] +Lylab = [r'$\theta$ (K)'] +Lylim = [(290, 305)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'Rv')]] +Ltitle = ['Water vapor mixing ratio'] +Lylab = ['Rv (kg/kg))'] +Lylim = [(0, 0.01)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'Tke')]] +Ltitle = ['Turbulent Kinetic Energy'] +Lylab = ['TKE ($m^2s^{-2}$)'] +Lylim = [(0, 0.1)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'Tke_Diss')]] +Ltitle = ['Turbulent Kinetic Energy Dissipation'] +Lylab = ['TKE Diss ($m^2s^{-2}$'] +Lylim = [(0, 1000)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'H_FLUX')]] +Ltitle = ['Sensible Heat Flux H'] +Lylab = ['H ($W/m^2$)'] +Lylim = [(-0.7, 0.)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'LE_FLUX')]] +Ltitle = ['Latent Heat Flux LE'] +Lylab = ['LE ($W/m^2$)'] +Lylim = [(0, 2.0)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +Lplot = [ Dvar['f13'][(LG_AVIONT,'Tsrad')]] +Ltitle = ['Radiative surface temperature'] +Lylab = ['Tsrad (K))'] +Lylim = [(250, 1000)] +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Lxlim=Lxlim, ax=fig.axes) + +fig.tight_layout() +Panel.save_graph(7,fig) +```` diff --git a/gallery/view/sectionH_OCEAN.md b/gallery/view/sectionH_OCEAN.md new file mode 100644 index 0000000..7389eef --- /dev/null +++ b/gallery/view/sectionH_OCEAN.md @@ -0,0 +1,65 @@ +## Plot 2 + +![sectionH_OCEAN.png](../figures/sectionH_OCEAN.png) + +````python +#!/usr/bin/env python3 +""" +@author: Quentin Rodier +Creation : 23/06/2021 + +Last modifications +""" +import matplotlib as mpl +mpl.use('Agg') +from read_MNHfile import read_netcdf +from Panel_Plot import PanelPlot +from misc_functions import * +import cartopy.crs as ccrs +import numpy as np +import os +# +# User's parameter / Namelist +# +path="" +LnameFiles = ['SPWAN.1.25m00.003.nc','SPWAN.2.25m00.003.nc'] + +Dvar_input = {'f1':['WT','TKET','THT','level_w','ni','nj'], + 'f2':['WT','TKET','THT','level_w','ni','nj']} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path=path, removeHALO=False) + +################################################################ +######### PANEL 1 +############################################################### +Panel = PanelPlot(2,3, [25,15],'', titlepad=20, minmaxpad=1.03, timepad=-0.10, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=35, lateralminmaxpad=1.02) + +Lplot = [ Dvar['f1']['WT'] ,Dvar['f1']['TKET'], Dvar['f1']['THT']-273.15, + Dvar['f2']['WT'] ,Dvar['f2']['TKET'], Dvar['f2']['THT']-273.15 ] + +lon = [Dvar['f1']['ni'], Dvar['f1']['ni'], Dvar['f1']['ni'], + Dvar['f2']['ni'], Dvar['f2']['ni'], Dvar['f2']['ni']] +lat = [Dvar['f1']['nj'], Dvar['f1']['nj'], Dvar['f1']['nj'], + Dvar['f2']['nj'], Dvar['f2']['nj'], Dvar['f2']['nj']] +Llevel = [97]*len(Lplot) +Ltitle = ['Vertical velocity D1', 'Subgrid TKE D1', 'Temperature D1','Vertical velocity D2', 'Subgrid TKE D2', 'Temperature D2'] +Lcbarlabel = ['cm/s','m2/s2','°C']*2 +Lxlab = ['X (m)']*len(Lplot) +Lylab = ['Y (m)']*len(Lplot) +Lminval = [-7., 0, 10.31]*2 +Lmaxval = [7., 2E-4, 10.3625]*2 +Lstep = [0.1, 5E-6, 1E-5]*2 +Lstepticks = [1, 2.5E-5, 1E-2]*2 +Lcolormap = ['seismic','gist_rainbow_r','gist_rainbow_r']*2 +Lfacconv = [100.0,1,1]*2 +LaddWhite = [False,True,False]*2 +Lcbformatlabel=[False,True,False]*2 + +fig = Panel.psectionH(lon=lon, lat=lat, Llevel=Llevel, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, + LaddWhite_cm=LaddWhite, Lfacconv=Lfacconv, Lcbformatlabel=Lcbformatlabel) +fig.tight_layout() +Panel.save_graph(1,fig) +```` diff --git a/gallery/view/sectionH_vectors_007janvier_full.md b/gallery/view/sectionH_vectors_007janvier_full.md new file mode 100644 index 0000000..e3808ac --- /dev/null +++ b/gallery/view/sectionH_vectors_007janvier_full.md @@ -0,0 +1,118 @@ +## Plot 2 + +![sectionH_vectors_007janvier_full.png](../figures/sectionH_vectors_007janvier_full.png) + +````python +#!/usr/bin/env python3 +""" +@author: Quentin Rodier +Creation : 07/01/2021 + +Last modifications +""" +import matplotlib as mpl +mpl.use('Agg') +import cartopy.crs as ccrs +from read_MNHfile import read_netcdf +from Panel_Plot import PanelPlot +import os + +os.system('rm -f tempgraph*') +# +# User's parameter / Namelist +# +# +path="" +LnameFiles = ['16JAN.1.12B18.001dg.nc', '16JAN.2.12B18.001dg.nc'] + +Dvar_input = { +'f1':['MRV700HPA','THT850HPA','UT850HPA','VT850HPA','UT700HPA','VT700HPA', 'ALT_PRESSURE','ALT_U','ALT_V', 'ZS', 'latitude', 'longitude'], +'f2':['MRV700HPA','THT850HPA','UT850HPA','VT850HPA','UT700HPA','VT700HPA', 'ALT_PRESSURE', 'ZS', 'ALT_U','ALT_V','latitude', 'longitude'] +} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path=path, removeHALO=True) + +################################################################ +######### PANEL 1 +############################################################### +Panel1 = PanelPlot(2,2, [20,20],'007_janvier domaine 1 16JAN.1.12B18.001dg.nc', minmaxpad=1.05) + +Lplot = [ Dvar['f1']['ZS'],Dvar['f1']['THT850HPA'], Dvar['f1']['MRV700HPA'],Dvar['f1']['ALT_PRESSURE']] +lon = [Dvar['f1']['longitude']]*len(Lplot) +lat = [Dvar['f1']['latitude']]*len(Lplot) +Ltitle = ['Orography', 'Potential Temperature at 850hPa', 'Water vapor mixing at 700hPa','Pressure at z = 9000m'] +Lcbarlabel = ['m','K', 'g/kg', 'hPa'] +Lxlab = ['longitude']*len(Lplot) +Lylab = ['latitude']*len(Lplot) +Lminval = [0, 285, 0.9, 286] +Lmaxval = [300, 289, 2.6, 294] +Lstep = [10, 0.25, 0.1, 0.4] +Lstepticks = [50, 1, 0.2, 0.4] +Lfacconv = [1.0, 1.0, 1.0, 1./100.0] +Lcolormap = ['terrain', 'gist_rainbow_r', 'gist_rainbow_r', 'gist_rainbow_r'] +Lprojection = [ccrs.PlateCarree()]*len(Lplot) +Llvl = [0, 0, 0, 0] +fig1 = Panel1.psectionH(lon=lon, lat=lat, Lvar=Lplot, Lcarte=[], Llevel=Llvl, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lproj=Lprojection, Lfacconv=Lfacconv) + +Lplot1 = [ Dvar['f1']['UT850HPA'], Dvar['f1']['UT700HPA'], Dvar['f1']['ALT_U']] +Lplot2 = [ Dvar['f1']['VT850HPA'], Dvar['f1']['VT700HPA'], Dvar['f1']['ALT_V']] +Ltitle = ['Wind at 850hPa', 'Wind at 700hPa', 'Wind at 9000m'] +Lxlab = ['longitude']*len(Lplot1) +Lylab = ['latitude']*len(Lplot1) +Llegendval = [20,20,40] +Lcbarlabel = ['(m/s)']*len(Lplot1) +Larrowstep = [2]*len(Lplot1) +Lwidth = [0.002]*len(Lplot1) +Lcolor = ['black']*len(Lplot1) +Lprojection = [ccrs.PlateCarree()]*len(Lplot1) +Llvl = [0]*len(Lplot1) +fig2 = Panel1.pvector(Lxx=lon, Lyy=lat, Lvar1=Lplot1, Lvar2=Lplot2, Lcarte=[], Llevel=Llvl, Lxlab=Lxlab, Lylab=Lylab, + Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, Lproj=Lprojection, + Lcolor=Lcolor, Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lid_overlap=[2,4,6], ax=fig1.axes) + +Panel1.save_graph(1,fig2) + +################################################################ +######### PANEL 2 +############################################################### +Panel2 = PanelPlot(2,2, [20,20],'007_janvier domaine 2 16JAN.1.12B18.001dg.nc', minmaxpad=1.05) + +Lplot = [ Dvar['f2']['ZS'],Dvar['f2']['THT850HPA'], Dvar['f2']['MRV700HPA'],Dvar['f2']['ALT_PRESSURE']] +lon = [Dvar['f2']['longitude']]*len(Lplot) +lat = [Dvar['f2']['latitude']]*len(Lplot) +Ltitle = ['Orography', 'Potential Temperature at 850hPa', 'Water vapor mixing at 700hPa','Pressure at z = 9000m'] +Lcbarlabel = ['m','K', 'g/kg', 'hPa'] +Lxlab = ['longitude']*len(Lplot) +Lylab = ['latitude']*len(Lplot) +Lminval = [0, 285, 0.9, 286] +Lmaxval = [300, 289, 2.6, 294] +Lstep = [10, 0.25, 0.1, 0.4] +Lstepticks = [50, 1, 0.2, 0.4] +Lfacconv = [1.0, 1.0, 1.0, 1./100.0] +Lcolormap = ['terrain', 'gist_rainbow_r', 'gist_rainbow_r', 'gist_rainbow_r'] +Lprojection = [ccrs.PlateCarree()]*len(Lplot) +Llvl = [0]*len(Lplot) +fig1 = Panel2.psectionH(lon=lon, lat=lat, Lvar=Lplot, Lcarte=[], Llevel=Llvl, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lproj=Lprojection, Lfacconv=Lfacconv) + +Lplot1 = [ Dvar['f2']['UT850HPA'], Dvar['f2']['UT700HPA'], Dvar['f2']['ALT_U']] +Lplot2 = [ Dvar['f2']['VT850HPA'], Dvar['f2']['VT700HPA'], Dvar['f2']['ALT_V']] +Ltitle = ['Wind at 850hPa', 'Wind at 700hPa', 'Wind at 9000m'] +Llegendval = [20,20,40] +Lxlab = ['longitude']*len(Lplot1) +Lylab = ['latitude']*len(Lplot1) +Lcbarlabel = ['(m/s)']*len(Lplot1) +Larrowstep = [2]*len(Lplot1) +Lwidth = [0.002]*len(Lplot1) +Lcolor = ['black']*len(Lplot1) +Lprojection = [ccrs.PlateCarree()]*len(Lplot1) +Llvl = [0]*len(Lplot1) +fig2 = Panel2.pvector(Lxx=lon, Lyy=lat, Lvar1=Lplot1, Lvar2=Lplot2, Lcarte=[], Llevel=Llvl, Lxlab=Lxlab, Lylab=Lylab, + Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, Lproj=Lprojection, + Lcolor=Lcolor, Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lid_overlap=[2,4,6], ax=fig1.axes) + +Panel2.save_graph(2,fig2) +```` diff --git a/gallery/view/sectionV_KW78_full.md b/gallery/view/sectionV_KW78_full.md new file mode 100644 index 0000000..ff604ce --- /dev/null +++ b/gallery/view/sectionV_KW78_full.md @@ -0,0 +1,235 @@ +## Plot 2 + +![sectionV_KW78_full.png](../figures/sectionV_KW78_full.png) + +````python +#!/usr/bin/env python3 +""" + +@author: Quentin Rodier +Creation : 07/01/2021 + +Last modifications +""" + +import matplotlib as mpl +mpl.use('Agg') +from read_MNHfile import read_netcdf +from Panel_Plot import PanelPlot +from misc_functions import comp_altitude2DVar, oblique_proj, windvec_verti_proj, mean_operator +import math +import os + +os.system('rm -f tempgraph*') +# +# User's parameter / Namelist +# +path="" + +LnameFiles = ['KWRAI.1.SEG01.004.nc','KWRAI.1.SEG01.004dia.nc' ] + +Dvar_input = { +'f1':['ZS', 'UT','VT', 'WT','THT', + 'ni_u','nj_u','level','ZTOP', 'ni','nj','level_w','time', + 'INPRR','ACPRR','PABST','RCT','RVT','RRT','LSTHM'], +'f2':['ALT_CLOUD', 'ALT_U', 'ALT_V', 'ni','nj']} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path=path, removeHALO=True) + +################################################################ +######### PANEL 1 +############################################################### +Panel1 = PanelPlot(2,3, [25,14],'', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.01) + +Lplot = [ Dvar['f1']['INPRR'], Dvar['f1']['ACPRR'], Dvar['f1']['PABST'],Dvar['f2']['ALT_CLOUD'],Dvar['f2']['ALT_CLOUD'] ] + +LaxeX = [Dvar['f1']['ni']]*len(Lplot) +LaxeY = [Dvar['f1']['nj']]*len(Lplot) +Ltitle = ['Instantaneous precipitation INPRR', 'Accumulated precipitation ACPRR','Absolute pressure','Mixing ratio of liquid droplets at z=3000m','Mixing ratio of liquid droplets at z=5000m' ] +Lcbarlabel = ['mm/h', 'mm','hPa','g/kg','g/kg'] +Lxlab = ['x (m)']*len(Lplot) +Lylab = ['y (m)']*len(Lplot) +Lminval = [0, 0, 982.25, 0, 0] +Lmaxval = [6.25, 0.15, 983.55, 3.0, 3.0] +Lstep = [0.25, 0.005, 0.05, 0.05, 0.05] +Lstepticks = [0.5, 0.02, 0.2, 0.5, 0.5] +Lfacconv = [1, 1, 1./100.0,1,1] +Lcolormap = ['gist_ncar_r']*len(Lplot) +Llvl = [0,0,0,0,1] +Ltime = [Dvar['f1']['time']]*len(Lplot) +LaddWhite = [True]*len(Lplot) +Lpltype = ['cf']*len(Lplot) + +fig1 = Panel1.psectionH(lon=LaxeX, lat=LaxeY, Lvar=Lplot, Llevel=Llvl, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + Ltime=Ltime, LaddWhite_cm=LaddWhite) +fig1.tight_layout() + +# Wind vectors +Lplot1 = [ Dvar['f1']['UT'], Dvar['f2']['ALT_U'], Dvar['f2']['ALT_U']] +Lplot2 = [ Dvar['f1']['VT'], Dvar['f2']['ALT_V'], Dvar['f2']['ALT_V']] +Ltitle = ['Wind at K=2', 'Wind at 3000m', 'Wind at 5000m'] +Lxlab = ['x (m)']*len(Lplot) +Lylab = ['y (m)']*len(Lplot) +Llegendval = [10,10,10] +Lcbarlabel = ['m/s']*len(Lplot) +Larrowstep = [1]*len(Lplot) +Lwidth = [0.002]*len(Lplot) +Lcolor = ['black']*len(Lplot) +Llvl = [0,0,1] +lon = [Dvar['f1']['ni_u'], Dvar['f2']['ni'], Dvar['f2']['ni'] ] +lat = [Dvar['f1']['nj_u'], Dvar['f2']['nj'], Dvar['f2']['nj'] ] +Lscale = [200]*len(Lplot) +fig2 = Panel1.pvector(Lxx=lon, Lyy=lat, Lvar1=Lplot1, Lvar2=Lplot2, Lcarte=[500,23500,500,23500], Llevel=Llvl, + Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Lcolor=Lcolor, Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lid_overlap=[4,6,8], ax=fig1.axes, Lscale=Lscale) +# Oblique projection +i_beg, j_beg = (3,0) +i_end, j_end = (22,21) +# Black line +Panel1.addLine(fig2.axes[6],[Dvar['f1']['ni'][i_beg],Dvar['f1']['nj'][j_beg]],[Dvar['f1']['ni'][i_end],Dvar['f1']['nj'][j_end]],'black',2) +Panel1.save_graph(1,fig2) + +################################################################ +######### PANEL 2 : Oblique projection +############################################################### +Panel2 = PanelPlot(2,2, [17,17],'Oblique section (angle = 47)', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.01, lateralminmaxpad=0.97) + +Dvar['f1']['THT-LSTHM'] = Dvar['f1']['THT'] - Dvar['f1']['LSTHM'] + +tomass = mean_operator() +Dvar['f1']['UM'] = tomass.MXM(Dvar['f1']['UT']) +Dvar['f1']['VM'] = tomass.MYM(Dvar['f1']['VT']) +Dvar['f1']['WM'] = tomass.MZM(Dvar['f1']['WT']) + + +angle_sec1, RVT_sec1, axe_m1 = oblique_proj(Dvar['f1']['RVT'], Dvar['f1']['ni'], Dvar['f1']['nj'], Dvar['f1']['level'], i_beg, j_beg, i_end, j_end) +WIND_proj = windvec_verti_proj(Dvar['f1']['UM'], Dvar['f1']['VM'], Dvar['f1']['level'], angle_sec1) +angle_sec1, WIND_sec1, axe_m1 = oblique_proj(WIND_proj, Dvar['f1']['ni'], Dvar['f1']['nj'], Dvar['f1']['level'], i_beg, j_beg, i_end, j_end) +angle_sec1, WT_sec1, axe_m1 = oblique_proj(Dvar['f1']['WM'], Dvar['f1']['ni'], Dvar['f1']['nj'], Dvar['f1']['level'], i_beg, j_beg, i_end, j_end) +angle_sec1, RCT_sec1, axe_m1 = oblique_proj(Dvar['f1']['RCT'], Dvar['f1']['ni'], Dvar['f1']['nj'], Dvar['f1']['level'], i_beg, j_beg, i_end, j_end) +angle_sec1, RRT_sec1, axe_m1 = oblique_proj(Dvar['f1']['RRT'], Dvar['f1']['ni'], Dvar['f1']['nj'], Dvar['f1']['level'], i_beg, j_beg, i_end, j_end) +angle_sec1, anoTHT_sec1, axe_m1 = oblique_proj(Dvar['f1']['THT-LSTHM'], Dvar['f1']['ni'], Dvar['f1']['nj'], Dvar['f1']['level'], i_beg, j_beg, i_end, j_end) + +Lplot = [RVT_sec1, RCT_sec1, anoTHT_sec1, WT_sec1] +LaxeX = [axe_m1]*len(Lplot) +LaxeZ = [Dvar['f1']['level'], Dvar['f1']['level'], Dvar['f1']['level'],Dvar['f1']['level_w']] +Ltitle = ['Water vapor mixing ratio', 'Liquid cloud mxing ratio', 'Potential temperature anomaly', 'Vertical velocity'] +Lcbarlabel = ['g/kg','g/kg', 'K', 'm/s'] +Lxlab = ['distance (m)']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lminval = [0., 0., -5, -18] +Lmaxval = [15, 3.0, 5, 18] +Lstep = [0.5, 0.05, 0.2, 0.5] +Lstepticks = [1, 0.2, 1, 2.5] +Lfacconv = [1000, 1000, 1, 1] +Lcolormap = ['gist_rainbow_r','gist_rainbow_r', 'seismic','seismic'] +Ltime = [Dvar['f1']['time']]*len(Lplot) +Lpltype = ['cf']*len(Lplot) +LaddWhite = [True, True, False, False] + +fig3 = Panel2.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + Ltime=Ltime, Lpltype=Lpltype, LaddWhite_cm=LaddWhite) + +Lplot1 = [ WIND_sec1] +Lplot2 = [ WT_sec1] +Ltitle = ['Wind'] +Llegendval = [25] +Lcbarlabel = ['m/s']*len(Lplot) +Larrowstep = [1]*len(Lplot) +Lwidth = [0.004]*len(Lplot) +Lscale = [200]*len(Lplot) + +fig4 = Panel2.pvector(Lxx=LaxeX, Lyy=LaxeZ, Lvar1=Lplot1, Lvar2=Lplot2, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lid_overlap=[0], ax=fig3.axes, Lscale=Lscale) + +Lplot = [RRT_sec1] +LaxeX = [axe_m1] +LaxeZ = [Dvar['f1']['level']] +Ltitle = ['precipitation'] +Lcbarlabel = ['g/kg']*len(Lplot) +Lxlab = ['distance (m)']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,10000.1)]*len(Lplot) +Lminval = [0.] +Lmaxval = [3.5] +Lstep = [0.5] +Lstepticks = [0.5] +Lfacconv = [1000]*len(Lplot) +LcolorLine = ['black']*len(Lplot) +Llvl = [0]*len(Lplot) +Ltime = [Dvar['f1']['time']] +Lpltype = ['c']*len(Lplot) +LaddWhite = [True]*len(Lplot) + +fig5 = Panel2.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, LcolorLine=LcolorLine, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + Ltime=Ltime, Lpltype=Lpltype, LaddWhite_cm=LaddWhite, ax=fig4.axes,Lid_overlap=[2],colorbar=False) + +Panel2.save_graph(2,fig5) +################################################################ +######### PANEL 3 +############################################################### +Panel3 = PanelPlot(2,2, [17,17],'Vertical section along y at I=14', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.01, lateralminmaxpad=0.97) + +Lplot = [Dvar['f1']['RVT'][:,:,13], Dvar['f1']['RCT'][:,:,13], Dvar['f1']['THT-LSTHM'][:,:,13], Dvar['f1']['WT'][:,:,13]] +LaxeX = [Dvar['f1']['nj']]*len(Lplot) +LaxeZ = [Dvar['f1']['level'], Dvar['f1']['level'], Dvar['f1']['level'],Dvar['f1']['level_w']] +Ltitle = ['Water vapor mixing ratio', 'Liquid cloud mxing ratio', 'Potential temperature anomaly', 'Vertical velocity'] +Lcbarlabel = ['g/kg','g/kg', 'K', 'm/s'] +Lxlab = ['distance (m)']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lminval = [0., 0., -5, -18] +Lmaxval = [15, 3.0, 5, 18] +Lstep = [0.5, 0.05, 0.2, 0.5] +Lstepticks = [1, 0.2, 1, 2.5] +Lfacconv = [1000, 1000, 1, 1] +Lcolormap = ['gist_rainbow_r','gist_rainbow_r', 'seismic','seismic'] +Ltime = [Dvar['f1']['time']]*len(Lplot) +Lpltype = ['cf']*len(Lplot) +LaddWhite = [True, True, False, False] + +fig6 = Panel3.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + Ltime=Ltime, Lpltype=Lpltype, LaddWhite_cm=LaddWhite) + +Lplot1 = [ Dvar['f1']['VM'][:,:,13]] +Lplot2 = [ Dvar['f1']['WM'][:,:,13]] +Ltitle = ['Wind'] +Llegendval = [25] +Lcbarlabel = ['m/s']*len(Lplot) +Larrowstep = [1]*len(Lplot) +Lwidth = [0.004]*len(Lplot) +Lscale = [200]*len(Lplot) + +fig7 = Panel3.pvector(Lxx=LaxeX, Lyy=LaxeZ, Lvar1=Lplot1, Lvar2=Lplot2, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lid_overlap=[0], ax=fig6.axes, Lscale=Lscale) + + +Lplot = [Dvar['f1']['RRT'][:,:,13]] +Ltitle = ['precipitation'] +Lcbarlabel = ['g/kg']*len(Lplot) +Lxlab = ['distance (m)']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,10000.1)]*len(Lplot) +Lminval = [0.] +Lmaxval = [3.5] +Lstep = [0.5] +Lstepticks = [0.5] +Lfacconv = [1000]*len(Lplot) +LcolorLine = ['black']*len(Lplot) +Llvl = [0]*len(Lplot) +Ltime = [Dvar['f1']['time']] +Lpltype = ['c']*len(Lplot) +LaddWhite = [True]*len(Lplot) + +fig8 = Panel3.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, LcolorLine=LcolorLine, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + Ltime=Ltime, Lpltype=Lpltype, LaddWhite_cm=LaddWhite, ax=fig7.axes,Lid_overlap=[2],colorbar=False) + + +Panel3.save_graph(3,fig8) +```` diff --git a/gallery/view/sectionV_Reunion_full.md b/gallery/view/sectionV_Reunion_full.md new file mode 100644 index 0000000..cd28da6 --- /dev/null +++ b/gallery/view/sectionV_Reunion_full.md @@ -0,0 +1,282 @@ +## Plot 2 + +![sectionV_Reunion_full.png](../figures/sectionV_Reunion_full.png) + +````python +#!/usr/bin/env python3 +""" + +@author: Quentin Rodier +Creation : 07/01/2021 + +Last modifications +""" + +import matplotlib as mpl +mpl.use('Agg') +from read_MNHfile import read_netcdf +from Panel_Plot import PanelPlot +from misc_functions import comp_altitude2DVar, windvec_verti_proj, mean_operator +import cartopy.crs as ccrs +import numpy as np +import math +import copy +import os + +os.system('rm -f tempgraph*') +# +# User's parameter / Namelist +# +path="" +LnameFiles = ['REUNI.1.CEN4T.004dia.nc', 'REUNI.1.CEN4T.004.nc','REUNI.1.CEN4T.000.nc'] +LG_TGLOB = '/Time_series/TSERIES/GLOB/' +LG_TLAND = '/Time_series/TSERIES/LAND' +LG_TSEA = '/Time_series/TSERIES/SEA/' +LG_ZTGLOB = '/Time_series/ZTSERIES/GLOB/' +LG_ZTLAND = '/Time_series/ZTSERIES/LAND/' +LG_ZTSEA = '/Time_series/ZTSERIES/SEA/' +LG_XTSERIES01='/Time_series/XTSERIES01/' + +Dvar_input = { +'f1':['ZS', 'UT', 'VT', 'WT', 'THT', 'ALT_PRESSURE','ALT_U','ALT_V','ALT_THETA','level','ZTOP', 'longitude','latitude','level_w','time'], +'f2':['LSTHM', 'LSVM'], +'f3':[(LG_TGLOB,'RVT_GLOB'), (LG_TLAND,'RVT_LAND'), (LG_TSEA,'RVT_SEA'), + (LG_ZTGLOB,'WT_GLOB'),(LG_ZTGLOB,'THT_GLOB'),(LG_ZTGLOB,'PABST_GLOB'),(LG_ZTGLOB,'RVT_GLOB'), + (LG_ZTLAND,'WT_LAND'),(LG_ZTLAND,'THT_LAND'),(LG_ZTLAND,'PABST_LAND'),(LG_ZTLAND,'RVT_LAND'), + (LG_ZTSEA,'WT_SEA'),(LG_ZTSEA,'THT_SEA'),(LG_ZTSEA,'PABST_SEA'),(LG_ZTSEA,'RVT_SEA'), + (LG_XTSERIES01,'UCLS002Y029_034'),(LG_XTSERIES01,'WCLA001Y029_034'),(LG_XTSERIES01,'W011_017Y029_034'), + (LG_XTSERIES01,'RVCLS002Y029_034'),(LG_XTSERIES01,'RVMID013Y029_034'), + 'time_series','series_level_w','series_level','ni','ni_u' ] +} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path=path, removeHALO=True) + +################################################################ +######### PANEL 1 # Horizontal cross-section +############################################################### +Panel1 = PanelPlot(2,2, [20,20],'004_Reunion horizontal sections') + +Dvar['f1']['WIND'] = np.sqrt(Dvar['f1']['UT']**2 + Dvar['f1']['VT']**2) +Lplot = [ Dvar['f1']['ZS'][:,:], Dvar['f1']['WIND'][0,:,:], Dvar['f1']['ALT_THETA'][:,:], Dvar['f1']['ALT_PRESSURE'][:,:]] + +LaxeX = [Dvar['f1']['longitude']]*len(Lplot) +LaxeY = [Dvar['f1']['latitude']]*len(Lplot) +Ltitle = ['Orography', 'Wind speed ','Potential temperature at z = 1500m', 'Pressure'] +Lcbarlabel = ['m', 'm/s','K','hPa'] +Lxlab = ['longitude']*len(Lplot) +Lylab = ['latitude']*len(Lplot) +Lminval = [0, 0, 299.5, 831] +Lmaxval = [3000, 26, 308, 838] +Lstep = [50,1, 0.1, 0.25, 0.1] +Lstepticks = [500, 2,1,0.5] +Lfacconv = [1, 1, 1, 1./100.] +Lcolormap = ['gist_rainbow_r']*len(Lplot) +Ltime = [Dvar['f1']['time']]*len(Lplot) +Lpltype = ['cf']*len(Lplot) +LaddWhite_cm = [True, False, False, False] +Lprojection = [ccrs.PlateCarree()]*len(Lplot) + +fig1 = Panel1.psectionH(lon=LaxeX, lat=LaxeY, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + colorbar=True, Ltime=Ltime, LaddWhite_cm=LaddWhite_cm, Lproj=Lprojection) + +Lplot1 = [ Dvar['f1']['UT'], Dvar['f1']['ALT_U']] +Lplot2 = [ Dvar['f1']['VT'], Dvar['f1']['ALT_V']] +Ltitle = ['wind vectors at K=2', 'wind vectors at z = 1500m '] +Lxlab = ['longitude']*len(Lplot1) +Lylab = ['latitude']*len(Lplot1) +Llegendval = [25,25] +Lcbarlabel = ['(m/s)']*len(Lplot1) +Larrowstep = [4]*len(Lplot1) +Lwidth = [0.003]*len(Lplot1) +Lcolor = ['black']*len(Lplot1) +Lprojection = [ccrs.PlateCarree()]*len(Lplot1) +Llvl = [0]*len(Lplot1) +Lscale = [400]*len(Lplot1) +fig2 = Panel1.pvector(Lxx=LaxeX, Lyy=LaxeY, Llevel=Llvl, Lvar1=Lplot1, Lvar2=Lplot2, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lproj=Lprojection, Lid_overlap=[2,6], ax=fig1.axes, Lscale=Lscale) + +################################################################ +######### PANEL 2 # Vertical cross-section +############################################################### +# Compute wind into mass point +tomass = mean_operator() +Dvar['f1']['WM'] = tomass.MZM(Dvar['f1']['WT']) +Dvar['f1']['VM'] = tomass.MYM(Dvar['f1']['VT']) + +Panel2 = PanelPlot(2,2, [20,20],'004_Reunion vertical sections at i=35') +i_slice = 33 + +# Black line +Panel1.addLine(fig2.axes[0],[Dvar['f1']['longitude'][0,i_slice],Dvar['f1']['latitude'][0,i_slice]],[Dvar['f1']['longitude'][-1,i_slice],Dvar['f1']['latitude'][-1,i_slice]],'black',3) +Panel1.save_graph(1,fig2) + +# Compute altitude variable in 3D with a 2D topography +Dvar['f1']['altitude'] , Dvar['f1']['nx_3D'], Dvar['f1']['ny_3D'] = comp_altitude2DVar(Dvar['f2']['LSTHM'], Dvar['f1']['ZS'],Dvar['f1']['ZTOP'], Dvar['f1']['level'], Dvar['f1']['latitude'], Dvar['f1']['longitude']) +Dvar['f1']['altitude_w'], Dvar['f1']['nx_3D'], Dvar['f1']['ny_3D'] = comp_altitude2DVar(Dvar['f1']['WM'], Dvar['f1']['ZS'],Dvar['f1']['ZTOP'], Dvar['f1']['level_w'], Dvar['f1']['latitude'], Dvar['f1']['longitude']) +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) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,16000)]*len(Lplot) +Lminval = [300, -6.5, -12.5, -9.75] +Lmaxval = [355, 6.5, 12.5, 9.75] +Lstep = [2.5, 0.2, 1, 0.5] +Lstepticks = Lstep +Lcolormap=['gist_rainbow_r','seismic','seismic','seismic'] +orog = Dvar['f1']['ZS'][:,i_slice] + +fig3 = Panel2.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, Lylim=Lylim, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, + orog=orog, colorbar=True, Ltime=Ltime) + +# Wind vector on last panel +Lplot1 = [ Dvar['f1']['VM'][:,:,i_slice]] +Lplot2 = [ Dvar['f1']['WM'][:,:,i_slice]] +Ltitle = ['Wind'] +Llegendval = [15] +Lcbarlabel = ['m/s']*len(Lplot) +Lxlab = ['longitude']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Larrowstep = [1]*len(Lplot) +Lwidth = [0.002]*len(Lplot) +Lscale = [800]*len(Lplot) +Lylim=[(0,3000)] +Lxlim = [(-21.3,-20.9)]*len(Lplot) +Lcolor=['lightgray'] + +fig4 = Panel2.pvector(Lxx=LaxeX, Lyy=LaxeZ, Lvar1=Lplot1, Lvar2=Lplot2, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lwidth=Lwidth, Larrowstep=Larrowstep, + Llegendval=Llegendval, Lcbarlabel=Lcbarlabel, Lid_overlap=[6], ax=fig3.axes, Lscale=Lscale, Lylim=Lylim, Lxlim=Lxlim, Lcolor=Lcolor) + +Panel2.save_graph(2,fig4) +################################################################ +######### PANEL 3 # TSERIES +############################################################### + +Panel = PanelPlot(1,1, [20,20],'TSERIES', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=40) +Lplot = [ Dvar['f3'][(LG_TGLOB,'RVT_GLOB')], Dvar['f3'][(LG_TLAND,'RVT_LAND')], Dvar['f3'][(LG_TSEA,'RVT_SEA')]] +Ltime = [Dvar['f3']['time_series']]*len(Lplot) +Ltitle = ['RVT time series']*len(Lplot) +Llinelabel = ['RVT_GLOB','RVT_LAND','RVT_SEA'] +Lxlab = ['time (s)']*len(Lplot) +Lylab = ['RVT']*len(Lplot) +Lylim = [(0,0.4)]*len(Lplot) +Llinecolor = ['black','r','blue'] +LaxisColor = ['black']*len(Lplot) +fig = Panel.pXY_lines(Lyy=Lplot, Lxx=Ltime, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lylim=Lylim, Llinelabel=Llinelabel, + Llinecolor=Llinecolor, LaxisColor=LaxisColor) +Panel.save_graph(3, fig) + +################################################################ +######### PANEL 4 # ZTSERIES GLOB +############################################################### + +Panel = PanelPlot(2,2, [20,20],'ZTSERIES GLOB', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=40) +Lplot = [ Dvar['f3'][(LG_ZTGLOB,'WT_GLOB')],Dvar['f3'][(LG_ZTGLOB,'THT_GLOB')], Dvar['f3'][(LG_ZTGLOB,'PABST_GLOB')], + Dvar['f3'][(LG_ZTGLOB,'RVT_GLOB')]] +Ltitle = ['WT_GLOB','THT_GLOB','PABST_GLOB','RVT_GLOB'] +LaxeZ = [Dvar['f3']['series_level_w'], Dvar['f3']['series_level'], Dvar['f3']['series_level'], Dvar['f3']['series_level'] ] +LaxeX = [Dvar['f3']['time_series']]*len(Lplot) +Lcbarlabel = ['m/s', 'K','hPa', 'g/kg'] +Lxlab = ['time (s']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,16200)]*len(Lplot) +Lminval = [-0.85, 300, 50, 0.] +Lmaxval = [0.85, 352.5, 1000, 1.2] +Lstep = [0.1,2.5,50, 0.05 ] +Lstepticks = Lstep +Lcolormap=['seismic','gist_rainbow_r','gist_rainbow_r','gist_rainbow_r'] +Lfacconv = [1,1,0.01,1000] +LaddWhite=[False,False,False,True] +fig = Panel.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, Lylim=Lylim, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel,Lfacconv=Lfacconv,LaddWhite_cm=LaddWhite, + colorbar=True) +Panel.save_graph(4, fig) + +################################################################ +######### PANEL # ZTSERIES LAND +############################################################### +Panel = PanelPlot(2,2, [20,20],'ZTSERIES LAND', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=40) +Lplot = [ Dvar['f3'][(LG_ZTLAND,'WT_LAND')],Dvar['f3'][(LG_ZTLAND,'THT_LAND')], Dvar['f3'][(LG_ZTLAND,'PABST_LAND')], + Dvar['f3'][(LG_ZTLAND,'RVT_LAND')]] +Ltitle = ['WT_LAND','THT_LAND','PABST_LAND','RVT_LAND'] +LaxeZ = [Dvar['f3']['series_level_w'], Dvar['f3']['series_level'], Dvar['f3']['series_level'], Dvar['f3']['series_level'] ] +LaxeX = [Dvar['f3']['time_series']]*len(Lplot) +Lcbarlabel = ['m/s', 'K','hPa', 'g/kg'] +Lxlab = ['time (s']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,16200)]*len(Lplot) +Lminval = [-1.25, 300, 50, 0.] +Lmaxval = [1.25, 352.5, 1000, 1.2] +Lstep = [0.1,2.5,50, 0.05 ] +Lstepticks = Lstep +Lcolormap=['seismic','gist_rainbow_r','gist_rainbow_r','gist_rainbow_r'] +Lfacconv = [1,1,0.01,1000] +LaddWhite=[False,False,False,True] +fig = Panel.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, Lylim=Lylim, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel,Lfacconv=Lfacconv,LaddWhite_cm=LaddWhite, + colorbar=True) +Panel.save_graph(5, fig) + +################################################################ +######### PANEL # ZTSERIES SEA +############################################################### +Panel = PanelPlot(2,2, [20,20],'ZTSERIES SEA', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=40) +Lplot = [ Dvar['f3'][(LG_ZTSEA,'WT_SEA')], Dvar['f3'][(LG_ZTSEA,'THT_SEA')] , Dvar['f3'][(LG_ZTSEA,'PABST_SEA')] , + Dvar['f3'][(LG_ZTSEA,'RVT_SEA')]] +Ltitle = ['WT_SEA','THT_SEA','PABST_SEA','RVT_SEA'] +LaxeZ = [Dvar['f3']['series_level_w'], Dvar['f3']['series_level'], Dvar['f3']['series_level'], Dvar['f3']['series_level'] ] +LaxeX = [Dvar['f3']['time_series']]*len(Lplot) +Lcbarlabel = ['m/s', 'K','hPa', 'g/kg'] +Lxlab = ['time (s']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,16200)]*len(Lplot) +Lminval = [-0.85, 300, 50, 0.] +Lmaxval = [0.85, 352.5, 1000, 1.2] +Lstep = [0.1,2.5,50, 0.05 ] +Lstepticks = Lstep +Lcolormap=['seismic','gist_rainbow_r','gist_rainbow_r','gist_rainbow_r'] +Lfacconv = [1,1,0.01,1000] +LaddWhite=[False,False,False,True] +fig = Panel.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, Lylim=Lylim, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel,Lfacconv=Lfacconv,LaddWhite_cm=LaddWhite, + colorbar=True) +Panel.save_graph(6, fig) + +################################################################ +######### PANEL # XTSERIES01 +############################################################### + +Panel = PanelPlot(2,3, [25,14],'XTSERIES01', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=40) +Lplot = [ Dvar['f3'][(LG_XTSERIES01,'UCLS002Y029_034')],Dvar['f3'][(LG_XTSERIES01,'WCLA001Y029_034')], + Dvar['f3'][(LG_XTSERIES01,'W011_017Y029_034')], + Dvar['f3'][(LG_XTSERIES01,'RVCLS002Y029_034')], Dvar['f3'][(LG_XTSERIES01,'RVMID013Y029_034')]] + +Ltitle = ['UCLS002Y029_034','WCLA001Y029_034','W011_017Y029_034','RVCLS002Y029_034','RVMID013Y029_034'] +LaxeZ = [Dvar['f3']['ni_u'], Dvar['f3']['ni'], Dvar['f3']['ni'], Dvar['f3']['ni'],Dvar['f3']['ni'] ] +LaxeX = [Dvar['f3']['time_series']]*len(Lplot) +Lcbarlabel = ['m/s', 'm/s','m/s', 'g/kg', 'g/kg'] +Lxlab = ['time (s']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lminval = [-7, -3.25, -3.25, 0., 0.] +Lmaxval = [12, 3.25, 3.25, 1.7, 1.8E-5] +Lstep = [1,0.2 ,0.2, 0.1, 0.1E-5 ] +Lstepticks = Lstep +Lcolormap=['gist_rainbow_r','seismic','seismic','gist_rainbow_r','gist_rainbow_r'] +Lfacconv = [1,1,1,1000, 1000] +LaddWhite=[False,False,False,True,True] +fig = Panel.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel,Lfacconv=Lfacconv,LaddWhite_cm=LaddWhite, + colorbar=True) +Panel.save_graph(7, fig) +```` diff --git a/gallery/view/single_file.md b/gallery/view/single_file.md new file mode 100644 index 0000000..0428914 --- /dev/null +++ b/gallery/view/single_file.md @@ -0,0 +1,18 @@ +## Read single file + +````python +from read_MNHfile import read_netcdf + +# List of Meso-NH files present in the path +path="" +LnameFiles = ['DUST7.1.SEG02.004.nc'] + +Dvar_input = {'f1':['ZS', 'UT','VT', 'WT','THT', + 'DSTM03T','DSTM33T','DSTM02T','DSTM32T','DSTM01T','DSTM31T','F_DST001P1','F_DST002P1','F_DST003P1', + 'latitude','longitude','level', + 'INPRR','ACPRR','PABST','RCT','RVT','RRT','LSTHM']} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path=path) +```` diff --git a/gallery/view/timeseries_FIRE_full.md b/gallery/view/timeseries_FIRE_full.md new file mode 100644 index 0000000..86dfd37 --- /dev/null +++ b/gallery/view/timeseries_FIRE_full.md @@ -0,0 +1,43 @@ +## Plot 2 + +![timeseries_FIRE_full.png](../figures/timeseries_FIRE_full.png) + +````python +LnameFiles = ['FIRE_.1.CEN4T.000.nc' ] +LG_MEAN = '/LES_budgets/Mean/Cartesian/Not_time_averaged/Not_normalized/cart/' + +Dvar_input = { +'f1':[(LG_MEAN,'MEAN_RC'), (LG_MEAN,'MEAN_RR'), (LG_MEAN,'MEAN_U'), + (LG_MEAN,'MEAN_V'), (LG_MEAN,'MEAN_W'), (LG_MEAN,'MEAN_THL'), + 'time_les','level_les'] +} + +# Read the variables in the files +Dvar = {} +Dvar = read_netcdf(LnameFiles, Dvar_input, path=path, removeHALO=False) + +Panel1 = PanelPlot(2,3, [25,14],'', titlepad=25, minmaxpad=1.04, timepad=-0.07, colorbarpad=0.03, labelcolorbarpad = 13, colorbaraspect=40) + +Lplot = [Dvar['f1'][(LG_MEAN,'MEAN_RC')][:,180:], Dvar['f1'][(LG_MEAN,'MEAN_RR')][:,180:],Dvar['f1'][(LG_MEAN,'MEAN_U')][:,180:], + Dvar['f1'][(LG_MEAN,'MEAN_V')][:,180:], Dvar['f1'][(LG_MEAN,'MEAN_W')][:,180:], Dvar['f1'][(LG_MEAN,'MEAN_THL')][:,180:]] + +LaxeX = [Dvar['f1']['time_les'][180:]/3600.]*len(Lplot) +LaxeZ = [Dvar['f1']['level_les']]*len(Lplot) +Ltitle = ['MEAN_RC', 'MEAN_RR','MEAN_U', 'MEAN_V','MEAN_W','MEAN_THL'] +Lcbarlabel = ['g/kg', 'g/kg' ,'m/s' ,'m/s', 'm/s', 'K'] +Lxlab = ['time (h)']*len(Lplot) +Lylab = ['altitude (m)']*len(Lplot) +Lylim = [(0,700)]*len(Lplot) +Lminval = [0, 0, 2, -5, -0.2E-12, 286] +Lmaxval = [0.62, 0.1, 6, 0.25, 0.2E-12, 300] +Lstep = [0.025, 0.01, 0.25, 0.25, 0.2E-13,0.5 ] +Lstepticks = Lstep +Lfacconv = [1000, 1000, 1, 1, 1, 1] +Lcolormap = ['gist_rainbow_r', 'gist_rainbow_r', 'gist_rainbow_r', 'gist_rainbow_r', 'seismic','gist_rainbow_r'] +LaddWhite = [True, True, False, False, False, False] + +fig1 = Panel1.psectionV(Lxx=LaxeX, Lzz=LaxeZ, Lvar=Lplot, Lxlab=Lxlab, Lylab=Lylab, Ltitle=Ltitle, Lminval=Lminval, Lmaxval=Lmaxval, + Lstep=Lstep, Lstepticks=Lstepticks, Lcolormap=Lcolormap, Lcbarlabel=Lcbarlabel, Lfacconv=Lfacconv, + LaddWhite_cm=LaddWhite, Lylim=Lylim) +Panel1.save_graph(1,fig1) +```` diff --git a/index.md b/index.md new file mode 100644 index 0000000..1b04a8f --- /dev/null +++ b/index.md @@ -0,0 +1,78 @@ +# MNHPy + +--- + +## Read Meso-NH outputs + +| Single file | Multiple file | Diachronic file | Full doc | +| ---- | ---- | ---- | ---- | +| [View source](gallery/view/single_file.md) |[View source](gallery/view/multiple_file.md) | [View source](gallery/view/diachronic_file.md) |[View source](gallery/view/full_doc.md) | + +--- + +## XY lines + +| Plot 1 | Plot 2 | +| ---- | ---- | +| ![XY_multisimple_GABLS1.png](gallery/figures/XY_multisimple_GABLS1.png) |![XY_lines_tseries_aircraft_AZF2M.png](gallery/figures/XY_lines_tseries_aircraft_AZF2M.png) | +| [View source](gallery/view/XY_multisimple_GABLS1.md) |[View source](gallery/view/XY_lines_tseries_aircraft_AZF2M.md) | + +--- + +| Plot 3 | Plot 4 | +| ---- | ---- | +| ![XY_multisimple_GABLS1.png](gallery/figures/XY_budget_terms.png) |![XY_lines_tseries_aircraft_AZF2M.png](gallery/figures/XY_lines_001_2Drelief.png) | +| [View source](gallery/view/XY_budget_terms.md) |[View source](gallery/view/XY_lines_001_2Drelief.md) | + +--- + +## Horizontal cross section + +| Plot 1 | Plot 2 | +| ---- | ---- | +| ![plot1.png](gallery/figures/sectionH_004_Reunion.png) |![MayaviPlt1.png](gallery/figures/sectionH_2dom_front_AZF_full.png) | +| [View source](gallery/view/sectionH_004_Reunion.md) |[View source](gallery/view/sectionH_2dom_front_AZF_full.md) | + +--- + +| Plot 3 | Plot 4 | +| ---- | ---- | +|![plot1.png](gallery/figures/sectionH_OCEAN.png) |![plot1.png](gallery/figures/sectionH_vectors_007janvier_full.png) | +|[View source](gallery/view/sectionH_OCEAN.md) |[View source](gallery/view/sectionH_vectors_007janvier_full.md) | + +--- + +## Vertical cross section + +| Plot 1 | Plot 2 | +| ---- | ---- | +| ![plot1.png](gallery/figures/sectionV_KW78_full.png) |![plot1.png](gallery/figures/sectionV_Reunion_full.png) | +| [View source](gallery/view/sectionV_KW78_full.md) | [View source](gallery/view/sectionV_Reunion_full.md) | + +--- + +## 3D + +| Mayavi | +| ---- | +| ![plot1.png](gallery/figures/3D_mayavi.png) | +| [View source](gallery/view/3D_mayavi.md) | + +--- + +## Hovmoller plot + +| Plot 1 | +| ---- | +| ![timeseries_FIRE_full.png](gallery/figures/timeseries_FIRE_full.png) | +| [View source](gallery/view/timeseries_FIRE_full.md) | + +--- + +## Histogram + +| 009 test case | +| ---- | +| ![histogramm_009ICARTT_full.png](gallery/figures/histogramm_009ICARTT_full.png) | +| [View source](gallery/view/histogramm_009ICARTT_full.md) | +