The GSParams class
As mentioned in the GSObject
docstring, all of the various GSObject
classes take an optional
gsparams
argument, which can be used to specify various numbers that govern the tradeoff
between accuracy and speed for the calculations made in drawing a GSObject. The numbers are
encapsulated in a class called GSParams
.
- class galsim.GSParams(minimum_fft_size=128, maximum_fft_size=8192, folding_threshold=0.005, stepk_minimum_hlr=5, maxk_threshold=0.001, kvalue_accuracy=1e-05, xvalue_accuracy=1e-05, table_spacing=1, realspace_relerr=0.0001, realspace_abserr=1e-06, integration_relerr=1e-06, integration_abserr=1e-08, shoot_accuracy=1e-05, allowed_flux_variation=0.81, range_division_for_extrema=32, small_fraction_of_flux=0.0001)[source]
GSParams stores a set of numbers that govern how a
GSObject
makes various speed/accuracy tradeoff decisions.All
GSObject
classes can take an optional parameter namedgsparams
, which would be an instance of this class. e.g.:>>> gsp = galsim.GSParams(folding_threshold=1.e-3) >>> gal = galsim.Sersic(n=3.4, half_light_radius=3.2, flux=200, gsparams=gsp)
One can also update the parameters for an existing object using the method
GSObject.withGSParams
. e.g.:>>> gal = gal.withGSParams(kvalue_accuracy=1.e-8)
All parameters have reasonable default values. You only need to specify the ones you want to change.
- Parameters:
minimum_fft_size – The minimum size of any FFT that may need to be performed. [default: 128]
maximum_fft_size – The maximum allowed size of an image for performing an FFT. This is more about memory use than accuracy. We have this maximum value to help prevent the user from accidentally trying to perform an extremely large FFT that crashes the program. Instead, GalSim will raise an exception indicating that the image is too large, which is often a sign of an error in the user’s code. However, if you have the memory to handle it, you can raise this limit to allow the calculation to happen. [default: 8192]
folding_threshold – This sets a maximum amount of real space folding that is allowed, an effect caused by the periodic nature of FFTs. FFTs implicitly use periodic boundary conditions, and a profile specified on a finite grid in Fourier space corresponds to a real space image that will have some overlap with the neighboring copies of the real space profile. As the step size in k increases, the spacing between neighboring aliases in real space decreases, increasing the amount of folded, overlapping flux.
folding_threshold
is used to set an appropriate step size in k to allow at most this fraction of the flux to be folded. This parameter is also relevant when you let GalSim decide how large an image to use for your object. The image is made to be large enough that at most a fractionfolding_threshold
of the total flux is allowed to fall off the edge of the image. [default: 5.e-3]stepk_minimum_hlr – In addition to the above constraint for aliasing, also set stepk such that pi/stepk is at least
stepk_minimum_hlr
times the profile’s half-light radius (for profiles that have a well-defined half-light radius). [default: 5]maxk_threshold – This sets the maximum amplitude of the high frequency modes in Fourier space that are excluded by truncating the FFT at some maximum k value. Lowering this parameter can help minimize the effect of “ringing” if you see that in your images. [default: 1.e-3]
kvalue_accuracy – This sets the accuracy of values in Fourier space. Whenever there is some kind of approximation to be made in the calculation of a Fourier space value, the error in the approximation is constrained to be no more than this value times the total flux. [default: 1.e-5]
xvalue_accuracy – This sets the accuracy of values in real space. Whenever there is some kind of approximation to be made in the calculation of a real space value, the error in the approximation is constrained to be no more than this value times the total flux. [default: 1.e-5]
table_spacing – Several profiles use lookup tables for either the Hankel transform (
Sersic
,Moffat
) or the real space radial function (Kolmogorov
). We try to estimate a good spacing between values in the lookup tables based on eitherxvalue_accuracy
orkvalue_accuracy
as appropriate. However, you may change the spacing with this parameter. Usingtable_spacing < 1
will use a spacing value that is that much smaller than the default, which should produce more accurate interpolations. [default: 1]realspace_relerr – This sets the relative error tolerance for real-space integration. [default: 1.e-4]
realspace_abserr – This sets the absolute error tolerance for real-space integration. [default: 1.e-6] The estimated integration error for the flux value in each pixel when using the real-space rendering method (either explicitly with
method='real_space'
or if it is triggered automatically withmethod='auto'
) is constrained to be no larger than eitherrealspace_relerr
times the pixel flux orrealspace_abserr
times the object’s total flux.integration_relerr – The relative error tolerance for integrations other than real-space rendering. [default: 1.e-6]
integration_abserr – The absolute error tolerance for integrations other than real-space rendering. [default: 1.e-8]
shoot_accuracy – This sets the relative accuracy on the total flux when photon shooting. The photon shooting algorithm at times needs to make approximations, such as how high in radius it needs to sample the radial profile. When such approximations need to be made, it makes sure that the resulting fractional error in the flux will be at most this much. [default: 1.e-5]
After construction, all of the above parameters are available as read-only attributes.
- static check(gsparams, default=None, **kwargs)[source]
Checks that gsparams is either a valid GSParams instance or None.
In the former case, it returns gsparams, in the latter it returns default (GSParams.default if no other default specified).