Core functions¶
Note
For Developers and Advanced Users
Functions used by UPI.
Data Analysis¶
-
smoothy.core.analysis.
denoise
(data, threshold)[source]¶ Performs denoising of data cube, thresholding over the threshold value.
Parameters: data : numpy.ndarray or astropy.nddata.NDData or or astropy.nddata.NDData
Astronomical data cube.
threshold : float
Threshold value used for denoising.
Returns: result : numpy.ndarray
Denoised (thresholded) astronomical data cube.
-
smoothy.core.analysis.
gaussian_function
(mu, P, feat, peak)[source]¶ Generates an N-dimensional Gaussian using the feature matrix feat, centered at mu, with precision matrix P and with intensity peak.
Parameters: mu : numpy.ndarray
Centers of gaussians array.
P : numpy.ndarray
Precision matrix.
feat : numpy.ndarray.
Features matrix.
peak : float
Peak value of the resulting evaluation.
Returns: result: 2D numpy.ndarray
Returns the gaussian function evaluated at the value on feat.
-
smoothy.core.analysis.
integrate
(data, mask=None, axis=0)[source]¶ Sums the slices of a cube of data given an axis.
Parameters: data : (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
mask : numpy.ndarray (default = None)
axis : int (default=(0))
Returns: A numpy array with the integration results.
-
smoothy.core.analysis.
rms
(data, mask=None)[source]¶ Compute the RMS of data. If mask != None, then we use that mask.
Parameters: data : (M,N,Z) numpy.ndarray or astropy.nddata.NDData or or astropy.nddata.NDDataRef
Astronomical data cube.
mask : numpy.ndarray (default = None)
Returns: RMS of the data (float)
Utils¶
-
smoothy.core.utilities.
add
(data, flux, lower, upper)[source]¶ Adds flux to a sub-cube of an astronomical data cube.
Parameters: data : numpy.ndarray or astropy.nddata.NDData or or astropy.nddata.NDData
Astronomical data cube.
flux : numpy.ndarray
Flux added to the cube.
lower : tuple
Lower bound of the sub-cube to which flux will be added.
upper : tuple
Upper bound of the sub-cube to which flux will be added.
-
smoothy.core.utilities.
fix_limits
(data, vect)[source]¶ Fix vect index to be inside data
Parameters: data : numpy.ndarray or numpy.ma.MaskedArray
Astronomical data cube.
vect : tuple, list or numpy.ndarray
Array with the indexes to be fixed.
Returns: result : numpy.ndarray
Fixed array of indexes.
-
smoothy.core.utilities.
fix_mask
(data, mask)[source]¶ Parameters: data : numpy.ndarray or numpy.ma.MaskedArray
Astronomical data cube.
mask : numpy.ndarray
Boolean that will be applied.
Returns: result : numpy.ma.MaskedArray
Masked astronomical data cube.
-
smoothy.core.utilities.
index_features
(data, lower=None, upper=None)[source]¶ Creates an array with indices in features format
-
smoothy.core.utilities.
matching_slabs
(data, flux, lower, upper)[source]¶ Obtain the matching subcube inside the lower and upper points.
Parameters: data : numpy.ndarray
First data cube
flux : numpy.ndarray
Second data cubse
lower : tuple
Lower coordinates for the subcube.
upper : tuple
Upper coordinates for the subcube.
Returns: The subcube inside the lower and upper points that matches both data cube dimensions.
-
smoothy.core.utilities.
slab
(data, lower=None, upper=None)[source]¶ Obtain the n-dimensional slab from lower to upper (i.e. slab is a vector of slices)
Parameters: data : numpy.ndarray
Atronomical data cube.
lower : 3-tuple (default=None)
Lower coordinates for the subcube.
upper : 3-tuple (default=None)
Upper coordinates for the subcube.
Returns: result : list
list of slices using lower and upper coordinates to create a subcube.
-
smoothy.core.utilities.
standarize
(data)[source]¶ Standarize astronomical data cubes in the 0-1 range.
Parameters: data : numpy.ndarray or astropy.nddata.NDData or or astropy.nddata.NDData
Astronomical data cube.
Returns: result : tuple
Tuple containing the standarized numpy.ndarray or astropy.nddata.NDData cube, the factor scale y_fact and the shift y_min.
-
smoothy.core.utilities.
unstandarize
(data, a, b)[source]¶ Unstandarize the astronomical data cube: \(a \cdot data + b\).
Parameters: data : numpy.ndarray or astropy.nddata.NDData or or astropy.nddata.NDData
Astronomical data cube.
a : float
Scale value.
b : float
Shift value.
Returns: result : numpy.ndarray or astropy.nddata.NDData
Unstandarized astronomical cube.