Transformed Profiles
Any profile can be modified in a number of ways, including stretching, dilating, rotating, and translating, and even more complicated things like forming the inverse in Fourier space to effect a deconvolution.
Affine Transformations
- class galsim.Transformation(obj, jac=None, offset=(0.0, 0.0), flux_ratio=1.0, gsparams=None, propagate_gsparams=True)[source]
Bases:
GSObject
A class for modeling an affine transformation of a
GSObject
instance.Typically, you do not need to construct a Transformation object explicitly. This is the type returned by the various transformation methods of
GSObject
such asGSObject.shear
,GSObject.rotate
,GSObject.shift
,GSObject.transform
, etc.All the various transformations can be described as a combination of a jacobian matrix (i.e.
GSObject.transform
) and a translation (GSObject.shift
), which are described by (dudx,dudy,dvdx,dvdy) and (dx,dy) respectively.Note
The name of the flux_ratio parameter is technically wrong here if the jacobian has a non-unit determinant, since that would also scale the flux. The flux_ratio parameter actually only refers to an overall amplitude ratio for the surface brightness profile. The total flux scaling is actually
|det(jac)| * flux_ratio
.- Parameters:
obj – The object to be transformed.
jac – A list, tuple or numpy array ( dudx, dudy, dvdx, dvdy ) describing the Jacobian of the transformation. Use None to indicate that the Jacobian is the 2x2 unit matrix. [default: None]
offset – A galsim.PositionD or tuple giving the offset by which to shift the profile. [default: (0.,0.)]
flux_ratio – A factor by which to multiply the surface brightness of the object. (Technically, not necessarily the flux. See above.) [default: 1]
gsparams – An optional
GSParams
argument. [default: None]propagate_gsparams – Whether to propagate gsparams to the transformed object. This is normally a good idea, but there may be use cases where one would not want to do this. [default: True]
- Attributes:
original – The original object that is being transformed.
jac – The jacobian of the transformation matrix.
offset – The offset being applied.
flux_ratio – The amount by which the overall surface brightness amplitude is multiplied.
gsparams – The usual gsparams attribute that all
GSObject
classes have.
Note: if
gsparams
is unspecified (or None), then the Transformation instance inherits theGSParams
from obj. Also, note that parameters related to the Fourier-space calculations must be set when initializing obj, NOT when creating the Transform (at which point the accuracy and threshold parameters will simply be ignored).- property flux_ratio
The flux ratio of the transformation.
- property jac
The Jacobian of the transforamtion.
- property offset
The offset of the transformation.
- property original
The original object being transformed.
- galsim.Transform(obj, jac=None, offset=(0.0, 0.0), flux_ratio=1.0, gsparams=None, propagate_gsparams=True)[source]
A function for transforming either a
GSObject
orChromaticObject
.This function will inspect its input argument to decide if a
Transformation
object or aChromaticTransformation
object is required to represent the resulting transformed object.Note: the name of the flux_ratio parameter is technically wrong here if the jacobian has a non-unit determinant, since that would also scale the flux. The flux_ratio parameter actually only refers to an overall amplitude ratio for the surface brightness profile. The total flux scaling is actually
|det(jac)| * flux_ratio
.- Parameters:
obj – The object to be transformed.
jac – A list or tuple ( dudx, dudy, dvdx, dvdy ) describing the Jacobian of the transformation. Use None to indicate that the Jacobian is the 2x2 unit matrix. [default: None]
offset – A galsim.PositionD or tuple giving the offset by which to shift the profile. [default: (0.,0.)]
flux_ratio – A factor by which to multiply the surface brightness of the object. (Technically, not necessarily the flux. See above.) [default: 1]
gsparams – An optional
GSParams
argument. [default: None]propagate_gsparams – Whether to propagate gsparams to the transformed object. This is normally a good idea, but there may be use cases where one would not want to do this. [default: True]
- Returns:
a
Transformation
orChromaticTransformation
instance as appropriate.
- galsim._Transform(obj, jac=None, offset=(0.0, 0.0), flux_ratio=1.0)[source]
Approximately equivalent to Transform, but without some of the sanity checks (such as checking for chromatic options) or setting a new gsparams.
For a
ChromaticObject
, you must use the regularTransform
.- Parameters:
obj – The object to be transformed.
jac – A 2x2 numpy array describing the Jacobian of the transformation. Use None to indicate that the Jacobian is the 2x2 unit matrix. [default: None]
offset – The offset to apply. [default (0.,0.)]
flux_ratio – A factor by which to multiply the surface brightness of the object. [default: 1.]
De-convolution of a GSObject
- class galsim.Deconvolution(obj, gsparams=None, propagate_gsparams=True)[source]
Bases:
GSObject
A class for deconvolving a
GSObject
.The Deconvolution class represents a deconvolution kernel. Note that the Deconvolution class, or compound objects (Sum, Convolution) that include a Deconvolution as one of the components, cannot be photon-shot using the ‘phot’ method of
GSObject.drawImage
method.You may also specify a
gsparams
argument. See the docstring forGSParams
for more information about this option. Note: ifgsparams
is unspecified (or None), then the Deconvolution instance inherits the sameGSParams
as the object being deconvolved.The normal way to use this class is to use the Deconvolve() factory function:
>>> inv_psf = galsim.Deconvolve(psf) >>> deconv_gal = galsim.Convolve(inv_psf, gal)
- Parameters:
obj – The object to deconvolve.
gsparams – An optional
GSParams
argument. [default: None]propagate_gsparams – Whether to propagate gsparams to the deconvolved object. This is normally a good idea, but there may be use cases where one would not want to do this. [default: True]
- property orig_obj
The original object that is being deconvolved.
- galsim.Deconvolve(obj, gsparams=None, propagate_gsparams=True)[source]
A function for deconvolving by either a
GSObject
orChromaticObject
.This function will inspect its input argument to decide if a
Deconvolution
object or aChromaticDeconvolution
object is required to represent the deconvolution by a surface brightness profile.- Parameters:
obj – The object to deconvolve.
gsparams – An optional
GSParams
argument. [default: None]propagate_gsparams – Whether to propagate gsparams to the deconvolved object. This is normally a good idea, but there may be use cases where one would not want to do this. [default: True]
- Returns:
a
Deconvolution
orChromaticDeconvolution
instance as appropriate.
Fourier-space Square Root
- class galsim.FourierSqrtProfile(obj, gsparams=None, propagate_gsparams=True)[source]
Bases:
GSObject
A class for computing the Fourier-space sqrt of a
GSObject
.The FourierSqrtProfile class represents the Fourier-space square root of another profile. Note that the FourierSqrtProfile class, or compound objects (Sum, Convolution) that include a FourierSqrtProfile as one of the components cannot be photon-shot using the ‘phot’ method of
GSObject.drawImage
method.You may also specify a
gsparams
argument. See the docstring forGSParams
for more information about this option. Note: ifgsparams
is unspecified (or None), then the FourierSqrtProfile instance inherits the sameGSParams
as the object being operated on.The normal way to use this class is to use the
FourierSqrt
factory function:>>> fourier_sqrt = galsim.FourierSqrt(obj)
- Parameters:
obj – The object to compute Fourier-space square root of.
gsparams – An optional
GSParams
argument. [default: None]propagate_gsparams – Whether to propagate gsparams to the transformed object. This is normally a good idea, but there may be use cases where one would not want to do this. [default: True]
- property orig_obj
The original object being Fourier sqrt-ed.
- galsim.FourierSqrt(obj, gsparams=None, propagate_gsparams=True)[source]
A function for computing the Fourier-space square root of either a
GSObject
orChromaticObject
.The FourierSqrt function is principally used for doing an optimal coaddition algorithm originally developed by Nick Kaiser (but unpublished) and also described by Zackay & Ofek 2015 (http://adsabs.harvard.edu/abs/2015arXiv151206879Z). See the script make_coadd.py in the GalSim/examples directory for an example of how it works.
This function will inspect its input argument to decide if a
FourierSqrtProfile
object or aChromaticFourierSqrtProfile
object is required to represent the operation applied to a surface brightness profile.- Parameters:
obj – The object to compute the Fourier-space square root of.
gsparams – An optional
GSParams
argument. [default: None]propagate_gsparams – Whether to propagate gsparams to the transformed object. This is normally a good idea, but there may be use cases where one would not want to do this. [default: True]
- Returns:
a
FourierSqrtProfile
orChromaticFourierSqrtProfile
instance as appropriate.