Dendrogram_Stats

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

Bases: turbustat.statistics.base_statistic.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:
data : numpy.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_params : dict

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

num_deltas : int, 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(self[, num]) Create an array delta values that the dendrogram will be pruned to.
compute_dendro(self[, show_progress, …]) Compute the dendrogram and prune to the minimum deltas.
fit_numfeat(self[, size, verbose]) Fit a line to the power-law tail.
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_dendrogram(hdf5_file[, min_deltas]) Load in a previously saved dendrogram.
load_results(pickle_file) Load in a saved pickle file.
make_hists(self[, min_number]) Creates histograms based on values from the tree.
plot_fit(self[, save_name, show_hists, …])
Parameters:
run(self[, periodic_bounds, verbose, …]) Compute dendrograms.
save_results(self, 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(self, num=10)[source] [edit on github]

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:
num : int, optional

Number of delta values to create.

compute_dendro(self, show_progress=False, save_dendro=False, dendro_name=None, dendro_obj=None, periodic_bounds=False)[source] [edit on github]

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

Parameters:
show_progress : optional, bool

Enables the progress bar in astrodendro.

save_dendro : optional, bool

Saves the dendrogram in HDF5 format. Requires pyHDF5

dendro_name : str, optional

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

dendro_obj : Dendrogram, optional

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

periodic_bounds : bool, optional

Enable when the data is periodic in the spatial dimensions.

fit_numfeat(self, size=5, verbose=False)[source] [edit on github]

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:
size : int. optional

Size of std. window. Passed to std_window.

verbose : bool, optional

Shows the model summary.

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.

static load_dendrogram(hdf5_file, min_deltas=None)[source] [edit on github]

Load in a previously saved dendrogram. Requires pyHDF5

Parameters:
hdf5_file : str

Name of saved file.

min_deltas : numpy.ndarray or list

Minimum deltas of leaves in the dendrogram.

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

make_hists(self, min_number=10, **kwargs)[source] [edit on github]

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_number : int, optional

Minimum number of structures needed to create a histogram.

plot_fit(self, save_name=None, show_hists=True, color='r', fit_color='k', symbol='o')[source] [edit on github]
Parameters:
save_name : str,optional

Save the figure when a file name is given.

xunit : u.Unit, optional

The unit to show the x-axis in.

show_hists : bool, 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(self, 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] [edit on github]

Compute dendrograms. Necessary to maintain the package format.

Parameters:
periodic_bounds : bool 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.

verbose : optional, bool

Enable plotting of results.

save_name : str,optional

Save the figure when a file name is given.

show_progress : optional, bool

Enables progress bars while making the dendrogram.

dendro_obj : Dendrogram, optional

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

save_results : bool, optional

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

output_name : str, optional

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

fit_kwargs : dict, optional

Passed to fit_numfeat.

make_hists : bool, optional

Enable computing histograms.

hist_kwargs : dict, optional

Passed to make_hists.

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.