VCS

class turbustat.statistics.VCS(cube, header=None)[source]

Bases: BaseStatisticMixIn

The VCS technique (Lazarian & Pogosyan, 2004).

Parameters:
cubenumpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or SpectralCube

Data cube.

headerFITS header, optional

Corresponding FITS header.

vel_unitsbool, optional

Convert frequencies to the spectral unit in the header.

Attributes Summary

brk

Fitted break point.

brk_err

1-sigma on the break point.

data

distance

header

need_header_flag

no_data_flag

ps1D

The 1D VCS spectrum.

slope

Power spectrum slope(s).

slope_err

1-sigma error on the power spectrum slope(s).

Methods Summary

compute_pspec([use_pyfftw, threads])

Take the FFT of each spectrum in the velocity dimension and average.

fit_pspec([breaks, log_break, low_cut, ...])

Fit the 1D Power spectrum using a segmented linear model.

input_data_header(data, header[, need_copy])

Check if the header is given separately from the data type.

load_beam([beam])

Try loading the beam from the header or a given object.

load_results(pickle_file)

Load in a saved pickle file.

plot_fit([save_name, xunit, color, symbol, ...])

Plot the VCS curve and the associated fit.

run([verbose, save_name, xunit, use_pyfftw, ...])

Run the entire computation.

save_results(output_name[, keep_data])

Save the results of the SCF to avoid re-computing.

Attributes Documentation

brk

Fitted break point.

brk_err

1-sigma on the break point.

data
distance
header
need_header_flag = True
no_data_flag = False
ps1D

The 1D VCS spectrum.

slope

Power spectrum slope(s).

slope_err

1-sigma error on the power spectrum slope(s).

Methods Documentation

compute_pspec(use_pyfftw=False, threads=1, **pyfftw_kwargs)[source]

Take the FFT of each spectrum in the velocity dimension and average.

Parameters:
use_pyfftwbool, optional

Enable to use pyfftw, if it is installed.

threadsint, optional

Number of threads to use in FFT when using pyfftw.

pyfftw_kwargsPassed to

rfft_to_fft. See here for a list of accepted kwargs.

fit_pspec(breaks=None, log_break=True, low_cut=None, high_cut=None, fit_verbose=False, bootstrap=False, **bootstrap_kwargs)[source]

Fit the 1D Power spectrum using a segmented linear model. Note that the current implementation allows for only 1 break point in the model. If the break point is estimated via a spline, the breaks are tested, starting from the largest, until the model finds a good fit.

Parameters:
breaksfloat or None, optional

Guesses for the break points. If given as a list, the length of the list sets the number of break points to be fit. If a choice is outside of the allowed range from the data, Lm_Seg will raise an error. If None, a spline is used to estimate the breaks.

log_breakbool, optional

Sets whether the provided break estimates are log-ed values.

low_cutQuantity, optional

Lowest frequency to consider in the fit.

high_cutQuantity, optional

Highest frequency to consider in the fit.

fit_verbosebool, optional

Enables verbose mode in Lm_Seg.

bootstrapbool, optional

Bootstrap using the model residuals to estimate the standard errors.

bootstrap_kwargsdict, optional

Pass keyword arguments to residual_bootstrap.

input_data_header(data, header, need_copy=False)

Check if the header is given separately from the data type.

load_beam(beam=None)

Try loading the beam from the header or a given object.

Parameters:
beamBeam, optional

The beam.

static load_results(pickle_file)

Load in a saved pickle file.

Parameters:
pickle_filestr

Name of filename to load in.

Returns:
selfSave statistic class

Statistic instance with saved results.

Examples

Load saved results. >>> stat = Statistic.load_results(“stat_saved.pkl”) # doctest: +SKIP

plot_fit(save_name=None, xunit=Unit('1 / pix'), color='r', symbol='o', fit_color='k', label=None, show_residual=True)[source]

Plot the VCS curve and the associated fit.

Parameters:
save_namestr, optional

Save name for the figure. Enables saving the plot.

xunitUnit, optional

Choose the angular unit to convert to when ang_units is enabled.

color{str, RGB tuple}, optional

Color to plot the VCS curve.

symbolstr, optional

Symbol to use for the data.

fit_color{str, RGB tuple}, optional

Color of the 1D fit.

labelstr, optional

Label to later be used in a legend.

show_residualbool, optional

Plot the residuals for the 1D power-spectrum fit.

run(verbose=False, save_name=None, xunit=Unit('1 / pix'), use_pyfftw=False, threads=1, pyfftw_kwargs={}, **fit_kwargs)[source]

Run the entire computation.

Parameters:
verbose: bool, optional

Enables plotting.

save_namestr,optional

Save the figure when a file name is given.

xunitu.Unit, optional

Choose the unit to convert the x-axis in the plot to.

use_pyfftwbool, optional

Enable to use pyfftw, if it is installed.

threadsint, optional

Number of threads to use in FFT when using pyfftw.

pyfftw_kwargsPassed to

rfft_to_fft. See here for a list of accepted kwargs.

fit_kwargsPassed to fit_pspec.
save_results(output_name, keep_data=False)

Save the results of the SCF to avoid re-computing. The pickled file will not include the data cube by default.

Parameters:
output_namestr

Name of the outputted pickle file.

keep_databool, optional

Save the data cube in the pickle file when enabled.