Interpolation¶
Interpolants¶
- class jax_galsim.Interpolant[source]¶
Bases:
objectA base class that defines how interpolation should be done.
LAX-backend implementation of
galsim.interpolant.Interpolant().Original GalSim Documentation
An Interpolant is needed for an InterpolatedImage to define how interpolation should be done an locations in between the integer pixel centers.
- static from_name(name, tol=None, gsparams=None)[source]¶
A factory function to create an Interpolant of the correct type according to the (string) name of the Interpolant.
LAX-backend implementation of
galsim.interpolant.from_name().- Parameters:
name – The name of the interpolant to create.
tol – [deprecated]
gsparams – An optional GSParams argument. [default: None]
Original GalSim Documentation
This is mostly used to simplify how config files specify the Interpolant to use.
Valid names are:
‘delta’ = Delta
‘nearest’ = Nearest
‘sinc’ = SincInterpolant
‘linear’ = Linear
‘cubic’ = Cubic
‘quintic’ = Quintic
‘lanczosN’ = Lanczos (where N is an integer, given the
nparameter)
In addition, if you want to specify the
conserve_dcoption for Lanczos, you can append either T or F to representconserve_dc = True/False(respectively). Otherwise, the defaultconserve_dc=Trueis used.
- property gsparams¶
The GSParams of the Interpolant
LAX-backend implementation of
gsparams().
- property tol¶
- withGSParams(gsparams=None, **kwargs)[source]¶
Create a version of the current interpolant with the given gsparams
LAX-backend implementation of
galsim.interpolant.withGSParams().
- xval(x)[source]¶
Calculate the value of the interpolant kernel at one or more x values
LAX-backend implementation of
galsim.interpolant.xval().- Parameters:
x – The value (as a float) or values (as a np.array) at which to compute the amplitude of the Interpolant kernel.
Original GalSim Documentation
- Returns:
- xval: The value(s) at the x location(s). If x was an array, then this is also
an array.
- kval(k)[source]¶
Calculate the value of the interpolant kernel in Fourier space at one or more k values.
LAX-backend implementation of
galsim.interpolant.kval().- Parameters:
k – The value (as a float) or values (as a np.array) at which to compute the amplitude of the Interpolant kernel in Fourier space.
Original GalSim Documentation
- Returns:
- kval: The k-value(s) at the k location(s). If k was an array, then this is also
an array.
- unit_integrals(max_len=None)[source]¶
Compute the unit integrals of the real-space kernel.
LAX-backend implementation of
galsim.interpolant.unit_integrals().- Parameters:
max_len – The maximum length of the returned array. This is usually only relevant for SincInterpolant, where xrange = inf.
Original GalSim Documentation
integrals[i] = int(xval(x), i-0.5, i+0.5)
- Returns:
integrals: An array of unit integrals of length max_len or smaller.
- tree_flatten()[source]¶
This function flattens the Interpolant into a list of children nodes that will be traced by JAX and auxiliary static data.
- classmethod tree_unflatten(aux_data, children)[source]¶
Recreates an instance of the class from flattened representation
- property positive_flux¶
The positive-flux fraction of the interpolation kernel.
LAX-backend implementation of
positive_flux().
- property negative_flux¶
The negative-flux fraction of the interpolation kernel.
LAX-backend implementation of
negative_flux().
- property xrange¶
The maximum extent of the interpolant from the origin (in pixels).
- property ixrange¶
The total integral range of the interpolant. Typically 2 * xrange.
- property krange¶
The maximum extent of the interpolant in Fourier space (in 1/pixels).
- class jax_galsim.Delta(tol=None, gsparams=None)[source]¶
Bases:
InterpolantDelta-function interpolation.
LAX-backend implementation of
galsim.interpolant.Delta().- Parameters:
tol – [deprecated]
gsparams – An optional GSParams argument. [default: None]
Original GalSim Documentation
The interpolant for when you do not want to interpolate between samples. It is not really intended to be used for any analytic drawing because it is infinite in the x domain at the location of samples, and it extends to infinity in the u domain. But it could be useful for photon-shooting, where it is trivially implemented as no displacements.
- class jax_galsim.Nearest(tol=None, gsparams=None)[source]¶
Bases:
InterpolantNearest-neighbor interpolation (boxcar).
LAX-backend implementation of
galsim.interpolant.Nearest().- Parameters:
tol – [deprecated]
gsparams – An optional GSParams argument. [default: None]
Original GalSim Documentation
The nearest-neighbor interpolant performs poorly as a k-space or x-space interpolant for interpolated images. (See paper by “Bernstein & Gruen, http://arxiv.org/abs/1401.2636.) The objection to its use in Fourier space does not apply when shooting photons to generate an image; in that case, the nearest-neighbor interpolant is quite efficient (but not necessarily the best choice in terms of accuracy).
- class jax_galsim.SincInterpolant(tol=None, gsparams=None)[source]¶
Bases:
InterpolantSinc interpolation (inverse of nearest-neighbor).
LAX-backend implementation of
galsim.interpolant.SincInterpolant().- Parameters:
tol – [deprecated]
gsparams – An optional GSParams argument. [default: None]
Original GalSim Documentation
The Sinc interpolant (K(x) = sin(pi x)/(pi x)) is mathematically perfect for band-limited data, introducing no spurious frequency content beyond kmax = pi/dx for input data with pixel scale dx. However, it is formally infinite in extent and, even with reasonable trunction, is still quite large. It will give exact results in GSObject.kValue for InterpolatedImage when it is used as a k-space interpolant, but is extremely slow. The usual compromise between sinc accuracy vs. speed is the Lanczos interpolant (see its documentation for details).
- property xrange¶
The maximum extent of the interpolant from the origin (in pixels).
LAX-backend implementation of
xrange().
- unit_integrals(max_len=None)[source]¶
Compute the unit integrals of the real-space kernel.
LAX-backend implementation of
galsim.interpolant.unit_integrals().- Parameters:
max_len – The maximum length of the returned array.
Original GalSim Documentation
integrals[i] = int(xval(x), i-0.5, i+0.5)
- Returns:
integrals: An array of unit integrals of length max_len or smaller.
- class jax_galsim.Linear(tol=None, gsparams=None)[source]¶
Bases:
InterpolantLinear interpolation
LAX-backend implementation of
galsim.interpolant.Linear().- Parameters:
tol – [deprecated]
gsparams – An optional GSParams argument. [default: None]
Original GalSim Documentation
The linear interpolant is a poor choice for FFT-based operations on interpolated images, as it rings to high frequencies. (See Bernstein & Gruen, http://arxiv.org/abs/1401.2636.) This objection does not apply when shooting photons, in which case the linear interpolant is quite efficient (but not necessarily the best choice in terms of accuracy).
- class jax_galsim.Cubic(tol=None, gsparams=None)[source]¶
Bases:
InterpolantCubic interpolation
LAX-backend implementation of
galsim.interpolant.Cubic().- Parameters:
tol – [deprecated]
gsparams – An optional GSParams argument. [default: None]
Original GalSim Documentation
The cubic interpolant is exact to 3rd order Taylor expansion (from R. G. Keys, IEEE Trans. Acoustics, Speech, & Signal Proc 29, p 1153, 1981). It is a reasonable choice for a four-point interpolant for interpolated images. (See Bernstein & Gruen, http://arxiv.org/abs/1401.2636.)
- class jax_galsim.Quintic(tol=None, gsparams=None)[source]¶
Bases:
InterpolantFifth order interpolation
LAX-backend implementation of
galsim.interpolant.Quintic().- Parameters:
tol – [deprecated]
gsparams – An optional GSParams argument. [default: None]
Original GalSim Documentation
The quintic interpolant is exact to 5th order in the Taylor expansion and was found by Bernstein & Gruen (http://arxiv.org/abs/1401.2636) to give optimal results as a k-space interpolant.
- class jax_galsim.Lanczos(n, conserve_dc=True, tol=None, gsparams=None)[source]¶
Bases:
InterpolantThe Lanczos interpolation filter, nominally sinc(x)*sinc(x/n)
LAX-backend implementation of
galsim.interpolant.Lanczos().- Parameters:
n – The order of the Lanczos function
conserve_dc – Whether to add the first order correction to flatten out the flux response to a constant input. [default: True, see above]
tol – [deprecated]
gsparams – An optional GSParams argument. [default: None]
Original GalSim Documentation
The Lanczos filter is an approximation to the band-limiting sinc filter with a smooth cutoff at high x. Order n Lanczos has a range of +/- n pixels. It typically is a good compromise between kernel size and accuracy.
Note that pure Lanczos, when interpolating a set of constant-valued samples, does not return this constant. Setting
conserve_dcin the constructor tweaks the function so that it approximately conserves the value of constant (DC) input data (accurate to better than 1.e-5 when used in two dimensions).- tree_flatten()[source]¶
This function flattens the Interpolant into a list of children nodes that will be traced by JAX and auxiliary static data.
- classmethod tree_unflatten(aux_data, children)[source]¶
Recreates an instance of the class from flattened representation
- property conserve_dc¶
Whether this interpolant is modified to improve flux conservation.
LAX-backend implementation of
conserve_dc().
- property xrange¶
The maximum extent of the interpolant from the origin (in pixels).
LAX-backend implementation of
xrange().
- property ixrange¶
The total integral range of the interpolant. Typically 2 * xrange.
LAX-backend implementation of
ixrange().
- property positive_flux¶
The positive-flux fraction of the interpolation kernel.
LAX-backend implementation of
positive_flux().
- property negative_flux¶
The negative-flux fraction of the interpolation kernel.
LAX-backend implementation of
negative_flux().
- unit_integrals(max_len=None)[source]¶
Compute the unit integrals of the real-space kernel.
LAX-backend implementation of
galsim.interpolant.unit_integrals().- Parameters:
max_len – The maximum length of the returned array. This is usually only relevant for SincInterpolant, where xrange = inf.
Original GalSim Documentation
integrals[i] = int(xval(x), i-0.5, i+0.5)
- Returns:
integrals: An array of unit integrals of length max_len or smaller.