Wavelet

class turbustat.statistics.Wavelet(data, header=None, scales=None, num=50, distance=None)[source]

Bases: BaseStatisticMixIn

Compute the wavelet transform of a 2D array.

Parameters:
arraynumpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice

2D data.

headerFITS header, optional

Header for the array.

scalesnumpy.ndarray or list

The scales where the transform is calculated.

numint, optional

Number of scales to compute the transform at.

distanceQuantity, 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([show_progress, ...])

Compute the wavelet transform at each scale.

fit_transform([xlow, xhigh, brk, ...])

Perform a fit to the transform in log-log space.

fitted_model(xvals)

Computes the fitted power-law in log-log space using the given x values.

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_transform([save_name, xunit, color, ...])

Plot the transform and the fit.

run([show_progress, verbose, xunit, ...])

Compute the Wavelet transform.

save_results(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(show_progress=True, scale_normalization=True, keep_convolved_arrays=False, convolve_kwargs={}, use_pyfftw=False, threads=1, pyfftw_kwargs={})[source]

Compute the wavelet transform at each scale.

Parameters:
show_progressbool, 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_kwargsdict, optional

Passed to convolve_fft.

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

See here for a list of accepted kwargs.

fit_transform(xlow=None, xhigh=None, brk=None, min_fits_pts=3, weighted_fit=False, bootstrap=False, bootstrap_kwargs={}, **fit_kwargs)[source]

Perform a fit to the transform in log-log space.

Parameters:
xlowQuantity, optional

Lower scale value to consider in the fit.

xhighQuantity, optional

Upper scale value to consider in the fit.

brkQuantity, optional

Give an initial guess for a break point. This enables fitting with a turbustat.statistics.Lm_Seg.

min_fits_ptsint, 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.

bootstrapbool, optional

Bootstrap using the model residuals to estimate the standard errors.

bootstrap_kwargsdict, optional

Pass keyword arguments to residual_bootstrap.

fit_kwargsPassed to turbustat.statistics.Lm_Seg.fit_model
fitted_model(xvals)[source]

Computes the fitted power-law in log-log space using the given x values.

Parameters:
xvalsndarray

Values of log(lags) to compute the model at (base 10 log).

Returns:
model_valuesndarray

Values of the model at the given values.

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_transform(save_name=None, xunit=Unit('pix'), color='r', symbol='o', fit_color='k', label=None, show_residual=True)[source]

Plot the transform and the 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 wavelet 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 fit residuals.

run(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]

Compute the Wavelet transform.

Parameters:
show_progressbool, optional

Show a progress bar during the creation of the covariance matrix.

verbosebool, optional

Plot wavelet transform.

xunitu.Unit, optional

Choose the unit to convert to when ang_units is enabled.

convolve_kwargsdict, optional

Passed to convolve_fft.

scale_normalization: bool, optional

Compute the transform with the correct scale-invariant normalization.

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

See here for a list of accepted kwargs.

scale_normalization: bool, optional

Multiply the wavelet transform by the correct normalization factor.

xlowQuantity, optional

Lower scale value to consider in the fit.

xhighQuantity, optional

Upper scale value to consider in the fit.

brkQuantity, optional

Give an initial guess for a break point. This enables fitting with a turbustat.statistics.Lm_Seg.

fit_kwargsdict, optional

Passed to fit_transform

save_namestr,optional

Save the figure when a file name is given.

plot_kwargsPassed to plot_transform.
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.