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

Possibly fix derived param aliases test #232

Merged
merged 2 commits into from
Jul 7, 2022
Merged
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
26 changes: 14 additions & 12 deletions Ska/engarchive/tests/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,27 @@ def test_filter_bad_times_default_copy():
assert np.all(dates == DATES_EXPECT2)


@pytest.mark.parametrize('msid', ['DP_piTch_fss', 'Calc_pitCH_fss'])
@pytest.mark.parametrize('msid', ['DP_piTch_css', 'Calc_pitCH_css'])
@pytest.mark.parametrize('sources', (('cxc',), ('maude',), ('cxc', 'maude')))
def test_fetch_derived_param_aliases(msid, sources):
cxc_tstop = fetch.get_time_range('dp_pitch_fss', 'secs')[1]
cxc_tstop = fetch.get_time_range('dp_pitch_css', 'secs')[1]
dt = 2000 # seconds
msg = (f'{CxoTime(cxc_tstop).date=} {dt=}\n'
f'{CxoTime(cxc_tstop - dt).date=}\n'
f'{CxoTime(cxc_tstop + dt).date=}\n'
f'{CxoTime.now().date=}\n'
f'{CxoTime.now().iso=}\n'
f'{sources=} {msid=}')
print(msg) # stdout gets reported for test failures
with fetch.data_source(*sources):
# Get data from +/- 1 day from end of CXC data
dt = 86400 # seconds
d1 = fetch.Msid('piTch_fss', cxc_tstop - dt, cxc_tstop + dt)
d2 = fetch.Msid(msid, cxc_tstop - dt, cxc_tstop + dt)
# Get data within `dt` secs of end of CXC data
d1 = fetch.MSID('piTCh_css', cxc_tstop - dt, cxc_tstop + dt)
d2 = fetch.MSID(msid, cxc_tstop - dt, cxc_tstop + dt)
assert d2.msid == msid # version as the user provide
assert d2.MSID == d1.MSID # normalized version for accessing databases
assert np.all(d1.times == d2.times)
assert np.all(d1.vals == d2.vals)
if len(d1) == 0:
msg = (f'No data found for cxo_tstop={CxoTime(cxc_tstop).date} {dt=}'
f' {sources=} {msid=} '
f'{CxoTime(cxc_tstop - dt).date=} '
f'{CxoTime(cxc_tstop + dt).date=}')
raise AssertionError(msg)
assert len(d1) > 0


def test_interpolate():
Expand Down