Gaussian2D¶
- class sofia_redux.scan.source_models.beams.gaussian_2d.Gaussian2D(peak=1.0, x_mean=0.0, y_mean=0.0, x_fwhm=0.0, y_fwhm=0.0, theta=<Quantity 0. deg>, peak_unit=None, position_unit=None)[source]¶
Bases:
ABC
Initializes a 2-D Gaussian beam model.
The Gaussian2D class is a wrapper around the
functional_models.Gaussian2D
class with additional functionality including convolution/deconvolution with another beam, and header parsing/editing.- Parameters:
- peakfloat or units.Quantity, optional
The peak amplitude of the Gaussian.
- x_meanfloat or units.Quantity, optional
The position of the peak along the x-axis.
- y_meanfloat or units.Quantity, optional
The position of the peak along the y-axis.
- x_fwhmfloat or units.Quantity, optional
The Full-Width-Half-Max beam width in the x-direction.
- y_fwhmfloat or units.Quantity, optional
The Full-Width-Half-Max beam width in the y-direction.
- thetafloat or units.Quantity, optional
The rotation of the beam pertaining to
x_fwhm
andy_fwhm
in relation to the actual (x, y) coordinate axis. If a float value is supplied, it is assumed to be in degrees.- peak_unitunits.Unit or units.Quantity or str, optional
The physical units for the peak amplitude. The default is dimensionless.
- position_unitunits.Unit or units.Quantity or str, optional
The physical units of all position based parameters (
x_mean
,y_mean
,x_fwhm
,y_fwhm
)
Attributes Summary
Return the area of the PSF.
Return the average FWHM
Return the major (maximum) FWHM value.
Return the minor (minimum) FWHM value.
Return the peak amplitude of the Gaussian.
Return the position angle of the Gaussian.
Return the names of attributes to be referenced rather than copied.
Return the position angle of the Gaussian.
Return the FWHM in the x-direction.
Return the center of the Gaussian in x.
Return the standard deviation in x.
Return the FWHM in the y-direction.
Return the center of the Gaussian in y.
Return the standard deviation in y.
Methods Summary
combine_with
(psf[, deconvolve])Combine with another beam.
convolve_with
(psf)Convolve with a given PSF.
copy
()Return a copy of the Gaussian 2D model.
deconvolve_with
(psf)Deconvolve with a given PSF.
edit_header
(header[, fits_id, beam_name, ...])Edit a FITS header with the beam parameters.
encompass
(psf)Encompass with another beam.
extent
()Return the extent in x and y.
get_beam_map
(grid[, sigmas])Return a beam map given an output grid.
Return the FWHM of a circular Gaussian with equivalent area.
get_equivalent
(beam_map, pixel_size)Return a 2-D Gaussian for a beam map and given pixel size.
Return whether the PSF is circular.
is_encompassing
(psf)Check if the psf is encompassing the beam.
parse_header
(header[, size_unit, fits_id])Set the beam from a FITS header.
rotate
(angle)Rotate the beam by a given angle.
scale
(factor)Scale the FWHM in both axes by a given amount.
set_area
(area)Set the Gaussian parameters based on the overall area of the beam.
set_equivalent
(beam_map, pixel_size)Set Gaussian parameters from a given beam map and pixel size.
set_xy_fwhm
(x_fwhm, y_fwhm)Set and validate both new x and y FWHM values at once.
validate
()Set the (x, y) FWHM and position angle so that x >= y.
Attributes Documentation
- AREA_FACTOR = 1.1330900354567985¶
- FWHM_TO_SIZE = 1.0644670194312262¶
- QUARTER = <Quantity 1.57079633 rad>¶
- area¶
Return the area of the PSF.
- Returns:
- units.Quantity
- fwhm¶
Return the average FWHM
- Returns:
- units.Quantity
- major_fwhm¶
Return the major (maximum) FWHM value.
- Returns:
- units.Quantity or float
- minor_fwhm¶
Return the minor (minimum) FWHM value.
- Returns:
- units.Quantity
- peak¶
Return the peak amplitude of the Gaussian.
- Returns:
- float or units.Quantity
- position_angle¶
Return the position angle of the Gaussian.
- Returns:
- units.Quantity
- referenced_attributes¶
Return the names of attributes to be referenced rather than copied.
- Returns:
- set of str
- theta¶
Return the position angle of the Gaussian.
- Returns:
- units.Quantity
- x_fwhm¶
Return the FWHM in the x-direction.
- Returns:
- units.Quantity
- x_mean¶
Return the center of the Gaussian in x.
- Returns:
- units.Quantity or float
- x_stddev¶
Return the standard deviation in x.
- Returns:
- valueunits.Quantity or float
- y_fwhm¶
Return the FWHM in the y-direction.
- Returns:
- units.Quantity
- y_mean¶
Return the center of the Gaussian in y.
- Returns:
- units.Quantity or float
- y_stddev¶
Return the standard deviation in y.
- Returns:
- valueunits.Quantity or float
Methods Documentation
- combine_with(psf, deconvolve=False)[source]¶
Combine with another beam.
Combination consists of either convolution (default) or deconvolution of this beam by another.
- Parameters:
- psfGaussian2D
The beam to combine.
- deconvolvebool, optional
If
True
, indicates a deconvolution rather than a convolution.
- Returns:
- None
- convolve_with(psf)[source]¶
Convolve with a given PSF.
- Parameters:
- psfGaussian2D
The Point Spread Function to convolve with.
- Returns:
- None
- deconvolve_with(psf)[source]¶
Deconvolve with a given PSF.
- Parameters:
- psfGaussian2D
The Point Spread Function to deconvolve with.
- Returns:
- None
- edit_header(header, fits_id='', beam_name=None, size_unit=None)[source]¶
Edit a FITS header with the beam parameters.
- Parameters:
- headerastropy.io.fits.header.Header
The FITS header to edit.
- fits_idstr, optional
The name prefixing the FITS header BMAJ/BMIN keywords. For example, IBMAJ.
- beam_namestr, optional
The name of the beam.
- size_unitunits.Unit or units.Quantity or str, optional
If set, convert the major/minor beam values to this unit before setting in the header.
- Returns:
- None
- encompass(psf)[source]¶
Encompass with another beam.
- Parameters:
- psfGaussian2D or units.Quantity
Another Gaussian PSF or the FWHM of another Gaussian PSF.
- Returns:
- None
- extent()[source]¶
Return the extent in x and y.
The extent is the maximum (x, y) deviation away from the center of the psf in the native coordinate frame, accounting for rotation by the position angle.
- Returns:
- extentCoordinate2D
The extent in x and y.
- get_beam_map(grid, sigmas=3.0)[source]¶
Return a beam map given an output grid.
- Parameters:
- gridGrid2D
The output grid on which the beam map should be projected.
- sigmasfloat, optional
The number of Gaussian sigmas to be encapsulated within the map (determines the size of the map).
- Returns:
- beam_mapnumpy.ndarray (float)
A 2-D beam map image.
- get_circular_equivalent_fwhm()[source]¶
Return the FWHM of a circular Gaussian with equivalent area.
- Returns:
- units.Quantity
- static get_equivalent(beam_map, pixel_size)[source]¶
Return a 2-D Gaussian for a beam map and given pixel size.
The equivalent psf if circular with a FWHM equal to that determined from the beam map.
- Parameters:
- beam_mapnumpy.ndarray (float)
A map of the beam of shape (ky, kx).
- pixel_sizeCoordinate2D or numpy.ndarray or float or units.Quantity
The pixel size.
- Returns:
- Gaussian2D
- is_encompassing(psf)[source]¶
Check if the psf is encompassing the beam.
- Parameters:
- psfGaussian2D
- Returns:
- bool
- parse_header(header, size_unit=None, fits_id='')[source]¶
Set the beam from a FITS header.
Reads a FITS header to determine:
- The major FWHM (BMAJ) - The minor FWHM (BMIN) - The position angle (BPA)
By default, an attempt will be made to determine the size unit for the FWHMs from the header comments, although a fixed unit may be supplied by the
size_unit
parameter. The same process will occur for the position angle, but no overriding unit may be supplied. In case no unit is determined, all parameters will default to ‘degree’.- Parameters:
- headerastropy.io.fits.header.Header
- size_unitunits.Unit or units.Quantity or str
The size unit to apply to the header values. If
None
, an attempt will be made to determine the size unit from the header comments for the appropriate keywords, and if not found, will default to ‘degree’. Any other supplied value will take priority.- fits_idstr, optional
The name prefixing the FITS header BMAJ/BMIN keywords. For example, IBMAJ.
- Returns:
- None
- rotate(angle)[source]¶
Rotate the beam by a given angle.
- Parameters:
- angleunits.Quantity
- Returns:
- None
- scale(factor)[source]¶
Scale the FWHM in both axes by a given amount.
- Parameters:
- factorfloat
- Returns:
- None
- set_area(area)[source]¶
Set the Gaussian parameters based on the overall area of the beam.
- Parameters:
- areafloat or units.Quantity
- Returns:
- None
- set_equivalent(beam_map, pixel_size)[source]¶
Set Gaussian parameters from a given beam map and pixel size.
The area and thus FWHM are determined from the input parameters. Therefore, only a circular Gaussian will be set with zero position angle.
- Parameters:
- beam_mapnumpy.ndarray (float)
A map of the beam of shape (ky, kx).
- pixel_sizeCoordinate2D or numpy.ndarray or float or units.Quantity
The pixel size.
- Returns:
- None
- set_xy_fwhm(x_fwhm, y_fwhm)[source]¶
Set and validate both new x and y FWHM values at once.
The correct position angle must be set for the process to occur correctly. This is so both FWHMs get set correctly, as doing it sequentially may result in one of the values getting overwritten by the other.
- Parameters:
- x_fwhmunits.Quantity
- y_fwhmunits.Quantity
- Returns:
- None