Dendrogram_Stats

class turbustat.statistics.Dendrogram_Stats(data, header=None, min_deltas='auto', dendro_params=None, num_deltas=10)[source]

Bases: BaseStatisticMixIn

Dendrogram statistics as described in Burkhart et al. (2013) Two statistics are contained: * number of leaves & branches vs. \(\delta\) parameter * statistical moments of the intensity histogram

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

Data to create the dendrogram from.

min_deltas{ndarray, ‘auto’, None}, optional

Minimum deltas of leaves in the dendrogram. Multiple values must be given in increasing order to correctly prune the dendrogram. The default estimates delta levels from percentiles in the data.

dendro_paramsdict

Further parameters for the dendrogram algorithm (see www.dendrograms.org for more info).

num_deltasint, optional

Number of min_delta values to use when min_delta='auto'.

Attributes Summary

data

distance

fitvals

Log values of delta and number of structures used for the power-law tail fit.

header

hists

Histogram values and bins computed from the peak intensity in all structures.

min_deltas

Array of min_delta values to compute the dendrogram.

model

Power-law tail fit model.

need_header_flag

no_data_flag

numfeatures

Number of branches and leaves at each value of min_delta

tail_slope

Slope of power-law tail.

tail_slope_err

1-sigma error on slope of power-law tail.

values

Array of peak intensity values of leaves and branches at all values of min_delta.

Methods Summary

autoset_min_deltas([num])

Create an array delta values that the dendrogram will be pruned to.

compute_dendro([show_progress, save_dendro, ...])

Compute the dendrogram and prune to the minimum deltas.

fit_numfeat([size, verbose])

Fit a line to the power-law tail.

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_dendrogram(hdf5_file[, min_deltas])

Load in a previously saved dendrogram.

load_results(pickle_file)

Load in a saved pickle file.

make_hists([min_number])

Creates histograms based on values from the tree.

plot_fit([save_name, show_hists, color, ...])

Parameters:

run([periodic_bounds, verbose, save_name, ...])

Compute dendrograms.

save_results(output_name[, keep_data])

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

Attributes Documentation

data
distance
fitvals

Log values of delta and number of structures used for the power-law tail fit.

header
hists

Histogram values and bins computed from the peak intensity in all structures. One set of values and bins are returned for each value of min_deltas

min_deltas

Array of min_delta values to compute the dendrogram.

model

Power-law tail fit model.

need_header_flag = True
no_data_flag = False
numfeatures

Number of branches and leaves at each value of min_delta

tail_slope

Slope of power-law tail.

tail_slope_err

1-sigma error on slope of power-law tail.

values

Array of peak intensity values of leaves and branches at all values of min_delta.

Methods Documentation

autoset_min_deltas(num=10)[source]

Create an array delta values that the dendrogram will be pruned to. Creates equally-spaced delta values between the minimum value set in dendro_params and the maximum in the data. The last delta (which would only occur at the peak in the data) is removed.

Parameters:
numint, optional

Number of delta values to create.

compute_dendro(show_progress=False, save_dendro=False, dendro_name=None, dendro_obj=None, periodic_bounds=False)[source]

Compute the dendrogram and prune to the minimum deltas. ** min_deltas must be in ascending order! **

Parameters:
show_progressoptional, bool

Enables the progress bar in astrodendro.

save_dendrooptional, bool

Saves the dendrogram in HDF5 format. Requires pyHDF5

dendro_namestr, optional

Save name when save_dendro is enabled. “.hdf5” appended automatically.

dendro_objDendrogram, optional

Input a pre-computed dendrogram object. It is assumed that the dendrogram has already been computed!

periodic_boundsbool, optional

Enable when the data is periodic in the spatial dimensions.

fit_numfeat(size=5, verbose=False)[source]

Fit a line to the power-law tail. The break is approximated using a moving window, computing the standard deviation. A spike occurs at the break point.

Parameters:
sizeint. optional

Size of std. window. Passed to std_window.

verbosebool, optional

Shows the model summary.

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_dendrogram(hdf5_file, min_deltas=None)[source]

Load in a previously saved dendrogram. Requires pyHDF5

Parameters:
hdf5_filestr

Name of saved file.

min_deltasnumpy.ndarray or list

Minimum deltas of leaves in the dendrogram.

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

make_hists(min_number=10, **kwargs)[source]

Creates histograms based on values from the tree. Note: These histograms are remade when calculating the distance to ensure the proper form for the Hellinger distance.

Parameters:
min_numberint, optional

Minimum number of structures needed to create a histogram.

plot_fit(save_name=None, show_hists=True, color='r', fit_color='k', symbol='o')[source]
Parameters:
save_namestr,optional

Save the figure when a file name is given.

xunitu.Unit, optional

The unit to show the x-axis in.

show_histsbool, optional

Plot the histograms of intensity. Requires make_hists to be run first.

color{str, RGB tuple}, optional

Color to show the delta-variance curve in.

fit_color{str, RGB tuple}, optional

Color of the fitted line. Defaults to color when no input is given.

run(periodic_bounds=False, verbose=False, save_name=None, show_progress=True, dendro_obj=None, save_results=False, output_name=None, fit_kwargs={}, make_hists=True, hist_kwargs={})[source]

Compute dendrograms. Necessary to maintain the package format.

Parameters:
periodic_boundsbool or list, optional

Enable when the data is periodic in the spatial dimensions. Passing a two-element list can be used to individually set how the boundaries are treated for the datasets.

verboseoptional, bool

Enable plotting of results.

save_namestr,optional

Save the figure when a file name is given.

show_progressoptional, bool

Enables progress bars while making the dendrogram.

dendro_objDendrogram, optional

Pass a pre-computed dendrogram object. MUST have min_delta set at or below the smallest value in`~Dendro_Statistics.min_deltas`.

save_resultsbool, optional

Save the statistic results as a pickle file. See save_results.

output_namestr, optional

Filename used when save_results is enabled. Must be given when saving.

fit_kwargsdict, optional

Passed to fit_numfeat.

make_histsbool, optional

Enable computing histograms.

hist_kwargsdict, optional

Passed to make_hists.

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.