Skip to content

Commit

Permalink
Merge pull request #250 from sot/more-pitch-roll-comp-fixes
Browse files Browse the repository at this point in the history
Fix problems that came up in `pitch/roll-comp` when using real-time data
  • Loading branch information
taldcroft authored Sep 13, 2023
2 parents 94b2f6e + 1d0dedf commit 9fb8d25
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
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

0 comments on commit 9fb8d25

Please sign in to comment.