H2SSSCAM Modules
Functions to perform basic calculations required to create spectograms.
- class h2ssscam.BaseCalc.BaseCalc(constant: h2ssscam.Constants.Constants, _dv_phys: astropy.units.quantity.Quantity = None, _dv_tot: astropy.units.quantity.Quantity = None, _tau: astropy.units.quantity.Quantity = None, _tau_tot: astropy.units.quantity.Quantity = None, _siglu: astropy.units.quantity.Quantity = None)
Bases:
object- blackbody(lam, temp, unit)
Compute the photon radiance of a blackbody at a given temperature.
- Parameters:
lam (astropy.units.Quantity) – Wavelength array (e.g., in Å or m).
temp (astropy.units.Quantity) – Blackbody temperature (e.g., in K).
unit (astropy.units.Quantity) – Continuum units or CGS units.
- Returns:
Photon radiance [ph / (cm2 s sr Å)].
- Return type:
astropy.units.Quantity
- boltzmann(Ntot, ju, jl, lam, T)
Partitioning via Boltzmann distribution.
- Parameters:
Ntot (astropy.units.Quantity) – Total column density.
ju (int) – Upper rotational quantum numbers.
jl (int) – Lower rotational quantum numbers.
lam (astropy.units.Quantity) – Transition wavelength.
T (astropy.units.Quantity) – Gas temperature.
- Returns:
Column density in lower level (cm^-2).
- Return type:
astropy.units.Quantity
- calc_abs_rate(I0, tau, tau_all, unit)
Compute absorbed rate per line.
- Parameters:
I0 (array) – Incident continuum intensity.
tau (array) – Line optical depths.
tau_all (array) – Total optical depth across lines.
unit (astropy.units.Quantity) – Continuum units or CGS units.
- Returns:
Absorption rates per line.
- Return type:
array
Notes
Implements Eq. 12-13 (McJunkin et al. 2016).
- calc_flu(ju, jl, lamlu, Aul)
Calculate oscillator strength f_lu from Einstein A coefficient.
- Parameters:
ju (array-like) – Upper rotation levels
jl (array-like) – Lower rotation levels
lamlu (astropy.units.Quantity) – Transition wavelengths.
Aul (astropy.units.Quantity) – Einstein A coefficients.
- Returns:
Oscillator strengths.
- Return type:
array
Notes
Implements Eq. 1 (McJunkin et al. 2016).
Original code includes multiplicity (2s + 1); McJunkin et al. 2016 does not.
- calc_nvj(ntot, T)
Compute level populations N_vJ for all v,J.
- Parameters:
ntot (astropy.units.Quantity) – Total column density.
T (astropy.units.Quantity) – Temperature.
vmax (int, optional) – Max vibrational and rotational levels., by default VMAX
jmax (int, optional) – Max vibrational and rotational levels., by default JMAX
- Returns:
Populations per level.
- Return type:
array
Notes
Implements Eq. 8 (McJunkin et al. 2016).
- calc_spec(lam, lamlu, Atot, dv, flux_per_trans, source, unit, dopp_v=0)
Build emergent spectrum from line profiles + continuum.
- Parameters:
lam (astropy.units.Quantity) – Wavelength grid.
lamlu (astropy.units.Quantity) – Line wavelengths.
Atot (astropy.units.Quantity) – Damping constants.
dv (astropy.units.Quantity) – Doppler width.
flux_per_trans (array) – Flux per transition.
source (array) – Continuum source function.
unit (astropy.units.Quantity) – Continuum units or CGS units.
dopp_v (astropy.units.Quantity, optional) – Doppler Velocity.
- Returns:
array – Wavelength grid.
array – Normalized emission-only spectrum.
array – Normalized total spectrum including continuum.
- property dv_phys
- property dv_tot
- reset_parameters()
Clean calculated and stored values
- siglu(lam=None, hih2_lamlu=None, hih2_Atot=None, hih2_flu=None)
- tau(hih2_N=None)
- property tau_tot
- uv_continuum(lam, unit)
Empirical UV continuum function.
- Parameters:
lam (astropy.units.Quantity) – Wavelength grid.
unit (astropy.units.Quantity) – Continuum units or CGS units.
- Returns:
Continuum intensity.
- Return type:
array
Notes
Original fit comes from Draine (1978).
- h2ssscam.plotting_funcs.plot_spectrum(wavelengths, intensity, xmin=None, xmax=None, ymin=None, ymax=None, units=None, ylabel=None, title='Spectrum', show=False)
Plots intensity over wavelength.
- Parameters:
wavelengths (array) – Grid of equally spaced wavelength points.
intensity (array) – Grid of corresponding intensity points.
xmin (float, optional) – Minimum value on the x-axis, by default None
xmax (float, optional) – Maximum value on the x-axis, by default None
ymin (float, optional) – Minimum value on the y-axis, by default None
ymax (float, optional) – aximum value on the y-axis, by default None
units (astropy.units.Quantity, optional) – Chosen units for intensity, by default None
ylabel (str, optional) – Label on the y-axis, by default None
title (regexp, optional) – Title of the Plot, by default r”Spectrum”
show (bool, optional) – Option to display plot, by default False
- Raises:
ValueError –
- class h2ssscam.Constants.Constants(user_config_path: str | None = None)
Bases:
object- read_config_files(user_config_path)
Loads default config file from the package and user’s config file if specified
- Parameters:
user_config_path (str) – Path to the config file
- Return type:
configparser
- save_config_file(output_path)
Save config file with currently used parameters value
- Parameters:
output_path (str) – Output file path
- value(parameter_name, parameter_type=<class 'float'>)
Load a parameter value from the configparser and transform it to float if required
- Parameters:
parameter_name (str) – Name of a parameter
parameter_type (type, optional) – Transform parameter value into this type; configparser stores everything as strings. Only float is implemented, and by default float
- Return type:
str | float
- Raises:
ValueError – If parameter is not defined in the config file