Wavelet¶
-
class
turbustat.statistics.
Wavelet
(data, header=None, scales=None, num=50, distance=None)[source] [edit on github]¶ Bases:
turbustat.statistics.base_statistic.BaseStatisticMixIn
Compute the wavelet transform of a 2D array.
Parameters: - array : numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice
2D data.
- header : FITS header, optional
Header for the array.
- scales : numpy.ndarray or list
The scales where the transform is calculated.
- num : int, optional
Number of scales to compute the transform at.
- distance :
Quantity
, optional Physical distance to the region in the data.
Attributes Summary
Wf
The wavelet transforms of the image. brk
Break point in the segmented linear model. brk_err
1-sigma on the break point in the segmented linear model. data
distance
fit_range
Range of scales used in the fit. header
need_header_flag
no_data_flag
scales
Wavelet scales. slope
Fitted slope. slope_err
Standard error on the fitted slope. stddev
Standard deviation of the 1-dimensional wavelet transform. values
The 1-dimensional wavelet transform. Methods Summary
compute_transform
(self[, show_progress, …])Compute the wavelet transform at each scale. fit_transform
(self[, xlow, xhigh, brk, …])Perform a fit to the transform in log-log space. fitted_model
(self, xvals)Computes the fitted power-law in log-log space using the given x values. input_data_header
(self, data, header[, …])Check if the header is given separately from the data type. load_beam
(self[, beam])Try loading the beam from the header or a given object. load_results
(pickle_file)Load in a saved pickle file. plot_transform
(self[, save_name, xunit, …])Plot the transform and the fit. run
(self[, show_progress, verbose, xunit, …])Compute the Wavelet transform. save_results
(self, output_name[, keep_data])Save the results of the SCF to avoid re-computing. Attributes Documentation
-
Wf
¶ The wavelet transforms of the image. Each plane is the transform at different wavelet sizes.
-
brk
¶ Break point in the segmented linear model.
-
brk_err
¶ 1-sigma on the break point in the segmented linear model.
-
data
¶
-
distance
¶
-
fit_range
¶ Range of scales used in the fit.
-
header
¶
-
need_header_flag
= True¶
-
no_data_flag
= False¶
-
scales
¶ Wavelet scales.
-
slope
¶ Fitted slope.
-
slope_err
¶ Standard error on the fitted slope.
-
stddev
¶ Standard deviation of the 1-dimensional wavelet transform.
-
values
¶ The 1-dimensional wavelet transform.
Methods Documentation
-
compute_transform
(self, show_progress=True, scale_normalization=True, keep_convolved_arrays=False, convolve_kwargs={}, use_pyfftw=False, threads=1, pyfftw_kwargs={})[source] [edit on github]¶ Compute the wavelet transform at each scale.
Parameters: - show_progress : bool, optional
Show a progress bar during the creation of the covariance matrix.
- scale_normalization: bool, optional
Compute the transform with the correct scale-invariant normalization.
- keep_convolved_arrays: bool, optional
Keep the image convolved at all wavelet scales. For large images, this can require a large amount memory. Default is False.
- convolve_kwargs : dict, optional
Passed to
convolve_fft
.- 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
See here for a list of accepted kwargs.
-
fit_transform
(self, xlow=None, xhigh=None, brk=None, min_fits_pts=3, weighted_fit=False, bootstrap=False, bootstrap_kwargs={}, **fit_kwargs)[source] [edit on github]¶ Perform a fit to the transform in log-log space.
Parameters: - xlow :
Quantity
, optional Lower scale value to consider in the fit.
- xhigh :
Quantity
, optional Upper scale value to consider in the fit.
- brk :
Quantity
, optional Give an initial guess for a break point. This enables fitting with a
turbustat.statistics.Lm_Seg
.- min_fits_pts : int, optional
Minimum number of points required above or below the fitted break for it to be considered a valid fit. Only used when a segmented line is fit, i.e. when a value for
brk
is given.- weighted_fit: bool, optional
Use the
stddev
to perform a weighted fit.- bootstrap : bool, optional
Bootstrap using the model residuals to estimate the standard errors.
- bootstrap_kwargs : dict, optional
Pass keyword arguments to
residual_bootstrap
.- fit_kwargs : Passed to
turbustat.statistics.Lm_Seg.fit_model
- xlow :
-
fitted_model
(self, xvals)[source] [edit on github]¶ Computes the fitted power-law in log-log space using the given x values.
Parameters: - xvals :
ndarray
Values of log(lags) to compute the model at (base 10 log).
Returns: - model_values :
ndarray
Values of the model at the given values.
- xvals :
-
input_data_header
(self, data, header, need_copy=False) [edit on github]¶ Check if the header is given separately from the data type.
-
load_beam
(self, 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_transform
(self, save_name=None, xunit=Unit("pix"), color='r', symbol='o', fit_color='k', label=None, show_residual=True)[source] [edit on github]¶ Plot the transform and the 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 wavelet 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 fit residuals.
-
run
(self, show_progress=True, verbose=False, xunit=Unit("pix"), convolve_kwargs={}, use_pyfftw=False, threads=1, pyfftw_kwargs={}, scale_normalization=True, xlow=None, xhigh=None, brk=None, fit_kwargs={}, save_name=None, **plot_kwargs)[source] [edit on github]¶ Compute the Wavelet transform.
Parameters: - show_progress : bool, optional
Show a progress bar during the creation of the covariance matrix.
- verbose : bool, optional
Plot wavelet transform.
- xunit : u.Unit, optional
Choose the unit to convert to when ang_units is enabled.
- convolve_kwargs : dict, optional
Passed to
convolve_fft
.- scale_normalization: bool, optional
Compute the transform with the correct scale-invariant normalization.
- 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
See here for a list of accepted kwargs.
- scale_normalization: bool, optional
Multiply the wavelet transform by the correct normalization factor.
- xlow :
Quantity
, optional Lower scale value to consider in the fit.
- xhigh :
Quantity
, optional Upper scale value to consider in the fit.
- brk :
Quantity
, optional Give an initial guess for a break point. This enables fitting with a
turbustat.statistics.Lm_Seg
.- fit_kwargs : dict, optional
Passed to
fit_transform
- save_name : str,optional
Save the figure when a file name is given.
- plot_kwargs : Passed to
plot_transform
.
-
save_results
(self, 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.