tglc 0.6.0__tar.gz → 0.6.2__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.
tglc-0.6.2/PKG-INFO ADDED
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.1
2
+ Name: tglc
3
+ Version: 0.6.2
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
+ License: UNKNOWN
9
+ Description: ==================================
10
+ Introduction
11
+ ==================================
12
+
13
+ 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.
14
+
15
+
16
+ ==================================
17
+ Usage
18
+ ==================================
19
+ There are four fluxes in each FITS file: aperture flux, PSF flux, calibrated aperture flux, and calibrated PSF flux.
20
+ If you are uncertain which to use:
21
+
22
+ * Calibrated psf flux is better in **deblending** targets. Use this if you need to deblend a target near a variable source. The best deblending can be achieved with tglc package by setting a non-zero prior. It also gives the more accurate **transit depth** in most cases, especially when fitting with an optimized prior.
23
+ * Calibrated aperture flux usually has slightly **higher SNR**. The transit depth (or variation amplitude), however, can be imperfect since the normalization depends on the PSF fitting which is imperfect. This imperfection can be minimized by using a bigger aperture than the default aperture (3*3). One need to use the tglc package and set tglc_lc(save_aper=True) to access the 5*5 aperture. In the presence of a bright but "constant" contamination (several magnitudes brighter), the calibrated aperture flux is better in removing the constant contamination.
24
+ * The aperture flux and PSF flux are not detrended or normalized. Use this if you are doing stellar variability science with long baseline. Or, if the detrending is not optimal (default detrending has a window length of 1 day; see Known Problems below), start with the aperture flux or PSF flux and detrend carefully!
25
+ * **If you are uncertain, start with calibrated aperture flux!**
26
+
27
+ The `tutorial <tutorial/TGLC_tutorial.ipynb>`_ shows the syntaxes and differences among these light curves in several examples.
28
+
29
+ ==================================
30
+ Data Access
31
+ ==================================
32
+ There are three data access methods:
33
+
34
+ * MAST Portal: Easiest for acquiring light curves for a few stars. However, new sectors are updated relatively slowly.
35
+ * MAST bulk download: Best for downloading light curves for all stars (<16 TESS magnitude) in a sectors.
36
+ * tglc package: Capable of producing similar quality light curves for any sector and any star with custom options.
37
+
38
+ MAST Portal/bulk download
39
+ ----------------------------
40
+ The easiest usage requires no package installation. Simply follow the `TGLC HLSP page <https://archive.stsci.edu/hlsp/tglc>`_ to download light curves from MAST or use `MAST Portal <https://mast.stsci.edu/portal/Mashup/Clients/Mast/Portal.html>`_. Light curves are being fitted sector by sector and will be available on MAST gradually. MAST hosts all Gaia DR3 stars down to 16th magnitude. Each .fits file includes PSF and aperture light curves and their calibrated versions.
41
+
42
+ MAST available sectors: `sector worklist <https://docs.google.com/spreadsheets/d/1FhHElWb1wmx9asWiZecAJ2umN0-P_aXn55OBVB34_rg/edit?usp=sharing>`_
43
+
44
+
45
+ tglc package
46
+ ----------------------------
47
+ Users can also fit light curves using the package tglc. Using tglc, one can specify a region, sector(s), and customized aperture shape if needed. It can also allow all field stars to float by assigning Gaussian priors, which can help decontaminate variable field stars. tglc is currently only available for linux. Run::
48
+
49
+ pip install tglc
50
+
51
+ for the latest tglc release. After installation, follow the `tutorial <tutorial/TGLC_tutorial.ipynb>`_ to fit light curves. If there is a problem, please leave a comment in the Issues section to help us improve. Thank you!
52
+
53
+
54
+ ==================================
55
+ Known Problems
56
+ ==================================
57
+ There are several imperfections we noticed in the MAST TGLC light curves and tglc package:
58
+
59
+ * If the star is very dim (~< 15 Tmag) near a variable source, it can make the aperture and/or PSF light curve negative for some cadences. The detrending algorithm could malfunction and result in bad cal_aper_flux and/or cal_psf_flux. This is now fixed for tglc package, but this problem remains for the primary mission light curves published on MAST. Please detrend again if necessary. The extended mission light curves on MAST will not be affected. This is a very rare scenario, but could be important.
60
+
61
+ ==================================
62
+ Reference
63
+ ==================================
64
+ If you find the TGLC light curves or the tglc package useful in your research, please cite `our paper <https://iopscience.iop.org/article/10.3847/1538-3881/acaaa7>`_ published on the Astronomical Journal.
65
+
66
+ Platform: UNKNOWN
67
+ Classifier: Programming Language :: Python :: 3
68
+ Classifier: License :: OSI Approved :: MIT License
69
+ Classifier: Operating System :: OS Independent
70
+ Requires-Python: >=3.8
71
+ Description-Content-Type: text/x-rst
@@ -4,6 +4,7 @@ Introduction
4
4
 
5
5
  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.
6
6
 
7
+
7
8
  ==================================
8
9
  Usage
9
10
  ==================================
@@ -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.0',
9
+ version='0.6.2',
10
10
  author="Te Han",
11
11
  author_email="tehanhunter@gmail.com",
12
12
  description="TESS-Gaia Light Curve",
@@ -0,0 +1,3 @@
1
+ __version__ = "0.6.2"
2
+ __author__ = 'Te Han, Timothy Brandt'
3
+ __credits__ = 'University of California, Santa Barbara'
@@ -447,7 +447,10 @@ def bg_mod(source, q=None, aper_lc=None, psf_lc=None, portion=None, star_num=0,
447
447
  if np.isnan(local_bg):
448
448
  local_bg = 0
449
449
  psf_lc = psf_lc - local_bg
450
-
450
+ negative_arg_aper = np.where(aper_lc <= 0) # Negative frames
451
+ aper_lc[negative_arg_aper] = np.nan
452
+ negative_arg_psf = np.where(psf_lc <= 0)
453
+ psf_lc[negative_arg_psf] = np.nan
451
454
  # removes very large outliers to prevent wotan to freeze
452
455
  cal_aper_lc = aper_lc / np.nanmedian(aper_lc)
453
456
  cal_aper_lc[np.where(cal_aper_lc > 100)] = np.nan
@@ -203,7 +203,9 @@ class Source(object):
203
203
  self.mask = mask[y:y + size, x:x + size]
204
204
  self.time = np.array(time)
205
205
  median_time = np.median(self.time)
206
- interval = (median_time - 388.5) / 365.25
206
+ interval = (median_time + 388.5) / 365.25
207
+ # Julian Day Number: 2457000.0 (TBJD=0)
208
+ # Calendar Date/Time: 2014-12-08 12:00:00 388.5 days before J2016
207
209
 
208
210
  num_gaia = len(catalogdata)
209
211
  tic_id = np.zeros(num_gaia)
@@ -282,6 +284,7 @@ def ffi(ccd=1, camera=1, sector=1, size=150, local_directory='', producing_mask=
282
284
  path to the FFI folder
283
285
  :return:
284
286
  """
287
+ # input_files = glob(f'/pdo/spoc-data/sector-{sector:03d}/ffi*/**/*{camera}-{ccd}-????-?_ffic.fits*')
285
288
  input_files = glob(f'{local_directory}ffi/*{camera}-{ccd}-????-?_ffic.fits')
286
289
  print('camera: ' + str(camera) + ' ccd: ' + str(ccd) + ' num of files: ' + str(len(input_files)))
287
290
  time = []
@@ -315,7 +318,8 @@ def ffi(ccd=1, camera=1, sector=1, size=150, local_directory='', producing_mask=
315
318
  # for i in range(len(time)):
316
319
  # mask[np.where(flux[i] > np.percentile(flux[i], 99.95))] = False
317
320
  # mask[np.where(flux[i] < np.median(flux[i]) / 2)] = False
318
-
321
+ if np.min(np.diff(cadence)) != 1:
322
+ np.save(f'{local_directory}/Wrong_Cadence_sector{sector:04d}_cam{camera}_ccd{ccd}.npy', np.min(np.diff(cadence)))
319
323
  if producing_mask:
320
324
  median_flux = np.median(flux, axis=0)
321
325
  mask = background_mask(im=median_flux)
@@ -117,7 +117,7 @@ class Source_cut(object):
117
117
  data_time = hdu[1].data['TIME']
118
118
  data_flux = hdu[1].data['FLUX']
119
119
  data_flux_err = hdu[1].data['FLUX_ERR']
120
- # data_quality = hdu[1].data['QUALITY']
120
+ data_quality = hdu[1].data['QUALITY']
121
121
  # data_time = data_time[np.where(data_quality == 0)]
122
122
  # data_flux = data_flux[np.where(data_quality == 0), :, :][0]
123
123
  # data_flux_err = data_flux_err[np.where(data_quality == 0), :, :][0]
@@ -125,9 +125,9 @@ class Source_cut(object):
125
125
  self.time = data_time
126
126
  self.flux = data_flux
127
127
  self.flux_err = data_flux_err
128
- self.quality = np.zeros(len(data_time))
128
+ self.quality = data_quality
129
129
  median_time = np.median(data_time)
130
- interval = (median_time - 388.5) / 365.25
130
+ interval = (median_time + 388.5) / 365.25
131
131
 
132
132
  mask = np.ones(np.shape(data_flux[0]))
133
133
  bad_pixels = np.zeros(np.shape(data_flux[0]))
@@ -14,6 +14,7 @@ from astroquery.mast import Catalogs
14
14
  import astropy.units as u
15
15
  from astropy.coordinates import SkyCoord
16
16
  from astroquery.mast import Tesscut
17
+ # Tesscut._service_api_connection.TIMEOUT = 6000
17
18
 
18
19
  # warnings.simplefilter('ignore', UserWarning)
19
20
  from threadpoolctl import ThreadpoolController, threadpool_limits
@@ -43,7 +44,8 @@ def tglc_lc(target='TIC 264468702', local_directory='', size=90, save_aper=True,
43
44
  sector = 'first'
44
45
  elif last_sector_only:
45
46
  sector = 'last'
46
- target_ = Catalogs.query_object(target, radius=21 * 0.707 / 3600, catalog="Gaia", version=2)
47
+ print(f'Target: {target}')
48
+ target_ = Catalogs.query_object(target, radius=42 * 0.707 / 3600, catalog="Gaia", version=2)
47
49
  if len(target_) == 0:
48
50
  target_ = Catalogs.query_object(target.name, radius=5 * 21 * 0.707 / 3600, catalog="Gaia", version=2)
49
51
  ra = target_[0]['ra']
@@ -103,7 +105,7 @@ def tglc_lc(target='TIC 264468702', local_directory='', size=90, save_aper=True,
103
105
  else:
104
106
  print(
105
107
  f'Processing all available sectors of the target in a single run. Note that if the number of sectors is '
106
- f'large, the download is likely to cause a timeout error from MAST.')
108
+ f'large, the download might cause a timeout error from MAST.')
107
109
  print('Downloading Data from MAST and Gaia ...')
108
110
  source = ffi_cut(target=target, size=size, local_directory=local_directory, sector=sector,
109
111
  limit_mag=limit_mag, transient=transient) # sector
@@ -127,6 +129,30 @@ def search_stars(i, sector=1, tics=None, local_directory=None):
127
129
  pass
128
130
 
129
131
 
132
+ def timebin(time, meas, meas_err, binsize):
133
+ ind_order = np.argsort(time)
134
+ time = time[ind_order]
135
+ meas = meas[ind_order]
136
+ meas_err = meas_err[ind_order]
137
+ ct = 0
138
+ while ct < len(time):
139
+ ind = np.where((time >= time[ct]) & (time < time[ct] + binsize))[0]
140
+ num = len(ind)
141
+ wt = (1. / meas_err[ind]) ** 2. # weights based in errors
142
+ wt = wt / np.sum(wt) # normalized weights
143
+ if ct == 0:
144
+ time_out = [np.sum(wt * time[ind])]
145
+ meas_out = [np.sum(wt * meas[ind])]
146
+ meas_err_out = [1. / np.sqrt(np.sum(1. / (meas_err[ind]) ** 2))]
147
+ else:
148
+ time_out.append(np.sum(wt * time[ind]))
149
+ meas_out.append(np.sum(wt * meas[ind]))
150
+ meas_err_out.append(1. / np.sqrt(np.sum(1. / (meas_err[ind]) ** 2)))
151
+ ct += num
152
+
153
+ return time_out, meas_out, meas_err_out
154
+
155
+
130
156
  def star_spliter(server=1, # or 2
131
157
  tics=None, local_directory=None):
132
158
  for i in range(server, 27, 2):
@@ -135,8 +161,8 @@ def star_spliter(server=1, # or 2
135
161
  return
136
162
 
137
163
 
138
- def plot_lc(local_directory=None, type='cal_aper_flux'):
139
- files = glob(f'{local_directory}*.fits')
164
+ def plot_lc(local_directory=None, type='cal_aper_flux', xlow=None, xhigh=None, ylow=None, yhigh=None):
165
+ files = glob(f'{local_directory}lc/*.fits')
140
166
  os.makedirs(f'{local_directory}plots/', exist_ok=True)
141
167
  for i in range(len(files)):
142
168
  with fits.open(files[i], mode='denywrite') as hdul:
@@ -144,8 +170,8 @@ def plot_lc(local_directory=None, type='cal_aper_flux'):
144
170
  plt.figure(constrained_layout=False, figsize=(8, 4))
145
171
  plt.plot(hdul[1].data['time'], hdul[1].data[type], '.', c='silver', label=type)
146
172
  plt.plot(hdul[1].data['time'][q], hdul[1].data[type][q], '.k', label=f'{type}_flagged')
147
- # plt.xlim(2753, 2755)
148
- # plt.ylim(0.7, 1.1)
173
+ plt.xlim(xlow, xhigh)
174
+ plt.ylim(ylow, yhigh)
149
175
  plt.title(f'TIC_{hdul[0].header["TICID"]}_sector_{hdul[0].header["SECTOR"]:04d}_{type}')
150
176
  plt.legend()
151
177
  # plt.show()
@@ -200,15 +226,21 @@ def plot_aperture(local_directory=None, type='cal_aper_flux'):
200
226
  np.savetxt(f'{local_directory}TESS_TOI-5344_5_5_aper.csv', data, delimiter=',')
201
227
 
202
228
 
203
- def plot_pf_lc(local_directory=None, period=None, type='cal_aper_flux'):
229
+ def plot_pf_lc(local_directory=None, period=None, mid_transit_tbjd=None, type='cal_aper_flux'):
204
230
  files = glob(f'{local_directory}*.fits')
205
231
  os.makedirs(f'{local_directory}plots/', exist_ok=True)
206
232
  fig = plt.figure(figsize=(13, 5))
233
+ t_all = np.array([])
234
+ f_all = np.array([])
235
+ f_err_all = np.array([])
207
236
  for j in range(len(files)):
208
237
  not_plotted_num = 0
209
238
  with fits.open(files[j], mode='denywrite') as hdul:
210
239
  q = [a and b for a, b in
211
240
  zip(list(hdul[1].data['TESS_flags'] == 0), list(hdul[1].data['TGLC_flags'] == 0))]
241
+ # q = [a and b for a, b in zip(q, list(hdul[1].data[type] > 0.85))]
242
+ # if hdul[0].header['sector'] == 15:
243
+ # q = [a and b for a, b in zip(q, list(hdul[1].data['time'] < 1736))]
212
244
  if len(hdul[1].data['cal_aper_flux']) == len(hdul[1].data['time']):
213
245
  if hdul[0].header["SECTOR"] <= 26:
214
246
  t = hdul[1].data['time'][q]
@@ -221,9 +253,18 @@ def plot_pf_lc(local_directory=None, period=None, type='cal_aper_flux'):
221
253
  t = np.mean(hdul[1].data['time'][q][:len(hdul[1].data['time'][q]) // 9 * 9].reshape(-1, 9), axis=1)
222
254
  f = np.mean(
223
255
  hdul[1].data[type][q][:len(hdul[1].data[type][q]) // 9 * 9].reshape(-1, 9), axis=1)
224
- plt.plot(hdul[1].data['time'] % period / period, hdul[1].data[type], '.', c='silver', ms=2)
225
- plt.errorbar(t % period / period, f, hdul[1].header['CAPE_ERR'], c=f'C{j}', ls='', elinewidth=1,
226
- marker='.', ms=2, zorder=2, label=f'Sector {hdul[0].header["sector"]}')
256
+ t_all = np.append(t_all, t)
257
+ f_all = np.append(f_all, f)
258
+ f_err_all = np.append(f_err_all, np.array([hdul[1].header['CAPE_ERR']] * len(t)))
259
+
260
+ # plt.plot(hdul[1].data['time'] % period / period, hdul[1].data[type], '.', c='silver', ms=3)
261
+ plt.errorbar(t % period / period, f, hdul[1].header['CAPE_ERR'], c='silver', ls='', elinewidth=1.5,
262
+ marker='.', ms=3, zorder=2)
263
+ # time_out, meas_out, meas_err_out = timebin(time=t % period, meas=f,
264
+ # meas_err=np.array([hdul[1].header['CAPE_ERR']] * len(t)),
265
+ # binsize=600 / 86400)
266
+ # plt.errorbar(np.array(time_out) / period, meas_out, meas_err_out, c=f'C{j}', ls='', elinewidth=1.5,
267
+ # marker='.', ms=8, zorder=3, label=f'Sector {hdul[0].header["sector"]}')
227
268
  else:
228
269
  not_plotted_num += 1
229
270
  title = f'TIC_{hdul[0].header["TICID"]} with {len(files) - not_plotted_num} sector(s) of data, {type}'
@@ -234,12 +275,21 @@ def plot_pf_lc(local_directory=None, period=None, type='cal_aper_flux'):
234
275
  # f = np.mean(PDCSAP['col2'][:len(PDCSAP['col2']) // 15 * 15].reshape(-1, 15), axis=1)
235
276
  # ferr = np.mean(PDCSAP['col3'][:len(PDCSAP['col3']) // 15 * 15].reshape(-1, 15), axis=1)
236
277
  # plt.errorbar((t - 2457000) % period / period, f, ferr, c='C0', ls='', elinewidth=0, marker='.', ms=2, zorder=1)
237
- # plt.ylim(0.94, 1.025)
238
- # plt.xlim(0.84, 0.86)
278
+ time_out, meas_out, meas_err_out = timebin(time=t_all % period, meas=f_all,
279
+ meas_err=f_err_all,
280
+ binsize=300 / 86400)
281
+ plt.errorbar(np.array(time_out) / period, meas_out, meas_err_out, c=f'r', ls='', elinewidth=1.5,
282
+ marker='.', ms=8, zorder=3, label=f'All sectors')
283
+
284
+ plt.ylim(0.87, 1.05)
285
+ # plt.xlim(0.3, 0.43)
239
286
  plt.legend()
240
287
  plt.title(title)
241
- # plt.xlim(0.6, 0.7)
242
- plt.ylim(0.9, 1.1)
288
+ plt.xlim(mid_transit_tbjd % period - 0.1 * period, mid_transit_tbjd % period + 0.1 * period)
289
+ # plt.ylim(0.9, 1.1)
290
+ # plt.hlines(y=0.92, xmin=0, xmax=1, ls='dotted', colors='k')
291
+ # plt.hlines(y=0.93, xmin=0, xmax=1, ls='dotted', colors='k')
292
+ plt.vlines(x=(mid_transit_tbjd % period), ymin=0, ymax=2, ls='dotted', colors='grey')
243
293
  plt.xlabel('Phase')
244
294
  plt.ylabel('Normalized flux')
245
295
  plt.savefig(f'{local_directory}/plots/{title}.png', dpi=300)
@@ -248,30 +298,33 @@ def plot_pf_lc(local_directory=None, period=None, type='cal_aper_flux'):
248
298
 
249
299
  def plot_contamination(local_directory=None, gaia_dr3=None):
250
300
  files = glob(f'{local_directory}lc/*.fits')
251
- os.makedirs(f'{local_directory}lc/plots/', exist_ok=True)
301
+ os.makedirs(f'{local_directory}plots/', exist_ok=True)
252
302
  for i in range(len(files)):
253
- with open(glob(f'{local_directory}source/*.pkl')[0], 'rb') as input_:
254
- with fits.open(files[i], mode='denywrite') as hdul:
255
- sector = hdul[0].header['SECTOR']
303
+ with fits.open(files[i], mode='denywrite') as hdul:
304
+ sector = hdul[0].header['SECTOR']
305
+ with open(glob(f'{local_directory}source/*_{sector}.pkl')[0], 'rb') as input_:
256
306
  source = pickle.load(input_)
257
307
  source.select_sector(sector=sector)
258
308
  star_num = np.where(source.gaia['DESIGNATION'] == f'Gaia DR3 {gaia_dr3}')
309
+ plt.imshow(source.flux[0], origin='lower')
310
+ plt.show()
311
+ plt.close()
259
312
  # print(source.gaia[891])
260
- # print(source.gaia[140])
313
+ # print(source.gaia[star_num])
261
314
  nearby_stars = np.argsort(
262
315
  (source.gaia[f'sector_{sector}_x'][:500] - source.gaia[star_num][f'sector_{sector}_x']) ** 2 +
263
316
  (source.gaia[f'sector_{sector}_y'][:500] - source.gaia[star_num][f'sector_{sector}_y']) ** 2)[0:5]
264
317
  # print(f'sector = {source.sector}')
265
318
  star_x = source.gaia[star_num][f'sector_{sector}_x'][0]
266
319
  star_y = source.gaia[star_num][f'sector_{sector}_y'][0]
267
- max_flux = np.max(
268
- np.median(source.flux[:, round(star_y) - 2:round(star_y) + 3, round(star_x) - 2:round(star_x) + 3],
320
+ max_flux = np.nanmax(
321
+ np.nanmedian(source.flux[:, round(star_y) - 2:round(star_y) + 3, round(star_x) - 2:round(star_x) + 3],
269
322
  axis=0))
270
- fig = plt.figure(constrained_layout=False, figsize=(15, 7))
271
- gs = fig.add_gridspec(5, 10)
272
- gs.update(wspace=0.5, hspace=0.5)
323
+ fig = plt.figure(constrained_layout=False, figsize=(15, 5))
324
+ gs = fig.add_gridspec(5, 16)
325
+ gs.update(wspace=0.1, hspace=0.1)
273
326
  ax0 = fig.add_subplot(gs[:5, :5])
274
- ax0.imshow(source.flux[0], cmap='RdBu', vmin=-max_flux, vmax=max_flux, origin='lower')
327
+ ax0.imshow(np.median(source.flux, axis=0), cmap='RdBu', vmin=-max_flux, vmax=max_flux, origin='lower')
275
328
 
276
329
  ax0.scatter(source.gaia[f'sector_{sector}_x'][:500], source.gaia[f'sector_{sector}_y'][:500], s=50,
277
330
  c='r', label='background stars')
@@ -331,7 +384,7 @@ def plot_contamination(local_directory=None, gaia_dr3=None):
331
384
  np.median(source.flux[:, int(star_y) - 2:int(star_y) + 3, int(star_x) - 2:int(star_x) + 3], axis=0))
332
385
  for j in range(y_):
333
386
  for k in range(x_):
334
- ax_ = fig.add_subplot(gs[(4 - j), (5 + k)])
387
+ ax_ = fig.add_subplot(gs[(4 - j), (6 + 2 * k):(8 + 2 * k)])
335
388
  ax_.patch.set_facecolor('C0')
336
389
  ax_.patch.set_alpha(min(1, max(0, 5 * np.nanmedian(hdul[0].data[:, j, k]) / max_flux)))
337
390
  q = [a and b for a, b in
@@ -343,11 +396,29 @@ def plot_contamination(local_directory=None, gaia_dr3=None):
343
396
  cal_aper = (hdul[0].data[:, j, k][q] - np.nanmin(
344
397
  hdul[0].data[:, j, k][q]) + 1000 - trend) / np.nanmedian(
345
398
  hdul[0].data[:, j, k][q]) + 1
346
- ax_.plot(hdul[1].data['time'][q], cal_aper, '.k', ms=1, label='center pixel')
347
- ax_.set_ylim(0.95, 1.05)
348
- plt.savefig(f'{local_directory}lc/plots/contamination_sector_{hdul[0].header["SECTOR"]:04d}.pdf',
399
+ # ax_.plot(hdul[1].data['time'][q], cal_aper, '.k', ms=0.5)
400
+ ax_.plot(hdul[1].data['time'][q], hdul[0].data[:, j, k][q], '.k', ms=0.5)
401
+ # ax_.set_ylim(0.7, 1.3)
402
+ if j != 0:
403
+ ax_.set_xticklabels([])
404
+ if k != 0:
405
+ ax_.set_yticklabels([])
406
+
407
+ plt.savefig(f'{local_directory}plots/contamination_sector_{hdul[0].header["SECTOR"]:04d}.pdf',
349
408
  dpi=300)
350
- plt.show()
409
+ plt.close()
410
+
411
+
412
+ def plot_epsf(local_directory=None):
413
+ files = glob(f'{local_directory}epsf/*.npy')
414
+ os.makedirs(f'{local_directory}plots/', exist_ok=True)
415
+ for i in range(len(files)):
416
+ psf = np.load(files[i])
417
+ plt.imshow(psf[0, :23 ** 2].reshape(23, 23), cmap='bone', origin='lower')
418
+ plt.tick_params(axis='x', bottom=False)
419
+ plt.tick_params(axis='y', left=False)
420
+ plt.title(f'{files[i].split("/")[-1].split(".")[0]}')
421
+ plt.savefig(f'{local_directory}plots/{files[i].split("/")[-1]}.png', bbox_inches='tight', dpi=300)
351
422
 
352
423
 
353
424
  def choose_prior(tics, local_directory=None, priors=np.logspace(-5, 0, 100)):
@@ -380,46 +451,32 @@ def get_tglc_lc(tics=None, method='query', server=1, directory=None, prior=None)
380
451
  tglc_lc(target=target, local_directory=local_directory, size=90, save_aper=True, limit_mag=16,
381
452
  get_all_lc=False, first_sector_only=False, last_sector_only=False, sector=None, prior=prior,
382
453
  transient=None)
454
+ plot_lc(local_directory=f'{directory}TIC {tics[i]}/', type='cal_aper_flux')
383
455
  if method == 'search':
384
456
  star_spliter(server=server, tics=tics, local_directory=directory)
385
457
 
386
458
 
387
459
  if __name__ == '__main__':
388
- tics = [56913729]
389
- directory = f'/home/tehan/Documents/tglc/panyang/'
460
+ tics = [16005254]
461
+ directory = f'/home/tehan/Documents/tglc/'
462
+ # directory = f'/home/tehan/data/cosmos/GEMS/'
390
463
  os.makedirs(directory, exist_ok=True)
391
464
  get_tglc_lc(tics=tics, method='query', server=1, directory=directory)
392
- plot_lc(local_directory=f'{directory}TIC {tics[0]}/lc/', type='cal_aper_flux')
393
-
394
- # target = '145.3937083 75.8210000'
395
- # local_directory = f'{directory}{target}/'
396
- # tglc_lc(target=target, local_directory=local_directory, size=90, save_aper=True, limit_mag=16,
397
- # get_all_lc=False, first_sector_only=False, last_sector_only=False, sector=53, prior=None,
398
- # transient=('GRB 220623A', 145.3937083, 75.8210000))
399
- # plot_lc(local_directory=f'{local_directory}lc/', type='psf_flux')
400
- # plot_lc(local_directory=f'{local_directory}lc/', type='aperture_flux')
401
-
402
- # # running reference star for Roland
403
- # sectors = [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 40, 41,
404
- # 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60]
405
- #
406
- # target = f'TIC {tics[0]}'
465
+ plot_lc(local_directory=f'/home/tehan/Documents/tglc/TIC 16005254/', type='cal_aper_flux')
466
+ plot_contamination(local_directory=f'{directory}TIC {tics[0]}/', gaia_dr3=5751990597042725632)
467
+ # plot_epsf(local_directory=f'{directory}TIC {tics[0]}/')
468
+ # plot_pf_lc(local_directory=f'{directory}TIC {tics[0]}/lc/', period=0.71912603, mid_transit_tbjd=2790.58344,
469
+ # type='cal_psf_flux')
470
+ # plot_pf_lc(local_directory=f'{directory}TIC {tics[0]}/lc/', period=0.71912603, mid_transit_tbjd=2790.58344,
471
+ # type='cal_aper_flux')
472
+
473
+ # target = f'266.489125, -33.8428'
474
+ # directory = f'/home/tehan/data/cosmos/michelle/'
407
475
  # local_directory = f'{directory}{target}/'
408
476
  # os.makedirs(local_directory, exist_ok=True)
409
- # for i in range(len(sectors)):
410
- # tglc_lc(target=target, local_directory=local_directory, size=90, save_aper=True, limit_mag=16,
411
- # get_all_lc=False, first_sector_only=False, last_sector_only=False, sector=sectors[i], prior=None)
412
-
413
- # from astropy.io import fits
414
- # from glob import glob
415
- # import matplotlib.pyplot as plt
416
- #
417
- # files = glob('/home/tehan/Documents/MKI/Michael/TIC 165553746_lc/*.fits')
418
- # for i in range(len(files)):
419
- # with fits.open(files[i]) as hdul:
420
- # q = [a and b for a, b in zip(list(hdul[1].data['TESS_flags'] == 0),
421
- # list(hdul[1].data['TGLC_flags'] == 0))]
422
- # plt.plot(hdul[1].data['time'][q], hdul[1].data['aperture_flux'][q], '.')
423
- # plt.title('TIC 165553746')
424
- # # plt.ylim(8000,12000)
425
- # plt.show()
477
+ # tglc_lc(target=target, local_directory=local_directory, size=50, save_aper=True, limit_mag=17,
478
+ # get_all_lc=False, first_sector_only=False, last_sector_only=False, sector=39, prior=None,
479
+ # transient=['266.489125, -33.8428', 266.489125, -33.8428])
480
+ # plot_lc(local_directory=f'{local_directory}', type='cal_aper_flux')
481
+ # plot_lc(local_directory=f'{local_directory}', yhigh=150, type='aperture_flux')
482
+ # plot_contamination(local_directory=f'{local_directory}', gaia_dr3=4041831235071242624)
@@ -30,7 +30,24 @@ def lc_per_cut(i, camccd='', local_directory=''):
30
30
  source = pickle.load(input_)
31
31
  epsf(source, psf_size=11, factor=2, cut_x=cut_x, cut_y=cut_y, sector=source.sector, power=1.4,
32
32
  local_directory=local_directory, limit_mag=16, save_aper=False, no_progress_bar=True)
33
-
33
+ # residual =
34
+ # np.save(f'/home/tehan/cosmos/MKI/Roland/{cut_x:02d}_{cut_y:02d}.npy', residual)
35
+ # fig = plt.figure(constrained_layout=False, figsize=(8, 8))
36
+ # gs = fig.add_gridspec(2, 2)
37
+ # gs.update(wspace=0.4, hspace=0.2)
38
+ # wcs = source.wcs
39
+ # ax0 = fig.add_subplot(gs[0:2, 0:2], projection=wcs)
40
+ # ax0.imshow(residual, origin='bottom')
41
+ # ax0.coords['pos.eq.ra'].set_axislabel('Right Ascension')
42
+ # ax0.coords['pos.eq.ra'].set_axislabel_position('l')
43
+ # ax0.coords['pos.eq.ra'].set_ticklabel(rotation=90)
44
+ # ax0.coords['pos.eq.dec'].set_axislabel('Declination')
45
+ # ax0.coords['pos.eq.dec'].set_axislabel_position('b')
46
+ # ax0.coords.grid(color='k', ls='dotted')
47
+ # ax0.tick_params(axis='x', labelbottom=True)
48
+ # ax0.tick_params(axis='y', labelleft=True)
49
+ # ax0.set_title(f'Sector 42 Camera 1 CCD 1, cut {cut_x:02d}_{cut_y:02d}, cadence {source.cadence[2817]}, time {source.time[2817]}')
50
+ # plt.savefig(f'/home/tehan/cosmos/MKI/Roland/figs/{cut_x:02d}_{cut_y:02d}.png')
34
51
 
35
52
  def lc_per_ccd(camccd='1-1', local_directory=''):
36
53
  os.makedirs(f'{local_directory}epsf/{camccd}/', exist_ok=True)
@@ -4,6 +4,7 @@ os.environ["OPENBLAS_NUM_THREADS"] = "8"
4
4
  os.environ["MKL_NUM_THREADS"] = "8"
5
5
  os.environ["NUMEXPR_NUM_THREADS"] = "8"
6
6
  os.environ["OMP_NUM_THREADS"] = "8"
7
+ import glob
7
8
  from tglc.ffi import *
8
9
  from multiprocessing import Pool
9
10
  from functools import partial
@@ -65,7 +66,7 @@ def ffi_to_source(sector=1, local_directory=''):
65
66
  os.makedirs(f'{local_directory}log/', exist_ok=True)
66
67
  os.makedirs(f'{local_directory}mask/', exist_ok=True)
67
68
 
68
- with Pool(4) as p:
69
+ with Pool(1) as p:
69
70
  p.map(partial(cut_ffi_, sector=sector, size=150, local_directory=local_directory), range(16))
70
71
 
71
72
  # for i in range(16):
@@ -73,6 +74,12 @@ def ffi_to_source(sector=1, local_directory=''):
73
74
 
74
75
 
75
76
  if __name__ == '__main__':
76
- sector = 2
77
+ sector = 56
77
78
  ffi_to_source(sector=sector, local_directory=f'/home/tehan/data/sector{sector:04d}/')
78
79
  # med_mask = median_mask(sector_num=26)
80
+ # ffi_to_source(sector=sector, local_directory=f'/pdo/users/tehan/sector{sector:04d}/')
81
+ # files = glob.glob(f'/home/tehan/data/sector{sector:04d}/source/*/source_00_00.pkl')
82
+ # for i in range(len(files)):
83
+ # with open(files[i], 'rb') as input_:
84
+ # source = pickle.load(input_)
85
+ # print(np.min(np.diff(source.cadence)), files[i])
@@ -231,9 +231,10 @@ def epsf(source, psf_size=11, factor=2, local_directory='', target=None, cut_x=0
231
231
  else:
232
232
  bg_dof = 6
233
233
  os.makedirs(lc_directory, exist_ok=True)
234
- # sim_image = np.dot(A[:source.size ** 2, :], fit_psf(A, source, over_size, power=power, time=0).T)
235
- # residual = np.abs(source.flux[0].flatten() - sim_image)
236
- # return residual
234
+ # sim_image = np.dot(A[:source.size ** 2, :], fit_psf(A, source, over_size, power=power, time=2817).T)
235
+ # # residual = np.abs(source.flux[2817].flatten() - sim_image)
236
+ # residual = source.flux[2817].flatten() - sim_image
237
+ # return residual.reshape((source.size, source.size))
237
238
 
238
239
  epsf_exists = exists(epsf_loc)
239
240
  if epsf_exists:
@@ -312,7 +313,6 @@ def epsf(source, psf_size=11, factor=2, local_directory='', target=None, cut_x=0
312
313
  aperture, psf_lc, star_y, star_x, portion = \
313
314
  fit_lc(A, source, star_info=star_info, x=x_round[i], y=y_round[i], star_num=i, e_psf=e_psf,
314
315
  near_edge=near_edge)
315
-
316
316
  aper_lc = np.sum(
317
317
  aperture[:, max(0, star_y - 1):min(5, star_y + 2), max(0, star_x - 1):min(5, star_x + 2)],
318
318
  axis=(1, 2))
@@ -326,6 +326,7 @@ def epsf(source, psf_size=11, factor=2, local_directory='', target=None, cut_x=0
326
326
  aper_lc[saturated_arg_aper] = np.nan
327
327
  saturated_arg_psf = np.where(psf_lc > 1e5 * 9 * 2e5 / exposure_time)
328
328
  psf_lc[saturated_arg_psf] = np.nan
329
+
329
330
  local_bg, aper_lc, psf_lc, cal_aper_lc, cal_psf_lc = bg_mod(source, q=index, portion=portion,
330
331
  psf_lc=psf_lc,
331
332
  aper_lc=aper_lc,
@@ -334,13 +335,28 @@ def epsf(source, psf_size=11, factor=2, local_directory='', target=None, cut_x=0
334
335
  quality = np.zeros(len(source.time), dtype=np.int16)
335
336
  sigma = 1.4826 * np.nanmedian(np.abs(background_ - np.nanmedian(background_)))
336
337
  quality[abs(background_ - np.nanmedian(background_)) >= 5 * sigma] += 1
338
+ # if cut_x == 7:
339
+ # lc_directory = f'{local_directory}lc/{source.camera}-{source.ccd}_extra/'
340
+ # os.makedirs(lc_directory, exist_ok=True)
337
341
  if np.isnan(aper_lc).all():
338
342
  continue
339
343
  else:
340
- lc_output(source, local_directory=lc_directory, index=i,
341
- tess_flag=source.quality, cut_x=cut_x, cut_y=cut_y, cadence=source.cadence,
342
- aperture=aperture.astype(np.float32), star_y=y_round[i], star_x=x_round[i], tglc_flag=quality,
343
- bg=background_, time=source.time, psf_lc=psf_lc, cal_psf_lc=cal_psf_lc, aper_lc=aper_lc,
344
- cal_aper_lc=cal_aper_lc, local_bg=local_bg, x_aperture=x_aperture[i],
345
- y_aperture=y_aperture[i], near_edge=near_edge, save_aper=save_aper, portion=portion,
346
- prior=prior, transient=source.transient)
344
+ if type(source) == Source:
345
+ # if cut_x >= 7:
346
+ # lc_directory = f'{local_directory}lc/{source.camera}-{source.ccd}_extra/'
347
+ lc_output(source, local_directory=lc_directory, index=i,
348
+ tess_flag=source.quality, cut_x=cut_x, cut_y=cut_y, cadence=source.cadence,
349
+ aperture=aperture.astype(np.float32), star_y=y_round[i], star_x=x_round[i], tglc_flag=quality,
350
+ bg=background_, time=source.time, psf_lc=psf_lc, cal_psf_lc=cal_psf_lc, aper_lc=aper_lc,
351
+ cal_aper_lc=cal_aper_lc, local_bg=local_bg, x_aperture=x_aperture[i],
352
+ y_aperture=y_aperture[i], near_edge=near_edge, save_aper=save_aper, portion=portion,
353
+ prior=prior)
354
+ else:
355
+ lc_output(source, local_directory=lc_directory, index=i,
356
+ tess_flag=source.quality, cut_x=cut_x, cut_y=cut_y, cadence=source.cadence,
357
+ aperture=aperture.astype(np.float32), star_y=y_round[i], star_x=x_round[i],
358
+ tglc_flag=quality,
359
+ bg=background_, time=source.time, psf_lc=psf_lc, cal_psf_lc=cal_psf_lc, aper_lc=aper_lc,
360
+ cal_aper_lc=cal_aper_lc, local_bg=local_bg, x_aperture=x_aperture[i],
361
+ y_aperture=y_aperture[i], near_edge=near_edge, save_aper=save_aper, portion=portion,
362
+ prior=prior, transient=source.transient)
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.1
2
+ Name: tglc
3
+ Version: 0.6.2
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
+ License: UNKNOWN
9
+ Description: ==================================
10
+ Introduction
11
+ ==================================
12
+
13
+ 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.
14
+
15
+
16
+ ==================================
17
+ Usage
18
+ ==================================
19
+ There are four fluxes in each FITS file: aperture flux, PSF flux, calibrated aperture flux, and calibrated PSF flux.
20
+ If you are uncertain which to use:
21
+
22
+ * Calibrated psf flux is better in **deblending** targets. Use this if you need to deblend a target near a variable source. The best deblending can be achieved with tglc package by setting a non-zero prior. It also gives the more accurate **transit depth** in most cases, especially when fitting with an optimized prior.
23
+ * Calibrated aperture flux usually has slightly **higher SNR**. The transit depth (or variation amplitude), however, can be imperfect since the normalization depends on the PSF fitting which is imperfect. This imperfection can be minimized by using a bigger aperture than the default aperture (3*3). One need to use the tglc package and set tglc_lc(save_aper=True) to access the 5*5 aperture. In the presence of a bright but "constant" contamination (several magnitudes brighter), the calibrated aperture flux is better in removing the constant contamination.
24
+ * The aperture flux and PSF flux are not detrended or normalized. Use this if you are doing stellar variability science with long baseline. Or, if the detrending is not optimal (default detrending has a window length of 1 day; see Known Problems below), start with the aperture flux or PSF flux and detrend carefully!
25
+ * **If you are uncertain, start with calibrated aperture flux!**
26
+
27
+ The `tutorial <tutorial/TGLC_tutorial.ipynb>`_ shows the syntaxes and differences among these light curves in several examples.
28
+
29
+ ==================================
30
+ Data Access
31
+ ==================================
32
+ There are three data access methods:
33
+
34
+ * MAST Portal: Easiest for acquiring light curves for a few stars. However, new sectors are updated relatively slowly.
35
+ * MAST bulk download: Best for downloading light curves for all stars (<16 TESS magnitude) in a sectors.
36
+ * tglc package: Capable of producing similar quality light curves for any sector and any star with custom options.
37
+
38
+ MAST Portal/bulk download
39
+ ----------------------------
40
+ The easiest usage requires no package installation. Simply follow the `TGLC HLSP page <https://archive.stsci.edu/hlsp/tglc>`_ to download light curves from MAST or use `MAST Portal <https://mast.stsci.edu/portal/Mashup/Clients/Mast/Portal.html>`_. Light curves are being fitted sector by sector and will be available on MAST gradually. MAST hosts all Gaia DR3 stars down to 16th magnitude. Each .fits file includes PSF and aperture light curves and their calibrated versions.
41
+
42
+ MAST available sectors: `sector worklist <https://docs.google.com/spreadsheets/d/1FhHElWb1wmx9asWiZecAJ2umN0-P_aXn55OBVB34_rg/edit?usp=sharing>`_
43
+
44
+
45
+ tglc package
46
+ ----------------------------
47
+ Users can also fit light curves using the package tglc. Using tglc, one can specify a region, sector(s), and customized aperture shape if needed. It can also allow all field stars to float by assigning Gaussian priors, which can help decontaminate variable field stars. tglc is currently only available for linux. Run::
48
+
49
+ pip install tglc
50
+
51
+ for the latest tglc release. After installation, follow the `tutorial <tutorial/TGLC_tutorial.ipynb>`_ to fit light curves. If there is a problem, please leave a comment in the Issues section to help us improve. Thank you!
52
+
53
+
54
+ ==================================
55
+ Known Problems
56
+ ==================================
57
+ There are several imperfections we noticed in the MAST TGLC light curves and tglc package:
58
+
59
+ * If the star is very dim (~< 15 Tmag) near a variable source, it can make the aperture and/or PSF light curve negative for some cadences. The detrending algorithm could malfunction and result in bad cal_aper_flux and/or cal_psf_flux. This is now fixed for tglc package, but this problem remains for the primary mission light curves published on MAST. Please detrend again if necessary. The extended mission light curves on MAST will not be affected. This is a very rare scenario, but could be important.
60
+
61
+ ==================================
62
+ Reference
63
+ ==================================
64
+ If you find the TGLC light curves or the tglc package useful in your research, please cite `our paper <https://iopscience.iop.org/article/10.3847/1538-3881/acaaa7>`_ published on the Astronomical Journal.
65
+
66
+ Platform: UNKNOWN
67
+ Classifier: Programming Language :: Python :: 3
68
+ Classifier: License :: OSI Approved :: MIT License
69
+ Classifier: Operating System :: OS Independent
70
+ Requires-Python: >=3.8
71
+ Description-Content-Type: text/x-rst
tglc-0.6.0/PKG-INFO DELETED
@@ -1,69 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: tglc
3
- Version: 0.6.0
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
12
- Description-Content-Type: text/x-rst
13
- License-File: LICENSE
14
-
15
- ==================================
16
- Introduction
17
- ==================================
18
-
19
- 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.
20
-
21
- ==================================
22
- Usage
23
- ==================================
24
- There are four fluxes in each FITS file: aperture flux, PSF flux, calibrated aperture flux, and calibrated PSF flux.
25
- If you are uncertain which to use:
26
-
27
- * Calibrated psf flux is better in **deblending** targets. Use this if you need to deblend a target near a variable source. The best deblending can be achieved with tglc package by setting a non-zero prior. It also gives the more accurate **transit depth** in most cases, especially when fitting with an optimized prior.
28
- * Calibrated aperture flux usually has slightly **higher SNR**. The transit depth (or variation amplitude), however, can be imperfect since the normalization depends on the PSF fitting which is imperfect. This imperfection can be minimized by using a bigger aperture than the default aperture (3*3). One need to use the tglc package and set tglc_lc(save_aper=True) to access the 5*5 aperture. In the presence of a bright but "constant" contamination (several magnitudes brighter), the calibrated aperture flux is better in removing the constant contamination.
29
- * The aperture flux and PSF flux are not detrended or normalized. Use this if you are doing stellar variability science with long baseline. Or, if the detrending is not optimal (default detrending has a window length of 1 day; see Known Problems below), start with the aperture flux or PSF flux and detrend carefully!
30
- * **If you are uncertain, start with calibrated aperture flux!**
31
-
32
- The `tutorial <tutorial/TGLC_tutorial.ipynb>`_ shows the syntaxes and differences among these light curves in several examples.
33
-
34
- ==================================
35
- Data Access
36
- ==================================
37
- There are three data access methods:
38
-
39
- * MAST Portal: Easiest for acquiring light curves for a few stars. However, new sectors are updated relatively slowly.
40
- * MAST bulk download: Best for downloading light curves for all stars (<16 TESS magnitude) in a sectors.
41
- * tglc package: Capable of producing similar quality light curves for any sector and any star with custom options.
42
-
43
- MAST Portal/bulk download
44
- ----------------------------
45
- The easiest usage requires no package installation. Simply follow the `TGLC HLSP page <https://archive.stsci.edu/hlsp/tglc>`_ to download light curves from MAST or use `MAST Portal <https://mast.stsci.edu/portal/Mashup/Clients/Mast/Portal.html>`_. Light curves are being fitted sector by sector and will be available on MAST gradually. MAST hosts all Gaia DR3 stars down to 16th magnitude. Each .fits file includes PSF and aperture light curves and their calibrated versions.
46
-
47
- MAST available sectors: `sector worklist <https://docs.google.com/spreadsheets/d/1FhHElWb1wmx9asWiZecAJ2umN0-P_aXn55OBVB34_rg/edit?usp=sharing>`_
48
-
49
-
50
- tglc package
51
- ----------------------------
52
- Users can also fit light curves using the package tglc. Using tglc, one can specify a region, sector(s), and customized aperture shape if needed. It can also allow all field stars to float by assigning Gaussian priors, which can help decontaminate variable field stars. tglc is currently only available for linux. Run::
53
-
54
- pip install tglc
55
-
56
- for the latest tglc release. After installation, follow the `tutorial <tutorial/TGLC_tutorial.ipynb>`_ to fit light curves. If there is a problem, please leave a comment in the Issues section to help us improve. Thank you!
57
-
58
-
59
- ==================================
60
- Known Problems
61
- ==================================
62
- There are several imperfections we noticed in the MAST TGLC light curves and tglc package:
63
-
64
- * If the star is very dim (~< 15 Tmag) near a variable source, it can make the aperture and/or PSF light curve negative for some cadences. The detrending algorithm could malfunction and result in bad cal_aper_flux and/or cal_psf_flux. This is now fixed for tglc package, but this problem remains for the primary mission light curves published on MAST. Please detrend again if necessary. The extended mission light curves on MAST will not be affected. This is a very rare scenario, but could be important.
65
-
66
- ==================================
67
- Reference
68
- ==================================
69
- If you find the TGLC light curves or the tglc package useful in your research, please cite `our paper <https://iopscience.iop.org/article/10.3847/1538-3881/acaaa7>`_ published on the Astronomical Journal.
@@ -1,3 +0,0 @@
1
- __version__ = "0.6.0"
2
- __author__ = 'Te Han, Timothy Brandt'
3
- __credits__ = 'University of California, Santa Barbara'
@@ -1,69 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: tglc
3
- Version: 0.6.0
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
12
- Description-Content-Type: text/x-rst
13
- License-File: LICENSE
14
-
15
- ==================================
16
- Introduction
17
- ==================================
18
-
19
- 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.
20
-
21
- ==================================
22
- Usage
23
- ==================================
24
- There are four fluxes in each FITS file: aperture flux, PSF flux, calibrated aperture flux, and calibrated PSF flux.
25
- If you are uncertain which to use:
26
-
27
- * Calibrated psf flux is better in **deblending** targets. Use this if you need to deblend a target near a variable source. The best deblending can be achieved with tglc package by setting a non-zero prior. It also gives the more accurate **transit depth** in most cases, especially when fitting with an optimized prior.
28
- * Calibrated aperture flux usually has slightly **higher SNR**. The transit depth (or variation amplitude), however, can be imperfect since the normalization depends on the PSF fitting which is imperfect. This imperfection can be minimized by using a bigger aperture than the default aperture (3*3). One need to use the tglc package and set tglc_lc(save_aper=True) to access the 5*5 aperture. In the presence of a bright but "constant" contamination (several magnitudes brighter), the calibrated aperture flux is better in removing the constant contamination.
29
- * The aperture flux and PSF flux are not detrended or normalized. Use this if you are doing stellar variability science with long baseline. Or, if the detrending is not optimal (default detrending has a window length of 1 day; see Known Problems below), start with the aperture flux or PSF flux and detrend carefully!
30
- * **If you are uncertain, start with calibrated aperture flux!**
31
-
32
- The `tutorial <tutorial/TGLC_tutorial.ipynb>`_ shows the syntaxes and differences among these light curves in several examples.
33
-
34
- ==================================
35
- Data Access
36
- ==================================
37
- There are three data access methods:
38
-
39
- * MAST Portal: Easiest for acquiring light curves for a few stars. However, new sectors are updated relatively slowly.
40
- * MAST bulk download: Best for downloading light curves for all stars (<16 TESS magnitude) in a sectors.
41
- * tglc package: Capable of producing similar quality light curves for any sector and any star with custom options.
42
-
43
- MAST Portal/bulk download
44
- ----------------------------
45
- The easiest usage requires no package installation. Simply follow the `TGLC HLSP page <https://archive.stsci.edu/hlsp/tglc>`_ to download light curves from MAST or use `MAST Portal <https://mast.stsci.edu/portal/Mashup/Clients/Mast/Portal.html>`_. Light curves are being fitted sector by sector and will be available on MAST gradually. MAST hosts all Gaia DR3 stars down to 16th magnitude. Each .fits file includes PSF and aperture light curves and their calibrated versions.
46
-
47
- MAST available sectors: `sector worklist <https://docs.google.com/spreadsheets/d/1FhHElWb1wmx9asWiZecAJ2umN0-P_aXn55OBVB34_rg/edit?usp=sharing>`_
48
-
49
-
50
- tglc package
51
- ----------------------------
52
- Users can also fit light curves using the package tglc. Using tglc, one can specify a region, sector(s), and customized aperture shape if needed. It can also allow all field stars to float by assigning Gaussian priors, which can help decontaminate variable field stars. tglc is currently only available for linux. Run::
53
-
54
- pip install tglc
55
-
56
- for the latest tglc release. After installation, follow the `tutorial <tutorial/TGLC_tutorial.ipynb>`_ to fit light curves. If there is a problem, please leave a comment in the Issues section to help us improve. Thank you!
57
-
58
-
59
- ==================================
60
- Known Problems
61
- ==================================
62
- There are several imperfections we noticed in the MAST TGLC light curves and tglc package:
63
-
64
- * If the star is very dim (~< 15 Tmag) near a variable source, it can make the aperture and/or PSF light curve negative for some cadences. The detrending algorithm could malfunction and result in bad cal_aper_flux and/or cal_psf_flux. This is now fixed for tglc package, but this problem remains for the primary mission light curves published on MAST. Please detrend again if necessary. The extended mission light curves on MAST will not be affected. This is a very rare scenario, but could be important.
65
-
66
- ==================================
67
- Reference
68
- ==================================
69
- If you find the TGLC light curves or the tglc package useful in your research, please cite `our paper <https://iopscience.iop.org/article/10.3847/1538-3881/acaaa7>`_ published on the Astronomical Journal.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes