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

Update tests for 2020-02 acq model update #320

Merged
merged 2 commits into from
Feb 10, 2020
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
43 changes: 16 additions & 27 deletions proseco/tests/test_acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ def test_get_acq_catalog_21007():
' 1 1 189410928 -62.52 1763.04 160',
' 2 2 189409160 -2223.75 1998.69 160',
' 3 3 189417920 1482.94 243.72 160',
' 4 4 189015480 2222.47 -580.99 160',
' 5 5 189417752 1994.07 699.55 60',
' 6 6 189406216 -2311.90 -240.18 120',
' 7 7 189416328 1677.88 137.11 80',
' 4 4 189015480 2222.47 -580.99 80',
' 5 5 189417752 1994.07 699.55 80',
' 6 6 189406216 -2311.90 -240.18 80',
' 7 7 189416328 1677.88 137.11 100',
' 8 -99 189416496 333.11 -63.30 120',
' 9 -99 189410280 -495.21 1712.02 120',
' 10 -99 189416808 2283.31 2007.54 120',
Expand All @@ -472,10 +472,10 @@ def test_get_acq_catalog_21007():
' 1 1 189410928 -62.52 1763.04 160',
' 2 2 189409160 -2223.75 1998.69 160',
' 3 3 189417920 1482.94 243.72 160',
' 4 4 189015480 2222.47 -580.99 80',
' 5 5 189417752 1994.07 699.55 60',
' 6 6 189406216 -2311.90 -240.18 120',
' 7 7 189416328 1677.88 137.11 80']
' 4 4 189015480 2222.47 -580.99 160',
' 5 5 189417752 1994.07 699.55 80',
' 6 6 189406216 -2311.90 -240.18 60',
' 7 7 189416328 1677.88 137.11 60']

assert repr(acqs[TEST_COLS]).splitlines() == exp

Expand All @@ -498,8 +498,8 @@ def test_box_strategy_20603():
' 3 3 40114416 394.22 1204.43 160',
' 4 4 40112304 -1644.35 2032.47 80',
' 5 5 116923528 -2418.65 1088.40 160',
' 6 6 116791744 985.38 -1210.19 100',
' 7 7 40108048 2.21 1619.17 140',
' 6 6 116791744 985.38 -1210.19 140',
' 7 7 40108048 2.21 1619.17 100',
' 8 -99 116785920 -673.94 -1575.87 120',
' 9 -99 116923744 -853.18 937.73 120',
' 10 -99 116792320 941.59 -1784.10 120',
Expand Down Expand Up @@ -685,12 +685,12 @@ def test_n_acq():
' idx slot id yang zang halfw',
'int64 int64 int32 float64 float64 int64',
'----- ----- ----- -------- -------- -----',
' 0 0 100 2000.00 0.00 140',
' 1 1 108 1500.00 0.00 140',
' 2 2 101 0.00 2000.00 140',
' 3 3 109 0.00 1500.00 140',
' 4 4 102 -2000.00 0.00 120',
' 5 5 110 -1500.00 0.00 120',
' 0 0 100 2000.00 0.00 160',
' 1 1 108 1500.00 0.00 160',
' 2 2 101 0.00 2000.00 160',
' 3 3 109 0.00 1500.00 160',
' 4 4 102 -2000.00 0.00 160',
' 5 5 110 -1500.00 0.00 160',
' 6 -99 103 0.00 -2000.00 120',
' 7 -99 111 0.00 -1500.00 120',
' 8 -99 104 1000.00 1000.00 120',
Expand Down Expand Up @@ -907,12 +907,10 @@ def test_acq_fid_catalog_zero_cand_fid():
detector='HRC-S', sim_offset=300000)
aca = get_aca_catalog(**kwargs)

assert not aca.fids.thumbs_up
assert len(aca.fids) == 0
assert len(aca.fids.cand_fids) == 0
assert aca.acqs.fid_set == ()
assert len(aca.acqs) == 5
assert aca.acqs.thumbs_up


def test_acq_fid_catalog_one_cand_fid():
Expand Down Expand Up @@ -959,9 +957,6 @@ def test_acq_fid_catalog_one_cand_fid():
assert aca.acqs.fid_set == (6,)

# Not enough fids
assert aca.thumbs_up == 0
assert aca.fids.thumbs_up == 0
assert aca.acqs.thumbs_up == 1
assert aca.warnings == ['WARNING: No acq-fid combination was '
'found that met stage requirements']

Expand Down Expand Up @@ -1009,12 +1004,6 @@ def test_acq_fid_catalog_two_cand_fid(n_fid):
assert aca.fids['id'].tolist() == [1, 2]
assert aca.acqs.fid_set == (1, 2)

# If n_fid=2 then getting only 2 fids is OK, but otherwise thumbs-down.
thumbs_up = (1 if n_fid == 2 else 0)
assert aca.thumbs_up == thumbs_up
assert aca.fids.thumbs_up == thumbs_up
assert aca.acqs.thumbs_up == 1


def test_0_5_degree_man_angle_bin():
"""
Expand Down
44 changes: 3 additions & 41 deletions proseco/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_get_aca_catalog_20603():
# Force not using a bright star so there is a GUI-only (not BOT) star
aca = get_aca_catalog(20603, exclude_ids_acq=[40113544], n_fid=2, n_guide=6, n_acq=7,
raise_exc=True)
# Expected 2 fids, 6 guide, 7 acq
# Expected 2 fids, 4 guide, 7 acq
exp = ['slot idx id type sz yang zang dim res halfw',
'---- --- --------- ---- --- -------- -------- --- --- -----',
' 0 1 4 FID 8x8 2140.23 166.63 1 1 25',
Expand All @@ -55,7 +55,7 @@ def test_get_aca_catalog_20603():
' 5 6 40113544 GUI 6x6 102.74 1133.37 1 1 25',
' 5 7 116923496 ACQ 6x6 -1337.79 1049.27 20 1 120',
' 6 8 116923528 ACQ 6x6 -2418.65 1088.40 20 1 160',
' 7 9 116791744 ACQ 6x6 985.38 -1210.19 20 1 140',
' 7 9 116791744 ACQ 6x6 985.38 -1210.19 20 1 160',
' 0 10 40108048 ACQ 6x6 2.21 1619.17 20 1 140']

repr(aca) # Apply default formats
Expand Down Expand Up @@ -158,11 +158,6 @@ def test_no_candidates():
assert 'id' in acas.guides.colnames
assert 'id' in acas.fids.colnames

assert acas.thumbs_up == 0
assert acas.acqs.thumbs_up == 0
assert acas.guides.thumbs_up == 0
assert acas.fids.thumbs_up == 0


@pytest.mark.skipif('not HAS_SC_ARCHIVE', reason='Test requires starcheck archive')
def test_big_dither_from_mica_starcheck():
Expand Down Expand Up @@ -194,11 +189,6 @@ def test_pickle():
stars.add_fake_constellation(mag=10.0, n_stars=5)
aca = get_aca_catalog(stars=stars, dark=DARK40, raise_exc=True, **STD_INFO)

assert aca.thumbs_up == 0
assert aca.acqs.thumbs_up == 0
assert aca.guides.thumbs_up == 1
assert aca.fids.thumbs_up == 1

aca2 = pickle.loads(pickle.dumps(aca))

assert repr(aca) == repr(aca2)
Expand All @@ -215,7 +205,7 @@ def test_pickle():
obj = aca
obj2 = aca2

for attr in ['att', 'date', 't_ccd', 'man_angle', 'dither', 'thumbs_up']:
for attr in ['att', 'date', 't_ccd', 'man_angle', 'dither']:
val = getattr(obj, attr)
val2 = getattr(obj2, attr)
if isinstance(val, float):
Expand Down Expand Up @@ -415,11 +405,6 @@ def test_bad_obsid():
aca = get_aca_catalog(obsid='blah blah', raise_exc=False)
assert 'ValueError: text does not have OBSID' in aca.exception

assert aca.thumbs_up == 0
assert aca.acqs.thumbs_up == 0
assert aca.guides.thumbs_up == 0
assert aca.fids.thumbs_up == 0


def test_bad_pixel_dark_current():
"""
Expand Down Expand Up @@ -450,29 +435,6 @@ def test_bad_pixel_dark_current():
assert aca.acqs['halfw'].tolist() == [100, 160, 160, 160, 160]


configs = [(8.5, 1, 1, 1),
(10.12, 0, 0, 1),
(10.25, 0, 0, 0)]


@pytest.mark.parametrize('config', configs)
def test_aca_acq_gui_thumbs_up(config):
"""
Test the thumbs_up property of aca, acq, and guide selection.
Fid thumbs up is tested separately.
"""
mag, acat, guit, acqt = config
stars = StarsTable.empty()
stars.add_fake_constellation(mag=mag, n_stars=8)
aca = get_aca_catalog(**mod_std_info(stars=stars, raise_exc=True,
n_acq=8, n_guide=5))

assert aca.thumbs_up == acat
assert aca.acqs.thumbs_up == acqt
assert aca.guides.thumbs_up == guit
assert aca.fids.thumbs_up == 1


def test_fid_trap_effect():
"""Test that guide stars impacted by fid trap effect are excluded.

Expand Down
3 changes: 0 additions & 3 deletions proseco/tests/test_fid.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ def test_get_initial_catalog():
# Spoil fids 1, 2, 3
fids3 = get_fid_catalog(stars=stars[:3], **STD_INFO)
assert np.all(fids3['id'] == [4, 5, 6])
assert fids3.thumbs_up

# Spoil fids 1, 2, 3, 4 => no initial catalog gets found
fids4 = get_fid_catalog(stars=stars[:4], **STD_INFO)
assert len(fids4) == 0
assert not fids4.thumbs_up
assert all(name in fids4.colnames for name in ['id', 'yang', 'zang', 'row', 'col'])


Expand All @@ -99,7 +97,6 @@ def test_n_fid():
# Get only 2 fids
fids = get_fid_catalog(n_fid=2, **STD_INFO)
assert len(fids) == 2
assert fids.thumbs_up


@pytest.mark.parametrize('dither_z', [8, 64])
Expand Down