Skip to content

Commit 9168558

Browse files
update docs
1 parent 98ab2ab commit 9168558

2 files changed

Lines changed: 65 additions & 8 deletions

File tree

docs/tutorials/calculating-barycentric-time-correction.ipynb

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"metadata": {},
109109
"source": [
110110
"SPOC data contains two time extensions:\n",
111-
"1. `TIME`: the time of the observations in Barycentric Julian Date (i.e. at the solar system barycenter)\n",
111+
"1. `TIME`: the time of the observations in the Barycentric Dynamical Time scale (TDB) as a Barycentric Julian Dates (i.e. time at the solar system barycenter)\n",
112112
"2. `TIMECORR`: the time correction applied to the original spacecraft time, to obtain `TIME`\n",
113113
"\n",
114114
"`lksearch` only works with spacecraft time. So we need to remove the SPOC applied time correction"
@@ -299,7 +299,9 @@
299299
"id": "38e86c6d-ecd5-4f02-94fa-eda02601148f",
300300
"metadata": {},
301301
"source": [
302-
"Looks like our correction is working!"
302+
"Looks like our correction is working!\n",
303+
"\n",
304+
"This has given us the number of seconds to apply to convert our time at the spacecraft into TDB."
303305
]
304306
},
305307
{
@@ -390,20 +392,63 @@
390392
},
391393
{
392394
"cell_type": "code",
393-
"execution_count": 18,
395+
"execution_count": null,
394396
"id": "83bee026-047d-422d-a895-2ac23f373c54",
395397
"metadata": {},
396398
"outputs": [],
397399
"source": [
398400
"time, time_corr = hdulist[1].data['TIME'], hdulist[1].data['TIMECORR']\n",
399401
"k = np.isfinite(time)\n",
400-
"time, time_corr = time[k], time_corr[k]\n",
402+
"time, time_corr = time[k], time_corr[k]"
403+
]
404+
},
405+
{
406+
"cell_type": "markdown",
407+
"id": "817afae7",
408+
"metadata": {},
409+
"source": [
410+
"Note that TESS gives times in Barycentric **TESS** Julian Date which is offset from BJD by"
411+
]
412+
},
413+
{
414+
"cell_type": "code",
415+
"execution_count": null,
416+
"id": "a46fa67d",
417+
"metadata": {},
418+
"outputs": [],
419+
"source": [
420+
"ts.time_offset"
421+
]
422+
},
423+
{
424+
"cell_type": "markdown",
425+
"id": "c001636d",
426+
"metadata": {},
427+
"source": [
428+
"We calculate the time at the spacecraft using"
429+
]
430+
},
431+
{
432+
"cell_type": "code",
433+
"execution_count": null,
434+
"id": "53dc2eed",
435+
"metadata": {},
436+
"outputs": [],
437+
"source": [
401438
"t = Time(time - time_corr + ts.time_offset, format='jd')"
402439
]
403440
},
441+
{
442+
"cell_type": "markdown",
443+
"id": "13368a28",
444+
"metadata": {},
445+
"source": [
446+
"Now we can calculate the barycentric time correction, i.e. the number of seconds to apply to the time at the spacecraft to obtain the time at the barycenter in TDB scale."
447+
]
448+
},
404449
{
405450
"cell_type": "code",
406-
"execution_count": 19,
451+
"execution_count": null,
407452
"id": "7fc89a8b-303b-43b4-9abd-144ed3bb2e1e",
408453
"metadata": {},
409454
"outputs": [
@@ -423,6 +468,14 @@
423468
"ts.get_barycentric_time_correction(time=t, ra=ra, dec=dec)"
424469
]
425470
},
471+
{
472+
"cell_type": "markdown",
473+
"id": "191a51e8",
474+
"metadata": {},
475+
"source": [
476+
"We can plot this against the time in the TESScut FFI to see how much of a difference this made"
477+
]
478+
},
426479
{
427480
"cell_type": "code",
428481
"execution_count": 20,

src/lkspacecraft/spacecraft.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,13 @@ def get_barycentric_time_correction(
208208
) -> npt.NDArray:
209209
"""Returns the barycentric time correction in days for observations of a particular target specified by RA and Dec.
210210
211-
Note that `time` here must be time in spacecraft time, in UTC format.
211+
Note that `time` here must be the time of the spacecraft clock.
212212
This means that for SPOC data this should be the time without the SPOC barycentric correction applied.
213213
214214
Parameters:
215215
-----------
216216
time: astropy.time.Time
217-
Time array at which to estimate position. Time must be in UTC.
217+
Time array at which to estimate position. Time must be at the spacecraft.
218218
ra: float, np.ndarray
219219
The right ascention of the target in degrees
220220
dec: float, np.ndarray
@@ -403,7 +403,7 @@ def get_barycentric_time_correction(
403403
) -> npt.NDArray:
404404
"""Returns the barycentric time correction in days for observations of a particular target specified by RA and Dec.
405405
406-
Note that `time` here must be time in spacecraft time, in UTC format.
406+
Note that `time` here must be time in spacecraft clock time.
407407
This means that for SPOC data this should be the time without the SPOC barycentric correction applied.
408408
409409
Note this also corrects the timing error in the Kepler TIME column, see https://archive.stsci.edu/kepler/timing_error.html
@@ -419,6 +419,10 @@ def get_barycentric_time_correction(
419419
"""
420420
time = self._process_time(time)
421421
tcorr = super().get_barycentric_time_correction(time, ra, dec)
422+
# see data release notes in https://archive.stsci.edu/missions/kepler/docs/drn/release_notes19/DataRelease_19_20130204.pdf
423+
# section 3.4
424+
# For Kepler the TIME column was erroneously in UTC not TDB as reported. As such it did not account for leap seconds
425+
# This corrects the error in the original products
422426
tcorr += 66.184
423427
k = time.jd > Time("2012-06-30 23:59:60", format="iso").jd
424428
tcorr[k] += 1

0 commit comments

Comments
 (0)