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] [edit on github]¶ Bases:
turbustat.statistics.base_statistic.BaseStatisticMixInGenus Statistics based off of Chepurnov et al. (2008).
Parameters: - img : numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice
2D image.
- min_value :
Quantityor float, optional Minimum value in the data to consider. If None, the minimum is used. When
imghas an attached brightness unit,min_valuemust have the same units.- max_value :
Quantityor float, optional Maximum value in the data to consider. If None, the maximum is used. When
imghas an attached brightness unit,min_valuemust have the same units.- lowdens_percent : float, optional
Lower percentile of the data to use. Defaults to the minimum value. Overrides
min_valuewhen the value of this percentile is greater thanmin_value.- highdens_percent : float, optional
Upper percentile of the data to use. Defaults to the maximum value. Overrides
max_valuewhen the value of this percentile is lower thanmax_value.- numpts : int, optional
Number of thresholds to calculate statistic at.
- smoothing_radii : np.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.
- distance :
Quantity, 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] # doctest: +SKIP >>> genus = Genus(moment0, lowdens_percent=15, highdens_percent=85) # doctest: +SKIP >>> genus.run() # doctest: +SKIP
Attributes Summary
datadistancegenus_statsArray of genus statistic values for all smoothed images (0th axis) and all threshold values (1st axis). headerneed_header_flagno_data_flagsmoothed_imagesList of smoothed versions of the image, using the radii in smoothing_radii.smoothing_radiiPixel radii used to smooth the data. thresholdsValues 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) [edit on github]¶ Check if the header is given separately from the data type.
-
load_beam(beam=None) [edit on github]¶ Try loading the beam from the header or a given object.
Parameters: - beam :
Beam, optional The beam.
- beam :
-
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_genus_curve(use_beam=False, min_size=4, connectivity=1, keep_smoothed_images=False, match_kernel=False, **convolution_kwargs)[source] [edit on github]¶ Smooth the data with a Gaussian kernel to create the genus curve from at the specified thresholds.
Parameters: - use_beam : bool, optional
When enabled, will use the given
beam_fwhmor try to load it from the header. When disabled, the minimum size is set bymin_size.- min_size : int 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_images : bool, optional
Keep the convolved images in the
smoothed_imageslist. Default isFalse.- match_kernel : bool, optional
Match kernel shape to the data shape when convolving. Default is
False. Enable to reproduce behaviour ofGenusprior to version 1.0 of TurbuStat.- convolution_kwargs: Passed to `~astropy.convolve.convolve_fft`.
-
plot_fit(save_name=None, color='r', symbol='o')[source] [edit on github]¶ Plot the Genus curves.
Parameters: - save_name : str,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] [edit on github]¶ Run the whole statistic.
Parameters: - verbose : bool, optional
Enables plotting.
- save_name : str,optional
Save the figure when a file name is given. Must have
verboseenabled for plotting.- kwargs : See
make_genus_curve.
-
save_results(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.