-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use CxoTime.linspace on get_aca_images for > 3hour range #181
Changes from all commits
3bcd3af
5fa5161
305d458
a2300c1
9cbc87a
15c66fa
c48deac
47fd7e4
e748730
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,11 @@ | |
import os | ||
import pickle | ||
|
||
import astropy.units as u | ||
import maude | ||
import numpy as np | ||
import pytest | ||
from cxotime import CxoTime | ||
|
||
from chandra_aca import maude_decom | ||
|
||
|
@@ -272,6 +274,58 @@ def test_partial_images(): | |
assert np.all(table[i]["IMG"].mask == mask[table[i]["IMGTYPE"]]) | ||
|
||
|
||
def test_aca_images_chunks_1(): | ||
"""Test that a fetch longer than the maude step limit works""" | ||
single_fetch_limit = maude_decom.MAUDE_SINGLE_FETCH_LIMIT | ||
maude_decom.MAUDE_SINGLE_FETCH_LIMIT = 1 * u.min | ||
start = "2023:001:00:00:01.000" | ||
stop = "2023:001:00:05:01.000" | ||
tstart = CxoTime(start).secs | ||
tstop = CxoTime(stop).secs | ||
try: | ||
imgs = maude_decom.get_aca_images(start, stop) | ||
finally: | ||
maude_decom.MAUDE_SINGLE_FETCH_LIMIT = single_fetch_limit | ||
|
||
imgs.sort(["TIME", "IMGNUM"]) | ||
|
||
for slot in range(8): | ||
# Confirm that the data is basically contiguous | ||
ok_slot = imgs["IMGNUM"] == slot | ||
# Confirm no duplicates by VCDUCTR | ||
assert len(np.unique(imgs[ok_slot]["VCDUCTR"])) == len(imgs[ok_slot]) | ||
# Confirm for these 8x8 data that there's no gap > 5 seconds | ||
assert np.max(np.diff(imgs[ok_slot]["TIME"])) < 5 | ||
|
||
# Confirm that the returned data times are within the start stop | ||
assert imgs["TIME"][0] >= tstart | ||
assert imgs["TIME"][-1] <= tstop | ||
|
||
# Confirm that the beginning and end match the expected values | ||
assert abs(imgs[0]["TIME"] - tstart) < 2 | ||
assert abs(imgs[-1]["TIME"] - tstop) < 2 | ||
|
||
imgs_start = maude_decom.get_aca_images(start, CxoTime(start) + 60 * u.s) | ||
imgs_stop = maude_decom.get_aca_images(CxoTime(stop) - 60 * u.s, stop) | ||
imgs_start.sort(["TIME", "IMGNUM"]) | ||
imgs_stop.sort(["TIME", "IMGNUM"]) | ||
assert np.all(imgs[0] == imgs_start[0]) | ||
assert np.all(imgs[-1] == imgs_stop[-1]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I simplified the PR and removed the code I had to fetch extra time and re-filter the images by TIME. And now this isn't passing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this suggest an upstream sort fix in get_aca_images? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The upstream fix would be to sort by time and slot. That's a question of API / expectations. In the current release the output is (empirically) sorted by [IMGNUM, TIME], so all the slot=0 are first and slot=7 are last. For chunked data this pattern is repeated for each chunk. Overall I think we don't care as long as the images are sorted by TIME for a given IMGNUM. That is the only ordering that is currently guaranteed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right - though we added sorting on the mica side to be out.sort(keys=["TIME", "IMGNUM"]), so maybe maude_decom.get_aca_images should just do the same for consistency. |
||
|
||
# Check the linspace times in the returned data | ||
used_step_max = 1 * u.min - 1 * u.s | ||
deltas_lte = [t <= used_step_max for t in np.diff(imgs.meta["times"])] | ||
assert np.all(deltas_lte) | ||
|
||
|
||
def test_aca_images_chunks_2(): | ||
"""Test that a fetch longer than MAUDE_FETCH_LIMIT throws a ValueError""" | ||
start = CxoTime("2023:001:00:00:01.000") | ||
stop = start + (maude_decom.MAUDE_FETCH_LIMIT * 1.1) | ||
with pytest.raises(ValueError, match="stop - start cannot be greater than"): | ||
maude_decom.get_aca_images(start, stop) | ||
|
||
|
||
def test_vcdu_vs_level0(): | ||
from astropy.table import Table | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation about the fetch intervals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't actually know that that meant so I just fluffed out the docstring a bit.