diff --git a/README.md b/README.md index 8984fd54..0b449882 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [**Detailed documentation: https://rpoleski.github.io/MulensModel/**](https://rpoleski.github.io/MulensModel/) -[Latest release: 1.14.0](https://github.com/rpoleski/MulensModel/releases/latest) and we're working on further developing the code. +[Latest release: 1.16.0](https://github.com/rpoleski/MulensModel/releases/latest) and we're working on further developing the code. MulensModel can generate a microlensing light curve for a given set of microlensing parameters, fit that light curve to some data, and return a chi2 value. That chi2 can then be input into an arbitrary likelihood function to find the best-fit parameters. @@ -42,10 +42,8 @@ pip install -r requirements.txt ``` Alternatively, you can run makefiles: go to `source/VBBL/` and run `make`, then go to `source/AdaptiveContouring/` and do the same. Then and add the path `MulensModel/source` to your `PYTHONPATH`. If you have any problems, please contact the authors and we will try to help. -If you want to **install MulensModel on Windows**, please see notes [here](documents/windows_install.md). If you have **problems with installing or running MulensModel on MacOS**, please see notes [here](documents/macos_install.md). We're now working on improving intallation process. - --- [![astropy](http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat)](http://www.astropy.org/) -file revised Jul 2020 +file revised Aug 2020 diff --git a/developers_board.md b/developers_board.md index 4eef2ff3..ba2a869f 100644 --- a/developers_board.md +++ b/developers_board.md @@ -2,10 +2,10 @@ 1. windows compilation - [link](https://docs.python.org/3.7/extending/index.html) 3. UC 16 - make it ready for e-mail annoucement 4. new method for FSPL with LD -5. UC 16 - file_name removed in minimal example +5. UC 16 - file\_name removed in minimal example 6. remove unused branches 7. check notes below -8. add notes: 1) adding t_eff_1, t_eff_2, 2) example with [parallel EMCEE](https://emcee.readthedocs.io/en/stable/tutorials/parallel/); 3) example 2 - clarify first function; 4) data.bad requires example - note that one has to substitute full vector, not single values +8. add notes: 1) adding t\_eff\_1, t\_eff\_2, 2) example with [parallel EMCEE](https://emcee.readthedocs.io/en/stable/tutorials/parallel/); 3) example 2 - clarify first function; 4) data.bad requires example - note that one has to substitute full vector, not single values 8. back to triple lenses ## Nov & Dec goals: @@ -30,7 +30,7 @@ _italics_ mark important tasks -Changes for planned v2 are here: [documents/MM_v2.md](documents/MM_v2.md) +Changes for planned v2 are here: [documents/MM\_v2.md](documents/MM_v2.md) * Install * **makefile for Windows (basic instructions exist already) [good example](https://stackoverflow.com/a/145649), [checking for Windows in makefile](https://github.com/dariomanesku/cmft/issues/28)** diff --git a/documents/macos_install.md b/documents/macos_install.md deleted file mode 100644 index 9246e138..00000000 --- a/documents/macos_install.md +++ /dev/null @@ -1,18 +0,0 @@ -### MacOS installation issues - -We have found that recent versions of MacOS produces strange error messages when MulensModel is installed or run. Example error message: - -``` -(ValueError: '
+
+#ifndef FLOAT
+#define FLOAT double
+#endif
+
+
+FLOAT ld_linear(int n, FLOAT gam[], FLOAT rho);
+
+FLOAT mag_binext(FLOAT y1, FLOAT y2, FLOAT rho, FLOAT d, FLOAT q,
+ FLOAT (*ld_func)(int,FLOAT*,FLOAT), int n, FLOAT gam[],
+ FLOAT acc, FLOAT ld_acc);
+
+FLOAT mag_binpt(FLOAT y1, FLOAT y2, FLOAT d, FLOAT q);
+
+
+static PyObject * Adaptive_Contouring_Linear_wrapper(PyObject *self, PyObject *args) {
+ double d, q, y1, y2, rho, gamma, acc, ld_acc;
+ double mag, gam[1];
+
+ if (!PyArg_ParseTuple(args, "dddddddd", &d, &q, &y1, &y2, &rho, &gamma, &acc, &ld_acc)) return NULL;
+
+ if (gamma == 0.0) {
+ mag = mag_binext(y1, y2, rho, d, q, NULL, -1, NULL, acc, ld_acc);
+ }
+ else {
+ gam[0] = gamma;
+ mag = mag_binext(y1, y2, rho, d, q, ld_linear, 1, gam, acc, ld_acc);
+ }
+
+ return Py_BuildValue("d", mag);
+}
+
+static PyMethodDef ACMethods[] = {
+ {"Adaptive_Contouring_Linear", Adaptive_Contouring_Linear_wrapper, METH_VARARGS, "some notes here"},
+ {NULL, NULL, 0, NULL} /* Sentinel */
+};
+
+static struct PyModuleDef ACmodule = {
+ PyModuleDef_HEAD_INIT,
+ "AdaptiveContouring",
+ NULL,
+ -1,
+ ACMethods
+};
+
+PyMODINIT_FUNC PyInit_AdaptiveContouring(void) {
+ return PyModule_Create(&ACmodule);
+}
diff --git a/source/MulensModel/binarylens.py b/source/MulensModel/binarylens.py
index ed2d58d5..0adcb174 100755
--- a/source/MulensModel/binarylens.py
+++ b/source/MulensModel/binarylens.py
@@ -8,6 +8,18 @@
import MulensModel
from MulensModel.utils import Utils
+try:
+ import MulensModel.VBBL as mm_vbbl
+except:
+ _vbbl_wrapped = False
+else:
+ _vbbl_wrapped = True
+try:
+ import MulensModel.AdaptiveContouring as mm_ac
+except:
+ _adaptive_contouring_wrapped = False
+else:
+ _adaptive_contouring_wrapped = True
def _try_load(path, name):
@@ -29,11 +41,6 @@ def _try_load(path, name):
return None
-def _get_path_1(name):
- """convenience function"""
- return os.path.join(os.path.dirname(MulensModel.__file__), name + "*.so")
-
-
def _get_path_2(name_1, name_2):
"""convenience function"""
module_path = os.path.abspath(__file__)
@@ -42,38 +49,53 @@ def _get_path_2(name_1, name_2):
return os.path.join(module_path, 'source', name_1, name_2)
-vbbl = _try_load(glob.glob(_get_path_1("VBBL")), "VBBL")
-if vbbl is None:
- vbbl = _try_load(_get_path_2('VBBL', "VBBinaryLensingLibrary_wrapper.so"),
- "VBBL")
-_vbbl_wrapped = (vbbl is not None)
+def _import_compiled_VBBL():
+ """try importing manually compiled VBBL package"""
+ vbbl = _try_load(
+ _get_path_2('VBBL', "VBBinaryLensingLibrary_wrapper.so"), "VBBL")
+ _vbbl_wrapped = (vbbl is not None)
+ if _vbbl_wrapped:
+ vbbl.VBBinaryLensing_BinaryMagDark.argtypes = 7 * [ctypes.c_double]
+ vbbl.VBBinaryLensing_BinaryMagDark.restype = ctypes.c_double
-ac = "AdaptiveContouring"
-adaptive_contour = _try_load(glob.glob(_get_path_1(ac)), ac)
-if adaptive_contour is None:
- adaptive_contour = _try_load(_get_path_2(ac, ac + "_wrapper.so"), ac)
-_adaptive_contouring_wrapped = (adaptive_contour is not None)
+ vbbl.VBBL_SG12_5.argtypes = 12 * [ctypes.c_double]
+ vbbl.VBBL_SG12_5.restype = np.ctypeslib.ndpointer(
+ dtype=ctypes.c_double, shape=(10,))
+ return (_vbbl_wrapped, vbbl.VBBinaryLensing_BinaryMagDark, vbbl.VBBL_SG12_5)
-if _vbbl_wrapped:
- vbbl.VBBinaryLensing_BinaryMagDark.argtypes = 7 * [ctypes.c_double]
- vbbl.VBBinaryLensing_BinaryMagDark.restype = ctypes.c_double
- _vbbl_binary_mag_dark = vbbl.VBBinaryLensing_BinaryMagDark
- vbbl.VBBL_SG12_5.argtypes = 12 * [ctypes.c_double]
- vbbl.VBBL_SG12_5.restype = np.ctypeslib.ndpointer(
- dtype=ctypes.c_double, shape=(10,))
- _vbbl_SG12_5 = vbbl.VBBL_SG12_5
+def _import_compiled_AdaptiveContouring():
+ """try importing manually compiled AdaptiveContouring package"""
+ ac = "AdaptiveContouring"
+ adaptive_contour = _try_load(_get_path_2(ac, ac + "_wrapper.so"), ac)
+ _adaptive_contouring_wrapped = (adaptive_contour is not None)
+ if _adaptive_contouring_wrapped:
+ adaptive_contour.Adaptive_Contouring_Linear.argtypes = (
+ 8 * [ctypes.c_double])
+ adaptive_contour.Adaptive_Contouring_Linear.restype = ctypes.c_double
+ return (_adaptive_contouring_wrapped,
+ adaptive_contour.Adaptive_Contouring_Linear)
+
+# Check import and try manually compiled versions.
+if _vbbl_wrapped:
+ _vbbl_binary_mag_dark = mm_vbbl.VBBinaryLensing_BinaryMagDark
+ _vbbl_SG12_5 = mm_vbbl.VBBL_SG12_5
+else:
+ out = _import_compiled_VBBL()
+ _vbbl_wrapped = out[0]
+ _vbbl_binary_mag_dark = out[1]
+ _vbbl_SG12_5 = out[2]
if not _vbbl_wrapped:
_solver = 'numpy'
else:
_solver = 'Skowron_and_Gould_12'
-
if _adaptive_contouring_wrapped:
- adaptive_contour.Adaptive_Contouring_Linear.argtypes = (
- 8 * [ctypes.c_double])
- adaptive_contour.Adaptive_Contouring_Linear.restype = ctypes.c_double
- _adaptive_contouring_linear = adaptive_contour.Adaptive_Contouring_Linear
+ _adaptive_contouring_linear = mm_ac.Adaptive_Contouring_Linear
+else:
+ out = _import_compiled_AdaptiveContouring()
+ _adaptive_contouring_wrapped = out[0]
+ _adaptive_contouring_linear = out[1]
class BinaryLens(object):
diff --git a/source/MulensModel/version.py b/source/MulensModel/version.py
index e07e4a2c..e95c214a 100644
--- a/source/MulensModel/version.py
+++ b/source/MulensModel/version.py
@@ -1,2 +1,2 @@
-__version__ = "1.15.12"
+__version__ = "1.16.0"
diff --git a/source/VBBL/VBBinaryLensingLibrary_wrapper.cpp_NEW b/source/VBBL/VBBinaryLensingLibrary_wrapper.cpp_NEW
deleted file mode 100644
index 038a9bc7..00000000
--- a/source/VBBL/VBBinaryLensingLibrary_wrapper.cpp_NEW
+++ /dev/null
@@ -1,72 +0,0 @@
-#include