StatMoments_Distance

class turbustat.statistics.StatMoments_Distance(image1, image2, radius=<Quantity 5. pix>, min_frac=0.8, weights1=None, weights2=None, nbins=None, periodic1=True, periodic2=True)[source]

Bases: object

Compute the distance between two images based on their moments. The distance is calculated for the skewness and kurtosis. The distance values for each for computed using the Hellinger Distance (default), or the Kullback-Leidler Divergence.

Unlike the other distance classes in TurbuStat, the computation of the histograms needed for the distance metric has been split into its own method. However, the change is fairly transparent, since it is called within distance_metric.

Note

When passing StatMoments classes as image1 or image2, if the radius does not match the given radius, or the common angular radius between the two datasets, compute_spatial_distrib will be re-run with a new radius.

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

2D image. Or a StatMoments class can be passed which may be pre-computed.

image2numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice or StatMoments

See image1.

radiusQuantity, optional

Radius of circle to use when computing moments. When given in pixel units, the radius will be adjusted such that a common angular scale is used between the two images, defined by whichever image has the coarser spatial grid. This assumes the pixels can be treated as square in the celestial frame! If an angular unit is given, there is no adjustment made.

weights1numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice

2D array of weights. Uniform weights are used if none are given.

weights2numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice

2D array of weights. Uniform weights are used if none are given.

nbinsint, optional

Number of bins to use when constructing histograms.

periodic1bool, optional

If image1 is periodic in the spatial boundaries, set to True.

periodic2bool, optional

If image2 is periodic in the spatial boundaries, set to True.

Methods Summary

create_common_histograms([nbins])

Calculate the histograms using a common set of bins.

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

Compute the distance.

Methods Documentation

create_common_histograms(nbins=None)[source]

Calculate the histograms using a common set of bins. Only histograms of the kurtosis and skewness are calculated, since only they are used in the distance metric.

Parameters:
nbinsint, optional

Bins to use in the histogram calculation.

distance_metric(verbose=False, nbins=None, plot_kwargs1={'color': 'b', 'label': '1'}, plot_kwargs2={'color': 'g', 'label': '2'}, save_name=None)[source]

Compute the distance.

Parameters:
metric‘Hellinger’ (default) or “KL Divergence”, optional

Set the metric to use compare the histograms.

verbosebool, optional

Enables plotting.

nbinsint, optional

Bins to use in the histogram calculation.

label1str, optional

Object or region name for image1

label2str, optional

Object or region name for image2

save_namestr,optional

Save the figure when a file name is given.