tglc 0.6.5__py3-none-any.whl → 0.7.0__py3-none-any.whl

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.
tglc/target_lightcurve.py CHANGED
@@ -13,6 +13,10 @@ from os.path import exists
13
13
  from tglc.effective_psf import get_psf, fit_psf, fit_lc, fit_lc_float_field, bg_mod
14
14
  from tglc.ffi import Source
15
15
  from tglc.ffi_cut import Source_cut
16
+ import tglc
17
+ from astropy.coordinates import SkyCoord
18
+ from tglc.barycentric_correction import apply_barycentric_correction
19
+ import astropy.units as u
16
20
 
17
21
  warnings.simplefilter('always', UserWarning)
18
22
 
@@ -20,7 +24,7 @@ warnings.simplefilter('always', UserWarning)
20
24
  def lc_output(source, local_directory='', index=0, time=None, psf_lc=None, cal_psf_lc=None, aper_lc=None,
21
25
  cal_aper_lc=None, bg=None, tess_flag=None, tglc_flag=None, cadence=None, aperture=None,
22
26
  cut_x=None, cut_y=None, star_x=2, star_y=2, x_aperture=None, y_aperture=None, near_edge=False,
23
- local_bg=None, save_aper=False, portion=1, prior=None, transient=None):
27
+ local_bg=None, save_aper=False, portion=1, prior=None, transient=None, target_5x5=None, field_stars_5x5=None, ffi='TICA'):
24
28
  """
25
29
  lc output to .FITS file in MAST HLSP standards
26
30
  :param tglc_flag: np.array(), required
@@ -45,7 +49,7 @@ def lc_output(source, local_directory='', index=0, time=None, psf_lc=None, cal_p
45
49
  objid = [int(s) for s in (source.gaia[index]['DESIGNATION']).split() if s.isdigit()][0]
46
50
  else:
47
51
  objid = transient[0]
48
- source_path = f'{local_directory}hlsp_tglc_tess_ffi_gaiaid-{objid}-s{source.sector:04d}-cam{source.camera}-ccd{source.ccd}_tess_v1_llc.fits'
52
+ source_path = f'{local_directory}hlsp_tglc_tess_ffi_gaiaid-{objid}-s{source.sector:04d}-cam{source.camera}-ccd{source.ccd}_tess_v2_llc.fits'
49
53
  source_exists = exists(source_path)
50
54
  # if source_exists and (os.path.getsize(source_path) > 0):
51
55
  # print('LC exists, please (re)move the file if you wish to overwrite.')
@@ -82,6 +86,13 @@ def lc_output(source, local_directory='', index=0, time=None, psf_lc=None, cal_p
82
86
  primary_hdu = fits.PrimaryHDU(aperture)
83
87
  else:
84
88
  primary_hdu = fits.PrimaryHDU()
89
+ # Simulated star images based on ePSF, used to estimate contamination ratio and others
90
+ image_data = np.zeros((3, 5, 5))
91
+ image_data[0] = target_5x5
92
+ image_data[1] = field_stars_5x5
93
+ # This is the pixel-wise contamination ratio
94
+ image_data[2] = field_stars_5x5/target_5x5
95
+ image_hdu = fits.ImageHDU(data=image_data)
85
96
 
86
97
  primary_hdu.header = fits.Header(cards=[
87
98
  fits.Card('SIMPLE', True, 'conforms to FITS standard'),
@@ -96,9 +107,11 @@ def lc_output(source, local_directory='', index=0, time=None, psf_lc=None, cal_p
96
107
  fits.Card('STAR_Y', y_aperture, 'star y position in cut'),
97
108
  fits.Card('COMMENT', 'hdul[0].data[:,star_y,star_x]=lc'),
98
109
  fits.Card('ORIGIN', 'UCSB/TGLC', 'institution responsible for creating this file'),
110
+ fits.Card('TGLCVER', f'{tglc.__version__}', 'TGLC version'),
99
111
  fits.Card('TELESCOP', 'TESS', 'telescope'),
100
112
  fits.Card('INSTRUME', 'TESS Photometer', 'detector type'),
101
113
  fits.Card('FILTER', 'TESS', 'the filter used for the observations'),
114
+ fits.Card('FFIVER', ffi, 'the FFI product used (SPOC/TICA)'),
102
115
  fits.Card('OBJECT', source.gaia[index]['DESIGNATION'], 'string version of Gaia DR3 ID'),
103
116
  fits.Card('GAIADR3', objid, 'integer version of Gaia DR3 ID'),
104
117
  fits.Card('TICID', ticid, 'TESS Input Catalog ID'),
@@ -116,6 +129,7 @@ def lc_output(source, local_directory='', index=0, time=None, psf_lc=None, cal_p
116
129
  fits.Card('GAIA_bp', gaia_bp, 'Gaia DR3 bp band magnitude'),
117
130
  fits.Card('GAIA_rp', gaia_rp, 'Gaia DR3 rp band magnitude'),
118
131
  fits.Card('RAWFLUX', raw_flux, 'median flux of raw FFI'),
132
+ fits.Card('CONTAMRT', round(np.nansum(field_stars_5x5[1:4,1:4])/np.nansum(target_5x5[1:4,1:4]), 9), 'contamination ratio of default 3*3 aperture'),
119
133
  fits.Card('CALIB', 'TGLC', 'pipeline used for image calibration')])
120
134
  if save_aper:
121
135
  primary_hdu.header.comments['NAXIS1'] = "Time (hdul[1].data['time'])"
@@ -130,7 +144,19 @@ def lc_output(source, local_directory='', index=0, time=None, psf_lc=None, cal_p
130
144
  exposure_time = 600
131
145
  else: # second extended
132
146
  exposure_time = 200
133
- c1 = fits.Column(name='time', array=np.array(time), format='D')
147
+
148
+ ### barycentric correction for TICA
149
+ if ffi == 'TICA':
150
+ sector = source.sector
151
+ tjd = time
152
+ coord = SkyCoord([(source.gaia[index]['ra'], source.gaia[index]['dec'])], unit=u.deg,)
153
+ time_bcc = apply_barycentric_correction(sector, tjd, coord)[0]
154
+ elif ffi == 'SPOC':
155
+ time_bcc = np.array(time)
156
+ else:
157
+ raise ValueError('ffi must be either TICA or SPOC')
158
+
159
+ c1 = fits.Column(name='time', array=np.array(time_bcc), format='D')
134
160
  c2 = fits.Column(name='psf_flux', array=np.array(psf_lc), format='E') # psf factor
135
161
  # c3 = fits.Column(name='psf_flux_err',
136
162
  # array=1.4826 * np.median(np.abs(psf_lc - np.median(psf_lc))) * np.ones(len(psf_lc)), format='E')
@@ -152,7 +178,7 @@ def lc_output(source, local_directory='', index=0, time=None, psf_lc=None, cal_p
152
178
  table_hdu = fits.BinTableHDU.from_columns([c1, c2, c4, c6, c8, c10, c11, c12, c13])
153
179
  table_hdu.header.append(('INHERIT', 'T', 'inherit the primary header'), end=True)
154
180
  table_hdu.header.append(('EXTNAME', 'LIGHTCURVE', 'name of extension'), end=True)
155
- table_hdu.header.append(('EXTVER', 1, 'extension version'), # TODO: version?
181
+ table_hdu.header.append(('EXTVER', 1, 'extension version'),
156
182
  end=True)
157
183
  table_hdu.header.append(('TELESCOP', 'TESS', 'telescope'), end=True)
158
184
  table_hdu.header.append(('INSTRUME', 'TESS Photometer', 'detector type'), end=True)
@@ -190,14 +216,15 @@ def lc_output(source, local_directory='', index=0, time=None, psf_lc=None, cal_p
190
216
  if type(prior) == float:
191
217
  table_hdu.header.append(('PRIOR', prior, 'prior of field stars'), end=True)
192
218
 
193
- hdul = fits.HDUList([primary_hdu, table_hdu])
219
+ hdul = fits.HDUList([primary_hdu, table_hdu, image_hdu])
194
220
  hdul.writeto(
195
- f'{local_directory}hlsp_tglc_tess_ffi_gaiaid-{objid}-s{source.sector:04d}-cam{source.camera}-ccd{source.ccd}_tess_v1_llc.fits',
221
+ f'{local_directory}hlsp_tglc_tess_ffi_gaiaid-{objid}-s{source.sector:04d}-cam{source.camera}-ccd{source.ccd}_tess_v2_llc.fits',
196
222
  overwrite=True)
197
223
  return
198
224
 
199
225
 
200
- def epsf(source, psf_size=11, factor=2, local_directory='', target=None, cut_x=0, cut_y=0, sector=0,
226
+
227
+ def epsf(source, psf_size=11, factor=2, local_directory='', target=None, cut_x=0, cut_y=0, sector=0, ffi='TICA',
201
228
  limit_mag=16, edge_compression=1e-4, power=1.4, name=None, save_aper=False, no_progress_bar=False, prior=None):
202
229
  """
203
230
  User function that unites all necessary steps
@@ -310,7 +337,7 @@ def epsf(source, psf_size=11, factor=2, local_directory='', target=None, cut_x=0
310
337
  fit_lc_float_field(A, source, star_info=star_info, x=x_round, y=y_round, star_num=i, e_psf=e_psf,
311
338
  near_edge=near_edge, prior=prior)
312
339
  else:
313
- aperture, psf_lc, star_y, star_x, portion = \
340
+ aperture, psf_lc, star_y, star_x, portion, target_5x5, field_stars_5x5 = \
314
341
  fit_lc(A, source, star_info=star_info, x=x_round[i], y=y_round[i], star_num=i, e_psf=e_psf,
315
342
  near_edge=near_edge)
316
343
  aper_lc = np.sum(
@@ -347,16 +374,17 @@ def epsf(source, psf_size=11, factor=2, local_directory='', target=None, cut_x=0
347
374
  lc_output(source, local_directory=lc_directory, index=i,
348
375
  tess_flag=source.quality, cut_x=cut_x, cut_y=cut_y, cadence=source.cadence,
349
376
  aperture=aperture.astype(np.float32), star_y=y_round[i], star_x=x_round[i], tglc_flag=quality,
377
+ ffi='SPOC',
350
378
  bg=background_, time=source.time, psf_lc=psf_lc, cal_psf_lc=cal_psf_lc, aper_lc=aper_lc,
351
379
  cal_aper_lc=cal_aper_lc, local_bg=local_bg, x_aperture=x_aperture[i],
352
380
  y_aperture=y_aperture[i], near_edge=near_edge, save_aper=save_aper, portion=portion,
353
- prior=prior)
381
+ prior=prior, transient=source.transient, target_5x5=target_5x5, field_stars_5x5=field_stars_5x5)
354
382
  else:
355
383
  lc_output(source, local_directory=lc_directory, index=i,
356
384
  tess_flag=source.quality, cut_x=cut_x, cut_y=cut_y, cadence=source.cadence,
357
385
  aperture=aperture.astype(np.float32), star_y=y_round[i], star_x=x_round[i],
358
- tglc_flag=quality,
386
+ tglc_flag=quality, ffi=ffi,
359
387
  bg=background_, time=source.time, psf_lc=psf_lc, cal_psf_lc=cal_psf_lc, aper_lc=aper_lc,
360
388
  cal_aper_lc=cal_aper_lc, local_bg=local_bg, x_aperture=x_aperture[i],
361
389
  y_aperture=y_aperture[i], near_edge=near_edge, save_aper=save_aper, portion=portion,
362
- prior=prior, transient=source.transient)
390
+ prior=prior, transient=source.transient, target_5x5=target_5x5, field_stars_5x5=field_stars_5x5)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: tglc
3
- Version: 0.6.5
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
@@ -8,20 +8,45 @@ Author-email: tehanhunter@gmail.com
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.8
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
15
- Requires-Dist: astroquery
16
- Requires-Dist: matplotlib
17
- Requires-Dist: numpy
14
+ Requires-Dist: astropy<6.2,>=6.1
15
+ Requires-Dist: astroquery==0.4.7
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
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
25
50
 
26
51
  ==================================
27
52
  Introduction
@@ -29,6 +54,10 @@ Introduction
29
54
 
30
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.
31
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
60
+
32
61
  ==================================
33
62
  Usage
34
63
  ==================================
@@ -0,0 +1,28 @@
1
+ tglc/__init__.py,sha256=mRui0a1UV8tt2htxZtyh6RsP2hgeU-0chLUIwgniJl4,116
2
+ tglc/barycentric_correction.py,sha256=hNqlzPunRFuRKoUDsBirsFaDLNUYbPCt5BUN3cGcEtc,4166
3
+ tglc/effective_psf.py,sha256=iaq_dFlReximmb2dlKIOtfqWAQCpSPJEo1eQGoxpWZ0,23575
4
+ tglc/ffi.py,sha256=1_3o849Vaiek5TaQGTWPR1f8qmEku8q9TEIrfkP918w,15718
5
+ tglc/ffi_cut.py,sha256=2yKBuYWp8KrIx2zwOmGMIOog1aoGPQiV29BAgf5rP5w,15971
6
+ tglc/lc_plot.py,sha256=-1wsw3mu0yxDGAEKNxB55Nv9-JQqVt44lB1DJCZbq7I,136246
7
+ tglc/mast.py,sha256=SyLTL6DCp2N_ZK3IwqG6_EISzjlptU_5414BYgPXPRM,4331
8
+ tglc/quick_lc.py,sha256=IgtY9dI5oCHH91n-fzF_pChWFgL4eB6eHPpm6R1TVFw,35610
9
+ tglc/run.py,sha256=exHt6VbrDVHKhho63p_3K-eCM2VRPEkArh7vO3-EgcQ,4123
10
+ tglc/source_output.py,sha256=zdCsgDjc2MB9_bPWlCoKMZjR3SMBZvorM6tIgbcQ7As,3171
11
+ tglc/target_lightcurve.py,sha256=Fso6hK1lFS1aHXNmivNqWcTreGgW2-nEdCKBeZ_mgFQ,22162
12
+ tglc/background_mask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ tglc/background_mask/median_mask.fits,sha256=1manbdxSQ_x780Puk8Lm4zDZOaEghknc2LbZA8J6P-Q,267840
14
+ tglc/ephemeris_data/20180720_tess_ephem.csv,sha256=aN4HDJrj7bLYZHAVMy_bregFi9WGS1-nOIY5NL2Zru4,2002174
15
+ tglc/ephemeris_data/20190101_tess_ephem.csv,sha256=WqA6LrDLzD80ilcvaNUqJBqQNbFEUXuZ_BQnahJlOHw,1856649
16
+ tglc/ephemeris_data/20200101_tess_ephem.csv,sha256=4VkN3uJxfsQRU43gVb2huDZEqXKw5Qxv_a3pjOra_f4,1861337
17
+ tglc/ephemeris_data/20210101_tess_ephem.csv,sha256=W9LUTH6sWeSOb1OZ6GWZqNBBeOC6j7ph6cd_tNbL_LQ,1786260
18
+ tglc/ephemeris_data/20211215_tess_ephem.csv,sha256=ZLwZAFjYeLtNZoF_ZM1WHx7poe-qFwzslVW0UvJjFwg,2414158
19
+ tglc/ephemeris_data/20221201_tess_ephem.csv,sha256=r8TnisAwUEPVPOnbXU9D1sgLci4B0VP_PpoIx5zVMi8,1998220
20
+ tglc/ephemeris_data/20231201_tess_ephem.csv,sha256=fFC7foLrhSy_YmJkAtWjyDIAK45VHFR-DLH0O2Wp9fM,2003394
21
+ tglc/ephemeris_data/20241201_tess_ephem.csv,sha256=V3gTJ1gNiS9lj1qmCr4vz5GrbRVBC16P3TvaUmU4FJw,1998712
22
+ tglc/ephemeris_data/README.md,sha256=BHGQ9tC3OThbnyf2ArCACkjUmGeyQLm4_BPjwXCfu0Q,2472
23
+ tglc/ephemeris_data/plot_ephemerides.py,sha256=txnHg3LzRKAH1s2pCMjaL4RZOi09fGaqBX78XMKeuo0,1750
24
+ tglc-0.7.0.dist-info/licenses/LICENSE,sha256=BP8oVkBHG81Tn8BrmTDDrn_i1L_jPpP16pqiqxSZHpw,1063
25
+ tglc-0.7.0.dist-info/METADATA,sha256=CLDVMdiL9jWo29Y0X6uBc2Rg9h4_wiVUNK4R9TBWIpk,6711
26
+ tglc-0.7.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
27
+ tglc-0.7.0.dist-info/top_level.txt,sha256=EaP_Ye331aCwisaGDcjQy4LIHXHfD3mL4D1ZiopvGMk,5
28
+ tglc-0.7.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,17 +0,0 @@
1
- tglc/__init__.py,sha256=_5LSqxLOO4-Aoa5wHuErEHALMwJSjZbatc9k8-StWcE,115
2
- tglc/effective_psf.py,sha256=S9W7iKdr2amxWO-2eGtxS45X9w4f4ennJN812T8MFyI,22712
3
- tglc/ffi.py,sha256=8J-BFUbseomP6r00PgjMS-Ize5n1vfH9U8R0T6DdJAE,15656
4
- tglc/ffi_cut.py,sha256=mPl-8gQK0sPjI0Tq0rbltOjdejqmbVJ_pEETBhKyEQU,11969
5
- tglc/lc_plot.py,sha256=-1wsw3mu0yxDGAEKNxB55Nv9-JQqVt44lB1DJCZbq7I,136246
6
- tglc/mast.py,sha256=SyLTL6DCp2N_ZK3IwqG6_EISzjlptU_5414BYgPXPRM,4331
7
- tglc/quick_lc.py,sha256=CFzZEPT02HLwFkCcZEWzNyMzjDvbcKjsR3N14CF5JQE,31541
8
- tglc/run.py,sha256=exHt6VbrDVHKhho63p_3K-eCM2VRPEkArh7vO3-EgcQ,4123
9
- tglc/source_output.py,sha256=zdCsgDjc2MB9_bPWlCoKMZjR3SMBZvorM6tIgbcQ7As,3171
10
- tglc/target_lightcurve.py,sha256=olJelItQ4Qs_0YXxYO7Ulg8EyGIDCwbudmhpSVBIPdk,20692
11
- tglc/background_mask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- tglc/background_mask/median_mask.fits,sha256=1manbdxSQ_x780Puk8Lm4zDZOaEghknc2LbZA8J6P-Q,267840
13
- tglc-0.6.5.dist-info/LICENSE,sha256=BP8oVkBHG81Tn8BrmTDDrn_i1L_jPpP16pqiqxSZHpw,1063
14
- tglc-0.6.5.dist-info/METADATA,sha256=qGoqA7AxK9BBcJti1PhNLvcvQ0JNA85QAUkFQAUiWgk,5575
15
- tglc-0.6.5.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
16
- tglc-0.6.5.dist-info/top_level.txt,sha256=EaP_Ye331aCwisaGDcjQy4LIHXHfD3mL4D1ZiopvGMk,5
17
- tglc-0.6.5.dist-info/RECORD,,