Plot Utilities
Warning
This module uses matplotlib and cartopy, which are not included in the dependencies of this package.
- class plot_utils.HeightLatPlotter(figsize, title_str, xgrid, ygrid, xlim, exclude_equator=True, white_space_width=20, x_axis_title='Latitude[deg]', y_axis_title='Pseudoheight[m]')[source]
Utility for plotting Height-latitude plot with matplotlib.pyplot.contourf.
- Parameters
figsize (Tuple[int, int]) – figure size in inch
title_str (str) – Title of the plot
xgrid (np.array) – Longitude grid points (in deg)
ygrid (np.array) – Latiitude grid points (in deg)
xlim (Tuple[float, float]) – Lower and Upper bound of x-axis
exclude_equator (bool) – whether to exclude equator or not
white_space_width (float) – The width of white space centered at equator if exclude_equator = True
x_axis_title (str) – Label of the x-axis [Longitude]
y_axis_title (str) – Label of the y-axis [Latiitude]
- class plot_utils.LatLonMapPlotter(figsize, title_str, xgrid, ygrid, xland, yland, lon_range, lat_range, wspace=0.3, hspace=0.3, coastlines_alpha=0.7, exclude_equator=True, white_space_width=20, x_axis_title='Longitude[deg]', y_axis_title='Latitude[deg]')[source]
Utility for plotting latitude-longitude maps with Cartopy.
- Parameters
figsize (Tuple[int, int]) – figure size in inch
title_str (str) – Title of the plot
xgrid (np.array) – Longitude grid points (in deg)
ygrid (np.array) – Latiitude grid points (in deg)
xland (np.ndarray) – With dimension same as np.meshgrid(xgrid, ygrid). Longitude grid points to be masked out
yland (np.ndarray) – With dimension same as np.meshgrid(xgrid, ygrid). Latitude grid points to be masked out
lon_range (np.array) – Longitude ticks/marks displayed on the plot
lat_range (np.array) – Latiitude ticks/marks displayed on the plot
wspace (float) – width space size
hspace (float) – height space size
coastlines_alpha (float) – Degree of transparency of coastlines (in percent)
exclude_equator (bool) – whether to exclude equator or not
white_space_width (float) – The width of white space centered at equator if exclude_equator = True
x_axis_title (str) – Label of the x-axis [Longitude]
y_axis_title (str) – Label of the y-axis [Latiitude]
- plot_utils.compare_two_fields(field_a, field_b, a_title, b_title, x_coord, y_coord, title, savefig_fname='default.png', diff_factor=0.01, figsize=(15, 4), cmap='rainbow') None[source]
A handy utility to compare the difference between two 2D-fields and plot their difference. The output plot has 3 columns:
value of field_a,
value of field_b,
absolute difference between field_a and field_b.
The color scale of this plot can be controlled by the parameter diff_factor: the color range of the plot will be the maximum value among field_a and field_b multiplied by diff_factor. If you want to use the auto-colorscale, set diff_factor to None.
New in version 0.7.0.
- Parameters
field_a (np.ndarray) – First 2D-field to compare
field_b (np.ndarray) – Second 2D-field to compare
a_title (str) – Title of the first field
b_title (str) – Title of the second field
x_coord (np.array) – array of x-coordinates
y_coord (np.array) – array of y-coordinates
title (str) – Main title of the whole plot
savefig_fname (str) – Filename of figure saved. Default: “default.png”. If you don’t want a file to be saved, set this to None.
diff_factor (float) – The color range of the plot will be the maximum value among field_a and field_b multiplied by diff_factor. If you want to use the auto-colorscale, set diff_factor to None. Default: 0.01.
figsize (Tuple[int, int]) – tuple specifying figure size
- plot_utils.compare_two_fields_on_map(field_a, field_b, a_title, b_title, x_coord, y_coord, title, savefig_fname='default.png', diff_factor=0.01, figsize=(15, 4), cmap='rainbow') None[source]
A handy utility to compare the difference between two 2D-fields and plot their difference. The output plot has 3 columns:
value of field_a,
value of field_b,
absolute difference between field_a and field_b.
The color scale of this plot can be controlled by the parameter diff_factor: the color range of the plot will be the maximum value among field_a and field_b multiplied by diff_factor. If you want to use the auto-colorscale, set diff_factor to None.
New in version 0.7.0.
- Parameters
field_a (np.ndarray) – First 2D-field to compare
field_b (np.ndarray) – Second 2D-field to compare
a_title (str) – Title of the first field
b_title (str) – Title of the second field
x_coord (np.array) – array of x-coordinates
y_coord (np.array) – array of y-coordinates
title (str) – Main title of the whole plot
savefig_fname (str) – Filename of figure saved. Default: “default.png”. If you don’t want a file to be saved, set this to None.
diff_factor (float) – The color range of the plot will be the maximum value among field_a and field_b multiplied by diff_factor. If you want to use the auto-colorscale, set diff_factor to None. Default: 0.01.
figsize (Tuple[int, int]) – tuple specifying figure size
- plot_utils.plot_lon_lat_field(filepath, variable_name, latitude_name='latitude', longitude_name='longitude', tstep=10, zonal_axis=0) None[source]
Plot a snapshot of longitude-latitude map from a netCDF file.
- Parameters
filepath (str) – path to the netCDF file
variable_name (str) – name of the variable to be plotted
latitude_name (str) – name of latitudinal coordinates
longitude_name (str) – name of latitudinal coordinates
tstep (int) – index of timestep to be plotted
zonal_axis (int) – axis of zonal dimension