From 71ea8c7f4d984e251a696c90ceda7929df349dfc Mon Sep 17 00:00:00 2001 From: Dar Dahlen Date: Tue, 3 Sep 2024 21:12:10 -0700 Subject: [PATCH] Remove WISE offset (#109) * Times in the WISE IRSA Metadata table are mid-observation There was a 4.4 second offset when downloading FOVs which should not exist. * Optimize loading MPC Observations from text * changelog * black --- CHANGELOG.md | 6 +++++- src/kete/mpc.py | 39 +++++++++++++++++++++------------------ src/kete/wise.py | 6 +----- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01713be..74e3258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,10 +17,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 done at the Palomar Observatory. - Added sunshield rotation calculation for NEO Surveyor. +### Fixed -## [0.3.0] - 2024 - 8 - 28 +- Fixed a time offset in the FOV's downloaded from IRSA WISE/NEOWISE. They were offset + by 4.4 seconds. +## [0.3.0] - 2024 - 8 - 28 + ### Added - Added an Omni-Directional Field of View. diff --git a/src/kete/mpc.py b/src/kete/mpc.py index f3c2aa6..049d926 100644 --- a/src/kete/mpc.py +++ b/src/kete/mpc.py @@ -874,27 +874,26 @@ def from_lines(cls, lines, load_sc_pos=True): """ Create a list of MPCObservations from a list of single 80 char lines. """ - lines = lines.copy() - - jds = [] - for line in lines: - year, month, day = line[15:32].strip().split() - jds.append(Time.from_ymd(int(year), int(month), float(day)).jd) - found = [] - while len(lines) > 0: - line = cls._read_first_line(lines.pop(0)) - line["jd"] = jds.pop(0) - if line["note2"] in "WwQqVvRrXx": + idx = 0 + unsupported = set("WwQqVvRrXx") + while True: + if idx >= len(lines): + break + line = cls._read_first_line(lines[idx]) + idx += 1 + if line["note2"] in unsupported: # unsupported or deprecated observation types continue - if line["note2"] == "s" or line["note2"] == "t": - raise ValueError("Second line of spacecraft observation found alone") - if line["note2"] == "S" or line["note2"] == "T": - if len(lines) == 0: - raise ValueError("Missing second line of spacecraft observation.") - pos_line = lines.pop(0) - jds.pop(0) + elif line["note2"] == "s" or line["note2"] == "t": + logger.warning("Second line of spacecraft observation found alone") + continue + elif line["note2"] == "S" or line["note2"] == "T": + if idx >= len(lines): + logger.warning("Missing second line of spacecraft observation.") + break + pos_line = lines[idx] + idx += 1 if load_sc_pos: line["sun2sc"] = cls._read_second_line(pos_line, line["jd"]) found.append(cls(**line)) @@ -903,6 +902,9 @@ def from_lines(cls, lines, load_sc_pos=True): @staticmethod def _read_first_line(line): mag_band = line[65:71].strip() + + year, month, day = line[15:32].strip().split() + jd = Time.from_ymd(int(year), int(month), float(day)).jd if len(mag_band) > 0: mag_band = mag_band.split(maxsplit=1)[0] contents = dict( @@ -915,6 +917,7 @@ def _read_first_line(line): mag_band=mag_band, obs_code=line[77:80], sun2sc=None, + jd=jd, ) return contents diff --git a/src/kete/wise.py b/src/kete/wise.py index 1a50c5d..601cc66 100644 --- a/src/kete/wise.py +++ b/src/kete/wise.py @@ -579,11 +579,7 @@ def fetch_WISE_fovs(phase): f"WHERE mjd >= {mjd_start} and mjd < {mjd_end}" ) - # Adding 4.4 seconds for the offset due to W3/4 exposures taking 8.8 seconds - jd = [ - Time.from_mjd(mjd, scaling="utc").jd + 5.092592592592592e-05 - for mjd in list(res.mjd) - ] + jd = [Time.from_mjd(mjd, scaling="utc").jd for mjd in list(res.mjd)] res["jd"] = jd fovs = []