Cramer_Distance

class turbustat.statistics.Cramer_Distance(cube1, cube2, noise_value1=-inf, noise_value2=-inf)[source]

Bases: object

Compute the Cramer distance between two data cubes. The data cubes are flattened spatially to give 2D objects. We clip off empty channels and keep only the top quartile in the remaining channels.

Parameters:
cube1numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or SpectralCube

First cube to compare.

cube2numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or SpectralCube

Second cube to compare.

noise_value1float, optional

Noise level in the first cube.

noise_value2float, optional

Noise level in the second cube.

data_formatstr, optional

Method to arange cube into 2D. Only ‘intensity’ is currently implemented.

Attributes Summary

data_matrix1

2D representation of cube1.

data_matrix2

2D representation of cube2.

distance

Cramer distance between cube1 and cube2.

Methods Summary

cramer_statistic([n_jobs])

Applies the Cramer Statistic to the datasets.

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

Run the Cramer statistic.

format_data([data_format, seed, normalize])

Rearrange data into a 2D object using the given format.

Attributes Documentation

data_matrix1

2D representation of cube1. Each column contains the brightest N pixels in a spectral channel, set in format_data.

data_matrix2

2D representation of cube2. Each column contains the brightest N pixels in a spectral channel, set in format_data.

distance

Cramer distance between cube1 and cube2.

Methods Documentation

cramer_statistic(n_jobs=1)[source]

Applies the Cramer Statistic to the datasets.

Parameters:
n_jobsint, optional

Sets the number of cores to use to calculate pairwise distances. Default is 1.

distance_metric(verbose=False, normalize=True, n_jobs=1, label1='1', label2='2', save_name=None)[source]

Run the Cramer statistic.

Parameters:
verbosebool, optional

Enable plotting of the data matrices.

normalizebool, optional

See Cramer_Distance.format_data.

n_jobsint, optional

See Cramer_Distance.cramer_statistic.

label1str, optional

Object or region name for data1

label2str, optional

Object or region name for data2

save_namestr,optional

Save the figure when a file name is given.

format_data(data_format='intensity', seed=13024, normalize=True, **kwargs)[source]

Rearrange data into a 2D object using the given format.

Parameters:
data_format{‘intensity’, ‘spectra’}, optional

The method to use to construct the data matrix. The default is intensity, which picks the brightest values in each channel. The other option is ‘spectra’, which will pick the N brightest spectra to compare.

seedint, optional

When the data are mismatched, the larger data set is randomly sampled to match the size of the other.

normalizebool, optional

Forces the data sets into the same interval, removing the effect of different ranges of intensities (or whatever unit the data traces).

kwargsPassed to _format_data.