vgrid
— Contains handling of Hybrid-Pressure vertical grid generation and plotting.¶
Package vgrid:
Contains handling of Hybrid-Pressure vertical grid generation and plotting.
Classes¶
-
class
vgrid.
HybridPressureVGrid
(source, vertical_mean=None, reference_pressure=101325.0, ptop=0.0, vgrid_name=None)[source]¶ Handle and represent information about a Hybrid-Pressure Vertical Grid.
Build the grid object from a source, which may be
- an infosup file from
mkvgrid.x
- an epygram Hybrid-Pressure VGeometry; in which case the below arguments must/may be provided:
Case of an epygram Hybrid-Pressure VGeometry source:
Parameters: - vertical_mean – mandatory, among (‘geometric’, ‘arithmetic’, ‘LAPRXPK=False’)
- reference_pressure – at the surface, for building a standard atmosphere
- ptop – pressure at the top of the model (upper boundary of the upper layer)
- vgrid_name – name of the grid, for plot/saving purpose
-
bokeh_add_domains
(fig, yaxis=None, xaxis=None, **span_options)[source]¶ Add domains limits to figure.
Parameters: - fig – the figure on which to plot.
- yaxis – ‘level’, ‘p’ (pressure), ‘z’ (height) or ‘pthickness’//’zthickness’
- xaxis – ‘level’, ‘p’ (pressure), ‘z’ (height) or ‘pthickness’//’zthickness’
Other options are passed to bokeh’s Span to plot domains limits.
-
bokeh_fig_to_html
(fig, htmlname=None, show_figure=True)[source]¶ Outputs figure to html file, and optionally display it.
Parameters: - htmlname – name of html file; if None, name of file is auto-generated from self.name
- show_figure – to show the plot in a WebBrowser tab
-
bokeh_plot_y_vs_x
(yaxis, xaxis, over=None, hover_attachment='right', bokeh_kwargs={}, fig_kwargs={}, legend_location='top_right', plot_domains=None, add_domains_options={})[source]¶ Plot grid and return the figure.
Parameters: - yaxis – ‘level’, ‘p’ (pressure), ‘z’ (height) or ‘pthickness’//’zthickness’
- xaxis – ‘level’, ‘p’ (pressure), ‘z’ (height) or ‘pthickness’//’zthickness’
- over – an eventual existing bokeh figure on which to plot
- hover_attachment – position of the hover
- bokeh_kwargs – passed to bokeh’s inner plot functions
- fig_kwargs – to be passed to bokeh’s figure()
- plot_domains – plot a horizontal bar separating each vertical domain (True/False/None)
- add_domains_options – options to be passed to bokeh_add_domains() method
-
domains_lower_limit
()[source]¶ Get the lower limit of each domain in pressure, height and level number. Pressures are given in hPa. Lower level is “last included level + 0.5”.
-
domains_upper_limit
()[source]¶ Get the upper limit of each domain in pressure, height and level number. Pressures are given in hPa. Lower level is “last included level - 0.5”.
-
grid
¶ Get grid height and pressure of full(mass) levels and frontiers. Pressures are given in hPa.
- an infosup file from
Standard atmosphere¶
Standard atmosphere functions.
-
vgrid.standard_atmosphere.
pressure_at
(altitude)[source]¶ Compute the pressure at a series of altitude, considering standard atmosphere.
For more documentation, cf. arpifs’ ppsta.F90
-
vgrid.standard_atmosphere.
altitude_at
(pressure)[source]¶ Compute the altitude at a series of pressure, considering standard atmosphere.
For more documentation, cf. arpifs’ susta.F90
It uses underlying Fortran routines that may need to be recompiled (to .so)
platform-wise. Sources and Makefile are provided in the sub-directory
vertical_discretization
.
Tools¶
mkvgrid.py
is a command-line tool used to generate a HybridPressure Vertical
grid according to a set of requirements in terms of:
- number of levels
- height of first level, pressure of last level
- number of levels by slices of atmosphere
- thickness of these levels
- dynamics options on how to compute levels
It uses an underlying Fortran program that may need to be recompiled
platform-wise. Sources and Makefile are provided in the sub-directory
vertical_discretization
.
The tool is autodocumented with option -h
.
These functionalities are also accessible from python:
from vgrid.mkvgrid import generate_vertical_grid
generate_vertical_grid(...)
or
from vgrid.mkvgrid import main as mkvgrid
mkvgrid(...)
-
vgrid.mkvgrid.
generate_vertical_grid
(namelist_file, to_clean=['.latex', '.mapping', '.namvv1'])[source]¶ Run the (Fortran)
mkvgrid.x
binary used to generate a vertical grid according to a namelist_file, and get back the name of the so-called infosup file to read data to plot from.
-
vgrid.mkvgrid.
main
(namelist_files, plot_grid=True, show_figure=True, yaxis='z', xaxis='pthickness', outputfilename=None, to_clean=['.latex', '.mapping', '.namvv1'], fig_kwargs={})[source]¶ Run the generation of grid, read grid, plot.
Parameters: - namelist_files – namelist(s) to use to generate grid(s) (1 or 2)
- plot_grid – to plot the grid or not
- show_figure – whether to open the plot in a WebBrowser tab or not
- yaxis – ‘level’, ‘p’ (pressure), ‘z’ (height) or ‘pthickness’//’zthickness’
- xaxis – ‘level’, ‘p’ (pressure), ‘z’ (height) or ‘pthickness’//’zthickness’
- yaxis – ‘p’ (pressure) or ‘z’ (height)
- outputfilename – a specific html filename for output: if None, name of file auto-generated
- to_clean – additional files to clean
- fig_kwargs – to be passed to bokeh’s figure()