Genus

class turbustat.statistics.Genus(img, min_value=None, max_value=None, lowdens_percent=0, highdens_percent=100, numpts=100, smoothing_radii=None, distance=None)[source]

Bases: BaseStatisticMixIn

Genus Statistics based off of Chepurnov et al. (2008).

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

2D image.

min_valueQuantity or float, optional

Minimum value in the data to consider. If None, the minimum is used. When img has an attached brightness unit, min_value must have the same units.

max_valueQuantity or float, optional

Maximum value in the data to consider. If None, the maximum is used. When img has an attached brightness unit, min_value must have the same units.

lowdens_percentfloat, optional

Lower percentile of the data to use. Defaults to the minimum value. Overrides min_value when the value of this percentile is greater than min_value.

highdens_percentfloat, optional

Upper percentile of the data to use. Defaults to the maximum value. Overrides max_value when the value of this percentile is lower than max_value.

numptsint, optional

Number of thresholds to calculate statistic at.

smoothing_radiinp.ndarray or astropy.units.Quantity, optional

Kernel radii to smooth data to. If units are not attached, the radii are assumed to be in pixels. If no radii are given, 5 smoothing radii will be used ranging from 1 pixel to one-tenth the smallest dimension size.

distanceQuantity, optional

Physical distance to the region in the data.

Examples

>>> from turbustat.statistics import Genus
>>> from astropy.io import fits
>>> import astropy.units as u
>>> import numpy as np
>>> moment0 = fits.open("Design4_21_0_0_flatrho_0021_13co.moment0.fits")[0]  
>>> genus = Genus(moment0, lowdens_percent=15, highdens_percent=85)  
>>> genus.run()  

Attributes Summary

data

distance

genus_stats

Array of genus statistic values for all smoothed images (0th axis) and all threshold values (1st axis).

header

need_header_flag

no_data_flag

smoothed_images

List of smoothed versions of the image, using the radii in smoothing_radii.

smoothing_radii

Pixel radii used to smooth the data.

thresholds

Values of the data to compute the Genus statistics at.

Methods Summary

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_results(pickle_file)

Load in a saved pickle file.

make_genus_curve([use_beam, min_size, ...])

Smooth the data with a Gaussian kernel to create the genus curve from at the specified thresholds.

plot_fit([save_name, color, symbol])

Plot the Genus curves.

run([verbose, save_name, color, symbol])

Run the whole statistic.

save_results(output_name[, keep_data])

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

Attributes Documentation

data
distance
genus_stats

Array of genus statistic values for all smoothed images (0th axis) and all threshold values (1st axis).

header
need_header_flag = True
no_data_flag = False
smoothed_images

List of smoothed versions of the image, using the radii in smoothing_radii.

smoothing_radii

Pixel radii used to smooth the data.

thresholds

Values of the data to compute the Genus statistics at.

Methods Documentation

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_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_genus_curve(use_beam=False, min_size=4, connectivity=1, keep_smoothed_images=False, match_kernel=False, **convolution_kwargs)[source]

Smooth the data with a Gaussian kernel to create the genus curve from at the specified thresholds.

Parameters:
use_beambool, optional

When enabled, will use the given beam_fwhm or try to load it from the header. When disabled, the minimum size is set by min_size.

min_sizeint or Quantity, optional

Directly specify the minimum area a region must have to be counted. Integer values with no units are assumed to be in pixels.

connectivity{1, 2}, optional

Connectivity used when removing regions below min_size.

keep_smoothed_imagesbool, optional

Keep the convolved images in the smoothed_images list. Default is False.

match_kernelbool, optional

Match kernel shape to the data shape when convolving. Default is False. Enable to reproduce behaviour of Genus prior to version 1.0 of TurbuStat.

convolution_kwargs: Passed to `~astropy.convolve.convolve_fft`.
plot_fit(save_name=None, color='r', symbol='o')[source]

Plot the Genus curves.

Parameters:
save_namestr,optional

Save the figure when a file name is given.

color{str, RGB tuple}, optional

Color to show the Genus curves in.

run(verbose=False, save_name=None, color='r', symbol='o', **kwargs)[source]

Run the whole statistic.

Parameters:
verbosebool, optional

Enables plotting.

save_namestr,optional

Save the figure when a file name is given. Must have verbose enabled for plotting.

kwargsSee make_genus_curve.
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.