SingleLensFitter 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- singlelensfitter-0.1.0/LICENSE +21 -0
- singlelensfitter-0.1.0/MANIFEST.in +2 -0
- singlelensfitter-0.1.0/PKG-INFO +63 -0
- singlelensfitter-0.1.0/README.md +42 -0
- singlelensfitter-0.1.0/THIRD_PARTY.md +12 -0
- singlelensfitter-0.1.0/docs/api.md +71 -0
- singlelensfitter-0.1.0/licenses/GPL-3.0.txt +674 -0
- singlelensfitter-0.1.0/licenses/VBMicrolensing-LGPL-3.0.txt +166 -0
- singlelensfitter-0.1.0/pyproject.toml +29 -0
- singlelensfitter-0.1.0/setup.cfg +4 -0
- singlelensfitter-0.1.0/setup.py +135 -0
- singlelensfitter-0.1.0/src/SingleLensFitter.egg-info/PKG-INFO +63 -0
- singlelensfitter-0.1.0/src/SingleLensFitter.egg-info/SOURCES.txt +55 -0
- singlelensfitter-0.1.0/src/SingleLensFitter.egg-info/dependency_links.txt +1 -0
- singlelensfitter-0.1.0/src/SingleLensFitter.egg-info/requires.txt +7 -0
- singlelensfitter-0.1.0/src/SingleLensFitter.egg-info/top_level.txt +1 -0
- singlelensfitter-0.1.0/src/singlelensfitter/__init__.py +33 -0
- singlelensfitter-0.1.0/src/singlelensfitter/_parallax_cpp.cpp +592 -0
- singlelensfitter-0.1.0/src/singlelensfitter/_vbm_cpp.cpp +508 -0
- singlelensfitter-0.1.0/src/singlelensfitter/auto_init.py +434 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/chebyshev_patch.hpp +68 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/ephemeris.hpp +113 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/linear_limb_darkening.hpp +55 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/mu_quadrature.hpp +186 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/mu_table_data.hpp +904 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/parallax_trajectory.hpp +225 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/sky_projection.hpp +40 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/source_limb.hpp +77 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/uniform_limb_table.hpp +84 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/uniform_table_data.hpp +1096 -0
- singlelensfitter-0.1.0/src/singlelensfitter/cpp/vbm_magnification.hpp +258 -0
- singlelensfitter-0.1.0/src/singlelensfitter/data/__init__.py +0 -0
- singlelensfitter-0.1.0/src/singlelensfitter/data/earth_orbital_parallax_table.txt +18750 -0
- singlelensfitter-0.1.0/src/singlelensfitter/fitters.py +832 -0
- singlelensfitter-0.1.0/src/singlelensfitter/fspl_initialization.py +674 -0
- singlelensfitter-0.1.0/src/singlelensfitter/init_config.py +103 -0
- singlelensfitter-0.1.0/src/singlelensfitter/jax_fspl.py +71 -0
- singlelensfitter-0.1.0/src/singlelensfitter/magnification.py +94 -0
- singlelensfitter-0.1.0/src/singlelensfitter/objective.py +16 -0
- singlelensfitter-0.1.0/src/singlelensfitter/parallax.py +628 -0
- singlelensfitter-0.1.0/src/singlelensfitter/parallax_backend.py +950 -0
- singlelensfitter-0.1.0/src/singlelensfitter/photometry.py +23 -0
- singlelensfitter-0.1.0/src/singlelensfitter/pspl_fft.py +692 -0
- singlelensfitter-0.1.0/src/singlelensfitter/signal_scale.py +978 -0
- singlelensfitter-0.1.0/src/singlelensfitter/singlelens_fit.py +50 -0
- singlelensfitter-0.1.0/src/singlelensfitter/singlelens_model.py +97 -0
- singlelensfitter-0.1.0/src/singlelensfitter/trajectory.py +138 -0
- singlelensfitter-0.1.0/tests/limb_reference.py +58 -0
- singlelensfitter-0.1.0/tests/test_auto_init.py +85 -0
- singlelensfitter-0.1.0/tests/test_cpp_extension.py +284 -0
- singlelensfitter-0.1.0/tests/test_linear_limb_darkening.py +221 -0
- singlelensfitter-0.1.0/tests/test_native_parallax_backend.py +381 -0
- singlelensfitter-0.1.0/tests/test_photometry.py +25 -0
- singlelensfitter-0.1.0/tests/test_pspl_fft.py +268 -0
- singlelensfitter-0.1.0/tests/test_rmdc.py +141 -0
- singlelensfitter-0.1.0/tests/test_signal_scale_gap.py +28 -0
- singlelensfitter-0.1.0/tests/test_space_parallax.py +320 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KansukeNunota
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: SingleLensFitter
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Single-lens (PSPL / FSPL / annual+space parallax) light-curve fitting
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Repository, https://github.com/NunotaKansuke/SingleLensFitter
|
|
7
|
+
Project-URL: Documentation, https://github.com/NunotaKansuke/SingleLensFitter/blob/main/docs/api.md
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: THIRD_PARTY.md
|
|
12
|
+
License-File: licenses/GPL-3.0.txt
|
|
13
|
+
License-File: licenses/VBMicrolensing-LGPL-3.0.txt
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: jax
|
|
16
|
+
Requires-Dist: scipy
|
|
17
|
+
Requires-Dist: VBMicrolensing>=5.5
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# SingleLensFitter
|
|
23
|
+
|
|
24
|
+
Fit single-band gravitational microlensing light curves with a point lens and
|
|
25
|
+
either a point source (PSPL) or a finite source (FSPL). Both fitters support
|
|
26
|
+
annual and satellite parallax. Finite-source models also support linear limb darkening.
|
|
27
|
+
SingleLensFitter began as the single-lens fitting code in `jacscanomaly`.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
Requires Python 3.10+ and a C++17 compiler with OpenMP. On macOS, set
|
|
32
|
+
`SINGLELENSFITTER_DISABLE_OPENMP=1` to build with Apple Clang.
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
python -m pip install git+https://github.com/NunotaKansuke/SingleLensFitter.git
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Fit a light curve
|
|
39
|
+
|
|
40
|
+
Pass one-dimensional arrays of observation times in days, fluxes, and positive
|
|
41
|
+
one-sigma flux uncertainties.
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from singlelensfitter import FSPLFitter
|
|
45
|
+
|
|
46
|
+
fit = FSPLFitter().fit(time, flux, flux_err)
|
|
47
|
+
print(fit.optimizer_success, dict(zip(fit.param_names, fit.params)))
|
|
48
|
+
print(fit.chi2, fit.fs, fit.fb)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## How the fit works
|
|
52
|
+
|
|
53
|
+
For a point source, an FFT template search finds starting values for the peak
|
|
54
|
+
time, Einstein time, and impact parameter. For a finite source, the fitter
|
|
55
|
+
uses the observed peak width to try combinations of source radius (`rho`) and
|
|
56
|
+
scaled impact parameter (`u0/rho`), and ranks these starting points by chi-square.
|
|
57
|
+
|
|
58
|
+
The fitter refines multiple starting points by weighted least squares using
|
|
59
|
+
model derivatives. At each step it solves for the source and blend fluxes
|
|
60
|
+
analytically.
|
|
61
|
+
|
|
62
|
+
See the [API guide](https://github.com/NunotaKansuke/SingleLensFitter/blob/main/docs/api.md)
|
|
63
|
+
for point-source fits, limb darkening, parallax, and derivatives.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# SingleLensFitter
|
|
2
|
+
|
|
3
|
+
Fit single-band gravitational microlensing light curves with a point lens and
|
|
4
|
+
either a point source (PSPL) or a finite source (FSPL). Both fitters support
|
|
5
|
+
annual and satellite parallax. Finite-source models also support linear limb darkening.
|
|
6
|
+
SingleLensFitter began as the single-lens fitting code in `jacscanomaly`.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
Requires Python 3.10+ and a C++17 compiler with OpenMP. On macOS, set
|
|
11
|
+
`SINGLELENSFITTER_DISABLE_OPENMP=1` to build with Apple Clang.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
python -m pip install git+https://github.com/NunotaKansuke/SingleLensFitter.git
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Fit a light curve
|
|
18
|
+
|
|
19
|
+
Pass one-dimensional arrays of observation times in days, fluxes, and positive
|
|
20
|
+
one-sigma flux uncertainties.
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from singlelensfitter import FSPLFitter
|
|
24
|
+
|
|
25
|
+
fit = FSPLFitter().fit(time, flux, flux_err)
|
|
26
|
+
print(fit.optimizer_success, dict(zip(fit.param_names, fit.params)))
|
|
27
|
+
print(fit.chi2, fit.fs, fit.fb)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## How the fit works
|
|
31
|
+
|
|
32
|
+
For a point source, an FFT template search finds starting values for the peak
|
|
33
|
+
time, Einstein time, and impact parameter. For a finite source, the fitter
|
|
34
|
+
uses the observed peak width to try combinations of source radius (`rho`) and
|
|
35
|
+
scaled impact parameter (`u0/rho`), and ranks these starting points by chi-square.
|
|
36
|
+
|
|
37
|
+
The fitter refines multiple starting points by weighted least squares using
|
|
38
|
+
model derivatives. At each step it solves for the source and blend fluxes
|
|
39
|
+
analytically.
|
|
40
|
+
|
|
41
|
+
See the [API guide](https://github.com/NunotaKansuke/SingleLensFitter/blob/main/docs/api.md)
|
|
42
|
+
for point-source fits, limb darkening, parallax, and derivatives.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
SingleLensFitter originated in jacscanomaly and retains its MIT copyright notice.
|
|
2
|
+
|
|
3
|
+
The native extensions compile the unmodified VBMicrolensing library supplied
|
|
4
|
+
by the build dependency. VBMicrolensing is by Valerio Bozza and collaborators
|
|
5
|
+
and is distributed under LGPL version 3. To rebuild against modified library
|
|
6
|
+
sources, set `VBMICROLENSING_SOURCE_DIR` to the directory containing
|
|
7
|
+
`VBMicrolensingLibrary.cpp` and its header before building the package.
|
|
8
|
+
See the [upstream source and citation instructions](https://github.com/valboz/VBMicrolensing)
|
|
9
|
+
and the license texts in `licenses/`.
|
|
10
|
+
|
|
11
|
+
The bundled Earth ephemeris is from NASA/JPL Horizons. Query and reference-frame
|
|
12
|
+
details are preserved in the header of the original table.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Fitting API
|
|
2
|
+
|
|
3
|
+
Import the fitters from `singlelensfitter`. Each fits a single photometric
|
|
4
|
+
series and solves for source and blend flux at each set of lens parameters,
|
|
5
|
+
using the supplied one-sigma errors as weights in chi-square.
|
|
6
|
+
|
|
7
|
+
| Fitter | Lens parameters returned in order |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `PSPLFitter()` | `t0, tE, u0` |
|
|
10
|
+
| `FSPLFitter()` | `t0, tE, u0, rho`, then the limb-darkening coefficient if fitted |
|
|
11
|
+
| `PSPLParallaxFitter(ra_deg, dec_deg, tref)` | `t0, tE, u0, piEN, piEE` |
|
|
12
|
+
| `FSPLParallaxFitter(ra_deg, dec_deg, tref)` | `t0, tE, u0, rho, piEN, piEE` |
|
|
13
|
+
|
|
14
|
+
### Inputs and results
|
|
15
|
+
|
|
16
|
+
Call `fitter.fit(time, flux, ferr)` with finite one-dimensional arrays of equal
|
|
17
|
+
length. Time, peak time `t0`, and Einstein time `tE` are in days. The impact
|
|
18
|
+
parameter `u0` and source radius `rho` are in units of the angular Einstein radius.
|
|
19
|
+
Flux and its positive uncertainty must share units.
|
|
20
|
+
|
|
21
|
+
Omit the initial parameters to run automatic multistart. To continue an
|
|
22
|
+
existing fit, use `fitter.fit(time, flux, ferr, fitter.seed_from_fit(result))`.
|
|
23
|
+
Finite-source seeds use `log(rho)`; results report physical `rho`. Pass an
|
|
24
|
+
`InitConfig` as `init_config` to customize automatic initialization.
|
|
25
|
+
|
|
26
|
+
`SingleLensFitResult` includes `param_names`, `params`, source flux `fs`,
|
|
27
|
+
blend flux `fb`, `model_flux`, `residual`, and `chi2`. Check
|
|
28
|
+
`optimizer_success` and `optimizer_status` before interpreting parameters.
|
|
29
|
+
`chi2_dof` divides by the number of observations minus the number of nonlinear
|
|
30
|
+
parameters (minimum denominator one). For nominal residual degrees of freedom,
|
|
31
|
+
also count the two fitted flux coefficients in a full-rank fit.
|
|
32
|
+
|
|
33
|
+
### Limb darkening and derivatives
|
|
34
|
+
|
|
35
|
+
Use `FSPLFitter(linear_limb_darkening=0.3)` to fix the coefficient in
|
|
36
|
+
`I(mu)/I(1) = 1 - a + a*mu`. Zero gives a uniform disk. Add
|
|
37
|
+
`fit_limb_darkening=True` to fit the coefficient over [0, 1] for a rectilinear
|
|
38
|
+
trajectory. The parallax fitter accepts a fixed coefficient.
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from singlelensfitter import fspl_magnification_gradient, jax_fspl_magnification
|
|
42
|
+
|
|
43
|
+
A, dA_du, dA_drho, dA_da = fspl_magnification_gradient(u, rho, 0.3)
|
|
44
|
+
A_jax = jax_fspl_magnification(u, rho, 0.3)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Supply nonnegative separations and a scalar source radius up to 100. At exact
|
|
48
|
+
limb contact the uniform-disk normal derivative uses a finite symmetric secant.
|
|
49
|
+
The JAX function supports JIT and first derivatives. Importing this package
|
|
50
|
+
enables JAX 64-bit mode.
|
|
51
|
+
|
|
52
|
+
### Parallax
|
|
53
|
+
|
|
54
|
+
Supply sky coordinates in degrees and a reference epoch in the same time
|
|
55
|
+
convention as the observations. The default uses full JD and the bundled
|
|
56
|
+
Earth ephemeris. For times expressed as JD minus 2450000, for example, use:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from singlelensfitter import PSPLParallaxFitter, TimeSpec
|
|
60
|
+
|
|
61
|
+
fitter = PSPLParallaxFitter(ra_deg, dec_deg, tref,
|
|
62
|
+
time_spec=TimeSpec(scale="jd", offset=2450000))
|
|
63
|
+
fit = fitter.fit(time, flux, ferr)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
For a satellite's geocentric offsets, pass `geometry="space"` and
|
|
67
|
+
`satellite_or_observer_ephemeris=Ephemeris(times, xyz, origin="earth",
|
|
68
|
+
time_spec=spec)`. Use ICRF/J2000 Cartesian positions shaped (N, 3) in AU
|
|
69
|
+
and set `spec` to the ephemeris time convention. The ephemeris must cover
|
|
70
|
+
the requested epochs. Parallax results include optimizer and ephemeris
|
|
71
|
+
information in `fit.diagnostics`.
|