VCS¶
-
class
turbustat.statistics.
VCS
(cube, header=None)[source] [edit on github]¶ Bases:
turbustat.statistics.base_statistic.BaseStatisticMixIn
The VCS technique (Lazarian & Pogosyan, 2004).
Parameters: - cube : numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or SpectralCube
Data cube.
- header : FITS header, optional
Corresponding FITS header.
- vel_units : bool, 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] [edit on github]¶ Take the FFT of each spectrum in the velocity dimension and average.
Parameters: - use_pyfftw : bool, optional
Enable to use pyfftw, if it is installed.
- threads : int, optional
Number of threads to use in FFT when using pyfftw.
- pyfftw_kwargs : Passed 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] [edit on github]¶ 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: - breaks : float 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_break : bool, optional
Sets whether the provided break estimates are log-ed values.
- low_cut :
Quantity
, optional Lowest frequency to consider in the fit.
- high_cut :
Quantity
, optional Highest frequency to consider in the fit.
- fit_verbose : bool, optional
Enables verbose mode in Lm_Seg.
- bootstrap : bool, optional
Bootstrap using the model residuals to estimate the standard errors.
- bootstrap_kwargs : dict, optional
Pass keyword arguments to
residual_bootstrap
.
-
input_data_header
(data, header, need_copy=False) [edit on github]¶ Check if the header is given separately from the data type.
-
load_beam
(beam=None) [edit on github]¶ Try loading the beam from the header or a given object.
Parameters: - beam :
Beam
, optional The beam.
- beam :
-
static
load_results
(pickle_file) [edit on github]¶ Load in a saved pickle file.
Parameters: - pickle_file : str
Name of filename to load in.
Returns: - self : Save 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] [edit on github]¶ Plot the VCS curve and the associated fit.
Parameters: - save_name : str, optional
Save name for the figure. Enables saving the plot.
- xunit :
Unit
, optional Choose the angular unit to convert to when ang_units is enabled.
- color : {str, RGB tuple}, optional
Color to plot the VCS curve.
- symbol : str, optional
Symbol to use for the data.
- fit_color : {str, RGB tuple}, optional
Color of the 1D fit.
- label : str, optional
Label to later be used in a legend.
- show_residual : bool, 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] [edit on github]¶ Run the entire computation.
Parameters: - verbose: bool, optional
Enables plotting.
- save_name : str,optional
Save the figure when a file name is given.
- xunit : u.Unit, optional
Choose the unit to convert the x-axis in the plot to.
- use_pyfftw : bool, optional
Enable to use pyfftw, if it is installed.
- threads : int, optional
Number of threads to use in FFT when using pyfftw.
- pyfftw_kwargs : Passed to
rfft_to_fft
. See here for a list of accepted kwargs.- fit_kwargs : Passed to
fit_pspec
.
-
save_results
(output_name, keep_data=False) [edit on github]¶ Save the results of the SCF to avoid re-computing. The pickled file will not include the data cube by default.
Parameters: - output_name : str
Name of the outputted pickle file.
- keep_data : bool, optional
Save the data cube in the pickle file when enabled.