lkreidberg / batman Goto Github PK
View Code? Open in Web Editor NEWFast transit light curves models in Python.
Home Page: http://lkreidberg.github.io/batman
License: GNU General Public License v3.0
Fast transit light curves models in Python.
Home Page: http://lkreidberg.github.io/batman
License: GNU General Public License v3.0
03/2020 update:
Here is an update on Windows installation courtesy of JP Beaulieu & K Hill, University of Tasmania
Batman on windows
Installing visual basic go to https://visualstudio.microsoft.com/downloads/
Install Visual Studio 2019
then scroll down the same page and click Tools for Visual Studio 2019 and install Build Tools for Visual Studio 2019
install miniconda from here: https://docs.conda.io/en/latest/miniconda.html
Open and anaconda prompt (with admin priv if installed for all users)
Execute the following commands to get most things set up
conda update conda
conda install numpy matplotlib scipy spyder
conda install -c anaconda astropy
pip install batman-package
#################################
Here is some earlier wisdom from Thomas Beatty (09/2017) about how to get batman up and running on windows:
The root problem is that Windows does not include a c++ compiler out-of-the-box, so installing via pip and from source will fail when it tries to compile the limb-darkening functions. For Windows, the primary c++ compilers are Microsoft Visual C++ (MSVC) and MinGW (gc++ for Win). If you're using Anaconda, everything since Anaconda 2.4 (python 3.5) has been compiled using MSVC by whomever makes Anaconda for Windows, so it greatly simplifies things to also use MSVC for Batman.
You can install the standalone MSVC compiler from http://landinghub.visualstudio.com/visual-cpp-build-tools. You then edit the Anaconda distutils.cfg (Anaconda3\Lib\distutils\distutils.cfg for me) so that it reads:
[build]
compiler=msvc
At this point you should be able to install from either pip or source.
Incidentally, trying to use MinGW to do the compilation by installing it and setting "compiler=mingw32" in distutils.cfg is a real headache. There are a series of old MSVC dlls (Windows' library files) that MinGW wants to use that are no longer included in either the out-of-the-box Windows, or in the current MSVC distribution. Specially, MinGW wants to use a sequence of "msvcrt..." dlls that have been replaced by a bunch of alternate files (for example vcruntime140.dll, appcrt140.dll, and desktopcrt140.dll). There may be a way around this if someone is a diehard MinGW user, but since using MSVC seems a lot easier, I didn't bother figuring it out.
Since a few days I'm not able to install batman (nor any library depending on it). This is what I get:
python3.8 -m pip install batman-package
Defaulting to user installation because normal site-packages is not writeable
Collecting batman-package
Using cached batman-package-2.4.7.tar.gz (394 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.8 /home/fardeau/.local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmp7m7ioa4a
cwd: /tmp/pip-install-36ubs319/batman-package_7e8b1cd6b3c047f78935953c2067de83
Complete output (38 lines):
Checking for OpenMP support...
Compiler supports OpenMP
running egg_info
writing batman_package.egg-info/PKG-INFO
/usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
Traceback (most recent call last):
File "/home/fardeau/.local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 280, in <module>
main()
File "/home/fardeau/.local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/fardeau/.local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 114, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-qacf88kl/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 154, in get_requires_for_build_wheel
return self._get_build_requires(
File "/tmp/pip-build-env-qacf88kl/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 135, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-qacf88kl/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 150, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 79, in <module>
setup( name='batman-package',
File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-qacf88kl/overlay/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 292, in run
writer(self, ep.name, os.path.join(self.egg_info, ep.name))
File "/tmp/pip-build-env-qacf88kl/overlay/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 628, in write_pkg_info
metadata.write_pkg_info(cmd.egg_info)
File "/usr/lib/python3.8/distutils/dist.py", line 1117, in write_pkg_info
self.write_pkg_file(pkg_info)
File "/tmp/pip-build-env-qacf88kl/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 172, in write_pkg_file
license = rfc822_escape(self.get_license())
File "/usr/lib/python3.8/distutils/util.py", line 475, in rfc822_escape
lines = header.split('\n')
AttributeError: 'list' object has no attribute 'split'
----------------------------------------
We had trouble with batman-package-2.4.6 with OpenMP flag on OSX 10.12 with clang
(on such OSX, gcc is a link to clang, without OpenMP operational ... we do have to deactivate openmp flag. Furthermore, on OSX & clang, the OpenMP flag is -fgomp)
I just add a line after the line 65
parallel_args = ['-fopenmp', '-std=c99'] if has_openmp else ['-std=c99']
diff -i setup.py_ref setup.py
65a66
> parallel_args = ['-std=c99']
and then succeed to go to the end
Hi there, I have a student fitting a light curve and our optimizer started returning negative values for the planet radius. After checking it out, I see that the code allows for negative values in the case of an "inverse transit". But for some reason it still returns something that looks like a regular transit. I thought you should know that this is happening.
Here's the test we ran:
import numpy as np
import matplotlib.pyplot as plt
import batman
print("Batman version", batman.__version__)
params = batman.TransitParams()
params.t0 = 0. #time of inferior conjunction
params.per = 1. #orbital period
params.rp = -0.1 #planet radius (in units of stellar radii)
params.a = 15. #semi-major axis (in units of stellar radii)
params.inc = 87. #orbital inclination (in degrees)
params.ecc = 0. #eccentricity
params.w = 90. #longitude of periastron (in degrees)
params.u = [0.1, 0.3] #limb darkening coefficients [u1, u2]
params.limb_dark = "quadratic" #limb darkening model
t = np.linspace(-0.05, 0.05, 100)
m = batman.TransitModel(params, t) #initializes model
print("Transit model radius =", m.rp)
print("Is this an inverse transit?", m.inverse)
flux = m.light_curve(params) #calculates light curve
plt.plot(t, flux)
plt.xlabel("Time from central transit")
plt.ylabel("Relative flux")
plt.show()
I realised that old version (< 2.4.8) of batman cannot be installed (either throug pip or through direct downloads).
The problem comes from line 84 of the setup.py file. In the 2.4.8 version, this line reads
license = "GNU GPLv3"
whereas it is
license = ["GNU GPLv3"]
in all the older versions, transforming the string to a list and generating compilation issues. Removing the brackets solves the problem.
Kind regards
I was trying to compare BATMAN to KTransit (https://github.com/mrtommyb/ktransit) for both uniform and quadratic limb darkening, when I realized that BATMAN with quadratic LD assumes that the delta-Flux is maximized along the light curve to exactly the same depth as the uniform LD model.
I've attached these images here to elaborate.
For each of these cases, I took the tutorial examples and set the limb darkening to zero. I changed absolutely nothing else in the models.
My assumptions about how BATMAN is interpreting the LD coefficients vs depth may be incorrect; but I imagine that the default thinking for any given user would be closer to the K-Transit example than the BATMAN example.
Am I interpreting LD incorrectly or should the uniform LD light curve be 'inside' the quadratic LD light curve? -- as is the case with K-Transit?
Hi Laura,
I noticed that when the user sets an exposure time in TransitModel
, since the supersample factor defaults to 1, there's nothing that makes it clear that both exp_time
and supersample_factor
need to be set in order to produce the light curve you want. I think it might be worthwhile to throw a warning or exception in this case, as it might not be obvious to someone who just skims through the documentation. I'm using commit 972164f.
I am trying to install batman on my M1 Apple MacBook Air (MacOS Ventura 13.4), and I am encountering some errors. First of all, I created a virtual environment with conda and tried with pip (Python 3.9.16, pip 23.1.2, conda 23.3.1). I got the following error:
Collecting batman-package
Using cached batman-package-2.4.9.tar.gz (394 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in /opt/anaconda3/envs/batman/lib/python3.9/site-packages (from batman-package) (1.24.3)
Building wheels for collected packages: batman-package
Building wheel for batman-package (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for batman-package (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
/private/var/folders/08/0nb4rk917kv0v2yjmh3k_wgm0000gn/T/pip-build-env-kfy1jz57/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Checking for OpenMP support...
Did not detect OpenMP support.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for batman-package
Failed to build batman-package
ERROR: Could not build wheels for batman-package, which is required to install pyproject.toml-based projects
Therefore, I tried to do it from source. I downloaded the code (https://github.com/lkreidberg/batman), extracted the zip folder, changed folder, and used sudo python setup.py install
. I got another error:
Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.
Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.
Checking for OpenMP support...
Did not detect OpenMP support.
/opt/anaconda3/envs/batman/lib/python3.9/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
/opt/anaconda3/envs/batman/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` directly.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
/opt/anaconda3/envs/batman/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/clang' failed with exit code 1
I looked at the other issues, in particular issue #46, since the title seemed to match my problem. However, what worked in that case did not work for me. I cannot properly understand what the problem is and how to solve it, so I would really appreciate some help.
Hey Laura!
I'm working on simulating transits of Mars-sized planets orbiting Sun-sized stars, and it seems that I'm butting up against some convergence failures by going to small planet sizes. For example, the following code:
from batman import TransitParams, TransitModel
import numpy as np
from astropy.constants import R_earth, R_sun
import astropy.units as u
params = TransitParams()
params.per = 365
params.rp = 0.6 * float(R_earth/R_sun)
params.a = float(1*u.AU/R_sun)
params.inc = 89.9
# Sing 2009: https://arxiv.org/pdf/0912.2274.pdf
params.u = [0.6283, -0.3063, 0.8965, -0.4593]
params.limb_dark = "nonlinear"
params.ecc = 0
params.w = np.pi/2
params.t0 = 0
times = np.linspace(-0.3, 0.3, 1000)
m = TransitModel(params, times)
m.light_curve(params)
Raises the error
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-4-5f6b6e406502> in <module>()
20
21 times = np.linspace(-0.3, 0.3, 1000)
---> 22 m = TransitModel(params, times)
23
24 m.light_curve(params)
/Users/bmmorris/anaconda/lib/python3.5/site-packages/batman/transitmodel.py in __init__(self, params, t, max_err, nthreads, fac, transittype, supersample_factor, exp_time)
125
126 if fac != None: self.fac = fac
--> 127 else: self.fac = self._get_fac()
128
129 if nthreads==None or nthreads == 1: self.nthreads=1
/Users/bmmorris/anaconda/lib/python3.5/site-packages/batman/transitmodel.py in _get_fac(self)
209 else: fac_lo = fac
210 n += 1
--> 211 if n > 1e3: raise Exception("Convergence failure in calculation of scale factor for integration step size")
212 return fac
213 else: return None
Exception: Convergence failure in calculation of scale factor for integration step size
Am I doing something wrong, or should I change the hard-coded convergence limit (1e3) to a higher number?
Thanks!
Hi Laura! I was running some benchmark tests and have a question about how batman computes the true anomaly for eccentric orbits. My understanding is that you get mean anomaly from time and orbital period, then eccentric anomaly from mean anomaly, then true anomaly from eccentric anomaly. But when I tried to compute it myself using scipy, I'm getting very different results. Have I misunderstood the calculation? Do you have any insights here?
Here's the code I wrote to compare the two:
import batman
import numpy as np
import scipy.optimize as opt
import matplotlib.pyplot as plt
t0 = 0.
Porb = 2 * np.pi
ecc = 0.05
omega_deg = -90.
nt = 10000
time = np.linspace(-0.3, 0.3, nt)
batp = batman.TransitParams()
batp.t0 = t0
batp.per = Porb
batp.rp = 0.1
batp.a = 5.
batp.inc = 80.
batp.ecc = ecc
batp.w = omega_deg
batp.u = [0.1, -0.02]
batp.limb_dark = 'quadratic'
model = batman.TransitModel(batp, time, fac=1e-4)
batman_trueanom = model.get_true_anomaly()
batman_trueanom = np.where(batman_trueanom > 0, batman_trueanom - 2 * np.pi, batman_trueanom)
omega = np.deg2rad(omega_deg)
meananom = 2 * np.pi * (time - t0) / Porb
def gen_eccanom():
for M in meananom:
sol = opt.root_scalar(lambda E: (E - ecc * np.sin(E)) - M, x0=M)
yield sol.root
eccanom = np.array(list(gen_eccanom()))
trueanom = 2 * np.arctan(np.sqrt((1 + ecc) / (1 - ecc)) * np.tan(0.5 * eccanom)) + omega - 0.5 * np.pi
trueanom = np.where(trueanom > 0, trueanom - 2 * np.pi, trueanom)
plt.plot(time, batman_trueanom, lw=2, ls='solid', label='batman')
plt.plot(time, trueanom, lw=2, ls='dashed', label='scipy')
plt.xlabel('time')
plt.ylabel('true anomaly')
plt.legend(loc='best')
plt.show()
I think this issue might be related to issue to issue #50.
I tried installing the badman package (2.4.8) from pip in a python 3.9.7 conda environment. The problem is that batman only works with numpy version 1.22.1, which is only available on conda-forge not in the regular channel. This is problematic as this breaks several other packages used in combination with batman. The problem are the compiled functions like _nonlinear_ld which depend on a certain numpy version. Falling back to a earlier version of numpy results in an "ImportError: numpy.core.multiarray failed to import" error . If there is no particular reason to use this numpy version could there be pypi wheels for numpy version 1.20.3?
I think the same problem occurs for batman version 2.4.6, where I also had to downgrade setuptools to 52.0.0 to get the install to work.
File "/anaconda/envs/py3/lib/python3.6/site-packages/batman/transitmodel.py", line 136
self.ds = _rsky._rsky(self.t_supersample, params.t0, params.per, params.a, params.inc*pi/180., params.ecc, params.w*pi/180., self.transittype, self.nthreads)
^
TabError: inconsistent use of tabs and spaces in indentation
This bug randomly appeared seemingly without changing anything else... (so maybe it's the fault of my bug-filled conda). It seems python stopped liking the spaces (rather than tabs) on line 136 of transitmodel. I fixed by deleting the spaces and putting tabs in manually, but in case anyone else gets this error, maybe you'd better do the same on the master branch. Awesome code btw!
Running the setup script with Python 3.9 results in a compiler error:
python setup.py install
Checking for OpenMP support...
Compiler supports OpenMP
/home/svanaverbeke/.conda/envs/tls/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
running install
running bdist_egg
running egg_info
writing batman_package.egg-info/PKG-INFO
writing dependency_links to batman_package.egg-info/dependency_links.txt
writing requirements to batman_package.egg-info/requires.txt
writing top-level names to batman_package.egg-info/top_level.txt
reading manifest file 'batman_package.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE.txt'
writing manifest file 'batman_package.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
building 'batman._nonlinear_ld' extension
mpiicc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/svanaverbeke/.conda/envs/tls/include -I/home/svanaverbeke/.conda/envs/tls/include -fPIC -O2 -isystem /home/svanaverbeke/.conda/envs/tls/include -O3 -axCORE-AVX512,AVX,SSE4.2 -ipo -no-prec-div -static-intel -fPIC -qopenmp -fPIC -I/home/svanaverbeke/.conda/envs/tls/lib/python3.9/site-packages/numpy/core/include -I/home/svanaverbeke/.conda/envs/tls/include/python3.9 -c c_src/_nonlinear_ld.c -o build/temp.linux-x86_64-3.9/c_src/_nonlinear_ld.o -fopenmp -std=c99
icc: command line warning #10148: option '-Wno-unused-result' not supported
In file included from /home/svanaverbeke/.conda/envs/tls/lib/python3.9/site-packages/numpy/core/include/numpy/ndarrayobject.h(12),
from /home/svanaverbeke/.conda/envs/tls/lib/python3.9/site-packages/numpy/core/include/numpy/arrayobject.h(4),
from c_src/_nonlinear_ld.c(21):
/home/svanaverbeke/.conda/envs/tls/lib/python3.9/site-packages/numpy/core/include/numpy/ndarraytypes.h(84): warning #2650: attributes ignored here
NPY_CHAR NPY_ATTR_DEPRECATE("Use NPY_STRING"),
^
c_src/_nonlinear_ld.c(67): warning #161: unrecognized #pragma
#pragma acc data copyin(intensity_args)
^
gcc -pthread -B /home/svanaverbeke/.conda/envs/tls/compiler_compat -shared -Wl,-rpath,/home/svanaverbeke/.conda/envs/tls/lib -Wl,-rpath-link,/home/svanaverbeke/.conda/envs/tls/lib -L/home/svanaverbeke/.conda/envs/tls/lib -L/home/svanaverbeke/.conda/envs/tls/lib -Wl,-rpath,/home/svanaverbeke/.conda/envs/tls/lib -Wl,-rpath-link,/home/svanaverbeke/.conda/envs/tls/lib -L/home/svanaverbeke/.conda/envs/tls/lib -O3 -axCORE-AVX512,AVX,SSE4.2 -ipo -no-prec-div -static-intel -fPIC -qopenmp build/temp.linux-x86_64-3.9/c_src/_nonlinear_ld.o -lgomp -o build/lib.linux-x86_64-3.9/batman/_nonlinear_ld.cpython-39-x86_64-linux-gnu.so
gcc: error: unrecognized command line option ‘-axCORE-AVX512,AVX,SSE4.2’
gcc: error: unrecognized command line option ‘-ipo’
gcc: error: unrecognized command line option ‘-no-prec-div’; did you mean ‘-fno-tree-dce’?
gcc: error: unrecognized command line option ‘-static-intel’; did you mean ‘-static-pie’?
gcc: error: unrecognized command line option ‘-qopenmp’; did you mean ‘-fopenmp’?
error: command '/home/lmod/software/Core/GCCcore/8.2.0/bin/gcc' failed with exit code 1
Apparently the option -Wno-unused-result should be replaced by -Wno-unused-value to work. Does someone else see this mistake ?
Hello.
I have a question about secondary eclipse model.
I ran this script and I got the error.
import batman
params = batman.TransitParams() #object to store transit parameters
#params.t0 = 0. #time of inferior conjunction
params.per = 1. #orbital period
params.rp = 0.1 #planet radius (in units of stellar radii)
params.a = 15. #semi-major axis (in units of stellar radii)
params.inc = 87. #orbital inclination (in degrees)
params.ecc = 0. #eccentricity
params.w = 90. #longitude of periastron (in degrees)
#params.limb_dark = "quadratic" #limb darkening model
#params.u = [0.5, 0.1] #limb darkening coefficients [u1, u2, u3, u4]
params.fp = 0.001
params.t_secondary = 0.5
t = np.linspace(0.48, 0.52, 1000)
m = batman.TransitModel(params, t, transittype="secondary")
flux = m.light_curve(params)
plt.plot(t, flux)
Error is
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-31-a203aba0009b> in <module>
15 t = np.linspace(0.48, 0.52, 1000)
16
---> 17 m = batman.TransitModel(params, t, transittype="secondary")
18 flux = m.light_curve(params)
19 plt.plot(t, flux)
~/anaconda3/envs/py35/lib/python3.6/site-packages/batman/transitmodel.py in __init__(self, params, t, max_err, nthreads, fac, transittype, supersample_factor, exp_time)
83 u = [u1, ..., un] for custom LD")
84 if params.limb_dark not in ["uniform", "linear", "quadratic", "logarithmic", "exponential", "squareroot", "nonlinear", "power2", "custom"]:
---> 85 raise Exception("\""+params.limb_dark+"\""+" limb darkening not supported; allowed options are:\n \
86 uniform, linear, quadratic, logarithmic, exponential, squareroot, nonlinear, power2, custom")
87 if max_err < 0.001: raise Exception("The lowest allowed value for max_err is 0.001. For more accurate calculation, set the integration step size explicitly with the fac parameter.")
TypeError: must be str, not NoneType
Why do we need to set "u" parameters?
Hello! I am currently attempting to use BATMAN for light curve fitting using nonlinear limb darkening coefficients. In pursuit of this, I am doing an MCMC (thanks emcee) analysis which, of course, relies greatly on computational efficiency. I have discovered that light curve evaluation with nonlinear limb darkening is significantly (~25x) slower than evaluation with quadratic limb darkening. I think I have found why; my quarrel is with this chunk of c_src/_nonlinear_ld.c
:
inline double intensity(double x, double* args)
{
double c1=args[0], c2=args[1], c3=args[2], c4=args[3], norm=args[4];
if(x > 0.99995) x = 0.99995;
double sqrtmu = pow(1. - x*x,0.25);
return (1. - c1*(1. - sqrtmu) - c2*(1. - pow(sqrtmu,2.)) - c3*(1. - pow(sqrtmu, 3.)) - c4*(1. - pow(sqrtmu,4.)))/norm;
}
I admit I am no expert, but I believe the repeated calls to pow()
are slowing things down.
I don't have the time right now to test this myself (hence opening the issue), but could this be accelerated by, in the 3rd line of the function, calling sqrt()
twice instead of pow(__, 0.25)
(since sqrt()
is a less general function than pow()
) and, in the 4th line, explicitly writing out the powers as multiplication. E.g.:
inline double intensity(double x, double* args)
{
double c1=args[0], c2=args[1], c3=args[2], c4=args[3], norm=args[4];
if(x > 0.99995) x = 0.99995;
double sqrtmu = sqrt(sqrt(1. - x*x));
return (1. - c1*(1. - sqrtmu) - c2*(1. - sqrtmu*sqrtmu) - c3*(1. - sqrtmu*sqrtmu*sqrtmu) - c4*(1. - sqrtmu*sqrtmu*sqrtmu*sqrtmu))/norm;
}
(Yes, that last bit of the 4th line looks horrible but c'est la vie.)
Thanks in advance for taking a look at this. If I get time I will try to test this solution myself, but for now here is the issue for posterity.
I have encountered this problem quite a few time. It always happened when I try to fit a light-curve with batman using an MCMC. The code just freeze and seems to be stuck in an infinite loop. At the beginning I noticed that this tends to happens when the eccentricity gets high (typically 0,75 or higher). So I ignored the problem by preventing my eccentricity to go to high, but now I would like to let the eccentricity go high so I am trying to understand where this comes from. I first thought the planets orbit was crossing the stellar disk. It might have been the problem some times, but I am now making sure that it's not the case, yet code sometimes still gets stuck. So I am a bit out of ideas. I was wondering if this could be due to the initialization of the model, which is initialized with values that are too far for the ones explored by my MCMC (I usually initialize the model with dummy parameters values) ? I have recently faced this issue with the non-linear limb darkening model. I have also encountered the issue with the quadratic one, but with the quadratic one I was not making sure that the planetary orbit doesn't cross the stellar surface.
I am trying to get a code that reproduces the error, but it's difficult, because the issue appears randomly during MCMC explorations (for which I often don't write on file the values taken by the parameters at each iteration as the code goes).
Hi Laura, thanks for the awesome package! I've stumbled upon this really strange bug when trying to compute a transit for a given set of times which are read from a local file.
Reading the times in using numpy and calculating a transit model on them gives a really unusual looking transit. I've found this is because the times are non-contiguous in memory, here's a plot of a transit using non-contiguous times:
I've uploaded a gist which reproduces the bug: https://gist.github.com/danhey/a5cac73ca554a9a411c56cb60352aab1#file-contiguous-ipynb
If you'd like, I can open a PR which checks that the array is C-contiguous before running the transit model.
Cheers!
Hello!
I'm trying to run a code which uses a library that has batman as a dependency, but I am receiving the following error message:
File "/home/giumartos/.local/lib/python2.7/site-packages/juliet/fit.py", line 2, in
import batman
File "/home/giumartos/.local/lib/python2.7/site-packages/batman/init.py", line 6, in
from .transitmodel import *
File "/home/giumartos/.local/lib/python2.7/site-packages/batman/transitmodel.py", line 18, in
from . import _nonlinear_ld
ImportError: /home/giumartos/.local/lib/python2.7/site-packages/batman/_nonlinear_ld.so: undefined symbol: intensity
I have installed batman using pip in other computers also, but I had the same problem. Any guess on what may be happening? Thank you!
When I try to import the current build of batman I get:
In [1]: import batman
batma---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-bdd3f47826ab> in <module>()
----> 1 import batman
/astro/users/bmmorris/git/batman/batman/__init__.py in <module>()
4 __version__ = "2.1.1"
5
----> 6 from .transitmodel import *
7 from .tests import *
8 from .plots import *
/astro/users/bmmorris/git/batman/batman/transitmodel.py in <module>()
17 import numpy as np
18 import matplotlib.pyplot as plt
---> 19 from . import _nonlinear_ld
20 from . import _quadratic_ld
21 from . import _uniform_ld
ImportError: cannot import name _nonlinear_ld
The batman.test()
function calls the entire pipeline, but doesn't test individual functions or files. Testing should be more comprehensive before any reorganization takes place.
Noticed this while randomizing transit parameters to validate my transit model against batman. The following code produces a strange out-of-transit feature at t = 0.2
. I'm using the stable version (0.9.0) installed with pip.
import batman
import matplotlib.pyplot as pl
import numpy as np
t = np.linspace(-0.25,0.25,5000)
params = batman.TransitParams()
params.__dict__.update({'a': 9.811579669220295,
'fp': None,
'ecc': 0.9144031132693238,
't_secondary': None,
'limb_dark': 'quadratic',
'per': 3.4080675996424503,
'u': (0.5683675815729324, -0.3666118891199541),
't0': 0., 'w': 237.10420149927214,
'rp': 0.0970098370703392,
'inc': 89.28481174292249})
m = batman.TransitModel(params, t, max_err = 0.001)
flux = m.light_curve(params)
pl.plot(t, flux, 'b.')
pl.show()
Hi Laura,
This is Rayna following up on our discussion with Andrew. When using BATMAN to initialize a model for data taken from KeplerCam and not using supersamplilng, no transit shape is generated. I have to use a small supersampling factor (~3) and the exposure time of 180s. Any thoughts?
Thanks!
Rayna
I suppose I made some kind of rookie mistake, but this is the error that I get when I try to install the package on windows:
C:\Users\John\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Users\John\Anaconda2\lib\site-packages\numpy\core\include -IC:\Users\John\Anaconda2\include -IC:\Users\John\Anaconda2\PC /Tcc_src/_nonlinear_ld.c /Fobuild\temp.win-amd64-2.7\Release\c_src/_nonlinear_ld.obj
_nonlinear_ld.c
c_src/_nonlinear_ld.c(35) : error C2143: syntax error : missing ';' before 'type'
c_src/_nonlinear_ld.c(36) : error C2065: 'sqrtmu' : undeclared identifier
c_src/_nonlinear_ld.c(36) : error C2065: 'sqrtmu' : undeclared identifier
c_src/_nonlinear_ld.c(36) : error C2065: 'sqrtmu' : undeclared identifier
c_src/_nonlinear_ld.c(36) : error C2065: 'sqrtmu' : undeclared identifier
c_src/_nonlinear_ld.c(48) : error C2065: 'M_PI' : undeclared identifier
c_src/_nonlinear_ld.c(49) : error C2065: 'M_PI' : undeclared identifier
c_src/_nonlinear_ld.c(66) : error C2143: syntax error : missing ';' before 'type'
c_src/_nonlinear_ld.c(67) : error C2143: syntax error : missing ';' before 'type'
c_src/_nonlinear_ld.c(86) : error C2143: syntax error : missing ';' before 'type'
c_src/_nonlinear_ld.c(93) : error C2065: 'd_array' : undeclared identifier
c_src/_nonlinear_ld.c(93) : error C2109: subscript requires array or pointer type
c_src/_nonlinear_ld.c(97) : error C2065: 'f_array' : undeclared identifier
c_src/_nonlinear_ld.c(97) : error C2109: subscript requires array or pointer type
c_src/_nonlinear_ld.c(111) : error C2065: 'norm' : undeclared identifier
c_src/_nonlinear_ld.c(120) : error C2065: 'norm' : undeclared identifier
c_src/_nonlinear_ld.c(123) : error C2065: 'f_array' : undeclared identifier
c_src/_nonlinear_ld.c(123) : error C2109: subscript requires array or pointer type
error: command 'C:\Users\John\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe' failed with exit status 2
while I use pip install batman-package
in cmd, I get an error
`Collecting batman-package
Using cached batman-package-2.4.9.tar.gz (394 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in d:\anaconda3\envs\python39\lib\site-packages (from batman-package) (1.25.0)
Building wheels for collected packages: batman-package
Building wheel for batman-package (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for batman-package (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [5 lines of output]
C:\Users\whlih\AppData\Local\Temp\pip-build-env-6eek7j3y\overlay\Lib\site-packages\setuptools_distutils\dist.py:265: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
Checking for OpenMP support...
Did not detect OpenMP support.
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for batman-package
Failed to build batman-package
ERROR: Could not build wheels for batman-package, which is required to install pyproject.toml-based projects`
how can I solve it?
I'm trying to install (for the first time) batman on my laptop which I currently run with MacOS Catalina. When I use sudo python setup.py install
I get the following error:
Checking for OpenMP support...
Did not detect OpenMP support.
/Applications/anaconda3/lib/python3.7/site-packages/setuptools/_distutils/dist.py:275: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
running install
running bdist_egg
running egg_info
writing batman_package.egg-info/PKG-INFO
writing dependency_links to batman_package.egg-info/dependency_links.txt
writing requirements to batman_package.egg-info/requires.txt
writing top-level names to batman_package.egg-info/top_level.txt
reading manifest file 'batman_package.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'batman_package.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.9-x86_64/egg
running install_lib
running build_py
running build_ext
building 'batman._nonlinear_ld' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Applications/anaconda3/include -arch x86_64 -I/Applications/anaconda3/include -arch x86_64 -I/Applications/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/Applications/anaconda3/include/python3.7m -c c_src/_nonlinear_ld.c -o build/temp.macosx-10.9-x86_64-3.7/c_src/_nonlinear_ld.o -std=c99
c_src/_nonlinear_ld.c: In function '_nonlinear_ld':
c_src/_nonlinear_ld.c:67: warning: ignoring #pragma acc data [-Wunknown-pragmas]
67 | #pragma acc data copyin(intensity_args)
|
gcc -bundle -undefined dynamic_lookup -L/Applications/anaconda3/lib -arch x86_64 -L/Applications/anaconda3/lib -arch x86_64 build/temp.macosx-10.9-x86_64-3.7/c_src/_nonlinear_ld.o -o build/lib.macosx-10.9-x86_64-3.7/batman/_nonlinear_ld.cpython-37m-darwin.so
ld: unexpected token: !tapi-tbd-v3 file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
error: command '/opt/local/bin/gcc' failed with exit code
When I try with pip install batman-package
I get this other error:
Collecting batman-package
Using cached batman-package-2.4.6.tar.gz (29 kB)
Requirement already satisfied: numpy in /Applications/anaconda3/lib/python3.7/site-packages (from batman-package) (1.17.2)
Building wheels for collected packages: batman-package
Building wheel for batman-package (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /Applications/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-install-f0dzyzrw/batman-package/setup.py'"'"'; __file__='"'"'/private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-install-f0dzyzrw/batman-package/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-wheel-81ndghjv
cwd: /private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-install-f0dzyzrw/batman-package/
Complete output (28 lines):
Checking for OpenMP support...
Did not detect OpenMP support.
/Applications/anaconda3/lib/python3.7/site-packages/setuptools/_distutils/dist.py:275: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/openmp.py -> build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/transitmodel.py -> build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/plots.py -> build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/tests.py -> build/lib.macosx-10.9-x86_64-3.7/batman
running build_ext
building 'batman._nonlinear_ld' extension
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/c_src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Applications/anaconda3/include -arch x86_64 -I/Applications/anaconda3/include -arch x86_64 -I/Applications/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/Applications/anaconda3/include/python3.7m -c c_src/_nonlinear_ld.c -o build/temp.macosx-10.9-x86_64-3.7/c_src/_nonlinear_ld.o -std=c99
c_src/_nonlinear_ld.c: In function '_nonlinear_ld':
c_src/_nonlinear_ld.c:67: warning: ignoring #pragma acc data [-Wunknown-pragmas]
67 | #pragma acc data copyin(intensity_args)
|
gcc -bundle -undefined dynamic_lookup -L/Applications/anaconda3/lib -arch x86_64 -L/Applications/anaconda3/lib -arch x86_64 build/temp.macosx-10.9-x86_64-3.7/c_src/_nonlinear_ld.o -o build/lib.macosx-10.9-x86_64-3.7/batman/_nonlinear_ld.cpython-37m-darwin.so
ld: unexpected token: !tapi-tbd-v3 file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
error: command '/opt/local/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for batman-package
Running setup.py clean for batman-package
Failed to build batman-package
DEPRECATION: Could not build wheels for batman-package which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.
Installing collected packages: batman-package
Running setup.py install for batman-package ... error
ERROR: Command errored out with exit status 1:
command: /Applications/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-install-f0dzyzrw/batman-package/setup.py'"'"'; __file__='"'"'/private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-install-f0dzyzrw/batman-package/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-record-uj8b37f_/install-record.txt --single-version-externally-managed --compile --install-headers /Applications/anaconda3/include/python3.7m/batman-package
cwd: /private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-install-f0dzyzrw/batman-package/
Complete output (28 lines):
Checking for OpenMP support...
Did not detect OpenMP support.
/Applications/anaconda3/lib/python3.7/site-packages/setuptools/_distutils/dist.py:275: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/openmp.py -> build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/transitmodel.py -> build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/plots.py -> build/lib.macosx-10.9-x86_64-3.7/batman
copying batman/tests.py -> build/lib.macosx-10.9-x86_64-3.7/batman
running build_ext
building 'batman._nonlinear_ld' extension
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/c_src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Applications/anaconda3/include -arch x86_64 -I/Applications/anaconda3/include -arch x86_64 -I/Applications/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/Applications/anaconda3/include/python3.7m -c c_src/_nonlinear_ld.c -o build/temp.macosx-10.9-x86_64-3.7/c_src/_nonlinear_ld.o -std=c99
c_src/_nonlinear_ld.c: In function '_nonlinear_ld':
c_src/_nonlinear_ld.c:67: warning: ignoring #pragma acc data [-Wunknown-pragmas]
67 | #pragma acc data copyin(intensity_args)
|
gcc -bundle -undefined dynamic_lookup -L/Applications/anaconda3/lib -arch x86_64 -L/Applications/anaconda3/lib -arch x86_64 build/temp.macosx-10.9-x86_64-3.7/c_src/_nonlinear_ld.o -o build/lib.macosx-10.9-x86_64-3.7/batman/_nonlinear_ld.cpython-37m-darwin.so
ld: unexpected token: !tapi-tbd-v3 file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
error: command '/opt/local/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Applications/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-install-f0dzyzrw/batman-package/setup.py'"'"'; __file__='"'"'/private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-install-f0dzyzrw/batman-package/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/g8/00zrj0v11bx6xqb0wzhlsyjw0000gp/T/pip-record-uj8b37f_/install-record.txt --single-version-externally-managed --compile --install-headers /Applications/anaconda3/include/python3.7m/batman-package Check the logs for full command output.
I have read through many forums and apparently the issue is with how Catalina OS rearranged the header files by not using /usr/include
as the usual directory, therefore the gcc compiler doesn't work. I still haven't been able to solve the issue.
Hi,
I'm interested in using batman to inject planetary transits around stars with radii < 1 solar radius, for example, M-dwarfs. I understand that I can get the required transit depth by scaling params.rp such that, for example, a 10 Earth-radii planet around an M4 star of radius 0.25 R_Sun could be scaled to get the requisite transit depth via params.rp = (R_Sun / R_M)*(R_Earth) = 40 R_Earth around a star of radius R_Sun
The issue I run into is that the transit durations are correspondingly amplified by a factor of (R_Sun / R_M-dwarf), which makes sense if I follow the analytic transit equations for duration provided by Seager 2003. However, this can lead to somewhat unphysical durations when I want to consider the physical context of planetary transits around smaller stars. I've attached a plot where I've used batman to inject a 10 R_Earth-size planet (in a circular orbit with a period of 10 days and impact parameter 0) into a simulated flat light curve with Gaussian noise, and have determined the semi-major axis assuming the mass of the star is 0.2 M_Sun. The observed duration is ~0.04 days (bottom panel) which is 4x larger than the maximum duration that I'd expect for such an orbit around a star of radius 0.25 R_Sun, using the classical analytic transit equations.
I noticed that there wasn't a stellar radius parameter in the TransitParams class, and after looking through the documentation and code, I was unable to find any variable to change stellar radius at all. Does batman have the inherent capability to modify the host star radius in addition to the injected planet radius? If not, is there a common workaround to resolve this problem and get physically-accurate durations? If it helps, I can also enclose the code I used to create this plot.
Thank you!
I have just installed a new Ubuntu 20.04 (WSL on Win11), with python3.8.2 and gcc 9.3.0. On such a fresh OS and I keep getting the following error:
trifonov@WIN:~$ pip3.8 install batman-package
Defaulting to user installation because normal site-packages is not writeable
Collecting batman-package
Using cached batman-package-2.4.9.tar.gz (394 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in ./.local/lib/python3.8/site-packages (from batman-package) (1.22.0)
Building wheels for collected packages: batman-package
Building wheel for batman-package (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for batman-package (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
Checking for OpenMP support...
Compiler supports OpenMP
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-38
creating build/lib.linux-x86_64-cpython-38/batman
copying batman/openmp.py -> build/lib.linux-x86_64-cpython-38/batman
copying batman/plots.py -> build/lib.linux-x86_64-cpython-38/batman
copying batman/tests.py -> build/lib.linux-x86_64-cpython-38/batman
copying batman/transitmodel.py -> build/lib.linux-x86_64-cpython-38/batman
copying batman/__init__.py -> build/lib.linux-x86_64-cpython-38/batman
running build_ext
building 'batman._nonlinear_ld' extension
creating build/temp.linux-x86_64-cpython-38
creating build/temp.linux-x86_64-cpython-38/c_src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/pip-build-env-6dgpp2e0/overlay/lib/python3.8/site-packages/numpy/core/include -I/usr/include/python3.8 -c c_src/_nonlinear_ld.c -o build/temp.linux-x86_64-cpython-38/c_src/_nonlinear_ld.o -fopenmp -std=c99
c_src/_nonlinear_ld.c:20:10: fatal error: Python.h: No such file or directory
20 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
/tmp/pip-build-env-6dgpp2e0/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py:275: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for batman-package
Failed to build batman-package
ERROR: Could not build wheels for batman-package, which is required to install pyproject.toml-based projects
The issue is that a fresh Ubuntu OS (and perhaps other linux systems) does not includes the Python Developement files. I.e., one must first install these:
$ sudo apt-get install python3-dev
then
$ pip3.8 install batman-package --user
I wonder if it is possible to modify the batman setup.py file to require the "python-dev-tools" , E.g., something like:
install_requires = ['numpy','python-dev-tool']
?
Would it be possible to add Travis CI testing to this repo? We here at ExoCTK are trying to make batman
a dependency for our exoplanet software but Travis builds fail when trying to install it, citing no numpy
install. Thanks!
Hi, when using batman occasionally I get the following error: "Convergence failure in calculation of scale factor for integration step size". I know this occurs if the fac
computation takes too many iterations, but i'm wondering if you have any intuition as to why this is happening? Is it some combination of the model parameters that's causing this?
If it's related to the parameters I can get hold of the parameters which are causing this issue. Alternatively could I just bump up the 1000 iteration limit and hope?
The package should automatically install its dependacies, including Numpy.
Downloading https://files.pythonhosted.org/packages/f3/59/a1ca181cafde7c99099da61cd578efc90c4319899a0c31c72241d50b0783/batman-package-2.4.6.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-05nyoioa/batman-package/setup.py", line 4, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-05nyoioa/batman-package/```
Hello, we have a data set containing flux and time for a timespan of around 80 days. There are however some time gaps in our data where we have no values. Using batman, we tried to simulate transits into our data. If we take the data as if it were taken with a fixed dt between these 80 days, batman seems to be working fine.
However, when trying it with the time gapped data, it seems to be working incorrectly. Below you can find a screenshot with our data and a plot of the different batman transits. In blue you can see the transits as if the data was with a fixed dt. These have a nice periodicity of 4.5 days. In green you see the transits when using the times from our (red) gapped data. These have a varying periodicity. All plots have the same amount of data points.
Can you see anything we're doing wrong or can you think of a solution to fix this problem?
I don't really have problems with batman, but I was trying to see if I can speed-up a bit the transit light curve calculation with batman while doing an MCMC or optimization runs wit the Exo-Striker,. According to:
you said that I can use the "fac" keyword in order to fix the step size factor.
Well, I am trying to, but it is not working. Perhaps the print screen below shows best what is going on:
To explain, batman is working as you can see from the plot. On the right side is the Jupyter test bentch where I try to get the step size factor from a constructed model with the same params as those in the GUI frame, but it returns 'None'. The same happens behind the GUI.
Perhaps I am missing something?
Cheers,
Trifon
I have a new M1 MacBook running an Apple Silicon ARM64 chip (as opposed to an Intel x86-64 chip). To get batman working, I followed the advice in issue 42 and installed from source after adding the following lines to the top of the setup.py file:
import os
os.environ["CC"] = "clang"
Before doing this, "pip install batman-package" had appeared to install everything okay, but when I tried to import batman into a Python session it gave errors:
ImportError: dlopen(/Users/tevans/opt/anaconda3/envs/astroconda/lib/python3.6/site-packages/batman/_nonlinear_ld.cpython-36m-darwin.so, 2): no suitable image found. Did find:
/Users/tevans/opt/anaconda3/envs/astroconda/lib/python3.6/site-packages/batman/_nonlinear_ld.cpython-36m-darwin.so: mach-o, but wrong architecture
/Users/tevans/opt/anaconda3/envs/astroconda/lib/python3.6/site-packages/batman/_nonlinear_ld.cpython-36m-darwin.so: mach-o, but wrong architecture
Presumably because the compiled binaries were not suitable for the new ARM64 architecture. This issue appears to be resolved when using the Apple-provided clang compiler in the installation from source. However, it means that OpenMP multithreading isn't supported by default. When I get a chance I might try following the pointers in issue 32 to get OpenMP working with clang.
I just wanted to share my experience as more people start getting set up on M1 Macs. Also, I'd welcome any additional advice people might have on getting OpenMP to work on M1 Macs.
The problem is that in your setup.py file, line 4 you have:
import numpy as np
I often test fresh python instalations on a virtual machine and my Exo-Striker setup.py never works
straightaway due to:
Collecting batman-package
Downloading batman-package-2.4.6.tar.gz (29 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qgdc17q4/batman-package/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qgdc17q4/batman-package/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-i5isigbu
cwd: /tmp/pip-install-qgdc17q4/batman-package/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-qgdc17q4/batman-package/setup.py", line 4, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I know.... one could always do a pip install numpy
, before that, and this is what I am doing,
but I feel that you can fix your setup.py somehow to avoid this crash. In your
setup.py you have:
install_requires = ['numpy'],
So batman needs numpy to run, but also to run the setup.py, and the only line in the setup.py
that depends on numpy is
include_dirs = [np.get_include()],
I am not sure what this line does, but if you want to include directories during the installation, perhaps you can use the MANIFEST.in method?
Failed to run the test python -c 'import batman; batman.test()'
after installing using pip on MacOS.
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/sdalal/opt/anaconda3/envs/galaxy/lib/python3.9/site-packages/batman/__init__.py", line 6, in <module>
from .transitmodel import *
File "/Users/sdalal/opt/anaconda3/envs/galaxy/lib/python3.9/site-packages/batman/transitmodel.py", line 18, in <module>
from . import _nonlinear_ld
ImportError: numpy.core.multiarray failed to import
I tried to install using the source code as well. But the error occurs in the routine _nonlinear_ld
.
File "c:\Users\huang\Desktop\planet 试行\11.py", line 4, in
import batman
File "C:\Users\huang\AppData\Local\Programs\Python\Python312\Lib\site-packages\batman_init_.py", line 6, in
from .transitmodel import *
File "C:\Users\huang\AppData\Local\Programs\Python\Python312\Lib\site-packages\batman\transitmodel.py", line 29, in
from . import openmp
File "C:\Users\huang\AppData\Local\Programs\Python\Python312\Lib\site-packages\batman\openmp.py", line 2, in
from distutils.ccompiler import new_compiler
ModuleNotFoundError: No module named 'distutils'
This happens when I try to import batman in VScode. My python is 3.12.0, which excludes the module 'distutils' and corporates 'setuptools' instead(true for python >=3.10). I wonder if batman takes python updates into account?
when I pip install batman-package
terminal shows this error:
ERROR: Failed building wheel for batman-package
Running setup.py clean for batman-package
Failed to build batman-package
Installing collected packages: batman-package
Running setup.py install for batman-package ... error
ERROR: Command errored out with exit status 1:
command: /snap/jupyter/6/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cuaealba/batman-package/setup.py'"'"'; file='"'"'/tmp/pip-install-cuaealba/batman-package/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-bejpgonj/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/mohammad/snap/jupyter/common/include/python3.7m/batman-package
cwd: /tmp/pip-install-cuaealba/batman-package/
Complete output (22 lines):
Checking for OpenMP support...
Did not detect OpenMP support.
/snap/jupyter/6/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'extras_requires'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/batman
copying batman/transitmodel.py -> build/lib.linux-x86_64-3.7/batman
copying batman/openmp.py -> build/lib.linux-x86_64-3.7/batman
copying batman/plots.py -> build/lib.linux-x86_64-3.7/batman
copying batman/tests.py -> build/lib.linux-x86_64-3.7/batman
copying batman/init.py -> build/lib.linux-x86_64-3.7/batman
running build_ext
building 'batman._nonlinear_ld' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/c_src
gcc -pthread -B /home/filipe/miniconda3/envs/JUPYTER/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/mohammad/snap/jupyter/common/lib/python3.7/site-packages/numpy/core/include -I/snap/jupyter/6/include/python3.7m -c c_src/_nonlinear_ld.c-o build/temp.linux-x86_64-3.7/c_src/_nonlinear_ld.o -std=c99
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /snap/jupyter/6/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cuaealba/batman-package/setup.py'"'"'; file='"'"'/tmp/pip-install-cuaealba/batman-package/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-bejpgonj/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/mohammad/snap/jupyter/common/include/python3.7m/batman-package Check the logs for full command output.
m-pip and install wheel doesnt work for I
Thank You
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.