Unable to use limb darkening
See original GitHub issueDescribe the bug Trying to compute the flux of any star or system with a star that includes non-uniform limb darkening (any udeg > 0) gives me a lengthy traceback that says “Elliptic integral CEL did not converge.” along with “error: cannot use 'throw' with exceptions disabled.”.
To Reproduce Any time I try to compute the flux of a limb-darkened star or system with a limb-darkened star (such as the cell below the comment “The effect of limb darkening is clear! Let’s plot a transit across this object:” in the Basics.ipynb notebook) I get the following traceback. I get a similar such error for any udeg > 0 regardless of what I set the limb darkening parameters to. I also get errors anytime ffmpeg is called in the notebook but I just didn’t bother to install that and am not worried about those errors.
You can find the C code in this temporary file: /var/folders/f3/_h5lxm511fv9sjb5d3xrj0jm0000gq/T/theano_compilation_error_rlmejtd5
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
Input In [37], in <cell line: 11>()
9 # Compute and plot the light curve
10 plt.figure(figsize=(12, 5))
---> 11 plt.plot(time, map.flux(xo=xo, yo=yo, ro=ro, zo=zo))
12 plt.xlabel("Time [arbitrary]", fontsize=20)
13 plt.ylabel("Flux [normalized]", fontsize=20)
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/starry/maps.py:1832, in LimbDarkenedBase.flux(self, **kwargs)
1829 xo, yo, zo, ro = self._get_flux_kwargs(kwargs)
1831 # Compute & return
-> 1832 return self.amp * self.ops.flux(xo, yo, zo, ro, self._u)
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/starry/_core/utils.py:161, in autocompile.<locals>.wrapper(instance, *args)
159 with CompileLogMessage(func.__name__):
160 with change_flags(compute_test_value="off"):
--> 161 compiled_func = theano.function(
162 [*dummy_args],
163 func(instance, *dummy_args),
164 on_unused_input="ignore",
165 profile=config.profile,
166 mode=config.mode,
167 )
168 setattr(instance, cname, compiled_func)
170 # Return the compiled version
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/compile/function/__init__.py:337, in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
331 fn = orig_function(
332 inputs, outputs, mode=mode, accept_inplace=accept_inplace, name=name
333 )
334 else:
335 # note: pfunc will also call orig_function -- orig_function is
336 # a choke point that all compilation must pass through
--> 337 fn = pfunc(
338 params=inputs,
339 outputs=outputs,
340 mode=mode,
341 updates=updates,
342 givens=givens,
343 no_default_updates=no_default_updates,
344 accept_inplace=accept_inplace,
345 name=name,
346 rebuild_strict=rebuild_strict,
347 allow_input_downcast=allow_input_downcast,
348 on_unused_input=on_unused_input,
349 profile=profile,
350 output_keys=output_keys,
351 )
352 return fn
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/compile/function/pfunc.py:524, in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, output_keys)
519 si = In(
520 variable=sv, value=sv.container, mutable=False, borrow=True, shared=True
521 )
522 inputs.append(si)
--> 524 return orig_function(
525 inputs,
526 cloned_outputs,
527 mode,
528 accept_inplace=accept_inplace,
529 name=name,
530 profile=profile,
531 on_unused_input=on_unused_input,
532 output_keys=output_keys,
533 )
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/compile/function/types.py:1981, in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys)
1970 m = Maker(
1971 inputs,
1972 outputs,
(...)
1978 name=name,
1979 )
1980 with config.change_flags(compute_test_value="off"):
-> 1981 fn = m.create(defaults)
1982 finally:
1983 t2 = time.time()
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/compile/function/types.py:1836, in FunctionMaker.create(self, input_storage, trustme, storage_map)
1833 start_import_time = theano.link.c.cmodule.import_time
1835 with config.change_flags(traceback__limit=config.traceback__compile_limit):
-> 1836 _fn, _i, _o = self.linker.make_thunk(
1837 input_storage=input_storage_lists, storage_map=storage_map
1838 )
1840 end_linker = time.time()
1842 linker_time = end_linker - start_linker
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/link/basic.py:266, in LocalLinker.make_thunk(self, input_storage, output_storage, storage_map)
265 def make_thunk(self, input_storage=None, output_storage=None, storage_map=None):
--> 266 return self.make_all(
267 input_storage=input_storage,
268 output_storage=output_storage,
269 storage_map=storage_map,
270 )[:3]
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/link/vm.py:1131, in VMLinker.make_all(self, profiler, input_storage, output_storage, storage_map)
1126 thunk_start = time.time()
1127 # no-recycling is done at each VM.__call__ So there is
1128 # no need to cause duplicate c code by passing
1129 # no_recycling here.
1130 thunks.append(
-> 1131 node.op.make_thunk(node, storage_map, compute_map, [], impl=impl)
1132 )
1133 linker_make_thunk_time[node] = time.time() - thunk_start
1134 if not hasattr(thunks[-1], "lazy"):
1135 # We don't want all ops maker to think about lazy Ops.
1136 # So if they didn't specify that its lazy or not, it isn't.
1137 # If this member isn't present, it will crash later.
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/graph/op.py:634, in COp.make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
630 self.prepare_node(
631 node, storage_map=storage_map, compute_map=compute_map, impl="c"
632 )
633 try:
--> 634 return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
635 except (NotImplementedError, MethodNotDefined):
636 # We requested the c code, so don't catch the error.
637 if impl == "c":
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/graph/op.py:600, in COp.make_c_thunk(self, node, storage_map, compute_map, no_recycling)
598 print(f"Disabling C code for {self} due to unsupported float16")
599 raise NotImplementedError("float16")
--> 600 outputs = cl.make_thunk(
601 input_storage=node_input_storage, output_storage=node_output_storage
602 )
603 thunk, node_input_filters, node_output_filters = outputs
605 def rval():
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/link/c/basic.py:1203, in CLinker.make_thunk(self, input_storage, output_storage, storage_map)
1175 """
1176 Compiles this linker's fgraph and returns a function to perform the
1177 computations, as well as lists of storage cells for both the inputs
(...)
1200 first_output = ostor[0].data
1201 """
1202 init_tasks, tasks = self.get_init_tasks()
-> 1203 cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
1204 input_storage, output_storage, storage_map
1205 )
1207 res = _CThunk(cthunk, init_tasks, tasks, error_storage, module)
1208 res.nodes = self.node_order
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/link/c/basic.py:1138, in CLinker.__compile__(self, input_storage, output_storage, storage_map)
1136 input_storage = tuple(input_storage)
1137 output_storage = tuple(output_storage)
-> 1138 thunk, module = self.cthunk_factory(
1139 error_storage,
1140 input_storage,
1141 output_storage,
1142 storage_map,
1143 )
1144 return (
1145 thunk,
1146 module,
(...)
1155 error_storage,
1156 )
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/link/c/basic.py:1634, in CLinker.cthunk_factory(self, error_storage, in_storage, out_storage, storage_map)
1632 for node in self.node_order:
1633 node.op.prepare_node(node, storage_map, None, "c")
-> 1634 module = get_module_cache().module_from_key(key=key, lnk=self)
1636 vars = self.inputs + self.outputs + self.orphans
1637 # List of indices that should be ignored when passing the arguments
1638 # (basically, everything that the previous call to uniq eliminated)
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/link/c/cmodule.py:1191, in ModuleCache.module_from_key(self, key, lnk)
1189 try:
1190 location = dlimport_workdir(self.dirname)
-> 1191 module = lnk.compile_cmodule(location)
1192 name = module.__file__
1193 assert name.startswith(location)
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/link/c/basic.py:1543, in CLinker.compile_cmodule(self, location)
1541 try:
1542 _logger.debug(f"LOCATION {location}")
-> 1543 module = c_compiler.compile_str(
1544 module_name=mod.code_hash,
1545 src_code=src_code,
1546 location=location,
1547 include_dirs=self.header_dirs(),
1548 lib_dirs=self.lib_dirs(),
1549 libs=libs,
1550 preargs=preargs,
1551 )
1552 except Exception as e:
1553 e.args += (str(self.fgraph),)
File ~/miniconda3/envs/starry/lib/python3.9/site-packages/theano/link/c/cmodule.py:2546, in GCC_compiler.compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
2542 # We replace '\n' by '. ' in the error message because when Python
2543 # prints the exception, having '\n' in the text makes it more
2544 # difficult to read.
2545 compile_stderr = compile_stderr.replace("\n", ". ")
-> 2546 raise Exception(
2547 f"Compilation failed (return status={status}): {compile_stderr}"
2548 )
2549 elif config.cmodule__compilation_warning and compile_stderr:
2550 # Print errors just below the command line.
2551 print(compile_stderr)
Exception: ('The following error happened while compiling the node', GetClOp(<TensorType(float64, vector)>), '\n', 'Compilation failed (return status=1): In file included from /Users/tjbell1/.theano/compiledir_macOS-11.6.5-x86_64-i386-64bit-i386-3.9.7-64/tmpqoie3ylj/mod.cpp:8:. /Users/tjbell1/miniconda3/envs/starry/lib/python3.9/site-packages/starry/_core/ops/lib/include/ellip.h:56:5: error: cannot use \'throw\' with exceptions disabled. throw std::runtime_error("Elliptic integral `CEL` ". ^. /Users/tjbell1/miniconda3/envs/starry/lib/python3.9/site-packages/starry/_core/ops/lib/include/ellip.h:103:3: error: cannot use \'throw\' with exceptions disabled. throw std::runtime_error("Elliptic integral CEL did not converge.");. ^. /Users/tjbell1/miniconda3/envs/starry/lib/python3.9/site-packages/starry/_core/ops/lib/include/ellip.h:132:5: error: cannot use \'throw\' with exceptions disabled. throw std::invalid_argument(. ^. /Users/tjbell1/miniconda3/envs/starry/lib/python3.9/site-packages/starry/_core/ops/lib/include/ellip.h:215:5: error: cannot use \'throw\' with exceptions disabled. throw std::runtime_error("Elliptic integral CEL did not converge.");. ^. In file included from /Users/tjbell1/.theano/compiledir_macOS-11.6.5-x86_64-i386-64bit-i386-3.9.7-64/tmpqoie3ylj/mod.cpp:9:. /Users/tjbell1/miniconda3/envs/starry/lib/python3.9/site-packages/starry/_core/ops/lib/include/limbdark.h:368:5: error: cannot use \'throw\' with exceptions disabled. throw std::runtime_error(. ^. /Users/tjbell1/miniconda3/envs/starry/lib/python3.9/site-packages/starry/_core/ops/lib/include/limbdark.h:467:5: error: cannot use \'throw\' with exceptions disabled. throw std::runtime_error(. ^. 6 errors generated.. ', 'FunctionGraph(GetClOp(<TensorType(float64, vector)>))')
<Figure size 1200x500 with 0 Axes>
Expected behavior A clear and concise description of what you expected to happen.
Your setup (please complete the following information):
- Version of starry: 1.2.0
- Operating system: macOS 11.6.5
- Python version & installation method (pip, conda, etc.): Starting from a clean conda environment I start with the following to install all the required dependencies
conda create -n starry python==3.9.7 mkl-service -y
conda activate starry
pip install 'numpy<1.22' starry==1.2.0 tqdm corner jupyter ipykernel
Additional context
silurian:notebooks tjbell1$ python --version
Python 3.9.7
silurian:notebooks tjbell1$ conda info
/Users/tjbell1/miniconda3/lib/python3.9/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
active environment : starry
active env location : /Users/tjbell1/miniconda3/envs/starry
shell level : 2
user config file : /Users/tjbell1/.condarc
populated config files : /Users/tjbell1/.condarc
conda version : 4.12.0
conda-build version : not installed
python version : 3.9.10.final.0
virtual packages : __osx=11.6.5=0
__unix=0=0
__archspec=1=x86_64
base environment : /Users/tjbell1/miniconda3 (writable)
conda av data dir : /Users/tjbell1/miniconda3/etc/conda
conda av metadata url : None
channel URLs : https://conda.anaconda.org/conda-forge/osx-64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/osx-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/osx-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /Users/tjbell1/miniconda3/pkgs
/Users/tjbell1/.conda/pkgs
envs directories : /Users/tjbell1/miniconda3/envs
/Users/tjbell1/.conda/envs
platform : osx-64
user-agent : conda/4.12.0 requests/2.27.1 CPython/3.9.10 Darwin/20.6.0 OSX/11.6.5
UID:GID : 503:20
netrc file : None
offline mode : False
silurian:notebooks tjbell1$ pip list
Package Version
---------------------- --------
aesara-theano-fallback 0.1.0
appnope 0.1.3
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
arviz 0.12.0
astropy 5.0.4
asttokens 2.0.5
attrs 21.4.0
backcall 0.2.0
beautifulsoup4 4.11.0
bleach 5.0.0
bokeh 2.4.2
cachetools 5.0.0
cffi 1.15.0
cftime 1.6.0
corner 2.2.1
cycler 0.11.0
debugpy 1.6.0
decorator 5.1.1
defusedxml 0.7.1
deprecat 2.1.1
dill 0.3.4
entrypoints 0.4
executing 0.8.3
exoplanet 0.5.2
exoplanet-core 0.1.2
fastjsonschema 2.15.3
fastprogress 1.0.2
ffmpeg-python 0.2.0
filelock 3.6.0
fonttools 4.32.0
future 0.18.2
ipykernel 6.12.1
ipython 8.2.0
ipython-genutils 0.2.0
ipywidgets 7.7.0
jedi 0.18.1
Jinja2 3.1.1
jsonschema 4.4.0
jupyter 1.0.0
jupyter-client 7.2.2
jupyter-console 6.4.3
jupyter-core 4.9.2
jupyterlab-pygments 0.2.0
jupyterlab-widgets 1.1.0
kiwisolver 1.4.2
MarkupSafe 2.1.1
matplotlib 3.5.1
matplotlib-inline 0.1.3
mistune 0.8.4
mkl-service 2.4.0
nbclient 0.5.13
nbconvert 6.4.5
nbformat 5.3.0
nest-asyncio 1.5.5
netCDF4 1.5.8
notebook 6.4.10
numpy 1.21.5
packaging 21.3
pandas 1.4.2
pandocfilters 1.5.0
parso 0.8.3
patsy 0.5.2
pexpect 4.8.0
pickleshare 0.7.5
Pillow 9.1.0
pip 22.0.4
prometheus-client 0.14.1
prompt-toolkit 3.0.29
psutil 5.9.0
ptyprocess 0.7.0
pure-eval 0.2.2
pycparser 2.21
pyerfa 2.0.0.1
Pygments 2.11.2
pymc3 3.11.5
pymc3-ext 0.1.1
pyparsing 3.0.7
pyrsistent 0.18.1
python-dateutil 2.8.2
pytz 2022.1
PyYAML 6.0
pyzmq 22.3.0
qtconsole 5.3.0
QtPy 2.0.1
scipy 1.7.3
semver 2.13.0
Send2Trash 1.8.0
setuptools 62.0.0
setuptools-scm 6.4.2
six 1.16.0
soupsieve 2.3.2
stack-data 0.2.0
starry 1.2.0
terminado 0.13.3
testpath 0.6.0
Theano-PyMC 1.1.2
tomli 2.0.1
tornado 6.1
tqdm 4.64.0
traitlets 5.1.1
typing_extensions 4.1.1
wcwidth 0.2.5
webencodings 0.5.1
wheel 0.37.1
widgetsnbextension 3.6.0
wrapt 1.14.0
xarray 2022.3.0
I have also attached the theano_compilation_error_rlmejtd5 file mentioned in the traceback (as a .txt file so I can upload it)
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
That indeed works for me - added that line just before importing starry! Thanks @dfm!
(BTW, if I ever have free time again I would like to re-write starry in jax…)