Set star IDs per star and fix get_starcats bug - #352
Conversation
So one failure does not abort the rest
d6f9770 to
1cd3ceb
Compare
| ) | ||
| assert np.count_nonzero(starcats[0]["id"] == -999) == 0 | ||
| assert np.count_nonzero(starcats[0]["mag"] == -999) == 0 | ||
| assert np.count_nonzero(starcats[1]["id"] == -999) == 3 |
There was a problem hiding this comment.
The previous value of 3 highlights the original bug because only one star in the catalog is not in AGASC 1.8.
| start, stop = "2021:365:19:00:00", "2022:002:01:25:00" | ||
| """Test getting star catalogs with commands""" | ||
| # The start is the AOSTRCAT date for the first of 7 observations. | ||
| start, stop = "2021:365:18:39:25.983", "2022:002:01:25:00" |
There was a problem hiding this comment.
This needed fine tuning because get_observations has an inclusive view of the start/stop range compared to get_cmds which is the exact command date range.
There was a problem hiding this comment.
I think these are good changes. I also think it is good to remove the exception from the logic, not just because it fixes the present issue of skipping subsequent rows. Whenever I have used exceptions to change the flow of the program, I have ended up regretting it.
Similar as PR #381, I think the commands v2 tests might need update. I get these failures:
_________________________________________________ test_get_starcat_only_agasc1p8 _________________________________________________
def test_get_starcat_only_agasc1p8():
"""For obsids 3829 and 2576, try AGASC 1.8 only
For 3829 star identification should succeed, for 2576 it fails.
"""
with (
conf.set_temp("cache_starcats", False),
conf.set_temp("date_start_agasc1p8", "1994:001"),
):
# Force AGASC 1.8 and show that star identification fails
with ska_helpers.utils.set_log_level(kadi.logger, "CRITICAL"):
starcats = get_starcats(
"2002:365:16:00:00", "2002:365:19:00:00", scenario="flight"
)
assert np.count_nonzero(starcats[0]["id"] == -999) == 0
assert np.count_nonzero(starcats[0]["mag"] == -999) == 0
> assert np.count_nonzero(starcats[1]["id"] == -999) == 3
E AssertionError: assert np.int64(1) == 3
E + where np.int64(1) = <function count_nonzero at 0x10362daf0>(<Column name='id' dtype='int64' length=13>\n 1\n 4\n 5\n1180048472\n1181749304\n1211498544\n1211508992\n1211501128\n1181748464\n1181746776\n -999\n1211502976\n1211507712 == -999)
E + where <function count_nonzero at 0x10362daf0> = np.count_nonzero
kadi/commands/tests/test_commands_v2.py:1104: AssertionError
__________________________________________________ test_get_starcats_with_cmds ___________________________________________________
def test_get_starcats_with_cmds():
start, stop = "2021:365:19:00:00", "2022:002:01:25:00"
cmds = commands.get_cmds(start, stop, scenario="flight")
starcats0 = get_starcats(start, stop)
starcats1 = get_starcats(cmds=cmds)
> assert len(starcats0) == len(starcats1)
E assert 7 == 6
E + where 7 = len([<ACATable length=11>\n slot idx id type sz mag ... yang zang dim res halfw\nint64 int64 in...468.81 -646.74 1 1 25\n 7 9 125311224 ACQ 8x8 9.14 ... 2308.41 709.62 8 1 60, ...])
E + and 6 = len([<ACATable length=10>\n slot idx id type sz mag ... yang zang dim res halfw\nint64 int64 in...... -1534.55 -1989.80 16 1 100\n 2 11 29884784 ACQ 6x6 9.64 ... 647.71 -848.31 24 1 140])
kadi/commands/tests/test_commands_v2.py:1113: AssertionError
==================================================== short test summary info =====================================================
FAILED kadi/commands/tests/test_commands_v2.py::test_get_starcat_only_agasc1p8 - AssertionError: assert np.int64(1) == 3
FAILED kadi/commands/tests/test_commands_v2.py::test_get_starcats_with_cmds - assert 7 == 6
|
@javierggt - I fixed the v2 tests. |
Description
This fixes a couple of issues:
get_starcatsfunction was not correctly using thecmdsargument when it was passed. It was only usingcmdsto get the observations, but then taking the actual starcat commands from the cached global dict of command parameters.Interface impacts
None.
Testing
Unit tests
Commands v2
Independent check of unit tests by Javier
Functional tests
No functional testing.