exoplanet-dev / exoplanet

Fast & scalable MCMC for all your exoplanet needs!
https://docs.exoplanet.codes
MIT License
206 stars 52 forks source link

SimpleLimbDark doesn't vary u1 #122

Closed ethankruse closed 3 years ago

ethankruse commented 4 years ago

Hey Dan,

Now that 0.4 is out, I'm trying out your suggestion from our conversation in starry. It looks like SimpleLimbDark is fast and exactly what I want, but your code example isn't working. set_u doesn't seem to care what you feed in as u1, the output is always the same. u2 does have an effect though. Was your example wrong? Any idea what's up?

Here's the example code and outputs I'm getting:

import matplotlib.pyplot as plt
import numpy as np
from exoplanet.theano_ops.driver import SimpleLimbDark

plt.figure()
bs = np.arange(-1.5, 1.5, 0.01)
rr = 0.2

u2 = 0.2
for u1 in [0., 0.2, 0.4, 0.6]:
    ld = SimpleLimbDark()
    ld.set_u([u1, u2])
    flux = 1 + ld.apply(bs, rr)
    plt.plot(bs, flux, label=f'u1 = {u1}, u2 = {u2}')
plt.legend()

plt.figure()

u1 = 0.2
for u2 in [0., 0.2, 0.4, 0.6]:
    ld = SimpleLimbDark()
    ld.set_u([u1, u2])
    flux = 1 + ld.apply(bs, rr)
    plt.plot(bs, flux, label=f'u1 = {u1}, u2 = {u2}')
plt.legend()

Figure_1 Figure_2

dfm commented 4 years ago

Good catch! I think that what you want is set_u([1, u1, u2]) for now, but let me do a few tests. It's related to the definitions from the limbdark paper.

dfm commented 4 years ago

I can confirm that this works. In the main code base, it actually is defined as [-1, u1, u2] but I think that since it gets normalized the actual value of the first entry does not enter (it would only matter for the baseline in the more general starry case, I think). It would be good to update this op to automatically add the -1 so that the behavior is as expected.

ericagol commented 4 years ago

Yes, that looks correct: just after equation (2) in the paper, it states that u_0 = -1.

limbdark_definitions
rodluger commented 3 years ago

@dfm @ethankruse Is this method now working? Do you need my help with anything?

ethankruse commented 3 years ago

Yep, my tests are passing and it seems to be working once I add in the -1 as the first parameter.