distroi.auxiliary.constants module#

A module to handle constants and other project-wide settings.

Contains constants, unit conversions, miscellaneous universal functions and plotting settings to be uniformly used throughout the project.

distroi.auxiliary.constants.AA2MICRON: float = 0.0001#

Angstrom to Micron conversion factor.

distroi.auxiliary.constants.AU2METER = 149600000000.0#

Astronomical unit to meter conversion factor.

distroi.auxiliary.constants.B_WIEN: float = 0.002897771955#

Wien’s displacement constant in SI units (m K).

distroi.auxiliary.constants.DEG2RAD: float = 0.017453292519943295#

Degree to radian conversion factor.

distroi.auxiliary.constants.ERG_PER_S_CM2_MICRON_2WATT_PER_M2_M: float = 1000.0#

Spectral flux density (F_lam) from erg s^-1 cm^-2 micron^-1 to SI (W m^-2 m^-1)

distroi.auxiliary.constants.FIG_DPI: int = 200#

DPI of the output figures.

distroi.auxiliary.constants.FIG_OUTPUT_TYPE: str = 'png'#

Output type of the figures (e.g. ‘pdf’ or ‘png’).

distroi.auxiliary.constants.GHZ2HZ: float = 999999999.9999999#

gigaHertz to Hertz conversion factor.

distroi.auxiliary.constants.HZ2GHZ: float = 1e-09#

Hertz to gigaHertz conversion factor.

distroi.auxiliary.constants.H_PLANCK: float = 6.62607015e-34#

Planck constant in SI units (J Hz^-1).

distroi.auxiliary.constants.IMG_CMAP = 'hot'#

Matplotlib colour map used for general images.

distroi.auxiliary.constants.IMG_CMAP_DIVERGING = 'bwr'#

Matplotlib colour map used for images needing a diverging colourmap.

distroi.auxiliary.constants.JY_2WATT_PER_M2_HZ: float = 9.999999999999999e-27#

Spectral flux density (F_nu) from Jansky to SI (W m^-2 Hz^-1) conversion factor.

distroi.auxiliary.constants.K_BOLTZMANN: float = 1.380649e-23#

Boltzmann’s constant in SI unis (J K^-1).

distroi.auxiliary.constants.LSOL2WATT: float = 3.828e+26#

Flux solar luminosity to Watt conversion factor.

distroi.auxiliary.constants.M2MICRON: float = 1000000.0#

Meter to micron conversion factor.

distroi.auxiliary.constants.MAS2RAD: float = 4.8481368110953594e-09#

Milli-arcsecond to radian conversion factor.

distroi.auxiliary.constants.METER2AU = 6.6844919786096254e-12#

Meter to astronomical unit conversion factor.

distroi.auxiliary.constants.MICRON2AA: float = 10000.0#

Micron to Angstrom conversion factor.

distroi.auxiliary.constants.MICRON2M: float = 1e-06#

Micrometer to meter conversion factor.

distroi.auxiliary.constants.PLOT_CMAP = 'rainbow'#

colour map used for other line/scatter plots.

distroi.auxiliary.constants.PROJECT_ROOT: str = '/home/docs/checkouts/readthedocs.org/user_builds/distroi/checkouts/latest'#

Root filepath of the project.

distroi.auxiliary.constants.RAD2DEG: float = 57.29577951308232#

Radian to degree conversion factor.

distroi.auxiliary.constants.RAD2MAS: float = 206264806.2470964#

Radian to milli-arcsecond conversion factor.

distroi.auxiliary.constants.SIG_STEFAN_BOLTZMANN: float = 5.670374419e-08#

Stefan-Boltzmann constant in SI units (W m^-2 K^-4).

distroi.auxiliary.constants.SPEED_OF_LIGHT: float = 299792458.0#

Speed of light in SI units (m s^-1).

distroi.auxiliary.constants.WATT2LSOL: float = 2.612330198537095e-27#

Flux Watt to solar luminosity conversion factor.

distroi.auxiliary.constants.WATT_PER_M2_HZ_2JY: float = 1e+26#

Spectral flux density (F_nu) from SI (W m^-2 Hz^-1) to Jansky conversion factor.

distroi.auxiliary.constants.WATT_PER_M2_M_2ERG_PER_S_CM2_MICRON: float = 0.001#

Spectral flux density (F_lam) from SI (W m^-2 m^-1) to erg s^-1 cm^-2 micron^-1

distroi.auxiliary.constants.bb_flam_at_frequency(frequency: ndarray | float, temp: float) ndarray | float#

Calculate spectral radiance of a blackbody curve in B_lam format and SI units for a given frequency.

Parameters:
  • temp (float) – Temperature of the blackbody in Kelvin.

  • frequency (float or np.ndarray) – Frequency in Hertz.

Returns:

B_lam spectral radiance of the blackbody in SI units (W m^-2 m^-1 sterradian^-1).

Return type:

float or np.ndarray

distroi.auxiliary.constants.bb_flam_at_wavelength(wavelength: ndarray | float, temp: float) ndarray | float#

Calculate spectral radiance of a blackbody curve in B_lam format and SI units for a given wavelength.

Parameters:
  • temp (float) – Temperature of the blackbody in Kelvin.

  • wavelength (float or np.ndarray) – Wavelength in micron.

Returns:

B_lam spectral radiance of the blackbody in SI units (W m^-2 m^-1 sterradian^-1).

Return type:

float or np.ndarray

distroi.auxiliary.constants.bb_fnu_at_frequency(frequency: ndarray | float, temp: float) ndarray | float#

Calculate spectral radiance of blackbody curve in B_nu format and SI units for a given frequency.

Parameters:
  • temp (float) – Temperature of the blackbody in Kelvin.

  • frequency (float or np.ndarray) – Frequency in Hertz.

Returns:

B_nu spectral radiance of the blackbody in SI units (W m^-2 Hz^-1 sterradian^-1).

Return type:

float or np.ndarray

distroi.auxiliary.constants.bb_fnu_at_wavelength(wavelength: ndarray | float, temp: float) ndarray | float#

Calculate spectral radiance of blackbody curve in B_nu format and SI units for given wavelength.

Parameters:
  • temp (float) – Temperature of the blackbody in Kelvin.

  • wavelength (float or np.ndarray) – Wavelength in micron.

Returns:

B_nu spectral radiance of the blackbody in SI units (W m^-2 Hz^-1 sterradian^-1).

Return type:

float or np.ndarray

distroi.auxiliary.constants.flam_cgs_per_mum_to_fnu_jansky(flam: ndarray | float, wavelength: ndarray | float) ndarray | float#

Convert spectral flux densities from F_lam in erg s^-1 cm^-2 micron^-1 to F_nu in Jansky.

Parameters:
  • flam (float or np.ndarray) – Spectral flux density in F_lam format and units of erg s^-1 cm^-2 micron^-1.

  • wavelength (float or np.ndarray) – Associated wavelengths in micron.

Returns:

Spectral flux density in F_nu format and Jy units.

Return type:

float or np.ndarray

distroi.auxiliary.constants.gaussian_2d_elliptical_ravel(points: tuple[ndarray, ndarray], amp: float = 1, x0: float = 0, y0: float = 0, sig_min: float = 1, sig_maj_min_sig_min: float = 0, pa: float = 0, offset: float = 0) ndarray#

Calculate value of elliptical 2D Gaussian as a ravelled array.

Function for calculating the value of a 2D Elliptical Gaussian at a given xy-point. Defined by an amplitude, xy center, standard deviations along major/minor axis, a major axis position angle and an offset. Returns a raveled array.

Parameters:
  • points (tuple of np.ndarray) – 2D tuples describing the (x, y) points to be inserted. Note that positive x is defined as leftward and positive y as upward (i.e. the East and North respectively in the OI convention).

  • amp (float, optional) – Amplitude of the Gaussian.

  • x0 (float, optional) – x-coordinate center of the Gaussian.

  • y0 (float, optional) – y-coordinate center of the Gaussian.

  • sig_min (float, optional) – Standard deviation in the minor axis direction.

  • sig_maj_min_sig_min (float, optional) – How much the standard deviation in major ellipse axis direction is greater than that of minor axis direction. Defined so it can always be greater than or equal to sig_min when used in scipy.optimize.curve_fit.

  • pa (float, optional) – Position angle of the Gaussian (i.e. the major axis direction) anti-clockwise, starting North (positive y).

  • offset (float, optional) – Base level offset from 0.

Returns:

A raveled 1D array containing the values of the Gaussian calculated at the points.

Return type:

np.ndarray

distroi.auxiliary.constants.nan_filter_arrays(ref_array, *args, filter_ref=False)#

Filter arrays based on NaN values of reference array.

Parameters:
  • ref_array (np.ndarray) – Reference array based on whose values NaN filtering will occur.

  • *args (tuple(np.ndarray)) – Extra arrays which will be filtered. Must have same shape as ref_array.

  • filter_ref (Bool) – Whether to filter ref_array itself. ref_array is not filtered in place but the filtered array is included in the returned tuple.

Returns:

filtered_arrays – Tuple of the filtered arrays in order, including the filtered reference array if filter_ref flag is used.

Return type:

tuple(np.ndarray)

distroi.auxiliary.constants.redden_flux(wavelength: ndarray | float, flux: ndarray | float, ebminv: float, reddening_law: str = '/home/docs/checkouts/readthedocs.org/user_builds/distroi/checkouts/latest/utils/ISM_reddening/ISMreddening_law_Cardelli1989.dat') ndarray#

Apply a reddening law to flux.

Takes wavelength(s) and the associated flux values, and reddens them according to the specified E(B-V) law. Note that this function will not extrapolate outside the wavelength ranges of the reddening law. Instead, no reddening will be applied outside this range.

Parameters:
  • wavelength (float or np.ndarray) – Wavelength(s) in micron.

  • flux (float or np.ndarray) – The flux(es) to be reddened. Can be in either F_nu/F_lam or nu*F_nu/lam*F_lam format and in any units.

  • ebminv (float) – E(B-V) reddening factor to be applied.

  • reddening_law (str, optional) – Path to the reddening law to be used. Defaults to the ISM reddening law by Cardelli (1989) in DISTROI’s ‘utils/ISM_reddening folder’. See this file for the expected formatting of your own reddening laws.

Returns:

The reddened flux value(s).

Return type:

np.ndarray

distroi.auxiliary.constants.set_matplotlib_params() None#

Function to set project-wide matplotlib parameters. To be used at the top of a distroi module if plotting functionalities are included in it.

Return type:

None