API Reference#

This is MUFASA’s class and function reference. In addition to the table below, you can also search with the search bar located on the top right corner of the webpage.

Object

Description

UCubePlus

A subclass of UltraCube that includes directory management for parameter maps and model fits.

UltraCube

A framework for multi-component spectral cube analysis and model fitting.

calc_AICc

Calculate the corrected Akaike Information Criterion (AICc) for a spectral cube model.

calc_AICc_likelihood

Calculate the relative likelihood of two models based on their AICc values.

calc_chisq

Calculate the chi-squared (χ²) or reduced chi-squared value for a spectral cube model fit.

calc_rss

Calculate the residual sum of squares (RSS) for a spectral cube model fit.

convolve_sky_byfactor

Convolve the spatial dimensions of a spectral cube by a specified factor.

expand_mask

Expand a 3D mask along the spectral axis by a specified buffer size.

fit_cube

Fit the spectral cube using the specified fitting type.

get_Tpeak

Calculate the peak value of a model cube at each spatial pixel.

get_all_lnk_maps

Compute log-likelihood ratio maps for model comparisons up to a specified number of components.

get_best_2c_parcube

Select the best 2-component parameter cube based on AICc likelihood thresholds.

get_chisq

Calculate the chi-squared or reduced chi-squared value for a spectral cube.

get_masked_moment

Calculate a masked moment of a spectral cube.

get_residual

Calculate the residual between the data cube and the model cube.

get_rms

Compute a robust estimate of the root mean square (RMS) from the fit residuals.

get_rss

Calculate the residual sum of squares (RSS) for a spectral cube model fit.

is_K

Check if a given unit is equivalent to Kelvin (K).

load_model_fit

Load the spectral fit results from a .fits file.

save_fit

Save the fitted parameter cube to a .fits file with the appropriate header.

to_K

Convert the unit of a spectral cube to Kelvin (K).

AIC

Calculate the Akaike Information Criterion (AIC).

AICc

Calculate the corrected Akaike Information Criterion (AICc).

fits_comp_AICc

A wrapper function to calculate corrected Akaike Information Criterion (AICc) values

fits_comp_chisq

Calculate and save chi-squared values for the given cube and model fits.

get_comp_AICc

Calculate AICc values for two models over the same samples.

likelihood

Calculate the log-likelihood of model A relative to model B.

fit_results

No description available.

above_ErrV_Thresh

No description available.

clean_2comp_maps

No description available.

exclusive_2comp_maps

No description available.

extremeV_mask

No description available.

remove_zeros

No description available.

convolve_sky

No description available.

convolve_sky_byfactor

No description available.

edge_trim

No description available.

get_celestial_hdr

No description available.

regrid

No description available.

regrid_mask

No description available.

snr_mask

No description available.

deblend

Deblend hyperfine structures in a cube based on fitted models.

FitTypeError

Fitttype provided is not valid.

SNRMaskError

SNR Mask has no valid pixel.

StartFitError

Fitting failed from the beginning

get_celestial_hdr

No description available.

guess_from_cnvpara

No description available.

mask_cleaning

No description available.

mask_swap_2comp

No description available.

master_mask

No description available.

quick_2comp_sort

No description available.

refine_2c_guess

No description available.

refine_each_comp

No description available.

refine_guess

No description available.

regrid

No description available.

save_guesses

No description available.

simple_para_clean

No description available.

tautex_renorm

No description available.

Region

A class to represent the observed spectral cube to perform the model fits.

expand_fits

Expand fits in a region by incrementally fitting pixels beyond a defined

fit_best_2comp_residual_cnv

Fit the convolved residual of the best-fit two-component spectral model

fit_surroundings

Expand fits around a region based on model log-likelihood thresholds and

get_2comp_wide_guesses

Generate initial guesses for fitting a two-component spectral model with

get_best_2comp_model

Retrieve the best-fit model cube for the given Region object.

get_best_2comp_residual

Calculate the residual cube for the best-fit two-component model.

get_best_2comp_residual_SpectralCube

Generate the residual spectral cube for the best-fit two-component

get_best_2comp_residual_cnv

Generate a convolved residual cube for the best-fit two-component

get_best_2comp_snr_mod

Calculate the signal-to-noise ratio (SNR) map for the best-fit two-

get_convolved_cube

Generate and save a convolved version of the spectral cube for a given

get_convolved_fits

Fit a model to the convolved cube and save the results.

get_fits

Fit a model to the original spectral cube and save the results.

get_local_bad

Identify local pixels with significantly lower relative log-likelihood

get_marginal_pix

Return pixels at the edge of structures with values greater than

get_refit_guesses

Generate initial guesses for refitting based on neighboring pixels or

get_skyheader

Generate a 2D sky projection header from a 3D spectral cube header.

iter_2comp_fit

Perform a two-component fit iterantively through two steps. The first

master_2comp_fit

Perform a two-component fit on the data cube within a Region object.

refit_2comp_wide

Refit pixels to recover compoents with wide velocity separation for

refit_bad_2comp

Refit pixels with poor 2-component fits, as determined by the log-

refit_marginal

Refit pixels with fits that appears marginally okay, as deterined by the

refit_swap_2comp

Refit the cube by using the previous fit result as guesses, but with the

replace_bad_pix

Refit pixels marked by the mask as “bad” and adopt the new model if it

replace_para

Replace parameter values in a parameter cube with those from a reference

replace_rss

Replace RSS-related maps in a `UltraCube` object for specific

save_best_2comp_fit

Save the best two-component fit results for the specified region.

save_map

Save a 2D map as a FITS file.

save_updated_paramaps

Save the updated parameter maps for specified components.

standard_2comp_fit

Perform a two-component fit for the cube using default moment map

LineSetup

No description available.

adaptive_moment_maps

No description available.

get_rms_prefit

No description available.

get_tau

No description available.

get_tex

No description available.

get_window_slab

No description available.

master_guess

No description available.

mom_guess_wide_sep

No description available.

moment_guesses

Generate reasonable initial guesses for multiple component fits based on moment maps.

moment_guesses_1c

No description available.

noisemask_moment

No description available.

peakT

No description available.

vmask_cube

No description available.

vmask_moments

No description available.

window_mask_pcube

No description available.

window_moments

Calculate the zeroth, first, and second moments of a spectrum or cube

cubefit_gen

No description available.

cubefit_simp

No description available.

default_masking

No description available.

get_chisq

No description available.

get_start_point

No description available.

get_vstats

No description available.

handle_snr

No description available.

make_header

No description available.

match_pcube_mask

No description available.

register_pcube

No description available.

retry_fit

No description available.

save_guesses

No description available.

save_pcube

No description available.

set_pyspeckit_verbosity

No description available.

snr_estimate

No description available.

estimate_mode

Estimate the mode of the data using a histogram.

get_moments

Calculate moments of the signals in a cube.

get_rms_robust

Make a robust RMS estimate.

get_signal_mask

Provide a 3D mask indicating signal regions based on RMS and SNR threshold.

get_snr

Calculate the peak signal-to-noise ratio of the cube.

get_v_at_peak

Find the velocity corresponding to the peak emission.

get_v_mask

Return a mask centered on a reference velocity with a spectral window.

refine_rms

Refine the RMS estimate by masking out signal regions.

refine_signal_mask

Refine a signal mask by removing noisy features and expanding the mask.

trim_cube_edge

Remove spatial edges from a cube.

trim_edge

Trim edges using a 2D mask.

v_estimate

Estimate the velocity centroid based on peak emission.

distance_metric

No description available.

mask_swap_2comp

No description available.

quick_2comp_sort

No description available.

refmap_2c_mask

No description available.

sort_2comp

No description available.

BaseModel

Generalized base class for multi-component spectral models.

HyperfineModel

Spectral model for multi-component fitting with hyperfine structure.

AmmoniaModel

Ammonia (NH₃) spectral model for multi-component fitting.

N2HplusModel

N₂H⁺ (Diazenylium) spectral model for multi-component fitting.

T_antenna

No description available.

ammonia_multi_v

No description available.

nh3_multi_v_model_generator

No description available.

MetaModel

A class to store spectral model-specific information relevant to spectral modeling tasks, such as fitting.

n2hp_vtau_singlemodel_deblended

No description available.

T_antenna

No description available.

n2hp_multi_v

No description available.

n2hp_multi_v_model_generator

No description available.

nh3_vtau_singlemodel_deblended

No description available.

assign_to_dataframe

Assign values from a new data array to an existing DataFrame based on spatial coordinates and component index.

make_dataframe

Create a DataFrame from a 3D parameter array, applying optional velocity and error thresholds.

read

Read a FITS file and convert the data to a pandas DataFrame, optionally including the header.

deprecated

Mark a function or class as deprecated.

downsample_header

Downsample a FITS header along a specified axis.

get_pixel_mapping

Compute the pixel mapping between two FITS headers or WCS objects.

expand_interpolate

No description available.

iter_expand

No description available.

dist_divide

No description available.

watershed_divide

No description available.

calculate_dask_memory_limit

Mimic Dask’s default memory limit setting.

calculate_target_memory

Calculate target memory per core for chunked computations.

get_size_mb

No description available.

get_system_free_memory

No description available.

monitor_peak_memory

Decorator to monitor and record the peak memory usage of a function.

peak_memory

Decorator to monitor and display the peak memory usage of a function,

tmp_save_gauge

Return whether or not it’s worth DaskSpectralCube results temporary

OriginContextFilter

No description available.

WarningContextFilter

No description available.

get_logger

No description available.

init_logging

:param logfile: file to save to (default mufasa.log)

reset_logger

No description available.

validate_n_cores

No description available.

disk_neighbour

No description available.

footprint_rectangle

Generate a rectangular or hyper-rectangular footprint.

get_neighbor_coord

No description available.

get_valid_neighbors

No description available.

maxref_neighbor_coords

No description available.

square_neighbour

No description available.

ScatterPPV

A class to plot the fitted parameters in 3D scatter plots. Most of the data is stored in a pandas DataFrame.

scatter_3D

Plot a 3D scatter plot with optional opacity scaling for point ranges.

scatter_3D_df

A wrapper for scatter_3D to quickly plot a pandas DataFrame in 3D.

Plotter

No description available.

ensure_units_compatible

Ensure the limits have compatible units with the data, converting if needed.

get_cube_slab

Extract a spectral slab from the cube over the specified velocity range.

get_spec_grid

Create a grid of subplots for spectra.

plot_fits_grid

Plot a grid of model fits from the cube centered at (x, y).

plot_model

Plot a model fit for a spectrum.

plot_spec

plot_spec_grid

Plot a grid of spectra from the cube centered at (x, y).

strip_units

Helper function to strip units from a limit tuple if it contains Quantity.