OpenCL models#
The GPU implementations. See The OpenCL backend for how they are used, how they differ from the CPU models, and when the GPU is worth it.
Warning
The OpenCL models compute in single precision. Always subtract a constant epoch from the times before passing them to one.
Uniform model#
- class pytransit.models.ma_uniform_cl.UniformModelCL(cl_ctx=None, cl_queue=None)[source]#
Bases:
OpenCLTransitModelExoplanet transit over a uniform disk (Mandel & Agol, ApJ 580, L171-L175 2002).
- evaluate(k, t0, p, a, i, e=None, w=None, copy=True)[source]#
Evaluate the transit model for a set of scalar or vector parameters.
- Parameters:
k – Radius ratio(s) either as a single float, 1D vector, or 2D array.
t0 – Transit center(s) as a float or a 1D vector.
p – Orbital period(s) as a float or a 1D vector.
a – Orbital semi-major axis (axes) divided by the stellar radius as a float or a 1D vector.
i – Orbital inclination(s) as a float or a 1D vector.
e (optional) – Orbital eccentricity as a float or a 1D vector.
w (optional) – Argument of periastron as a float or a 1D vector.
Notes
The model can be evaluated either for one set of parameters or for many sets of parameters simultaneously. In the first case, the orbital parameters should all be given as floats. In the second case, the orbital parameters should be given as a 1D array-like.
- Returns:
ndarray – Modelled flux either as a 1D or 2D ndarray.
- set_data(time, lcids=None, pbids=None, nsamples=None, exptimes=None, epids=None)#
Set the data and upload it to the device.
Takes the same arguments as TransitModel.set_data, which does the validation and stores the arrays. They are then cast to the types the kernels index – the times and the exposure times to the device floating point type, the indices and the sample counts to uint32 – and uploaded. Nothing happens if the base class reports the call a no-op.
Quadratic model#
- class pytransit.models.ma_quadratic_cl.QuadraticModelCL(klims=(0.05, 0.25), nk=256, nz=256, cl_ctx=None, cl_queue=None)[source]#
Bases:
OpenCLTransitModelOpenCL implementation of the transit light curve model with quadratic limb darkening by Mandel and Agol (2002).
This class implements the quadratic transit model by Mandel & Agol (ApJ 580, L171-L175, 2002) in OpenCL. The class can replace pytransit.QuadraticModel directly, and offers in most cases a significant performance boost with some drawbacks (see the notes below).
Notes
All the calculations are done in single precision. This can affect the results when modelling extremely shallow transits, and will certainly affect the model if the times are given in JD. The times should be given relative to some constant epoch that maximises the precision (see pytransit.lpf.lpf.BaseLPF for an example).
- __init__(klims=(0.05, 0.25), nk=256, nz=256, cl_ctx=None, cl_queue=None)[source]#
Transit model with quadratic limb darkening (Mandel & Agol, ApJ 580, L171-L175, 2002).
- Parameters:
klims (tuple, optional) – Radius ratio limits (kmin, kmax) for the interpolated model.
nk (int, optional) – Radius ratio grid size for the interpolated model.
nz (int, optional) – Normalized distance grid size for the interpolated model.
cl_ctx (optional) – OpenCL context.
cl_queue (optional) – OpenCL queue
- evaluate(k, ldc, t0, p, a, i, e=None, w=None, copy=True)[source]#
Evaluate the transit model for a set of scalar or vector parameters.
- Parameters:
k – Radius ratio(s) either as a single float, 1D vector, or 2D array.
ldc – Limb darkening coefficients as a 1D or 2D array.
t0 – Transit center(s) as a float or a 1D vector.
p – Orbital period(s) as a float or a 1D vector.
a – Orbital semi-major axis (axes) divided by the stellar radius as a float or a 1D vector.
i – Orbital inclination(s) as a float or a 1D vector.
e (optional) – Orbital eccentricity as a float or a 1D vector.
w (optional) – Argument of periastron as a float or a 1D vector.
Notes
The model can be evaluated either for one set of parameters or for many sets of parameters simultaneously. In the first case, the orbital parameters should all be given as floats. In the second case, the orbital parameters should be given as a 1D array-like.
- Returns:
ndarray – Modelled flux either as a 1D or 2D ndarray.
- set_data(time, lcids=None, pbids=None, nsamples=None, exptimes=None, epids=None)#
Set the data and upload it to the device.
Takes the same arguments as TransitModel.set_data, which does the validation and stores the arrays. They are then cast to the types the kernels index – the times and the exposure times to the device floating point type, the indices and the sample counts to uint32 – and uploaded. Nothing happens if the base class reports the call a no-op.
Power-2 model#
- class pytransit.models.qpower2_cl.QPower2ModelCL(cl_ctx=None, cl_queue=None)[source]#
Bases:
OpenCLTransitModelOpenCL implementation of the power-2 transit model (Maxted & Gill, A&A 622, A33, 2019).
A GPU implementation of
QPower2Model. SeeQPower2Modelfor the model itself, and the OpenCL section of the user guide for how the OpenCL models differ from their Numba counterparts.- evaluate(k, ldc, t0, p, a, i, e=None, w=None, copy=True)[source]#
Evaluate the transit model for a set of scalar or vector parameters.
- Parameters:
k – Radius ratio(s) either as a single float, 1D vector, or 2D array.
ldc – Limb darkening coefficients as a 1D or 2D array.
t0 – Transit center(s) as a float or a 1D vector.
p – Orbital period(s) as a float or a 1D vector.
a – Orbital semi-major axis (axes) divided by the stellar radius as a float or a 1D vector.
i – Orbital inclination(s) as a float or a 1D vector.
e (optional) – Orbital eccentricity as a float or a 1D vector.
w (optional) – Argument of periastron as a float or a 1D vector.
Notes
The model can be evaluated either for one set of parameters or for many sets of parameters simultaneously. In the first case, the orbital parameters should all be given as floats. In the second case, the orbital parameters should be given as a 1D array-like.
- Returns:
ndarray – Modelled flux either as a 1D or 2D ndarray.
- set_data(time, lcids=None, pbids=None, nsamples=None, exptimes=None, epids=None)#
Set the data and upload it to the device.
Takes the same arguments as TransitModel.set_data, which does the validation and stores the arrays. They are then cast to the types the kernels index – the times and the exposure times to the device floating point type, the indices and the sample counts to uint32 – and uploaded. Nothing happens if the base class reports the call a no-op.
RoadRunner model#
- class pytransit.models.roadrunner.rrmodel_cl.RoadRunnerModelCL(ldmodel='quadratic', interpolate=None, klims=None, nk=None, nzin=None, nzlimb=None, zcut=None, ng=100, parallel=False, small_planet_limit=0.05, cl_ctx=None, cl_queue=None, nz=None, nq=8, precision='single')[source]#
Bases:
OpenCLTransitModelOpenCL implementation of the RoadRunner transit model (Parviainen, MNRAS 499, 1633, 2020).
A GPU implementation of
RoadRunnerModelwith the same accuracy settings, nq and ng. The limb darkening profile is evaluated on the host on the same fixed grid of mu as in the Numba model and uploaded to the device, which integrates it over the planet’s footprint by the same geometry-matched Gauss quadrature, tabulates the mean intensity under the planet against the grazing parameter, and reads the table with a cubic lookup during the evaluation. Any radially symmetric limb darkening model the Numba model accepts works here as well.The model computes in single precision; see The OpenCL backend for what that implies.
This class is not exported at the package top level; import it from its module:
from pytransit.models.roadrunner.rrmodel_cl import RoadRunnerModelCL
- __init__(ldmodel='quadratic', interpolate=None, klims=None, nk=None, nzin=None, nzlimb=None, zcut=None, ng=100, parallel=False, small_planet_limit=0.05, cl_ctx=None, cl_queue=None, nz=None, nq=8, precision='single')[source]#
The OpenCL RoadRunner transit model.
- Parameters:
ldmodel – Limb darkening model: either the name of a built-in model, a callable returning the stellar intensity profile as a function of mu, a tuple of callables returning the profile and its integral over the stellar disk, or an
LDModelinstance.nq (int, optional) – Number of quadrature nodes per segment used to integrate the intensity profile over the planet’s footprint.
ng (int, optional) – Number of grazing parameter nodes in the mean intensity table, split at the limb contact and interpolated with cubics.
precision (str, optional) – Device floating point type,
'single'(the default) or'double'. Double precision needs cl_khr_fp64, which most GPUs support but run at a fraction of the single precision rate – typically a sixty-fourth on consumer NVIDIA cards – so it is an opt-in for accuracy rather than a better default. It also changes the dtype of the returned flux to float64. The precision is fixed for the lifetime of the model, because the kernel’s floating point type is a compile-time build option.interpolate (optional) – Deprecated and ignored: the mean intensity under the planet is always computed for the radius ratio being evaluated, so there is no weight table to precompute.
klims (optional) – Deprecated and ignored: the mean intensity under the planet is always computed for the radius ratio being evaluated, so there is no weight table to precompute.
nk (optional) – Deprecated and ignored: the mean intensity under the planet is always computed for the radius ratio being evaluated, so there is no weight table to precompute.
nz (optional) – Deprecated and ignored: the stellar disk is no longer discretised into annuli.
nzin (optional) – Deprecated and ignored: the stellar disk is no longer discretised into annuli.
nzlimb (optional) – Deprecated and ignored: the stellar disk is no longer discretised into annuli.
zcut (optional) – Deprecated and ignored: the stellar disk is no longer discretised into annuli.
parallel – Accepted for interface compatibility with the Numba model; unused here.
small_planet_limit – Accepted for interface compatibility with the Numba model; unused here.
cl_ctx (optional) – OpenCL context and command queue. Created with
cl.create_some_context()if omitted.cl_queue (optional) – OpenCL context and command queue. Created with
cl.create_some_context()if omitted.
- init_integration(nq, ng)[source]#
Set the quadrature resolution and the mean intensity table size.
Called by the initialiser, and useful afterwards for changing the model’s accuracy without creating a new model. The arguments have the same meaning as in the initialiser.
- set_data(time, lcids=None, pbids=None, nsamples=None, exptimes=None, epids=None)#
Set the data and upload it to the device.
Takes the same arguments as TransitModel.set_data, which does the validation and stores the arrays. They are then cast to the types the kernels index – the times and the exposure times to the device floating point type, the indices and the sample counts to uint32 – and uploaded. Nothing happens if the base class reports the call a no-op.
- evaluate(k, ldc, t0, p, a, i, e=None, w=None, copy=True)[source]#
Evaluate the transit model for a set of scalar or vector parameters.
- Parameters:
k – Radius ratio(s) either as a single float, 1D vector, or 2D array. A 1D vector is read as the radius ratios per passband when evaluating a single parameter vector, and as one radius ratio per parameter vector when evaluating a population. Give a population several radius ratios per parameter vector as an
(npv, nk)array.ldc – Limb darkening coefficients as a 1D or 2D array.
t0 – Transit center(s) as a float or a 1D vector.
p – Orbital period(s) as a float or a 1D vector.
a – Orbital semi-major axis (axes) divided by the stellar radius as a float or a 1D vector.
i – Orbital inclination(s) as a float or a 1D vector.
e (optional) – Orbital eccentricity as a float or a 1D vector.
w (optional) – Argument of periastron as a float or a 1D vector.
copy (optional) – Copy the fluxes back from the device. With
copy=Falsethe fluxes are left in the device buffer_b_fandNoneis returned.
Notes
The model can be evaluated either for one set of parameters or for many sets of parameters simultaneously. In the first case, the orbital parameters should all be given as floats. In the second case, the orbital parameters should be given as a 1D array-like.
- Returns:
ndarray – Modelled flux either as a 1D or 2D ndarray.