Spectral Modelling Functions

spectralradex.noise_from_spectrum(intensities)

Estimate the rms noise level from a spectrum by assuming it is a gaussian noise distribution plus positive signal. If this is true, the median should be the peak of the noise distribution and values smaller are just noise. Thus, the mean square difference between the median and smaller values is the square of the noise rms.

Parameters:intensities (float, iterable) – An array of the intensity values representing a spectrum
Returns:The rms noise value
Return type:float
spectralradex.convert_intensity_to_kelvin(frequencies, intensities, minor_beam, major_beam)

Convert a spectrum from jy/beam to kelvin. All spectra produced by spectralradex use kelvin so this function is intended to convert observed spectra for fitting. Treatment taken from https://science.nrao.edu/facilities/vla/proposing/TBconv

Parameters:
  • intensities (float, iterable) – An array of the frequency values representing a spectrum, in GHz
  • intensities – An array of the intensity values at each of the frequencies in the frequency array in Jy/beam.
  • minor_beam (float) – beamsize along minor axis in arcseconds
  • major_beam (float) – beamsize along major axis in arcseconds
spectralradex.maxwellian_distribution(v0, delta_v, tau_0, velocities)

Returns the optical depth as a function of velocity, assuming gaussian line profiles and given an optical depth a line centre

Parameters:
  • v0 (float) – Peak velocity of the emission
  • delta_v – FWHM of the peaks, taken from linewidth parameter of RADEX when called via model_spectrum()
  • tau_0 (float) – The optical depth at line centre. Taken from RADEX when called via model_spectrum()
  • velocities (float, iterable) – An iterable containing the velocity values at which to calculate tau
Returns:

An array with the tau value at each velocity in velocities

Return type:

ndarray,float

spectralradex.model_spectrum(obs_freqs, v0, radex_params, tau_profile=<function maxwellian_distribution>)

Calculates the brightness temperature as a function of frequency for given input frequencies, \(V_{LSR}\) velocity and RADEX parameters.

Parameters:
  • obs_freqs (iterable, float) – An array of frequency values in GHz at which the brightness temperature should be calculated.
  • v0 (float) – The \(V_{LSR}\) velocity of the emitting object to be modelled in km/s
  • radex_params (dict) – A dictionary containing the inputs for the RADEX model. See radex.get_default_parameters() for a list of possible parameters. Note this includes the linewidth in km/s that will be used to set the shape of the emission lines.
  • tau_profile (function, optional) – A function with the same arguments as maxwellian_distribution() that returns the optical depth as a function of velocity. If not set, spectralradex will assume gaussian line profiles centred on v0 and a FWHM taken from the RADEX parameters.