Gas¶
A Gas component contains all information about the gaseous medium in a galaxy. Below we provide examples of particle Gas
objects, and how to initialise and interact with them.
We do not define a parametric Gas component in the current version of synthesizer.
Particle Gas¶
To initialise a Gas
object you always need to provide the particle masses and metallicities along with units. The toy example below shows how to initialise a Gas
object with 1000 particles.
[1]:
import numpy as np
from unyt import Msun, Mpc
from synthesizer.particle import Gas
gas = Gas(
masses=np.ones(1000) * 10**6 * Msun,
metallicities=np.random.rand(1000) * 0.02,
)
print(gas)
+-----------------------------------------------------------------------------------+
| GAS |
+----------------------------+------------------------------------------------------+
| Attribute | Value |
+----------------------------+------------------------------------------------------+
| nparticles | 1000 |
+----------------------------+------------------------------------------------------+
| metallicity_floor | 1.00e-05 |
+----------------------------+------------------------------------------------------+
| name | 'Gas' |
+----------------------------+------------------------------------------------------+
| dust_to_metal_ratio | 0.30 |
+----------------------------+------------------------------------------------------+
| masses (1000,) | 1.00e+06 Msun -> 1.00e+06 Msun (Mean: 1.00e+06 Msun) |
+----------------------------+------------------------------------------------------+
| metallicities (1000,) | 2.06e-05 -> 2.00e-02 (Mean: 1.00e-02) |
+----------------------------+------------------------------------------------------+
| dust_masses (1000,) | 6.19e+00 Msun -> 6.00e+03 Msun (Mean: 3.00e+03 Msun) |
+----------------------------+------------------------------------------------------+
| log10metallicities (1000,) | -4.69e+00 -> -1.70e+00 (Mean: -2.13e+00) |
+----------------------------+------------------------------------------------------+
Like all other components, a Gas
object also supports a number of predefined kwargs including (but not limited to) velocities
, coordinates
, smoothing_lengths
and dust_masses
or dust_to_metal_ratio
. In addition, you can also provide custom kwargs to store arbitrary properties (below we’ll intialise with some HII properties).
[2]:
gas = Gas(
masses=np.ones(1000) * 10**6 * Msun,
metallicities=np.random.rand(1000) * 0.02,
dust_to_metal_ratio=0.25,
coordinates=np.random.rand(1000, 3) * 1 * Mpc,
centre=np.mean(np.random.rand(1000, 3) * 1, axis=0) * Mpc,
hii_mass=np.random.rand(1000) * 1e4 * Msun,
hii_metallicity=np.random.rand(1000) * 0.02,
)
print(gas)
+---------------------------------------------------------------------------------------+
| GAS |
+--------------------------------+------------------------------------------------------+
| Attribute | Value |
+--------------------------------+------------------------------------------------------+
| nparticles | 1000 |
+--------------------------------+------------------------------------------------------+
| metallicity_floor | 1.00e-05 |
+--------------------------------+------------------------------------------------------+
| name | 'Gas' |
+--------------------------------+------------------------------------------------------+
| dust_to_metal_ratio | 0.25 |
+--------------------------------+------------------------------------------------------+
| coordinates (1000, 3) | 2.71e-05 Mpc -> 1.00e+00 Mpc (Mean: 4.98e-01 Mpc) |
+--------------------------------+------------------------------------------------------+
| masses (1000,) | 1.00e+06 Msun -> 1.00e+06 Msun (Mean: 1.00e+06 Msun) |
+--------------------------------+------------------------------------------------------+
| centre | [0.50145586 0.49109727 0.48956152] Mpc |
+--------------------------------+------------------------------------------------------+
| metallicities (1000,) | 4.74e-06 -> 2.00e-02 (Mean: 9.89e-03) |
+--------------------------------+------------------------------------------------------+
| dust_masses (1000,) | 1.19e+00 Msun -> 5.00e+03 Msun (Mean: 2.47e+03 Msun) |
+--------------------------------+------------------------------------------------------+
| hii_mass (1000,) | 5.00e+31 kg -> 1.98e+34 kg (Mean: 1.01e+34 kg) |
+--------------------------------+------------------------------------------------------+
| hii_metallicity (1000,) | 1.76e-05 -> 1.99e-02 (Mean: 9.85e-03) |
+--------------------------------+------------------------------------------------------+
| centered_coordinates (1000, 3) | -5.01e-01 Mpc -> 5.10e-01 Mpc (Mean: 4.11e-03 Mpc) |
+--------------------------------+------------------------------------------------------+
| log10metallicities (1000,) | -5.32e+00 -> -1.70e+00 (Mean: -2.14e+00) |
+--------------------------------+------------------------------------------------------+
Once a Gas
object is initialised, it can be attached to a Galaxy
object and used in LOS calculations, or to analyse the gas distribution via maps or numerous other methods.
Default dust properties¶
You may have noticed that the original Gas
object we initialised automatically populated dust properties. This is because the dust_to_metal_ratio
is by default set to 0.3 if neither dust_masses
nor dust_to_metal_ratio
are provided. This default value is then used to calculate the dust masses from the gas metallicities. If a dust_to_metal_ratio
is provided, the dust masses are calculated from the gas metallicities and the provided ratio. If dust_masses
are provided
explicitly, the dust-to-metal ratio is calculated but ignored in all future calculations.
Computing characteristics radii¶
Like Stars
, characteristic radii can be computed for the gas particle distribution. We can either calculate the half-mass radius.
[3]:
r = gas.get_half_mass_radius()
print(r)
0.49684355121396273 Mpc
Or use an aribtrary attribute for the radius weight. Here we’ll use the dust masses for a “half dust mass radius”.
[4]:
r = gas.get_attr_radius("dust_masses")
print(r)
0.49670175833477365 Mpc
We can also compute radii for different fractions by passing the fraction we want to calculate a radius for.
[5]:
r20 = gas.get_attr_radius("masses", frac=0.2)
r80 = gas.get_attr_radius("masses", frac=0.8)
print(r20, r80)
0.3572065202960369 Mpc 0.6135705263373029 Mpc