carmapy.Results#

class carmapy.Results(carma, read_diag=False)#

An object which stores the results of a CARMA simulation.

Parameters:
  • carma (Carma) – The carma simulation to load results from

  • read_diag (boolean, optional) – If true reads in the microphysical rates and core mass fraction. Defaults to False.

Notes

The results.clouds dictionary is indexed by names of the cloud species (see results.group_names) and stores the following values:

  • results.clouds['r'] is a 1D numpy array of length NBIN which stores the radii of the cloud particle bins in cm

  • results.clouds['rmass'] is a 1D numpy array of length NBIN which stores the mass of the cloud particle bins in g

  • results.clouds['numden'] is a 3D numpy array of shape (NZ, NBIN, NT) which stores the number density of each cloud species in each size bin at each time step in units of cm⁻³

  • results.clouds['coremass_frac'] is a 3D numpy array of

    shape (NZ, NBIN, NT) which stores the fraction of mass in each bin stored in the particle core. Only stored if read_diag=True.

  • results.clouds['nuc_gain_rate'] is a 3D numpy array of

    shape (NZ, NBIN, NT) which stores the rate at which particles are added to the bin via nucleation [particles/s/cm³]. Only stored if read_diag=True.

  • results.clouds['nuc_loss_rate'] is a 3D numpy array of shape (NZ, NBIN, NT) which stores the rate at which particles are removed from a bin due to nucleation [particles/s/cm³]. Only stored if read_diag=True.

  • results.clouds['grow_gain_rate'] is a 3D numpy array of

    shape (NZ, NBIN, NT) which stores the rate at which particles are added to a bin due to condensational growth [particles/s/cm³]. Only stored if read_diag=True.

  • results.clouds['grow_loss_rate'] is a 3D numpy array of

    shape (NZ, NBIN, NT) which stores the rate at which particles are removed from a bin due to condensational growth [particles/s/cm³]. Only stored if read_diag=True.

  • results.clouds['evap_gain_rate'] is a 3D numpy array of

    shape (NZ, NBIN, NT) which stores the rate at which particles are added to a bin due to evaporation [particles/s/cm³] . Only stored if read_diag=True.

  • results.clouds['evap_loss_rate'] is a 3D numpy array of

    shape (NZ, NBIN, NT) which stores the rate at which particles are removed from a bin due to evaporation [particles/s/cm³]. Only stored if read_diag=True.

In a 2-D CARMApy run two additional items are saved:
  • results.gases_2d stores the same info as results.gases but stores (NZ, NLONGITUDE) arrays instead of (NZ, NT) arrays

  • results.longitude_map takes in a 3-D array of shape (NZ, NBIN, NT) and transforms it to an array of shape (NZ, NBIN, NLONGITUDE) where each longitude bin in the average of all timesteps corresponding to that longitude. This function is designed to work on the results.clouds["numden"] array as well as any of the microphysical rates arrays in results.clouds.

Methods

gen_picaso_atm_file(…)

Generates an atmosphere file for use in picaso.

gen_picaso_cloud_file(…)

Generate cloud opacity tables for use in picaso.

plot_condensation_curves(…)

Plots condensation curves for each gas species in the CARMA model overlaid on the model's P-T profile.

plot_numdens(…)

Interactively plots the number densities of the cloud species.

plot_toa_gas(…)

Plots the gas abundances at the top of the atmosphere.

Attributes

carma

The carma simulation that generated these results

clouds

A dictionary storing results for each cloud species (see notes)

dt_timestep

The length of time between each output [s]

gas_names

The name of each of the simulated gases

gases

The number mixing ratio for each of the gases

gases_2d

The number mixing ratio for each of the gases by longitude

group_names

The name of each of the simulated groups

longitude_map

A function to transform arrays to be by longitude (see notes)

P

Pressure centers alias [barye] (NZ)

path

The path to the CARMA output files

sat_vp

The saturation mixing ratios of the gases (NZ, NGAS, NT, [NLONG])

T

Temperature centers alias [K] (NZ, [NLONG])

ts

Time elapsed since start of simulation at each step [s] (NT)

Z

Altitude centers alias [cm] (NZ)

Results.gen_picaso_atm_file(file_path=None)#

Generates an atmosphere file for use in picaso. Picaso is a python package which can calculate spectra and is available at natashabatalha/picaso.

Parameters:

file_path (str) – The path to save the file to. If not provided, creates a file located in the directory storing the carma simulation.

Return type:

None

Results.gen_picaso_cloud_file(wavelengths, file_path=None, mie_table_path=None, skip_groups=[])#

Generate cloud opacity tables for use in picaso. Picaso is a python package which can calculate spectra and is available at natashabatalha/picaso.

Parameters:
  • wavelengths (ndarray) – The wavelengths at which to calculate to opacities [cm]

  • file_path (str) – The path to save the file to. If not provided, creates a file located in the directory storing the carma simulation.

  • mie_table_path (str) – The directory in which the mie tables of the species are located. It is assumed that each cloud species used has a .dat file in that directory named with the name of the cloud species (ie ‘Mg2SiO4 on TiO2.dat’), the first row of the table is a header row, and the columns are radius[cm], wavelength[cm], extinction efficiency (Q_ext), scattering efficiency (Q_sca), and asymmetry factor (g). The columns must be in that order and separated by whitespace. If no path is provided, the carma default tables will be used but these might be less accurate, even for the same species, as they might not be calculated at the same particle size and wavelengths.

  • skip_groups (list, optional) – The indices of any cloud groups to exclude from the opacity calculation, by default None

Results.plot_condensation_curves(ax=None, t_step=-1, skip_gases=None, **kwargs)#

Plots condensation curves for each gas species in the CARMA model overlaid on the model’s P-T profile.

For each gas the condensation curve is the locus of (T, P) points at which the gas partial pressure equals its saturation vapour pressure (i.e. saturation ratio = 1). The curve is computed analytically from the vapour-pressure coefficients stored in constants.gas_dict using the deep-atmosphere gas mixing ratio from the simulation. Species whose vapour-pressure formula does not have a temperature coefficient (e.g. H2O, which uses a custom Fortran routine) are plotted using the saturation vapour pressures stored directly in results.sat_vp.

Parameters:
  • ax (matplotlib.axes.Axes, optional) – Axes to draw on. A new figure is created when None.

  • t_step (int, optional) – Time-step index used to read gas abundances, by default -1 (last recorded step).

  • skip_gases (list[int], optional) – List of gas indices to exclude. Defaults to [] (plot all species).

  • **kwargs – Extra keyword arguments forwarded to ax.plot for the P-T profile line only.

Returns:

  • fig (matplotlib.figure.Figure)

  • ax (matplotlib.axes.Axes)

Results.plot_numdens(nlevels=11, min_order=-10, **kwargs)#

Interactively plots the number densities of the cloud species. Densities are normalized to the peak number density in the plot. Interactivly change the cloud species which is plotted and the timestep using the sliders

Note

If in a notebook, requires %matplotlib ipympl to have been invoked

Parameters:
  • nlevels (int, optional) – The number of contours to plot, by default 11

  • min_order (int, optional) – The number of orders of magnitude below the peak density to show, by default -10

Return type:

None

Results.plot_toa_gas(skip_gases=[0], burn_in=20, **kwargs)#

Plots the gas abundances at the top of the atmosphere. Useful for determining whether or not the simulation has converged. **kwargs are passed to pyplot

Parameters:
  • skip_gases (list, optional) – A list of gases, by index, to skip plotting, by default [0] (H2O)

  • burn_in (int, optional) – The number of timesteps to exclude from the start of the simulation, by default 20