Working with model output¶
For convenience, aeolus provides a way of keeping loaded and processed data within one object along with extra metadata. The object is called AtmoSim (as in “atmospheric simulation”). The code below provides an example of basic usage of AtmoSim.
[1]:
from pathlib import Path
import iris
from aeolus.core import AtmoSim
Note that you can use either a single filename or a list of filenames, each of which is either a str or (recommended) pathlib.Path object.
[2]:
sample_file = Path.cwd() / "sample_data" / "sample_t1e_2d_mean.pp"
To load the data, use iris functions.
[3]:
inp_data = iris.load(str(sample_file))
[4]:
type(inp_data)
[4]:
iris.cube.CubeList
This cube list can be then used to instantiate AtmoSim. It is also possible to add a short name, a long description of the experiment; and to specify a planet configuration with relevant constants (see “Physical constants” example for more info).
[5]:
my_run = AtmoSim(
cubes=inp_data,
name="t1e_example",
description="This is some sample data from a UM simulation of tidally-locked Trappist-1e planet.",
planet="trap1e", # this reads constants from a JSON file
)
[6]:
type(my_run)
[6]:
aeolus.core.AtmoSim
The loaded data are stored as a CubeList as the _cubes attribute.
[7]:
print(my_run._cubes)
0: convective_rainfall_flux / (kg m-2 s-1) (latitude: 90; longitude: 144)
1: convective_snowfall_flux / (kg m-2 s-1) (latitude: 90; longitude: 144)
2: high_type_cloud_area_fraction / (1) (latitude: 90; longitude: 144)
3: low_type_cloud_area_fraction / (1) (latitude: 90; longitude: 144)
4: medium_type_cloud_area_fraction / (1) (latitude: 90; longitude: 144)
5: stratiform_rainfall_flux / (kg m-2 s-1) (latitude: 90; longitude: 144)
6: stratiform_snowfall_flux / (kg m-2 s-1) (latitude: 90; longitude: 144)
Constants that have been used in the model:
[8]:
my_run.const
[8]:
Trap1eConstants(earth_day [s], stefan_boltzmann [W m-2 K-4], water_heat_vaporization [m2 s-2], water_molecular_weight [kg mol-1], molar_gas_constant [J K-1 mol-1], boltzmann [m^2 kg s^-2 K^-1], avogadro [mol-1], gravity [m s-2], radius [m], day [s], solar_constant [W m-2], reference_surface_pressure [Pa], semi_major_axis [au], eccentricity [1], obliquity [degree], dry_air_spec_heat_press [m2 s-2 K-1], dry_air_molecular_weight [kg mol-1], condensible_density [kg m-3], condensible_heat_vaporization [m2 s-2])
Individual cubes can be accessed either by via the _cubes attribute and iris methods, or, more conveniently, as keys or attributes of AtmoSim:
[9]:
print(my_run.cv_rain)
convective_rainfall_flux / (kg m-2 s-1) (latitude: 90; longitude: 144)
Dimension coordinates:
latitude x -
longitude - x
Scalar coordinates:
forecast_period: 36360.0 hours, bound=(36000.0, 36720.0) hours
forecast_reference_time: 2004-05-13 09:00:00
time: 2008-07-06 09:00:00, bound=(2008-06-21 09:00:00, 2008-07-21 09:00:00)
Attributes:
STASH: m01s05i205
planet_conf: Trap1eConstants(earth_day [s], stefan_boltzmann [W m-2 K-4], water_heat_vaporization...
source: Data from Met Office Unified Model
um_version: 11.3
Cell methods:
mean: time (1 hour)
[10]:
print(my_run["cv_rain"])
convective_rainfall_flux / (kg m-2 s-1) (latitude: 90; longitude: 144)
Dimension coordinates:
latitude x -
longitude - x
Scalar coordinates:
forecast_period: 36360.0 hours, bound=(36000.0, 36720.0) hours
forecast_reference_time: 2004-05-13 09:00:00
time: 2008-07-06 09:00:00, bound=(2008-06-21 09:00:00, 2008-07-21 09:00:00)
Attributes:
STASH: m01s05i205
planet_conf: Trap1eConstants(earth_day [s], stefan_boltzmann [W m-2 K-4], water_heat_vaporization...
source: Data from Met Office Unified Model
um_version: 11.3
Cell methods:
mean: time (1 hour)
which is equivalent to typing
[11]:
print(my_run._cubes.extract_cube("convective_rainfall_flux"))
convective_rainfall_flux / (kg m-2 s-1) (latitude: 90; longitude: 144)
Dimension coordinates:
latitude x -
longitude - x
Scalar coordinates:
forecast_period: 36360.0 hours, bound=(36000.0, 36720.0) hours
forecast_reference_time: 2004-05-13 09:00:00
time: 2008-07-06 09:00:00, bound=(2008-06-21 09:00:00, 2008-07-21 09:00:00)
Attributes:
STASH: m01s05i205
planet_conf: Trap1eConstants(earth_day [s], stefan_boltzmann [W m-2 K-4], water_heat_vaporization...
source: Data from Met Office Unified Model
um_version: 11.3
Cell methods:
mean: time (1 hour)
Short-cuts are defined using the Model container (see the “Model field names” example).
[12]:
my_run.model.cv_rain
[12]:
'convective_rainfall_flux'