1-D KiD Rainshaft Model Test Case

Copyright (c) 2024 MPI-M, Clara Bayley

—– Microphysics Test Cases —– File: perform_1dkid_test_case.py Project: test_case_1dkid Created Date: Monday 2nd September 2024 Author: Clara Bayley (CB) Additional Contributors: —– Last Modified: Wednesday 4th June 2025 Modified By: CB —– License: BSD 3-Clause “New” or “Revised” License https://opensource.org/licenses/BSD-3-Clause —– File Description: interface called by a test to run the 1-D KiD and then plot the results.

libs.test_case_1dkid.perform_1dkid_test_case.perform_1dkid_test_case(z_delta, z_max, time_end, timestep, thermo_init, microphys_scheme, binpath, run_name)[source]

Run test case for a 1-D KiD rainshaft model.

This function runs a 1-D KiD rainshaft model with a specified microphysics scheme and KiD dynamics given the initial thermodynamics. The data is then saved/plotted in the binpath directory using the run_name as a label.

Args:

z_delta (float): Grid spacing of 1-D column (m). z_max (float): Upper limit of 1-D column (max half-cell) (m). time_end (float): End time for the simulation (s). timestep (float): Timestep for the simulation (s). thermo_init (Thermodynamics): Initial thermodynamics. microphys_scheme: Microphysics scheme to use in test run. binpath (str): Path to the directory where data/plots will be saved. run_name (str): Name of the test run (used for labeling output).

Raises:

AssertionError: If the specified binpath does not exist or if run_name is empty.

Returns:

None

libs.test_case_1dkid.perform_1dkid_test_case.plot_1dkid_moisture(out, z_delta, z_max, binpath, run_name)[source]

Plots the 1D Kinematic Driver (KID) results and saves the plots.

Parameters:
out: OutputThermodynamics

The dataset containing the output variables to plot (qvap, qcond, temp, press).

z_delta: float

The vertical resolution of the model.

z_max: float

The maximum height of the model domain.

binpath: str

The path where the plot images will be saved.

run_name: str

The name of the run, used for labeling the plots and the output file name.

Returns:

None

libs.test_case_1dkid.perform_1dkid_test_case.plot_kid_result(fig, ax0, cax0, ax1, var, time, z_delta, z_max, label, mult=1.0, threshold=None, rng=None, cmap='copper', rasterized=False)[source]

Function extracted from pyMPDATA-examples Shipway and Hill 2012 plot.py script for a1-D KiD rainshaft.

Parameters: fig : matplotlib.figure.Figure

The figure object to plot on.

ax0matplotlib.axes.Axes

The first axes object for pcolormesh plot.

cax0matplotlib.axes.Axes

The axes object for the colorbar of ax0.

ax1matplotlib.axes.Axes

The second axes object for cross-section plot.

varnumpy.ndarray

The variable to be plotted, dimensions [time, height]

timefloat

The time data to plot (will be coarsened by ‘fctr’, see code)

z_deltafloat

The vertical resolution of the data.

z_maxfloat

The maximum vertical extent of the data (max half-cell).

labelstr

The label for variable on the plot, e.g. for colourbar.

multfloat, optional

A multiplicative factor to apply to ‘var’ data values (default is 1.0).

thresholdfloat, optional

A threshold value for the data to plot (default is None).

rng[float, float], optional

The range of data to plot (default is None).

cmapstr, optional

The colormap to be used for plotting (default is “copper”).

rasterizedbool, optional

Whether to rasterize the plot (default is False).

See Also: https://github.com/open-atmos/PyMPDATA/blob/main/examples/PyMPDATA_examples/Shipway_and_Hill_2012/plot.py for the original source code.