foldedleastsquares 0.1.4__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.
- foldedleastsquares-0.1.4/LICENSE +21 -0
- foldedleastsquares-0.1.4/MANIFEST.in +1 -0
- foldedleastsquares-0.1.4/PKG-INFO +88 -0
- foldedleastsquares-0.1.4/README.md +76 -0
- foldedleastsquares-0.1.4/foldedleastsquares/__init__.py +21 -0
- foldedleastsquares-0.1.4/foldedleastsquares/catalog.py +175 -0
- foldedleastsquares-0.1.4/foldedleastsquares/command_line.py +129 -0
- foldedleastsquares-0.1.4/foldedleastsquares/core.py +182 -0
- foldedleastsquares-0.1.4/foldedleastsquares/gpu.py +709 -0
- foldedleastsquares-0.1.4/foldedleastsquares/grid.py +32 -0
- foldedleastsquares-0.1.4/foldedleastsquares/helpers.py +112 -0
- foldedleastsquares-0.1.4/foldedleastsquares/interpolation.py +58 -0
- foldedleastsquares-0.1.4/foldedleastsquares/main.py +469 -0
- foldedleastsquares-0.1.4/foldedleastsquares/results.py +61 -0
- foldedleastsquares-0.1.4/foldedleastsquares/stats.py +416 -0
- foldedleastsquares-0.1.4/foldedleastsquares/template_generator/__init__.py +0 -0
- foldedleastsquares-0.1.4/foldedleastsquares/template_generator/default_transit_template_generator.py +394 -0
- foldedleastsquares-0.1.4/foldedleastsquares/template_generator/tailed_transit_template_generator.py +125 -0
- foldedleastsquares-0.1.4/foldedleastsquares/template_generator/transit_template_generator.py +335 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/__init__.py +0 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_FAP.py +13 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_catalog_data.py +75 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_cleaned_array.py +27 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_duration_grid.py +24 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_multi_planet.py +63 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_multi_planet_gpu.py +132 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_period_grid.py +67 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_resample.py +49 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_shapes.py +92 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_stats_gap.py +136 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_synthetic.py +195 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_transit_depth_min.py +75 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_uncertainties.py +61 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tests/test_validation.py +21 -0
- foldedleastsquares-0.1.4/foldedleastsquares/times.py +20 -0
- foldedleastsquares-0.1.4/foldedleastsquares/tls_constants.py +148 -0
- foldedleastsquares-0.1.4/foldedleastsquares/validate.py +203 -0
- foldedleastsquares-0.1.4/foldedleastsquares/version.py +2 -0
- foldedleastsquares-0.1.4/foldedleastsquares.egg-info/PKG-INFO +88 -0
- foldedleastsquares-0.1.4/foldedleastsquares.egg-info/SOURCES.txt +43 -0
- foldedleastsquares-0.1.4/foldedleastsquares.egg-info/dependency_links.txt +1 -0
- foldedleastsquares-0.1.4/foldedleastsquares.egg-info/requires.txt +14 -0
- foldedleastsquares-0.1.4/foldedleastsquares.egg-info/top_level.txt +1 -0
- foldedleastsquares-0.1.4/setup.cfg +4 -0
- foldedleastsquares-0.1.4/setup.py +49 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Michael Hippke
|
|
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 @@
|
|
|
1
|
+
include transitleastsquares/*.csv
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: foldedleastsquares
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: An optimized transit-fitting algorithm to search for periodic features in light curves
|
|
5
|
+
Home-page: https://github.com/martindevora/tls
|
|
6
|
+
Author: Martín Dévora Pajares
|
|
7
|
+
Author-email: martin.devora.pajares@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Description: 
|
|
10
|
+
### An optimized transit-fitting algorithm to search for periodic transits of small planets
|
|
11
|
+
[](https://github.com/hippke/tls/blob/master/LICENSE)
|
|
12
|
+
[](https://pypi.org/project/transitleastsquares/)
|
|
13
|
+
[](https://pypi.org/project/transitleastsquares/)
|
|
14
|
+
[](https://transitleastsquares.readthedocs.io/en/latest/index.html)
|
|
15
|
+
[](https://github.com/hippke/tls/tree/master/tutorials)
|
|
16
|
+
[](https://arxiv.org/abs/1901.02015)
|
|
17
|
+
[](https://travis-ci.com/hippke/tls)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Motivation
|
|
21
|
+
We present a new method to detect planetary transits from time-series photometry, the *Transit Least Squares* (TLS) algorithm. While the commonly used Box Least Squares [(BLS, Kovács et al. 2002)](http://adsabs.harvard.edu/abs/2002A%26A...391..369K) algorithm searches for rectangular signals in stellar light curves, *TLS* searches for transit-like features with stellar limb-darkening and including the effects of planetary ingress and egress. Moreover, *TLS* analyses the entire, unbinned data of the phase-folded light curve. These improvements yield a ~10 % higher detection efficiency (and similar false alarm rates) compared to BLS. The higher detection efficiency of our freely available Python implementation comes at the cost of higher computational load, which we partly compensate by applying an optimized period sampling and transit duration sampling, constrained to the physically plausible range. A typical Kepler K2 light curve, worth of 90 d of observations at a cadence of 30 min, can be searched with *TLS* in 10 seconds real time on a standard laptop computer, just as with BLS.
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
TLS can be installed conveniently using: `pip install transitleastsquares`
|
|
28
|
+
|
|
29
|
+
If you have multiple versions of Python and pip on your machine, try: `pip3 install transitleastsquares`
|
|
30
|
+
|
|
31
|
+
The latest version can be pulled from github::
|
|
32
|
+
```
|
|
33
|
+
git clone https://github.com/hippke/tls.git
|
|
34
|
+
cd tls
|
|
35
|
+
python setup.py install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If the command `python` does not point to Python 3 on your machine, you can try to replace the last line with `python3 setup.py install`. If you don't have `git` on your machine, you can find installation instructions [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). TLS also runs on Python 2, but without multi-threading.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Dependencies:
|
|
42
|
+
Python 3,
|
|
43
|
+
[NumPy](http://www.numpy.org/),
|
|
44
|
+
[numba](http://numba.pydata.org/),
|
|
45
|
+
[batman-package](https://www.cfa.harvard.edu/~lkreidberg/batman/),
|
|
46
|
+
[tqdm](https://github.com/tqdm/tqdm),
|
|
47
|
+
optional:
|
|
48
|
+
[argparse](https://docs.python.org/3/library/argparse.html) (for the command line version),
|
|
49
|
+
[astroquery](https://astroquery.readthedocs.io/en/latest/) (for LD and stellar density priors from Kepler K1, K2, and TESS).
|
|
50
|
+
|
|
51
|
+
If you have trouble installing, please [open an issue](https://github.com/hippke/tls/issues).
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Getting started
|
|
55
|
+
Here is a short animation of a real search for planets in Kepler K2 data. For more examples, have a look at the [tutorials](https://github.com/hippke/tls/tree/master/tutorials) and the [documentation](https://transitleastsquares.readthedocs.io/en/latest/index.html).
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
## Attribution
|
|
60
|
+
Please cite [Hippke & Heller (2019, A&A 623, A39)](https://ui.adsabs.harvard.edu/#abs/2019A&A...623A..39H/abstract) if you find this code useful in your research. The BibTeX entry for the paper is:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
@ARTICLE{2019A&A...623A..39H,
|
|
64
|
+
author = {{Hippke}, Michael and {Heller}, Ren{\'e}},
|
|
65
|
+
title = "{Optimized transit detection algorithm to search for periodic transits of small planets}",
|
|
66
|
+
journal = {\aap},
|
|
67
|
+
year = "2019",
|
|
68
|
+
month = "Mar",
|
|
69
|
+
volume = {623},
|
|
70
|
+
eid = {A39},
|
|
71
|
+
pages = {A39},
|
|
72
|
+
doi = {10.1051/0004-6361/201834672},
|
|
73
|
+
archivePrefix = {arXiv},
|
|
74
|
+
eprint = {1901.02015},
|
|
75
|
+
primaryClass = {astro-ph.EP},
|
|
76
|
+
adsurl = {https://ui.adsabs.harvard.edu/\#abs/2019A&A...623A..39H},
|
|
77
|
+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Contributing Code, Bugfixes, or Feedback
|
|
82
|
+
We welcome and encourage contributions. If you have any trouble, [open an issue](https://github.com/hippke/tls/issues).
|
|
83
|
+
|
|
84
|
+
Copyright 2019 Michael Hippke & René Heller.
|
|
85
|
+
|
|
86
|
+
Platform: UNKNOWN
|
|
87
|
+
Description-Content-Type: text/markdown
|
|
88
|
+
Provides-Extra: cupy
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+

|
|
2
|
+
### An optimized transit-fitting algorithm to search for periodic transits of small planets
|
|
3
|
+
[](https://github.com/hippke/tls/blob/master/LICENSE)
|
|
4
|
+
[](https://pypi.org/project/transitleastsquares/)
|
|
5
|
+
[](https://pypi.org/project/transitleastsquares/)
|
|
6
|
+
[](https://transitleastsquares.readthedocs.io/en/latest/index.html)
|
|
7
|
+
[](https://github.com/hippke/tls/tree/master/tutorials)
|
|
8
|
+
[](https://arxiv.org/abs/1901.02015)
|
|
9
|
+
[](https://travis-ci.com/hippke/tls)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Motivation
|
|
13
|
+
We present a new method to detect planetary transits from time-series photometry, the *Transit Least Squares* (TLS) algorithm. While the commonly used Box Least Squares [(BLS, Kovács et al. 2002)](http://adsabs.harvard.edu/abs/2002A%26A...391..369K) algorithm searches for rectangular signals in stellar light curves, *TLS* searches for transit-like features with stellar limb-darkening and including the effects of planetary ingress and egress. Moreover, *TLS* analyses the entire, unbinned data of the phase-folded light curve. These improvements yield a ~10 % higher detection efficiency (and similar false alarm rates) compared to BLS. The higher detection efficiency of our freely available Python implementation comes at the cost of higher computational load, which we partly compensate by applying an optimized period sampling and transit duration sampling, constrained to the physically plausible range. A typical Kepler K2 light curve, worth of 90 d of observations at a cadence of 30 min, can be searched with *TLS* in 10 seconds real time on a standard laptop computer, just as with BLS.
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
TLS can be installed conveniently using: `pip install transitleastsquares`
|
|
20
|
+
|
|
21
|
+
If you have multiple versions of Python and pip on your machine, try: `pip3 install transitleastsquares`
|
|
22
|
+
|
|
23
|
+
The latest version can be pulled from github::
|
|
24
|
+
```
|
|
25
|
+
git clone https://github.com/hippke/tls.git
|
|
26
|
+
cd tls
|
|
27
|
+
python setup.py install
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If the command `python` does not point to Python 3 on your machine, you can try to replace the last line with `python3 setup.py install`. If you don't have `git` on your machine, you can find installation instructions [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). TLS also runs on Python 2, but without multi-threading.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Dependencies:
|
|
34
|
+
Python 3,
|
|
35
|
+
[NumPy](http://www.numpy.org/),
|
|
36
|
+
[numba](http://numba.pydata.org/),
|
|
37
|
+
[batman-package](https://www.cfa.harvard.edu/~lkreidberg/batman/),
|
|
38
|
+
[tqdm](https://github.com/tqdm/tqdm),
|
|
39
|
+
optional:
|
|
40
|
+
[argparse](https://docs.python.org/3/library/argparse.html) (for the command line version),
|
|
41
|
+
[astroquery](https://astroquery.readthedocs.io/en/latest/) (for LD and stellar density priors from Kepler K1, K2, and TESS).
|
|
42
|
+
|
|
43
|
+
If you have trouble installing, please [open an issue](https://github.com/hippke/tls/issues).
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Getting started
|
|
47
|
+
Here is a short animation of a real search for planets in Kepler K2 data. For more examples, have a look at the [tutorials](https://github.com/hippke/tls/tree/master/tutorials) and the [documentation](https://transitleastsquares.readthedocs.io/en/latest/index.html).
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
## Attribution
|
|
52
|
+
Please cite [Hippke & Heller (2019, A&A 623, A39)](https://ui.adsabs.harvard.edu/#abs/2019A&A...623A..39H/abstract) if you find this code useful in your research. The BibTeX entry for the paper is:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
@ARTICLE{2019A&A...623A..39H,
|
|
56
|
+
author = {{Hippke}, Michael and {Heller}, Ren{\'e}},
|
|
57
|
+
title = "{Optimized transit detection algorithm to search for periodic transits of small planets}",
|
|
58
|
+
journal = {\aap},
|
|
59
|
+
year = "2019",
|
|
60
|
+
month = "Mar",
|
|
61
|
+
volume = {623},
|
|
62
|
+
eid = {A39},
|
|
63
|
+
pages = {A39},
|
|
64
|
+
doi = {10.1051/0004-6361/201834672},
|
|
65
|
+
archivePrefix = {arXiv},
|
|
66
|
+
eprint = {1901.02015},
|
|
67
|
+
primaryClass = {astro-ph.EP},
|
|
68
|
+
adsurl = {https://ui.adsabs.harvard.edu/\#abs/2019A&A...623A..39H},
|
|
69
|
+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Contributing Code, Bugfixes, or Feedback
|
|
74
|
+
We welcome and encourage contributions. If you have any trouble, [open an issue](https://github.com/hippke/tls/issues).
|
|
75
|
+
|
|
76
|
+
Copyright 2019 Michael Hippke & René Heller.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Optimized algorithm to search for transits of small extrasolar planets
|
|
2
|
+
# /
|
|
3
|
+
# , AUTHORS O/
|
|
4
|
+
# \ : / Michael Hippke (1) [michael@hippke.org] /\/|
|
|
5
|
+
# `. __/ \__ .' Rene' Heller (2) [heller@mps.mpg.de] |
|
|
6
|
+
# _ _\ /_ _ _________________________________________________________/ \_
|
|
7
|
+
# /_ _\
|
|
8
|
+
# .' \ / `. (1) Sonneberg Observatory, Sternwartestr. 32, Sonneberg
|
|
9
|
+
# / : \ (2) Max Planck Institute for Solar System Research,
|
|
10
|
+
# ' Justus-von-Liebig-Weg 3, 37077 G\"ottingen, Germany
|
|
11
|
+
|
|
12
|
+
from __future__ import division, print_function
|
|
13
|
+
from .main import transitleastsquares
|
|
14
|
+
from .helpers import cleaned_array, resample, transit_mask
|
|
15
|
+
from .stats import FAP
|
|
16
|
+
from .catalog import catalog_info
|
|
17
|
+
from .core import fold
|
|
18
|
+
from .template_generator.transit_template_generator import TransitTemplateGenerator
|
|
19
|
+
from .template_generator.default_transit_template_generator import DefaultTransitTemplateGenerator
|
|
20
|
+
from .results import transitleastsquaresresults
|
|
21
|
+
from . import version
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
from __future__ import division, print_function
|
|
2
|
+
import numpy
|
|
3
|
+
from os import path
|
|
4
|
+
from . import tls_constants
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def catalog_info_KIC(KIC_ID):
|
|
8
|
+
"""Takes KIC_ID, returns stellar information from online catalog using Vizier"""
|
|
9
|
+
|
|
10
|
+
if type(KIC_ID) is not int:
|
|
11
|
+
raise TypeError('KIC_ID ID must be of type "int"')
|
|
12
|
+
try:
|
|
13
|
+
from astroquery.vizier import Vizier
|
|
14
|
+
except:
|
|
15
|
+
raise ImportError("Package astroquery required but failed to import")
|
|
16
|
+
|
|
17
|
+
columns = ["Teff", "log(g)", "Rad", "E_Rad", "e_Rad", "Mass", "E_Mass", "e_Mass"]
|
|
18
|
+
catalog = "J/ApJS/229/30/catalog"
|
|
19
|
+
result = (
|
|
20
|
+
Vizier(columns=columns)
|
|
21
|
+
.query_constraints(KIC=KIC_ID, catalog=catalog)[0]
|
|
22
|
+
.as_array()
|
|
23
|
+
)
|
|
24
|
+
Teff = result[0][0]
|
|
25
|
+
logg = result[0][1]
|
|
26
|
+
radius = result[0][2]
|
|
27
|
+
radius_max = result[0][3]
|
|
28
|
+
radius_min = result[0][4]
|
|
29
|
+
mass = result[0][5]
|
|
30
|
+
mass_max = result[0][6]
|
|
31
|
+
mass_min = result[0][7]
|
|
32
|
+
return Teff, logg, radius, radius_min, radius_max, mass, mass_min, mass_max
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def catalog_info_EPIC(EPIC_ID):
|
|
36
|
+
"""Takes EPIC_ID, returns stellar information from online catalog using Vizier"""
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
from astroquery.vizier import Vizier
|
|
40
|
+
except:
|
|
41
|
+
raise ImportError("Package astroquery required but failed to import")
|
|
42
|
+
if type(EPIC_ID) is not int:
|
|
43
|
+
raise TypeError('EPIC_ID ID must be of type "int"')
|
|
44
|
+
if (EPIC_ID < 201000001) or (EPIC_ID > 251813738):
|
|
45
|
+
raise TypeError("EPIC_ID ID must be in range 201000001 to 251813738")
|
|
46
|
+
columns = ["Teff", "logg", "Rad", "E_Rad", "e_Rad", "Mass", "E_Mass", "e_Mass"]
|
|
47
|
+
catalog = "IV/34/epic"
|
|
48
|
+
result = (
|
|
49
|
+
Vizier(columns=columns)
|
|
50
|
+
.query_constraints(ID=EPIC_ID, catalog=catalog)[0]
|
|
51
|
+
.as_array()
|
|
52
|
+
)
|
|
53
|
+
Teff = result[0][0]
|
|
54
|
+
logg = result[0][1]
|
|
55
|
+
radius = result[0][2]
|
|
56
|
+
radius_max = result[0][3]
|
|
57
|
+
radius_min = result[0][4]
|
|
58
|
+
mass = result[0][5]
|
|
59
|
+
mass_max = result[0][6]
|
|
60
|
+
mass_min = result[0][7]
|
|
61
|
+
return Teff, logg, radius, radius_min, radius_max, mass, mass_min, mass_max
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def catalog_info_TIC(TIC_ID):
|
|
65
|
+
"""Takes TIC_ID, returns stellar information from online catalog using Vizier"""
|
|
66
|
+
if type(TIC_ID) is not int:
|
|
67
|
+
raise TypeError('TIC_ID ID must be of type "int"')
|
|
68
|
+
try:
|
|
69
|
+
from astroquery.mast import Catalogs
|
|
70
|
+
except:
|
|
71
|
+
raise ImportError("Package astroquery required but failed to import")
|
|
72
|
+
|
|
73
|
+
result = Catalogs.query_criteria(catalog="Tic", ID=TIC_ID).as_array()
|
|
74
|
+
Teff = result[0][64]
|
|
75
|
+
logg = result[0][66]
|
|
76
|
+
radius = result[0][70]
|
|
77
|
+
radius_max = result[0][71]
|
|
78
|
+
radius_min = result[0][71]
|
|
79
|
+
mass = result[0][72]
|
|
80
|
+
mass_max = result[0][73]
|
|
81
|
+
mass_min = result[0][73]
|
|
82
|
+
return Teff, logg, radius, radius_min, radius_max, mass, mass_min, mass_max
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def catalog_info(EPIC_ID=None, TIC_ID=None, KIC_ID=None):
|
|
86
|
+
"""Takes EPIC ID, returns limb darkening parameters u (linear) and
|
|
87
|
+
a,b (quadratic), and stellar parameters. Values are pulled for minimum
|
|
88
|
+
absolute deviation between given/catalog Teff and logg. Data are from:
|
|
89
|
+
- K2 Ecliptic Plane Input Catalog, Huber+ 2016, 2016ApJS..224....2H
|
|
90
|
+
- New limb-darkening coefficients, Claret+ 2012, 2013,
|
|
91
|
+
2012A&A...546A..14C, 2013A&A...552A..16C"""
|
|
92
|
+
|
|
93
|
+
if (EPIC_ID is None) and (TIC_ID is None) and (KIC_ID is None):
|
|
94
|
+
raise ValueError("No ID was given")
|
|
95
|
+
if (EPIC_ID is not None) and (TIC_ID is not None):
|
|
96
|
+
raise ValueError("Only one ID allowed")
|
|
97
|
+
if (EPIC_ID is not None) and (KIC_ID is not None):
|
|
98
|
+
raise ValueError("Only one ID allowed")
|
|
99
|
+
if (TIC_ID is not None) and (KIC_ID is not None):
|
|
100
|
+
raise ValueError("Only one ID allowed")
|
|
101
|
+
|
|
102
|
+
# KOI CASE (Kepler K1)
|
|
103
|
+
if KIC_ID is not None:
|
|
104
|
+
Teff, logg, radius, radius_min, radius_max, mass, mass_min, mass_max = catalog_info_KIC(
|
|
105
|
+
KIC_ID
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# EPIC CASE (Kepler K2)
|
|
109
|
+
if EPIC_ID is not None:
|
|
110
|
+
Teff, logg, radius, radius_min, radius_max, mass, mass_min, mass_max = catalog_info_EPIC(
|
|
111
|
+
EPIC_ID
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
# TESS CASE
|
|
115
|
+
if TIC_ID is not None:
|
|
116
|
+
Teff, logg, radius, radius_min, radius_max, mass, mass_min, mass_max = catalog_info_TIC(
|
|
117
|
+
TIC_ID
|
|
118
|
+
)
|
|
119
|
+
ld = numpy.genfromtxt(
|
|
120
|
+
path.join(tls_constants.resources_dir, "ld_claret_tess.csv"),
|
|
121
|
+
skip_header=1,
|
|
122
|
+
delimiter=",",
|
|
123
|
+
dtype="f8, int32, f8, f8",
|
|
124
|
+
names=["logg", "Teff", "a", "b"],
|
|
125
|
+
)
|
|
126
|
+
else: # Limb darkening is the same for K1 (KIC) and K2 (EPIC)
|
|
127
|
+
ld = numpy.genfromtxt(
|
|
128
|
+
path.join(tls_constants.resources_dir, "JAA546A14limb1-4.csv"),
|
|
129
|
+
skip_header=1,
|
|
130
|
+
delimiter=",",
|
|
131
|
+
dtype="f8, int32, f8, f8, f8",
|
|
132
|
+
names=["logg", "Teff", "u", "a", "b"],
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
if logg is None:
|
|
136
|
+
logg = 4
|
|
137
|
+
warnings.warn("No logg in catalog. Proceeding with logg=4")
|
|
138
|
+
|
|
139
|
+
if Teff is None:
|
|
140
|
+
Teff = 6000
|
|
141
|
+
warnings.warn("No Teff in catalog. Proceeding with Teff=6000")
|
|
142
|
+
|
|
143
|
+
"""From here on, K2 and TESS catalogs work the same:
|
|
144
|
+
- Take Teff from star catalog and find nearest entry in LD catalog
|
|
145
|
+
- Same for logg, but only for the Teff values returned before
|
|
146
|
+
- Return stellar parameters and best-match LD
|
|
147
|
+
"""
|
|
148
|
+
nearest_Teff = ld["Teff"][(numpy.abs(ld["Teff"] - Teff)).argmin()]
|
|
149
|
+
idx_all_Teffs = numpy.where(ld["Teff"] == nearest_Teff)
|
|
150
|
+
relevant_lds = numpy.copy(ld[idx_all_Teffs])
|
|
151
|
+
idx_nearest = numpy.abs(relevant_lds["logg"] - logg).argmin()
|
|
152
|
+
a = relevant_lds["a"][idx_nearest]
|
|
153
|
+
b = relevant_lds["b"][idx_nearest]
|
|
154
|
+
|
|
155
|
+
mass = numpy.array(mass)
|
|
156
|
+
mass_min = numpy.array(mass_min)
|
|
157
|
+
mass_max = numpy.array(mass_max)
|
|
158
|
+
radius = numpy.array(radius)
|
|
159
|
+
radius_min = numpy.array(radius_min)
|
|
160
|
+
radius_max = numpy.array(radius_max)
|
|
161
|
+
|
|
162
|
+
if mass == 0.0:
|
|
163
|
+
mass = numpy.nan
|
|
164
|
+
if mass_min == 0.0:
|
|
165
|
+
mass_min = numpy.nan
|
|
166
|
+
if mass_max == 0.0:
|
|
167
|
+
mass_max = numpy.nan
|
|
168
|
+
if radius == 0.0:
|
|
169
|
+
radius = numpy.nan
|
|
170
|
+
if radius_min == 0.0:
|
|
171
|
+
radius_min = numpy.nan
|
|
172
|
+
if radius_max == 0.0:
|
|
173
|
+
radius_max = numpy.nan
|
|
174
|
+
|
|
175
|
+
return ((a, b), mass, mass_min, mass_max, radius, radius_min, radius_max)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from __future__ import division, print_function
|
|
2
|
+
from . import transitleastsquares
|
|
3
|
+
from . import tls_constants as tls_constants
|
|
4
|
+
import numpy
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
from configparser import ConfigParser
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import argparse
|
|
11
|
+
except:
|
|
12
|
+
raise ImportError("Could not import package argparse")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
print(tls_constants.TLS_VERSION)
|
|
20
|
+
parser = argparse.ArgumentParser()
|
|
21
|
+
parser.add_argument("lightcurve", help="path to lightcurve file")
|
|
22
|
+
parser.add_argument("-o", "--output", help="path to output directory")
|
|
23
|
+
parser.add_argument("-c", "--config", help="path to configuration file")
|
|
24
|
+
args = parser.parse_args()
|
|
25
|
+
|
|
26
|
+
# Read config file if possible
|
|
27
|
+
use_config_file = False
|
|
28
|
+
if args.config is not None:
|
|
29
|
+
try:
|
|
30
|
+
config = ConfigParser()
|
|
31
|
+
config.read(args.config)
|
|
32
|
+
R_star = float(config["Grid"]["R_star"])
|
|
33
|
+
R_star_min = float(config["Grid"]["R_star_min"])
|
|
34
|
+
R_star_max = float(config["Grid"]["R_star_max"])
|
|
35
|
+
M_star = float(config["Grid"]["M_star"])
|
|
36
|
+
M_star_min = float(config["Grid"]["M_star_min"])
|
|
37
|
+
M_star_max = float(config["Grid"]["M_star_max"])
|
|
38
|
+
period_min = float(config["Grid"]["period_min"])
|
|
39
|
+
period_max = float(config["Grid"]["period_max"])
|
|
40
|
+
n_transits_min = int(config["Grid"]["n_transits_min"])
|
|
41
|
+
transit_template = config["Template"]["transit_template"]
|
|
42
|
+
duration_grid_step = float(config["Speed"]["duration_grid_step"])
|
|
43
|
+
transit_depth_min = float(config["Speed"]["transit_depth_min"])
|
|
44
|
+
oversampling_factor = int(config["Speed"]["oversampling_factor"])
|
|
45
|
+
T0_fit_margin = float(config["Speed"]["T0_fit_margin"])
|
|
46
|
+
use_threads = int(config["Speed"]["use_threads"])
|
|
47
|
+
delimiter = int(config["File"]["delimiter"])
|
|
48
|
+
use_config_file = True
|
|
49
|
+
print("Using TLS configuration from config file", args.config)
|
|
50
|
+
except:
|
|
51
|
+
print(
|
|
52
|
+
"Using default values because of broken or missing configuration file",
|
|
53
|
+
args.config,
|
|
54
|
+
)
|
|
55
|
+
else:
|
|
56
|
+
print("No config file given. Using default values")
|
|
57
|
+
|
|
58
|
+
# Load data
|
|
59
|
+
if use_config_file:
|
|
60
|
+
data = numpy.genfromtxt(args.lightcurve, delimiter=args.delimiter)
|
|
61
|
+
else:
|
|
62
|
+
data = numpy.genfromtxt(args.lightcurve, delimiter=",")
|
|
63
|
+
|
|
64
|
+
t = data[:, 0]
|
|
65
|
+
y = data[:, 1]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# Initiate transitleastsquares model
|
|
69
|
+
try:
|
|
70
|
+
dy = data[:, 2]
|
|
71
|
+
model = transitleastsquares(t, y, dy)
|
|
72
|
+
except:
|
|
73
|
+
model = transitleastsquares(t, y)
|
|
74
|
+
|
|
75
|
+
if use_config_file:
|
|
76
|
+
results = model.power(
|
|
77
|
+
R_star=R_star,
|
|
78
|
+
R_star_min=R_star_min,
|
|
79
|
+
R_star_max=R_star_max,
|
|
80
|
+
M_star=M_star,
|
|
81
|
+
M_star_min=M_star_min,
|
|
82
|
+
M_star_max=M_star_max,
|
|
83
|
+
period_min=period_min,
|
|
84
|
+
period_max=period_max,
|
|
85
|
+
n_transits_min=n_transits_min,
|
|
86
|
+
transit_template=transit_template,
|
|
87
|
+
duration_grid_step=duration_grid_step,
|
|
88
|
+
transit_depth_min=transit_depth_min,
|
|
89
|
+
oversampling_factor=oversampling_factor,
|
|
90
|
+
T0_fit_margin=T0_fit_margin,
|
|
91
|
+
use_threads=use_threads,
|
|
92
|
+
)
|
|
93
|
+
else:
|
|
94
|
+
results = model.power()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# Save results to CSV files
|
|
98
|
+
|
|
99
|
+
# Determine path and file names of output files
|
|
100
|
+
if args.output is None:
|
|
101
|
+
file_stats = args.lightcurve + "_statistics.csv"
|
|
102
|
+
file_power = args.lightcurve + "_power.csv"
|
|
103
|
+
else:
|
|
104
|
+
file_stats = os.path.join(args.output, args.lightcurve + "_statistics.csv")
|
|
105
|
+
file_power = os.path.join(args.output, args.lightcurve + "_power.csv")
|
|
106
|
+
|
|
107
|
+
# Save
|
|
108
|
+
try:
|
|
109
|
+
numpy.savetxt(
|
|
110
|
+
file_power,
|
|
111
|
+
numpy.column_stack(
|
|
112
|
+
[
|
|
113
|
+
list(dict(list(results.items())[25:26]).values())[0],
|
|
114
|
+
list(dict(list(results.items())[26:27]).values())[0],
|
|
115
|
+
]
|
|
116
|
+
),
|
|
117
|
+
delimiter=",",
|
|
118
|
+
fmt="%1.6f",
|
|
119
|
+
)
|
|
120
|
+
print("SDE-ogram saved to", file_stats)
|
|
121
|
+
|
|
122
|
+
statistics = dict(list(results.items())[0:25])
|
|
123
|
+
numpy.set_printoptions(precision=8, threshold=10e10)
|
|
124
|
+
with open(file_stats, "w") as f:
|
|
125
|
+
for key in statistics.keys():
|
|
126
|
+
f.write("%s %s\n" % (key, statistics[key]))
|
|
127
|
+
print("Statistics saved to", file_stats)
|
|
128
|
+
except IOError:
|
|
129
|
+
print("Error saving result file")
|