exoplanet-dev / exoplanet

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

Variable exposure time broken when `use_in_transit=True` #40

Closed rodluger closed 5 years ago

rodluger commented 5 years ago

The following code

import numpy as np
import matplotlib.pyplot as plt
import exoplanet as xo

# Generate a starry light curve
orbit = xo.orbits.KeplerianOrbit(period=1)
t = np.linspace(-0.5, 0.5, 1000)
u = [0.3, 0.2]
starry_op = xo.StarryLightCurve(u)

# Compute the light curve
lc_int = starry_op.get_light_curve(orbit=orbit, r=0.1, t=t, texp=0.1 * np.ones_like(t)).eval()

throws a very long error starting with

ERROR (theano.gof.opt): Optimization failure due to: constant_folding
ERROR (theano.gof.opt): node: Elemwise{add,no_inplace}(TensorConstant{[[-0.09159..09159159]]}, TensorConstant{[[-0.05   ..05      ]]})
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
  File "/anaconda3/lib/python3.7/site-packages/theano/gof/opt.py", line 2034, in process_node
    replacements = lopt.transform(node)
  File "/anaconda3/lib/python3.7/site-packages/theano/tensor/opt.py", line 6518, in constant_folding
    required = thunk()
  File "/anaconda3/lib/python3.7/site-packages/theano/gof/op.py", line 862, in rval
    thunk()
  File "/anaconda3/lib/python3.7/site-packages/theano/gof/cc.py", line 1739, in __call__
    reraise(exc_type, exc_value, exc_trace)
  File "/anaconda3/lib/python3.7/site-packages/six.py", line 693, in reraise
    raise value
ValueError: Input dimension mis-match. (input[0].shape[0] = 184, input[1].shape[0] = 1000)

The issue is on this line, which assumes that dt and t have the same shape. They don't because use_in_transit leads to t being cropped.

dfm commented 5 years ago

Brutal. This should be easy to fix. Thanks for reporting it!