User Programmatic Interface (UPI)¶
Functions to simplificate the programming task for standard users.
Axes Manipulation¶
-
smoothy.upi.axes.
axes_names
(data, wcs=None)[source]¶ Get the axes’s names.
Parameters: data : (M,N) or (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use.
Returns: result: numpy.ndarray
Numpy ndarray with the axes’s names from the WCS.
-
smoothy.upi.axes.
axes_units
(data, wcs=None)[source]¶ Get units of the axes
Parameters: data : (M,N) or (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use.
Returns: result: (M,N) or (M,N,Z) numpy.ndarray
Vector with the units of the axes
-
smoothy.upi.axes.
center
(data, wcs=None)[source]¶ Get center of the data
Parameters: data : (M,N) or (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use.
Returns: result: astropy.units.quantity.Quantity
Center of the data
-
smoothy.upi.axes.
extent
(data, wcs=None, region=None)[source]¶ Get the axes extent.
Parameters: data : (M,N) or (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use.
region :(lower : (M,N) or (M,N,Z), upper
Start and End index in data (int tuples)
Returns: result: (M, N) tuple of astropy.units.quantity.Quantity
Axes extent
-
smoothy.upi.axes.
features
(data, wcs=None, region=None)[source]¶ Creates an array with WCS axes in features format
Parameters: data : (M,N) or (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use.
region :(lower : (M,N) or (M,N,Z), upper
Start and End index in data (int tuples)
Returns: result: astropy.table.Table
Table with WCS information of a section from the data.
-
smoothy.upi.axes.
opening
(data, center, window, wcs=None)[source]¶ Field of view (center +- window) converted to indices
Parameters: data : (M,N) or (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
center : astropy.units.quantity.Quantity
Center of the field of view in WCS.
window : astropy.units.quantity.Quantity
Window for the field in WCS.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use.
Returns
——-
result: ((M1,N1,Z1),(M2,N2,Z2)) tuple of tuple of ints
-
smoothy.upi.axes.
resolution
(data, wcs=None)[source]¶ Get the resolution of data
Parameters: data : (M,N) or (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use.
Returns: result: (M,N) or (M,N,Z) numpy.ndarray
Resolution of the data
-
smoothy.upi.axes.
spectral_velocities
(data, wcs=None, fqs=None, fqis=None, restfrq=None)[source]¶ Get the spectral velocities from frequencies fqs given a rest frequency (by default search for it in the WCS). If fqs is None, then frequencies indices (fqis) need to be given.
Parameters: data : (M,N) or (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use.
fqs : astropy.units.quantity.Quantity
Array of frequencies with units.
fqis : list of integers
Array of frequencies indices
restfrq : astropy.units.quantity.Quantity
Rest frequency
Returns: result: astropy.units.quantity.Quantity
Array of Spectral velocities.
Data Manipulation¶
-
class
smoothy.upi.data.
Data
(data, uncertainty=None, mask=None, wcs=None, meta=None, unit=None, copy=False)[source]¶ A generic represenation of astronomical n-dimensional data array. Extends NDData.
-
axes_names
()[source]¶ Get the axes’s names.
Returns: result: numpy.ndarray
Numpy ndarray with the axes’s names from the WCS.
-
axes_units
()[source]¶ Get units of the axes
Returns: result: (M,N) or (M,N,Z) numpy.ndarray
Vector with the units of the axes
-
center
()[source]¶ Get center of the data
Returns: result: astropy.units.quantity.Quantity
Center of the data
-
extent
(region=None)[source]¶ Get the axes extent.
Parameters: region :(lower : (M,N) or (M,N,Z), upper
Start and End index in data (int tuples)
Returns: result: (M, N) tuple of astropy.units.quantity.Quantity
Axes extent
-
features
(region=None)[source]¶ Creates an array with WCS axea in features format
Parameters: region :(lower : (M,N) or (M,N,Z), upper
Start and End index in data (int tuples)
Returns: result: astropy.table.Table
Table with WCS information of a section from the data.
-
opening
(center, window)[source]¶ Field of view (center +- window) converted to indices
Parameters: center : astropy.units.quantity.Quantity
Center of the field of view in WCS.
window : astropy.units.quantity.Quantity
Window for the field in WCS.
Returns: result: ((M1,N1,Z1),(M2,N2,Z2)) tuple of tuple of ints
-
resolution
()[source]¶ Get the resolution of data
Returns: result: (M,N) or (M,N,Z) numpy.ndarray
Resolution of the data
-
spectral_velocities
(fqs=None, fqis=None, restfrq=None)[source]¶ Get the spectral velocities from frequencies fqs given a rest frequency (by default search for it in the WCS). If fqs is None, then frequencies indices (fqis) need to be given.
Parameters: fqs : astropy.units.quantity.Quantity
Array of frequencies with units.
fqis : list of integers
Array of frequencies indices
restfrq : astropy.units.quantity.Quantity
Rest frequency
Returns: result: astropy.units.quantity.Quantity
Array of Spectral velocities.
-
Flux Manipulation¶
-
smoothy.upi.flux.
add
(data, flux, lower=None, upper=None, wcs=None, unit=None, meta=None, mask=None)[source]¶ Create a new data with the new flux added.
Lower and upper are bounds for data. This operation is border-safe and creates a new object at each call.
Parameters: data : (M,N) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
flux : float
Flux of data
lower : numpy.ndarray
upper : numpy.ndarray
Bounds for data
wcs : World Coordinate System data (http://docs.astropy.org/en/stable/wcs/)
mask : numpy.ndarray
mask for the data
unit : astropy.units.Unit
Astropy Unit (http://docs.astropy.org/en/stable/units/)
meta : FITS metadata
Returns: NDDataRef: structure with new flux added
-
smoothy.upi.flux.
denoise
(data, wcs=None, mask=None, unit=None, threshold=0.0)[source]¶ Simple denoising given a threshold (creates a new object)
Parameters: data : (M,N) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
wcs : World Coordinate System data (http://docs.astropy.org/en/stable/wcs/)
mask : numpy.ndarray
mask for the data
unit : astropy.units.Unit
Astropy Unit (http://docs.astropy.org/en/stable/units/)
threshold : float
Returns: NDDataRef: Data denoised
-
smoothy.upi.flux.
noise_level
(data, mask=None, unit=None)[source]¶ Compute the RMS of data.
Parameters: data : (M,N) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
mask : numpy.ndarray
mask for the data
unit : astropy.units.Unit
Astropy Unit (http://docs.astropy.org/en/stable/units/)
Returns: rms : float
RMS of data
-
smoothy.upi.flux.
standarize
(data, wcs=None, unit=None, mask=None, meta=None)[source]¶ Standarize data:
Parameters: data : (M,N) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
wcs : World Coordinate System data (http://docs.astropy.org/en/stable/wcs/)
mask : numpy.ndarray
mask for the data
unit : astropy.units.Unit
Astropy Unit (http://docs.astropy.org/en/stable/units/)
meta : FITS metadata
Returns: Standarized data where data = a * res + b
-
smoothy.upi.flux.
unstandarize
(data, a, b, wcs=None, unit=None, mask=None, meta=None)[source]¶ Unstandarize data: res = a * data + b
Parameters: data : (M,N) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
a : float
slope of straight
b : float
Intercept of straight
wcs : World Coordinate System data (http://docs.astropy.org/en/stable/wcs/)
mask : numpy.ndarray
mask for the data
unit : astropy.units.Unit
Astropy Unit (http://docs.astropy.org/en/stable/units/)
meta : FITS metadata
Returns: NDDataRef: Unstandarized data: res = a * data + b
-
smoothy.upi.flux.
world_gaussian
(data, mu, P, peak, cutoff, wcs=None)[source]¶ Creates a gaussian flux at mu position (WCS), with P shape, with a maximum value equal to peak, and with compact support up to the cutoff contour
Parameters: data : (M,N) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
mu : float
P : tuple
Shape of result
peak : float
maximum value
cutoff :
wcs : World Coordinate System data (http://docs.astropy.org/en/stable/wcs/)
Returns: Tuple of gaussian flux and borders
Data Statistics¶
-
smoothy.upi.reduction.
moment0
(data, wcs=None, mask=None, unit=None, restfrq=None)[source]¶ Calculate moment 0 from a data cube.
Parameters: data : (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use.
mask : numpy.ndarray
Mask for data.
unit : astropy.units.Unit
Astropy unit (http://docs.astropy.org/en/stable/units/).
restfrq : astropy.units.quantity.Quantity
Rest frequency
Returns: result: astropy.nddata.NDDataRef
Moment 0 of the data cube
-
smoothy.upi.reduction.
moment1
(data, wcs=None, mask=None, unit=None, restfrq=None)[source]¶ Calculate moment 1 from a data cube.
Parameters: data : (M,N,Z) numpy.ndarray or astropy.nddata.NDData
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use
mask : numpy.ndarray
Mask for data.
unit : astropy.units.Unit
Astropy unit (http://docs.astropy.org/en/stable/units/)
restfrq : astropy.units.quantity.Quantity
Rest frequency
Returns: result: astropy.nddata.NDData
Moment 1 of the data cube
-
smoothy.upi.reduction.
moment2
(data, wcs=None, mask=None, unit=None, restfrq=None)[source]¶ Calculate moment 2 from a data cube.
Parameters: data : (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use
mask : numpy.ndarray
Mask for data.
unit : astropy.units.Unit
Astropy unit (http://docs.astropy.org/en/stable/units/)
restfrq : astropy.units.quantity.Quantity
Rest frequency
Returns: result: astropy.nddata.NDDataRef
Moment 2 of the data cube
-
smoothy.upi.reduction.
spectra
(data, wcs=None, mask=None, unit=None, restrict=None)[source]¶ Parameters: data : (M,N,Z) numpy.ndarray or astropy.nddata.NDData or astropy.nddata.NDDataRef
Astronomical data cube.
wcs : astropy.wcs.wcs.WCS
World Coordinate System to use
mask : numpy.ndarray
Mask for data.
unit : astropy.units.Unit
Astropy unit (http://docs.astropy.org/en/stable/units/)
restrict : boolean
Returns: result: astropy.nddata.NDData
Moment 2 of the data cube