Fields#
The pyathena.fields module provides a registry of derived fields and their
visualization metadata. A derived field is any quantity that can be computed
from the primitive fields stored in the simulation output (density, pressure,
velocity, magnetic field, etc.).
DerivedFields#
- class pyathena.fields.fields.DerivedFields(par, x0=array([0., 0., 0.]))[source]#
Registry of derived fields for an Athena/Athena++ simulation.
Reads simulation parameters and builds dictionaries of derived field metadata (compute function, primitive field dependencies, plot label, colormap, value range, and log-scale flag). The active set of fields is determined automatically from the
parconfiguration (e.g. MHD, cooling, radiation, cosmic rays).- Parameters
par (dict) – Simulation parameter dictionary as returned by
pyathena.read_athinput().x0 (array-like of float, optional) – Reference position
[x, y, z]used for distance-based fields such as radial velocity. Default is[0.0, 0.0, 0.0].
- func#
Maps field name → callable
f(d, u)that computes the field.- Type
dict
- field_dep#
Maps field name → set of required primitive field names.
- Type
dict
- label#
Maps field name → LaTeX label string for colorbars/axes.
- Type
dict
- cmap#
Maps field name → colormap.
- Type
dict
- vminmax#
Maps field name →
(vmin, vmax)defaults for visualization.- Type
dict
- take_log#
Maps field name → bool; if
Trueuse log normalization.- Type
dict
- norm#
Maps field name →
matplotlib.colors.Normalizeinstance.- Type
dict
- imshow_args#
Maps field name → dict of kwargs suitable for imshow/colorbar calls.
- Type
dict
- dfi#
Combined per-field metadata dict (union of all the above).
- Type
dict
Examples
>>> from pyathena import read_athinput >>> from pyathena.fields.fields import DerivedFields >>> par = read_athinput("/path/to/athinput") >>> df = DerivedFields(par) >>> print(list(df.func.keys())[:5])
Derived Field Builders#
Each set_derived_fields_* function populates the registry for a specific
physics category. They are called automatically by DerivedFields
based on the simulation configuration.
- pyathena.fields.fields.set_derived_fields_def(par, x0)[source]#
Function to define derived fields info, for example, functions to calculate derived fields, dependency, label, colormap, etc.
May not work correctly for problems using different unit system. Assume that density = nH, length unit = pc, etc.
This includes: - density (rho, nH) - pressure (pok, pok_trbz) - distance (r) - velocity (vmag, vr, vx/vy/vz) - sound speeds (cs, csound) - momentum density, ram pressure (Mr, Mr_abs, rhovr2ok)
- Parameters
par (dict) – Dictionary containing simulation parameter information
x0 (sequence of floats) – Coordinate of the center with respect to which distance is measured
- Return type
Tuple of dictionaries containing derived fields info
- pyathena.fields.fields.set_derived_fields_cooling(par, newcool)[source]#
Function to define derived fields info, for example, functions to calculate derived fields, dependency, label, colormap, etc.
May not work correctly for problems using different unit system. Assume that density = nH, length unit = pc, etc.
- Parameters
par (dict) – Dictionary containing simulation parameter information
newcool (bool) – Is new cooling turned on?
- Return type
Tuple of dictionaries containing derived fields info
- pyathena.fields.fields.set_derived_fields_mag(par, x0)[source]#
Magnetic-field / MHD derived fields.
- pyathena.fields.fields.set_derived_fields_rad(par, x0)[source]#
Register radiation field derived fields.
Includes normalized FUV (PE and LW band), C ionizing, and H2 dissociating radiation field strengths in Draine ISRF units (chi_PE, chi_LW, chi_FUV, chi_CI, chi_H2).
- Parameters
par (dict) – Dictionary containing simulation parameter information.
x0 (sequence of floats) – Reference coordinate (unused here, kept for interface consistency).
- Returns
Six dictionaries: (func, field_dep, label, cmap, vminmax, take_log).
- Return type
tuple
- pyathena.fields.fields.set_derived_fields_newcool(par, x0)[source]#
Register new-cooling (NCR) chemistry derived fields.
Includes temperature, molecular/atomic hydrogen fractions and densities (T, xH2, nH2, xHI, nHI, xe), carbon/oxygen species (xCII, nCII, xCI, nCI, xCO, nCO, xOI), cosmic-ray ionization rate, and cooling/heating rates.
- Parameters
par (dict) – Dictionary containing simulation parameter information.
x0 (sequence of floats) – Reference coordinate (unused here, kept for interface consistency).
- Returns
Six dictionaries: (func, field_dep, label, cmap, vminmax, take_log).
- Return type
tuple
- pyathena.fields.fields.set_derived_fields_sixray(par, x0)[source]#
Register six-ray external radiation field derived fields.
Includes external (attenuated) PE and LW radiation field strengths in Draine ISRF units (chi_PE_ext, chi_LW_ext, chi_H2_ext).
- Parameters
par (dict) – Dictionary containing simulation parameter information.
x0 (sequence of floats) – Reference coordinate (unused here, kept for interface consistency).
- Returns
Six dictionaries: (func, field_dep, label, cmap, vminmax, take_log).
- Return type
tuple
- pyathena.fields.fields.set_derived_fields_xray(par, x0, newcool)[source]#
Register X-ray emissivity derived fields.
Registers the X-ray emissivity field (j_X) in the 0.5–7 keV band, computed using APEC emissivity tables via the
ytlibrary.Note
Requires the optional dependency
yt. RaisesModuleNotFoundErrorifytis not installed.- Parameters
par (dict) – Dictionary containing simulation parameter information.
x0 (sequence of floats) – Reference coordinate (unused here, kept for interface consistency).
newcool (bool) – If
True, use new-cooling chemistry fields for the emissivity calculation; otherwise use classic fields.
- Returns
Six dictionaries: (func, field_dep, label, cmap, vminmax, take_log).
- Return type
tuple
- pyathena.fields.fields.set_derived_fields_cosmic_ray(par)[source]#
Register cosmic-ray derived fields.
Includes CR parallel diffusion coefficient (sigma_para), CR pressure (pok_cr), CR energy density (Ec), and CR-related velocity fields.
- Parameters
par (dict) – Dictionary containing simulation parameter information. Must include a
crblock with at leastvmax(maximum CR streaming speed in cm/s).- Returns
Six dictionaries: (func, field_dep, label, cmap, vminmax, take_log).
- Return type
tuple
- pyathena.fields.fields.set_derived_fields_feedback_scalars(par)[source]#
Register feedback scalar derived fields.
Includes gas metallicity (Zgas) and SN ejecta mass fraction (rSN) derived from passive scalar fields tracked during stellar feedback.
- Parameters
par (dict) – Dictionary containing simulation parameter information.
- Returns
Six dictionaries: (func, field_dep, label, cmap, vminmax, take_log).
- Return type
tuple
X-ray Emissivity#
Note
This module requires yt as an optional dependency. It is imported
lazily; if yt is not installed, X-ray derived fields will be unavailable.
- class pyathena.fields.xray_emissivity.XrayEmissivityIntegrator(table_type, redshift=0.0, data_dir=None, use_metals=True)[source]#
Class for making X-ray emissivity fields. Uses hdf5 data tables generated from Cloudy and AtomDB/APEC.
Initialize an XrayEmissivityIntegrator object.
- Parameters
table_type (string) – The type of data to use when computing the emissivity values. If “cloudy”, a file called “cloudy_emissivity.h5” is used, for photoionized plasmas. If, “apec”, a file called “apec_emissivity.h5” is used for collisionally ionized plasmas. These files contain emissivity tables for primordial elements and for metals at solar metallicity for the energy range 0.1 to 100 keV.
redshift (float, optional) – The cosmological redshift of the source of the field. Default: 0.0.
data_dir (string, optional) – The location to look for the data table in. If not supplied, the file will be looked for in the location of the YT_DEST environment variable or in the current working directory.
use_metals (boolean, optional) – If set to True, the emissivity will include contributions from metals. Default: True