Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible speed improvements to transit model fitting #110

Open
hrwakeford opened this issue Oct 2, 2020 · 3 comments
Open

Possible speed improvements to transit model fitting #110

hrwakeford opened this issue Oct 2, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@hrwakeford
Copy link
Member

Some possible speed improvements to occultnl the transit model fitting. Suggested by Lavender Elle Hanson (JHU).

Insert the following two lines immediately before the occultuniform function:

import numba
@numba.jit(numba.float64[:](numba.float64[:], numba.float64))

Then the start of the occultuniform function will look like this:

import numba
@numba.jit(numba.float64[:](numba.float64[:], numba.float64))
def occultuniform(b0, w):
"""
Compute the lightcurve for occultation of a uniform source without microlensing (Mandel & Agol 2002).

:param b0: array; impact parameter in units of stellar radii
:param w: array; occulting star size in units of stellar radius
:return: muo1: float; fraction of flux at each b0 for a uniform source
"""

if np.abs(w - 0.5) < 1.0e-3:
    w = 0.5

This trick requires the numba library, it can be installed it by adding the following in a Jupyter cell at the top of the notebook:

import sys
!conda install --yes --prefix {sys.prefix} numba

or (if that doesn’t work)

import sys
!{sys.executable} -m pip install numba

@hrwakeford hrwakeford added the enhancement New feature or request label Oct 2, 2020
@ivalaginja
Copy link
Collaborator

This is super interesting stuff, I have just recently started looking at numba and what it can do.

@hrwakeford do you want me to try the implementation suggested here by Lavender Elle Hanson or were they thinking of giving it a go themselves?

@hrwakeford
Copy link
Member Author

Give it a go if you have time. I was passed this information second hand but wanted to attribute credit here. It might be a good test for anything else you want to do with numba

@hrwakeford
Copy link
Member Author

I will try to find her on GitHub and tag her here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants