tglc 0.6.6__tar.gz → 0.7.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.
Files changed (38) hide show
  1. tglc-0.7.0/MANIFEST.in +2 -0
  2. {tglc-0.6.6 → tglc-0.7.0}/PKG-INFO +38 -11
  3. tglc-0.6.6/tglc.egg-info/PKG-INFO → tglc-0.7.0/README.rst +15 -25
  4. {tglc-0.6.6 → tglc-0.7.0}/setup.py +16 -3
  5. tglc-0.7.0/tglc/__init__.py +3 -0
  6. tglc-0.7.0/tglc/barycentric_correction.py +107 -0
  7. {tglc-0.6.6 → tglc-0.7.0}/tglc/effective_psf.py +10 -1
  8. tglc-0.7.0/tglc/ephemeris_data/20180720_tess_ephem.csv +10385 -0
  9. tglc-0.7.0/tglc/ephemeris_data/20190101_tess_ephem.csv +9635 -0
  10. tglc-0.7.0/tglc/ephemeris_data/20200101_tess_ephem.csv +9659 -0
  11. tglc-0.7.0/tglc/ephemeris_data/20210101_tess_ephem.csv +9275 -0
  12. tglc-0.7.0/tglc/ephemeris_data/20211215_tess_ephem.csv +12512 -0
  13. tglc-0.7.0/tglc/ephemeris_data/20221201_tess_ephem.csv +10308 -0
  14. tglc-0.7.0/tglc/ephemeris_data/20231201_tess_ephem.csv +10339 -0
  15. tglc-0.7.0/tglc/ephemeris_data/20241201_tess_ephem.csv +10314 -0
  16. tglc-0.7.0/tglc/ephemeris_data/README.md +48 -0
  17. tglc-0.7.0/tglc/ephemeris_data/plot_ephemerides.py +54 -0
  18. {tglc-0.6.6 → tglc-0.7.0}/tglc/ffi.py +2 -2
  19. {tglc-0.6.6 → tglc-0.7.0}/tglc/ffi_cut.py +125 -22
  20. {tglc-0.6.6 → tglc-0.7.0}/tglc/quick_lc.py +236 -116
  21. {tglc-0.6.6 → tglc-0.7.0}/tglc/target_lightcurve.py +26 -7
  22. tglc-0.6.6/README.rst → tglc-0.7.0/tglc.egg-info/PKG-INFO +53 -0
  23. tglc-0.7.0/tglc.egg-info/SOURCES.txt +32 -0
  24. tglc-0.7.0/tglc.egg-info/requires.txt +13 -0
  25. tglc-0.6.6/MANIFEST.in +0 -1
  26. tglc-0.6.6/tglc/__init__.py +0 -3
  27. tglc-0.6.6/tglc.egg-info/SOURCES.txt +0 -21
  28. tglc-0.6.6/tglc.egg-info/requires.txt +0 -12
  29. {tglc-0.6.6 → tglc-0.7.0}/LICENSE +0 -0
  30. {tglc-0.6.6 → tglc-0.7.0}/setup.cfg +0 -0
  31. {tglc-0.6.6 → tglc-0.7.0}/tglc/background_mask/__init__.py +0 -0
  32. {tglc-0.6.6 → tglc-0.7.0}/tglc/background_mask/median_mask.fits +0 -0
  33. {tglc-0.6.6 → tglc-0.7.0}/tglc/lc_plot.py +0 -0
  34. {tglc-0.6.6 → tglc-0.7.0}/tglc/mast.py +0 -0
  35. {tglc-0.6.6 → tglc-0.7.0}/tglc/run.py +0 -0
  36. {tglc-0.6.6 → tglc-0.7.0}/tglc/source_output.py +0 -0
  37. {tglc-0.6.6 → tglc-0.7.0}/tglc.egg-info/dependency_links.txt +0 -0
  38. {tglc-0.6.6 → tglc-0.7.0}/tglc.egg-info/top_level.txt +0 -0
tglc-0.7.0/MANIFEST.in ADDED
@@ -0,0 +1,2 @@
1
+ include tglc/background_mask/*.fits
2
+ include tglc/ephemeris_data/*
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: tglc
3
- Version: 0.6.6
3
+ Version: 0.7.0
4
4
  Summary: TESS-Gaia Light Curve
5
5
  Home-page: https://github.com/TeHanHunter/TESS_Gaia_Light_Curve
6
6
  Author: Te Han
@@ -11,18 +11,42 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.8, <3.13
12
12
  Description-Content-Type: text/x-rst
13
13
  License-File: LICENSE
14
- Requires-Dist: astropy>=5.1
14
+ Requires-Dist: astropy<6.2,>=6.1
15
15
  Requires-Dist: astroquery==0.4.7
16
- Requires-Dist: matplotlib
17
- Requires-Dist: numpy
16
+ Requires-Dist: matplotlib<4.0,>=3.8
17
+ Requires-Dist: numpy<2.0,>=1.23
18
18
  Requires-Dist: oauthlib
19
- Requires-Dist: requests
20
- Requires-Dist: scipy
21
- Requires-Dist: threadpoolctl
22
- Requires-Dist: tqdm
23
- Requires-Dist: wheel
24
- Requires-Dist: wotan
19
+ Requires-Dist: requests<3.0,>=2.28
20
+ Requires-Dist: scipy<2.0,>=1.10
21
+ Requires-Dist: threadpoolctl<4.0,>=3.1
22
+ Requires-Dist: tqdm>=4.64
23
+ Requires-Dist: wotan~=1.9
25
24
  Requires-Dist: seaborn
25
+ Requires-Dist: pandas
26
+ Requires-Dist: importlib_resources
27
+ Dynamic: author
28
+ Dynamic: author-email
29
+ Dynamic: classifier
30
+ Dynamic: description
31
+ Dynamic: description-content-type
32
+ Dynamic: home-page
33
+ Dynamic: license-file
34
+ Dynamic: requires-dist
35
+ Dynamic: requires-python
36
+ Dynamic: summary
37
+
38
+ .. image:: https://raw.githubusercontent.com/TeHanHunter/TESS_Gaia_Light_Curve/main/logo/TGLC_Title.png
39
+ :width: 800
40
+ :alt: TESS-Gaia Light Curve
41
+
42
+ .. image:: https://zenodo.org/badge/420868490.svg
43
+ :target: https://zenodo.org/badge/latestdoi/420868490
44
+
45
+ .. image:: https://static.pepy.tech/personalized-badge/tglc?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Total%20Downloads
46
+ :target: https://pepy.tech/project/tglc
47
+
48
+ .. image:: https://img.shields.io/badge/Cite-TGLC-blue
49
+ :target: https://www.tomwagg.com/software-citation-station/?auto-select=tglc
26
50
 
27
51
  ==================================
28
52
  Introduction
@@ -30,6 +54,9 @@ Introduction
30
54
 
31
55
  TESS-Gaia Light Curve (`TGLC <https://archive.stsci.edu/hlsp/tglc>`_) is a dataset of TESS full-frame image light curves publicly available via the MAST portal. It is fitted with effective PSF and decontaminated with Gaia DR3 and achieved percent-level photometric precision down to 16th TESS magnitude! It unlocks astrophysics to a vast number of dim stars below 12th TESS magnitude. A package called tglc is pip-installable for customized light curve fits.
32
56
 
57
+ .. image:: https://raw.githubusercontent.com/TeHanHunter/TESS_Gaia_Light_Curve/main/logo/EB_comparison_git.png
58
+ :width: 800
59
+ :alt: EB light curve comparison to other pipeline
33
60
 
34
61
  ==================================
35
62
  Usage
@@ -1,28 +1,15 @@
1
- Metadata-Version: 2.1
2
- Name: tglc
3
- Version: 0.6.6
4
- Summary: TESS-Gaia Light Curve
5
- Home-page: https://github.com/TeHanHunter/TESS_Gaia_Light_Curve
6
- Author: Te Han
7
- Author-email: tehanhunter@gmail.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.8, <3.13
12
- Description-Content-Type: text/x-rst
13
- License-File: LICENSE
14
- Requires-Dist: astropy>=5.1
15
- Requires-Dist: astroquery==0.4.7
16
- Requires-Dist: matplotlib
17
- Requires-Dist: numpy
18
- Requires-Dist: oauthlib
19
- Requires-Dist: requests
20
- Requires-Dist: scipy
21
- Requires-Dist: threadpoolctl
22
- Requires-Dist: tqdm
23
- Requires-Dist: wheel
24
- Requires-Dist: wotan
25
- Requires-Dist: seaborn
1
+ .. image:: https://raw.githubusercontent.com/TeHanHunter/TESS_Gaia_Light_Curve/main/logo/TGLC_Title.png
2
+ :width: 800
3
+ :alt: TESS-Gaia Light Curve
4
+
5
+ .. image:: https://zenodo.org/badge/420868490.svg
6
+ :target: https://zenodo.org/badge/latestdoi/420868490
7
+
8
+ .. image:: https://static.pepy.tech/personalized-badge/tglc?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Total%20Downloads
9
+ :target: https://pepy.tech/project/tglc
10
+
11
+ .. image:: https://img.shields.io/badge/Cite-TGLC-blue
12
+ :target: https://www.tomwagg.com/software-citation-station/?auto-select=tglc
26
13
 
27
14
  ==================================
28
15
  Introduction
@@ -30,6 +17,9 @@ Introduction
30
17
 
31
18
  TESS-Gaia Light Curve (`TGLC <https://archive.stsci.edu/hlsp/tglc>`_) is a dataset of TESS full-frame image light curves publicly available via the MAST portal. It is fitted with effective PSF and decontaminated with Gaia DR3 and achieved percent-level photometric precision down to 16th TESS magnitude! It unlocks astrophysics to a vast number of dim stars below 12th TESS magnitude. A package called tglc is pip-installable for customized light curve fits.
32
19
 
20
+ .. image:: https://raw.githubusercontent.com/TeHanHunter/TESS_Gaia_Light_Curve/main/logo/EB_comparison_git.png
21
+ :width: 800
22
+ :alt: EB light curve comparison to other pipeline
33
23
 
34
24
  ==================================
35
25
  Usage
@@ -6,7 +6,7 @@ with open("README.rst", "r", encoding="utf-8") as fh:
6
6
  long_description = fh.read()
7
7
  setuptools.setup(
8
8
  name="tglc",
9
- version='0.6.6',
9
+ version='0.7.0',
10
10
  author="Te Han",
11
11
  author_email="tehanhunter@gmail.com",
12
12
  description="TESS-Gaia Light Curve",
@@ -18,8 +18,21 @@ setuptools.setup(
18
18
  "License :: OSI Approved :: MIT License",
19
19
  "Operating System :: OS Independent",
20
20
  ],
21
- install_requires=['astropy>=5.1', 'astroquery==0.4.7', 'matplotlib', 'numpy', 'oauthlib', 'requests', 'scipy',
22
- 'threadpoolctl', 'tqdm', 'wheel', 'wotan', 'seaborn'],
21
+ install_requires=[
22
+ 'astropy>=6.1,<6.2',
23
+ 'astroquery==0.4.7',
24
+ 'matplotlib>=3.8,<4.0',
25
+ 'numpy>=1.23,<2.0',
26
+ 'oauthlib',
27
+ 'requests>=2.28,<3.0',
28
+ 'scipy>=1.10,<2.0',
29
+ 'threadpoolctl>=3.1,<4.0',
30
+ 'tqdm>=4.64',
31
+ 'wotan~=1.9',
32
+ 'seaborn',
33
+ 'pandas',
34
+ 'importlib_resources',
35
+ ],
23
36
  packages=setuptools.find_packages(include=['tglc', 'tglc.*']),
24
37
  python_requires=">=3.8, <3.13",
25
38
  include_package_data=True
@@ -0,0 +1,3 @@
1
+ __version__ = "0.7.0"
2
+ __author__ = 'Te Han, Timothy Brandt'
3
+ __credits__ = 'University of California, Santa Barbara'
@@ -0,0 +1,107 @@
1
+ # Adapted from QLP: https://github.com/havijw/tess-time-correction/
2
+
3
+ from pathlib import Path
4
+ from astropy.coordinates import SkyCoord
5
+ from astropy.time import Time, TimeDelta, TimeFromEpoch
6
+ import astropy.units as u
7
+ import numpy as np
8
+ import pandas as pd
9
+
10
+ def get_ephemeris_file_path(sector: int) -> Path:
11
+ """Get the path to the appropriate TESS ephemeris data file for a given sector."""
12
+ ephemeris_data_directory = Path(__file__).resolve().parent / "ephemeris_data"
13
+ if 1 <= sector <= 5:
14
+ return ephemeris_data_directory / "20180720_tess_ephem.csv"
15
+ elif 6 <= sector <= 19:
16
+ return ephemeris_data_directory / "20190101_tess_ephem.csv"
17
+ elif 19 <= sector <= 32:
18
+ return ephemeris_data_directory / "20200101_tess_ephem.csv"
19
+ elif 33 <= sector <= 45:
20
+ return ephemeris_data_directory / "20210101_tess_ephem.csv"
21
+ elif 46 <= sector <= 59:
22
+ return ephemeris_data_directory / "20211215_tess_ephem.csv"
23
+ elif 60 <= sector <= 73:
24
+ return ephemeris_data_directory / "20221201_tess_ephem.csv"
25
+ elif 74 <= sector <= 87:
26
+ return ephemeris_data_directory / "20231201_tess_ephem.csv"
27
+ elif 88 <= sector <= 101:
28
+ return ephemeris_data_directory / "20241201_tess_ephem.csv"
29
+ else:
30
+ raise ValueError(
31
+ f"No spacecraft ephemeris file assigned for sector {sector}."
32
+ )
33
+
34
+ class TESSJD(TimeFromEpoch):
35
+ """
36
+ Define TJD as (JD - 2457000) and reported in units of days.
37
+
38
+ Importing this class registers the `"tjd"` format with `astropy.time`.
39
+ """
40
+
41
+ name = "tjd"
42
+ unit = 1
43
+ epoch_val = 2457000 * u.day
44
+ epoch_val2 = None
45
+ epoch_scale = "tdb"
46
+ epoch_format = "jd"
47
+
48
+
49
+ def apply_barycentric_correction(
50
+ sector: int, tjd: np.typing.ArrayLike, coord: SkyCoord
51
+ ) -> np.ndarray:
52
+ """
53
+ Apply barycentric time correction to timestamps in from a given sector.
54
+
55
+ Uses data from `ephmeris_data/` for TESS spacecraft position.
56
+ Uses vectorized operations so `tjd` and `coord` can be arrays.
57
+
58
+ Parameters
59
+ ----------
60
+ sector : int
61
+ Sector containing the time stamps that need to be corrected
62
+ tjd : ArrayLike
63
+ Timestamps (in days) as recorded on the TESS spacecraft
64
+ coord : SkyCoord
65
+ Sky coordinate(s) of the target star(s) for which correction is being applied
66
+
67
+ Returns
68
+ -------
69
+ btjd : Array
70
+ Barycentric JD, TDB timestamps.
71
+ If `coord` is a scalar, the array shape matches `tjd`.
72
+ Otherwise, an axis is added before axis 0 which corresponds to objects.
73
+ For instance, if `tjd` is a 1D array and `coord` is an array, the
74
+ returned array will have 1 row per coordinate.
75
+ """
76
+ input_times = Time(tjd, format="tjd", scale="tdb")
77
+
78
+ # Linearly interpolate spacecraft position at timestamps
79
+ ephemeris_data_file = get_ephemeris_file_path(sector)
80
+ tess_ephemeris = pd.read_csv(ephemeris_data_file, comment="#")
81
+ tess_spacecraft_x = np.interp(input_times.jd, tess_ephemeris["JDTDB"], tess_ephemeris["X"])
82
+ tess_spacecraft_y = np.interp(input_times.jd, tess_ephemeris["JDTDB"], tess_ephemeris["Y"])
83
+ tess_spacecraft_z = np.interp(input_times.jd, tess_ephemeris["JDTDB"], tess_ephemeris["Z"])
84
+ tess_spacecraft_position = np.array(
85
+ [tess_spacecraft_x, tess_spacecraft_y, tess_spacecraft_z]
86
+ ).T * u.au
87
+
88
+ # Calculate difference in light travel time to TESS vs solar system barycenter
89
+ star_vector = coord.cartesian.xyz
90
+ star_projection = np.dot(tess_spacecraft_position, star_vector).T
91
+ light_travel_time_delta = TimeDelta(
92
+ star_projection.to(u.lightsecond).value * u.second,
93
+ format="jd",
94
+ scale="tdb",
95
+ )
96
+ return (input_times + light_travel_time_delta).tjd
97
+
98
+ if __name__ == "__main__":
99
+ sector = 70
100
+ # Example MID_TJD timestamps from cadences 855745-855747 in camera 1
101
+ tjd = [3208.350463260291, 3208.352778074038, 3208.355092887784]
102
+ # Example values taken for TIC 2761238 and TIC 8939995
103
+ coord = SkyCoord(
104
+ [(356.485772436, -13.4999191877), (354.410412934, -8.16560533748)],
105
+ unit=u.deg,
106
+ )
107
+ print(apply_barycentric_correction(sector, tjd, coord))
@@ -204,6 +204,15 @@ def fit_lc(A, source, star_info=None, x=0., y=0., star_num=0, factor=2, psf_size
204
204
  aperture = aperture.reshape((len(source.time), up - down, right - left))
205
205
  target_5x5 = (np.dot(A_target, np.nanmedian(e_psf, axis=0)).reshape(cut_size, cut_size))
206
206
  field_stars_5x5 = (np.dot(A_cut, np.nanmedian(e_psf, axis=0)).reshape(cut_size, cut_size))
207
+ if target_5x5.shape != (cut_size, cut_size):
208
+ # Pad with nans to get to 5x5 shape
209
+ # Pad amount in a direction is (expected_num_pix) - (actual_num_pix)
210
+ pad_left = (cut_size // 2) - (x - left)
211
+ pad_right = (cut_size // 2 + 1) - (right - x)
212
+ pad_down = (cut_size // 2) - (y - down)
213
+ pad_up = (cut_size // 2 + 1) - (up - y)
214
+ target_5x5 = np.pad(target_5x5, [(pad_down, pad_up), (pad_left, pad_right)], constant_values=np.nan)
215
+ field_stars_5x5 = np.pad(field_stars_5x5, [(pad_down, pad_up), (pad_left, pad_right)], constant_values=np.nan)
207
216
 
208
217
  # psf_lc
209
218
  over_size = psf_size * factor + 1
@@ -212,7 +221,7 @@ def fit_lc(A, source, star_info=None, x=0., y=0., star_num=0, factor=2, psf_size
212
221
  psf_lc[:] = np.NaN
213
222
  e_psf_1d = np.nanmedian(e_psf[:, :over_size ** 2], axis=0).reshape(over_size, over_size)
214
223
  portion = (36 / 49) * np.nansum(e_psf_1d[8:15, 8:15]) / np.nansum(e_psf_1d) # only valid for factor = 2
215
- return aperture, psf_lc, y - down, x - left, portion
224
+ return aperture, psf_lc, y - down, x - left, portion, target_5x5, field_stars_5x5
216
225
  left_ = left - x + 5
217
226
  right_ = right - x + 5
218
227
  down_ = down - y + 5