Photon Operators
- class galsim.PhotonOp[source]
A base class for photon operators, which just defines the interface.
Photon operators are designed to apply some physical effect to a bundle of photons. They may adjust the fluxes in some way, or the positions, maybe in a wavelength-dependent way, etc. They are typically applied via a
photon_ops
argument to theGSObject.drawImage
method. The order typically matters, so the operators are applied in the order they appear in the list.- applyTo(photon_array, local_wcs=None, rng=None)[source]
Apply the photon operator to a PhotonArray.
- Parameters:
photon_array – A
PhotonArray
to apply the operator to.local_wcs – A
LocalWCS
instance defining the local WCS for the current photon bundle in case the operator needs this information. [default: None]rng – A random number generator to use if needed. [default: None]
- class galsim.WavelengthSampler(sed, bandpass=None, rng=None, npoints=None)[source]
A photon operator that uses sed.sampleWavelength to set the wavelengths array of a
PhotonArray
.- Parameters:
sed – The
SED
to use for the objects spectral energy distribution.bandpass – A
Bandpass
object representing a filter, or None to sample over the fullSED
wavelength range.rng – If provided, a random number generator that is any kind of
BaseDeviate
object. Ifrng
is None, one will be automatically created, using the time as a seed. [default: None]npoints – Number of points
DistDeviate
should use for its internal interpolation tables. [default: None, which uses theDistDeviate
default]
- applyTo(photon_array, local_wcs=None, rng=None)[source]
Assign wavelengths to the photons sampled from the SED * Bandpass.
- Parameters:
photon_array – A
PhotonArray
to apply the operator to.local_wcs – A
LocalWCS
instance defining the local WCS for the current photon bundle in case the operator needs this information. [default: None]rng – A random number generator to use if needed. [default: None]
- class galsim.FRatioAngles(fratio, obscuration=0.0, rng=None)[source]
A photon operator that assigns photon directions based on the f/ratio and obscuration.
Assigns arrival directions at the focal plane for photons, drawing from a uniform brightness distribution between the obscuration angle and the edge of the pupil defined by the f/ratio of the telescope. The angles are expressed in terms of slopes dx/dz and dy/dz.
- Parameters:
fratio – The f/ratio of the telescope (e.g. 1.2 for LSST)
obscuration – Linear dimension of central obscuration as fraction of aperture linear dimension. [0., 1.). [default: 0.0]
rng – A random number generator to use or None, in which case an rng will be automatically constructed for you. [default: None]
- applyTo(photon_array, local_wcs=None, rng=None)[source]
Assign directions to the photons in photon_array.
- Parameters:
photon_array – A
PhotonArray
to apply the operator to.local_wcs – A
LocalWCS
instance defining the local WCS for the current photon bundle in case the operator needs this information. [default: None]rng – A random number generator to use if needed. [default: None]
- class galsim.PhotonDCR(base_wavelength, scale_unit=coord.arcsec, **kwargs)[source]
A photon operator that applies the effect of differential chromatic refraction (DCR) and optionally the chromatic dilation due to atmospheric seeing.
Due to DCR, blue photons land closer to the zenith than red photons. Kolmogorov turbulence also predicts that blue photons get spread out more by the atmosphere than red photons, specifically FWHM is proportional to \(\lambda^{-0.2}\). Both of these effects can be implemented by wavelength-dependent shifts of the photons.
Since DCR depends on the zenith angle and the parallactic angle (which is the position angle of the zenith measured from North through East) of the object being drawn, these must be specified via keywords. There are four ways to specify these values:
explicitly provide
zenith_angle
as a keyword of typeAngle
, andparallactic_angle
will be assumed to be 0 by default.explicitly provide both
zenith_angle
andparallactic_angle
as keywords of typeAngle
.provide the coordinates of the object
obj_coord
and the coordinates of the zenithzenith_coord
as keywords of typeCelestialCoord
.provide the coordinates of the object
obj_coord
as aCelestialCoord
, the hour angle of the objectHA
as anAngle
, and the latitude of the observerlatitude
as anAngle
.
DCR also depends on temperature, pressure and water vapor pressure of the atmosphere. The default values for these are expected to be appropriate for LSST at Cerro Pachon, Chile, but they are broadly reasonable for most observatories.
This photon op is intended to match the functionality of
ChromaticAtmosphere
, but acting on the photon array rather than as aChromaticObject
. The photons will need to have wavelengths defined in order to work.Warning
The alpha parameter is only appropriate for stars. This photon op will act on all of the photons, so applying a chromatic dilation according to the chromatic seeing is the wrong thing to do when the surface brightness being rendered is not a pure PSF. As such, the default is alpha=0, not -0.2, which would be appropriate for Kolmogorov turbulence.
- Parameters:
base_wavelength – Wavelength (in nm) represented by the fiducial photon positions
scale_unit – Units used for the positions of the photons. [default: galsim.arcsec]
alpha – Power law index for wavelength-dependent seeing. This should only be used if doing a star-only simulation. It is not correct when drawing galaxies. [default: 0.]
zenith_angle –
Angle
from object to zenith, expressed as anAngle
. [default: 0]parallactic_angle – Parallactic angle, i.e. the position angle of the zenith, measured from North through East. [default: 0]
obj_coord – Celestial coordinates of the object being drawn as a
CelestialCoord
. [default: None]zenith_coord – Celestial coordinates of the zenith as a
CelestialCoord
. [default: None]HA – Hour angle of the object as an
Angle
. [default: None]latitude – Latitude of the observer as an
Angle
. [default: None]pressure – Air pressure in kiloPascals. [default: 69.328 kPa]
temperature – Temperature in Kelvins. [default: 293.15 K]
H2O_pressure – Water vapor pressure in kiloPascals. [default: 1.067 kPa]
- applyTo(photon_array, local_wcs=None, rng=None)[source]
Apply the DCR effect to the photons
- Parameters:
photon_array – A
PhotonArray
to apply the operator to.local_wcs – A
LocalWCS
instance defining the local WCS for the current photon bundle in case the operator needs this information. [default: None]rng – A random number generator to use if needed. [default: None]
- class galsim.FocusDepth(depth)[source]
A photon operator that focuses/defocuses photons by changing the height of the focal surface with respect to the conical beam.
- Parameters:
depth – The z-distance by which to displace the focal surface, in units of pixels. A positive (negative) number here indicates an extra- (intra-) focal sensor height. I.e., depth > 0 means the sensor surface intersects the beam after it has converged, and depth < 0 means the sensor surface intersects the beam before it has converged.
- applyTo(photon_array, local_wcs=None, rng=None)[source]
Adjust a photon bundle to account for the change in focal depth.
- Parameters:
photon_array – A
PhotonArray
to apply the operator to.local_wcs – A
LocalWCS
instance defining the local WCS for the current photon bundle in case the operator needs this information. [default: None]rng – A random number generator to use if needed. [default: None]
- class galsim.Refraction(index_ratio)[source]
A photon operator that refracts photons (manipulating their dxdz and dydz values) at an interface, commonly the interface between vacuum and silicon at the surface of a CCD.
Assumes that the surface normal is along the z-axis. If the refraction would result in total internal reflection, then those photon’s dxdz and dydz values are set to NaN, and flux values set to 0.0.
- Parameters:
index_ratio – The ratio of the refractive index on the far side of the interface to the near side. Can be given as a number or a callable function. In the latter case, the function should accept a numpy array of vacuum wavelengths as input and return a numpy array of refractive index ratios.
- applyTo(photon_array, local_wcs=None, rng=None)[source]
Refract photons
- Parameters:
photon_array – A
PhotonArray
to apply the operator to.local_wcs – A
LocalWCS
instance defining the local WCS for the current photon bundle in case the operator needs this information. [default: None]rng – A random number generator to use if needed. [default: None]
- class galsim.PupilImageSampler(diam, **kwargs)[source]
A photon operator that samples the pupil-plane positions given a pupil-plane image. Samples are drawn discretely from pupil plane image pixels marked as illuminated.
- Parameters:
diam – Aperture diameter in meters.
lam – Wavelength in nanometers. [default: None]
circular_pupil – Adopt a circular pupil? [default: True]
obscuration – Linear dimension of central obscuration as fraction of aperture linear dimension. [0., 1.). [default: 0.0]
nstruts – Number of radial support struts to add to the central obscuration. [default: 0]
strut_thick – Thickness of support struts as a fraction of aperture diameter. [default: 0.05]
strut_angle –
Angle
made between the vertical and the strut starting closest to it, defined to be positive in the counter-clockwise direction; must be anAngle
instance. [default: 0. * galsim.degrees]oversampling – Optional oversampling factor in the image plane for the PSF eventually constructed using this
Aperture
. Settingoversampling < 1
will produce aliasing in the PSF (not good). [default: 1.0]pad_factor – Additional multiple by which to extend the PSF image to avoid folding. [default: 1.0]
pupil_plane_im – The GalSim.Image, NumPy array, or name of file containing the pupil plane image, to be used instead of generating one based on the obscuration and strut parameters. [default: None]
pupil_angle – If
pupil_plane_im
is not None, rotation angle for the pupil plane (positive in the counter-clockwise direction). Must be anAngle
instance. [default: 0. * galsim.degrees]pupil_plane_scale – Sampling interval in meters to use for the pupil plane array. In most cases, it’s a good idea to leave this as None, in which case GalSim will attempt to find a good value automatically. The exception is when specifying the pupil arrangement via an image, in which case this keyword can be used to indicate the sampling of that image. See also
pad_factor
for adjusting the pupil sampling scale. [default: None]pupil_plane_size – Size in meters to use for the pupil plane array. In most cases, it’s a good idea to leave this as None, in which case GalSim will attempt to find a good value automatically. See also
oversampling
for adjusting the pupil size. [default: None]
- applyTo(photon_array, local_wcs=None, rng=None)[source]
Sample the pupil plane u,v positions for each photon.
- Parameters:
photon_array – A
PhotonArray
to apply the operator to.local_wcs – A
LocalWCS
instance defining the local WCS for the current photon bundle in case the operator needs this information. [default: None]rng – A random number generator to use if needed. [default: None]
- class galsim.PupilAnnulusSampler(R_outer, R_inner=0.0)[source]
A photon operator that uniformly samples an annular entrance pupil.
- Parameters:
R_outer – Annulus outer radius in meters.
R_inner – Annulus inner radius in meters. [default: 0.0]
- applyTo(photon_array, local_wcs=None, rng=None)[source]
Sample the pupil plane u,v positions for each photon.
- Parameters:
photon_array – A
PhotonArray
to apply the operator to.local_wcs – A
LocalWCS
instance defining the local WCS for the current photon bundle in case the operator needs this information. [default: None]rng – A random number generator to use if needed. [default: None]
- class galsim.TimeSampler(t0=0.0, exptime=0.0)[source]
A photon operator that uniformly samples photon time stamps within some interval.
- Parameters:
t0 – The nominal start time of the observation in seconds. [default: 0]
exptime – The exposure time in seconds. [default: 0]
- applyTo(photon_array, local_wcs=None, rng=None)[source]
Add time stamps to photons.
- Parameters:
photon_array – A
PhotonArray
to apply the operator to.local_wcs – A
LocalWCS
instance defining the local WCS for the current photon bundle in case the operator needs this information. [default: None]rng – A random number generator to use if needed. [default: None]