Dendrogram_Distance

class turbustat.statistics.Dendrogram_Distance(dataset1, dataset2, min_deltas=None, nbins='best', min_features=100, dendro_params=None, dendro_kwargs={}, dendro2_kwargs=None)[source]

Bases: object

Calculate the distance between 2 cubes using dendrograms. The number of features vs. minimum delta is fit to a linear model, with an interaction term to gauge the difference. The distance is the t-statistic of that parameter. The Hellinger distance is computed for the histograms at each minimum delta value. The distance is the average of the Hellinger distances.

Note

When passing a computed DeltaVariance class for dataset1 or dataset2, it may be necessary to recompute the dendrogram if min_deltas does not equal min_deltas generated here (or passed as kwarg).

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

Data cube or 2D image. Or pass a Dendrogram_Stats class that may be pre-computed. where the dendrogram statistics are saved.

dataset2numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice or SpectralCube or Dendrogram_Stats

See dataset1 above.

min_deltasnumpy.ndarray or list

Minimum deltas (branch heights) of leaves in the dendrogram. The set of dendrograms must be computed with the same minimum branch heights.

nbinsstr or float, optional

Number of bins for the histograms. ‘best’ sets that number using the square root of the average number of features between the histograms to be compared.

min_featuresint, optional

The minimum number of features (branches and leaves) for the histogram be used in the histogram distance.

dendro_paramsdict or list of dicts, optional

Further parameters for the dendrogram algorithm (see the astrodendro documentation for more info). If a list of dictionaries is given, the first list entry should be the dictionary for dataset1, and the second for dataset2.

dendro_kwargsdict, optional

Passed to run.

dendro2_kwargsNone, dict, optional

Passed to run for dataset2. When None is given, parameters given in dendro_kwargs will be used for both datasets.

Attributes Summary

histogram_distance

num_distance

Distance between slopes from the for to the log Number of features vs.

Methods Summary

distance_metric([verbose, save_name, ...])

Calculate both distance metrics.

histogram_stat([verbose, save_name, ...])

Computes the distance using histograms.

numfeature_stat([verbose, save_name, ...])

Calculate the distance based on the number of features statistic.

Attributes Documentation

histogram_distance
num_distance

Distance between slopes from the for to the log Number of features vs. branch height.

Methods Documentation

distance_metric(verbose=False, save_name=None, plot_kwargs1={}, plot_kwargs2={})[source]

Calculate both distance metrics.

Parameters:
verbosebool, optional

Enables plotting.

save_namestr, optional

Save plots by passing a file name. hist_distance and num_distance will be appended to the file name to distinguish the plots made with the two metrics.

plot_kwargs1dict, optional

Set the color, symbol, and label for dataset1 (e.g., plot_kwargs1={‘color’: ‘b’, ‘symbol’: ‘D’, ‘label’: ‘1’}).

plot_kwargs2dict, optional

Set the color, symbol, and label for dataset2.

histogram_stat(verbose=False, save_name=None, plot_kwargs1={}, plot_kwargs2={})[source]

Computes the distance using histograms.

Parameters:
verbosebool, optional

Enables plotting.

save_namestr, optional

Saves the plot when a filename is given.

plot_kwargs1dict, optional

Set the color, symbol, and label for dataset1 (e.g., plot_kwargs1={‘color’: ‘b’, ‘symbol’: ‘D’, ‘label’: ‘1’}).

plot_kwargs2dict, optional

Set the color, symbol, and label for dataset2.

numfeature_stat(verbose=False, save_name=None, plot_kwargs1={}, plot_kwargs2={})[source]

Calculate the distance based on the number of features statistic.

Parameters:
verbosebool, optional

Enables plotting.

save_namestr, optional

Saves the plot when a filename is given.

plot_kwargs1dict, optional

Set the color, symbol, and label for dataset1 (e.g., plot_kwargs1={‘color’: ‘b’, ‘symbol’: ‘D’, ‘label’: ‘1’}).

plot_kwargs2dict, optional

Set the color, symbol, and label for dataset2.