MetaModel#
- class mufasa.spec_models.meta_model.MetaModel(fittype, ncomp)[source]#
Bases:
objectA class to store spectral model-specific information relevant to spectral modeling tasks, such as fitting.
- adoptive_snr_masking#
Whether to use adaptive SNR masking during fitting (default is True).
- Type:
- central_win_hwidth#
The half-width of the intermediate window for filtering out satellite hyperfine lines. Default is None.
- Type:
float or None
- main_hf_moments#
Function for calculating moments for the main hyperfine component.
- Type:
function
- fitter#
The model generator function for fitting spectral components. Set based on fittype.
- Type:
function
- freq_dict#
Dictionary containing rest frequencies for the spectral lines. Set based on fittype.
- Type:
- rest_value#
Rest frequency of the spectral line in Hz. Set based on fittype.
- Type:
astropy.units.Quantity
- tau_wts#
Weights for the optical depth of hyperfine lines. Set based on fittype.
- voff_at_peak#
Velocity offset at the brightest hyperfine line in km/s. Set based on fittype.
- Type:
- model_func#
The specific spectral model function used for fitting. Set based on fittype.
- Type:
function
- model_function(xarr, parameters, planemask=None, multithreaded=False)[source]#
Compute the spectral model for a given spectral axis and model parameters.
- Parameters:
xarr (pyspeckit.spectrum.units.SpectroscopicAxis) – The spectral axis along which to evaluate the model function.
parameters (array-like) –
The model parameters for evaluation. Can be:
A 1D array with shape (l,), representing a single set of parameters.
A 2D array with shape (l, n), where l is the number of parameters, and n is the number of spatial positions.
A 3D array with shape (l, m, n), where l is the number of parameters per pixel, and m and n represent the spatial dimensions. In this case, the function will evaluate the model at each (m, n) pixel specified by planemask.
planemask (array-like, optional) – A 2D mask array with shape (m, n) indicating the pixels to evaluate when parameters is 3D. Pixels with True in the mask will be evaluated. If None, a default mask is generated where all non-zero, finite values in parameters are considered valid.
multithreaded (bool, optional) – Whether to enable multithreading to evaluate pixels in parallel when parameters is 2D or 3D. Default is False.
- Returns:
The evaluated spectral model values. The output shape matches the input shape of parameters:
If parameters is 1D, returns a 1D array of computed values.
If parameters is 2D, returns a 1D array with length n, containing computed values for each position.
If parameters is 3D, returns a 2D array with shape (m, n), containing computed values for each evaluated pixel in the masked region. Masked pixels are filled with NaN.
- Return type:
np.ndarray
- peakT(parameters, index_v=0, planemask=None, multithreaded=False)[source]#
Estimate the peak brightness temperature of the spectral model by evaluating the model at the spectral location (i.e., the velocity) of the brightest hyperfine line.
Note
This method only works for a single-component model, where the peak brightness is expected to be located near the brightest hyperfine line.
- Parameters:
parameters (array-like) –
The model parameters to evaluate, where each element corresponds to a parameter used in the spectral model. Can be:
A 1D array with shape (l,), representing a single set of parameters.
A 2D array with shape (l, n), where l is the number of parameters and n is the number of spatial positions.
A 3D array with shape (l, m, n), where l is the number of parameters per pixel, and m and n represent the spatial dimensions.
index_v (int, optional) – Index of the parameter corresponding to the velocity centroid, which is 0 for all spectral models implemented in MUFASA. Default is 0.
planemask (array-like, optional) – A 2D mask array with shape (m, n) indicating the pixels to evaluate when parameters is 3D. Pixels with True in the mask will be evaluated. If None, a mask is generated based on finite, non-zero values in parameters.
multithreaded (bool, optional) – Whether to enable multithreading to evaluate pixels in parallel when parameters is 2D or 3D. Default is False.
- Returns:
An array with the peak brightness temperature for each evaluated pixel:
If parameters is 1D, returns a scalar representing the peak brightness temperature.
If parameters is 2D, returns a 1D array with length n, containing the peak brightness temperature for each position.
If parameters is 3D, returns a 2D array with shape (m, n), containing the peak brightness temperature for each evaluated pixel in the masked region. Masked pixels are filled with NaN.
- Return type:
np.ndarray