Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problems that came up in pitch/roll-comp when using real-time data #250

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 21 additions & 3 deletions cheta/derived/comps.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,13 @@ 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. 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)

vals = dp.calc(tlm)
i0, i1 = np.searchsorted(tlm.times, [tstart, tstop])
return tlm.times[i0:i1], vals[i0:i1]
Expand Down Expand Up @@ -739,15 +746,26 @@ 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, 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])
Expand Down