0-D Model Test Case

Copyright (c) 2024 MPI-M, Clara Bayley

—– Microphysics Test Cases —– File: run_0dparcel_test_case.py Project: test_case_0dparcel Created Date: Wednesday 28th February 2024 Author: Clara Bayley (CB) Additional Contributors: —– Last Modified: Monday 17th June 2024 Modified By: CB —– License: BSD 3-Clause “New” or “Revised” License https://opensource.org/licenses/BSD-3-Clause —– File Description:

tests.test_case_0dparcel.run_0dparcel_test_case.plot_0dparcel_massmix_ratios(out, binpath, run_name)[source]

Plot mass mixing ratios for a 0-D parcel model and save the plots.

This function plots the mass mixing ratios of water vapor, cloud liquid, cloud ice, rain, snow, and graupel for a run of the 0-D parcel model as a function of time and then saves the plots as a PNG image.

Args:
out (OutputThermodynamics):

OutputThermodynamics object containing the mass mixing ratio data.

binpath (str):

Path to the directory where the plots will be saved.

run_name (str):

Name of the test run to use in naming saved image.

Raises:

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

Returns:

None

tests.test_case_0dparcel.run_0dparcel_test_case.plot_0dparcel_thermodynamics(out, binpath, run_name)[source]

Plot thermodynamic variables for a 0-D parcel model and save the plots.

This function plots the pressure, density, temperature, and potential temperature(s) of a run of the 0-D parcel model as a function of time and then saves the plots as a PNG image.

Args:
out (OutputThermodynamics):

OutputThermodynamics object containing the thermodynamic data.

binpath (str):

Path to the directory where the plots will be saved.

run_name (str):

Name of the test run to use in naming saved image.

Raises:

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

Returns:

None

tests.test_case_0dparcel.run_0dparcel_test_case.plot_thetas_on_axis(ax, time, temp, press, press0)[source]

Plot potential temperature(s) on a specified axis.

This function calculates and plots potential temperature(s) against time on a specified axis.

Args:

ax (matplotlib.axes.Axes): The (x-y) axis on which to plot the potential temperature(s). time (array-like): Time values (x axis). temp (OutputVariable): Temperature variable. press (OutputVariable): Pressure variable.

Returns:

None

tests.test_case_0dparcel.run_0dparcel_test_case.plot_variable_on_axis(ax, time, var)[source]

Plot a variable against time on an axis.

Args:

ax (matplotlib.axes.Axes): The (x-y) axis on which to plot the variable. time (array-like): Time values (x axis). var (OutputVariable): The variable to be plotted (y axis).

Returns:

None

tests.test_case_0dparcel.run_0dparcel_test_case.run_0dparcel_test_case(time_init, time_end, timestep, thermo_init, microphys_scheme, binpath, run_name)[source]

Run test case for a 0-D parcel model.

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

Args:
time_init (float):

Initial time for the simulation (s).

time_end (float):

End time for the simulation (s).

timestep (float):

Timestep for the simulation (s).

thermo_init (Thermodynamics):

Initial thermodynamic conditions.

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

tests.test_case_0dparcel.run_0dparcel_test_case.save_figure(fig, binpath, figname)[source]

Save a Matplotlib figure as a PNG file with high resolution and tight bounding box.

Args:

fig (matplotlib.figure.Figure): The Matplotlib figure to be saved. binpath (str): The directory where the figure will be saved. figname (str): The name of the PNG file to save in binpath directory.

Returns:

None