synthesizer.units

A module for dynamically returning attributes with and without units.

The Units class below acts as a container of unit definitions for various attributes spread throughout Synthesizer.

The Quantity is the object that defines all attributes with attached units. Its a helper class which enables the optional return of units.

Example defintion:

class Foo:

bar = Quantity()

def __init__(self, bar):

self.bar = bar

Example usage:

foo = Foo(bar)

bar_with_units = foo.bar bar_no_units = foo._bar

Classes

class synthesizer.units.Quantity[source]

Provides the ability to associate attribute values on an object with unyt units defined in the global unit system held in (Units).

units

The global unit system.

Type:

Units

public_name

The name of the class variable containing Quantity. Used the user wants values with a unit returned.

Type:

str

private_name

The name of the class variable with a leading underscore. Used the mostly internally for (or when the user wants) values without a unit returned.

Type:

str

class synthesizer.units.UnitSingleton[source]

A metaclass used to ensure singleton behaviour of Units.

i.e. there can only ever be a single instance of a class in a namespace.

Adapted from: https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python

class synthesizer.units.Units(new_units=None, force=False)[source]

Holds the definition of the internal unit system using unyt.

Units is a Singleton, meaning there can only ever be one. Each time a new instance is instantiated the original will be returned. This enforces a consistent unit system is used in a single top level namespace.

All default attributes are hardcoded but these can be modified by instantiating the original Units instance with a dictionary of units of the form {“variable”: unyt.unit}. This must be done before any calculations have been performed, changing the unit system will not retroactively convert computed quantities! In fact, if any quantities have been calculated the original default Units object will have already been instantiated, thus the default Units will be returned regardless of the modifications dictionary due to the rules of a Singleton metaclass. The user can force an update but BE WARNED this is dangerous and should be avoided.

lam

Rest frame wavelength unit.

Type:

unyt.unit_object.Unit

obslam

Observer frame wavelength unit.

Type:

unyt.unit_object.Unit

wavelength

Alias for rest frame wavelength unit.

Type:

unyt.unit_object.Unit

nu

Rest frame frequency unit.

Type:

unyt.unit_object.Unit

obsnu

Observer frame frequency unit.

Type:

unyt.unit_object.Unit

nuz

Observer frame frequency unit.

Type:

unyt.unit_object.Unit

luminosity

Luminosity unit.

Type:

unyt.unit_object.Unit

lnu

Rest frame spectral luminosity density (in terms of frequency) unit.

Type:

unyt.unit_object.Unit

llam

Rest frame spectral luminosity density (in terms of wavelength) unit.

Type:

unyt.unit_object.Unit

continuum

Continuum level of an emission line unit.

Type:

unyt.unit_object.Unit

fnu

Spectral flux density (in terms of frequency) unit.

Type:

unyt.unit_object.Unit

flam

Spectral flux density (in terms of wavelength) unit.

Type:

unyt.unit_object.Unit

flux

“Rest frame” Spectral flux density (at 10 pc) unit.

Type:

unyt.unit_object.Unit

photo_luminosities

Rest frame photometry unit.

Type:

unyt.unit_object.Unit

photo_fluxes

Observer frame photometry unit.

Type:

unyt.unit_object.Unit

ew

Equivalent width unit.

Type:

unyt.unit_object.Unit

coordinates

Particle coordinate unit.

Type:

unyt.unit_object.Unit

smoothing_lengths

Particle smoothing length unit.

Type:

unyt.unit_object.Unit

softening_length

Particle gravitational softening length unit.

Type:

unyt.unit_object.Unit

velocities

Particle velocity unit.

Type:

unyt.unit_object.Unit

masses

Particle masses unit.

Type:

unyt.unit_object.Unit

initial_masses

Stellar particle initial mass unit.

Type:

unyt.unit_object.Unit

initial_mass

Stellar population initial mass unit.

Type:

unyt.unit_object.Unit

current_masses

Stellar particle current mass unit.

Type:

unyt.unit_object.Unit

dust_masses

Gas particle dust masses unit.

Type:

unyt.unit_object.Unit

ages

Stellar particle age unit.

Type:

unyt.unit_object.Unit

accretion_rate

Black hole accretion rate unit.

Type:

unyt.unit_object.Unit

bolometric_luminosity

Bolometric luminositiy unit.

Type:

unyt.unit_object.Unit

bolometric_luminosities

Bolometric luminositiy unit.

Type:

unyt.unit_object.Unit

bb_temperature

Black hole big bump temperature unit.

Type:

unyt.unit_object.Unit

bb_temperatures

Black hole big bump temperature unit.

Type:

unyt.unit_object.Unit

inclination

Black hole inclination unit.

Type:

unyt.unit_object.Unit

inclinations

Black hole inclination unit.

Type:

unyt.unit_object.Unit

resolution

Image resolution unit.

Type:

unyt.unit_object.Unit

fov

Field of View unit.

Type:

unyt.unit_object.Unit

orig_resolution

Original resolution (for resampling) unit.

Type:

unyt.unit_object.Unit

centre

Centre of the image unit.

Type:

unyt.unit_object.Unit