From a85ec0c31b1836f84abc3709389b769bb4af70c5 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Sun, 30 Apr 2023 11:10:20 -0400 Subject: [PATCH 1/4] Fix problems that came up running during a comm --- cheta/derived/comps.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cheta/derived/comps.py b/cheta/derived/comps.py index c7a56aa3..8a8d1f67 100644 --- a/cheta/derived/comps.py +++ b/cheta/derived/comps.py @@ -664,6 +664,11 @@ def calc_pitch_roll_obc(tstart: float, tstop: float, pitch_roll: str): dp = DP_PITCH() if pitch_roll == "pitch" else DP_ROLL() # Pad by 12 minutes on each side to ensure ephemeris data are available. tlm = dp.fetch(tstart - 720, tstop + 720) + + # Filter bad data values + tlm.interpolate(times=tlm.times) + tlm.bads = np.zeros(len(tlm.times), dtype=bool) + vals = dp.calc(tlm) i0, i1 = np.searchsorted(tlm.times, [tstart, tstop]) return tlm.times[i0:i1], vals[i0:i1] @@ -742,12 +747,22 @@ def get_msid_attrs(self, tstart, tstop, msid, msid_args): # Get states of either NPNT / NMAN or NSUN vals = np.isin(dat.vals, ["NPNT", "NMAN"]) states_npnt_nman = logical_intervals( - dat.times, vals, complete_intervals=False, max_gap=2.1 + dat.times, + vals, + complete_intervals=False, + max_gap=2.1, + start=ofp_state["tstart"], + stop=ofp_state["tstop"], ) states_npnt_nman["val"] = np.repeat("NPNT_NMAN", len(states_npnt_nman)) states_nsun = logical_intervals( - dat.times, dat.vals == "NSUN", max_gap=2.1, complete_intervals=False + dat.times, + dat.vals == "NSUN", + max_gap=2.1, + complete_intervals=False, + start=ofp_state["tstart"], + stop=ofp_state["tstop"], ) states_nsun["val"] = np.repeat("NSUN", len(states_nsun)) states = tbl.vstack([states_npnt_nman, states_nsun]) From 1b29b2920a13f2a73a283dec0f5c799722b72a3d Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Wed, 28 Jun 2023 14:09:18 -0400 Subject: [PATCH 2/4] Fix flake8 whitespace --- cheta/derived/comps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheta/derived/comps.py b/cheta/derived/comps.py index 8a8d1f67..8b6f74f4 100644 --- a/cheta/derived/comps.py +++ b/cheta/derived/comps.py @@ -668,7 +668,7 @@ def calc_pitch_roll_obc(tstart: float, tstop: float, pitch_roll: str): # Filter bad data values tlm.interpolate(times=tlm.times) tlm.bads = np.zeros(len(tlm.times), dtype=bool) - + vals = dp.calc(tlm) i0, i1 = np.searchsorted(tlm.times, [tstart, tstop]) return tlm.times[i0:i1], vals[i0:i1] From e5ecf99b734137af0eca882793608b440402a0e6 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Wed, 28 Jun 2023 14:20:38 -0400 Subject: [PATCH 3/4] Update flake8 check --- .github/workflows/flake8.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index ff1779ec..f75ba096 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up Python 3.8 + - name: Set up Python 3.10 uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: "3.10" - name: Lint with flake8 run: | pip install flake8 From 1d0dedf6ec303a7c68274f5fdaf82e77f89e5bae Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Wed, 28 Jun 2023 14:21:01 -0400 Subject: [PATCH 4/4] Improve code comments --- cheta/derived/comps.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cheta/derived/comps.py b/cheta/derived/comps.py index 8b6f74f4..16b8ce14 100644 --- a/cheta/derived/comps.py +++ b/cheta/derived/comps.py @@ -665,7 +665,9 @@ def calc_pitch_roll_obc(tstart: float, tstop: float, pitch_roll: str): # Pad by 12 minutes on each side to ensure ephemeris data are available. tlm = dp.fetch(tstart - 720, tstop + 720) - # Filter bad data values + # Filter bad data values. The `dp.fetch` above sets bad over intervals where any of + # the inputs are missing and calling interpolate like below will cut those out. + # See PR #250 for more details. tlm.interpolate(times=tlm.times) tlm.bads = np.zeros(len(tlm.times), dtype=bool) @@ -744,7 +746,8 @@ def get_msid_attrs(self, tstart, tstop, msid, msid_args): tlms.append((np.array([], dtype=float), np.array([], dtype=float))) continue - # Get states of either NPNT / NMAN or NSUN + # Get states of either NPNT / NMAN or NSUN which cover exactly the + # time span of the ofp_state interval. vals = np.isin(dat.vals, ["NPNT", "NMAN"]) states_npnt_nman = logical_intervals( dat.times,