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

Use P2 for calc_p_safe and optimization metric #190

Merged
merged 2 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions proseco/acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,8 @@ def calc_p_safe(self, verbose=False):
if verbose:
self.log(f'man_err = {man_err}, p_man_err = {p_man_err}')
self.log('p_acqs =' + ' '.join(['{:.3f}'.format(val) for val in p_acqs]))
self.log('log10(p 1_or_fewer) = {:.2f}'.format(np.log10(p_n_cum[1])))
p_01 = p_n_cum[1] # 1 or fewer => p_fail at this man_err
self.log('log10(p 2_or_fewer) = {:.2f}'.format(np.log10(p_n_cum[2])))
p_01 = p_n_cum[2] # 2 or fewer => p_fail at this man_err
taldcroft marked this conversation as resolved.
Show resolved Hide resolved

p_no_safe *= (1 - p_man_err * p_01)

Expand Down
12 changes: 6 additions & 6 deletions proseco/tests/test_acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def test_box_strategy_20603():
' 4 4 40112304 -1644.35 2032.47 160',
' 5 5 116923528 -2418.65 1088.40 160',
' 6 6 116791744 985.38 -1210.19 160',
' 7 7 40108048 2.21 1619.17 160']
' 7 7 40108048 2.21 1619.17 60']

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

Expand Down Expand Up @@ -753,7 +753,7 @@ def test_acq_fid_catalog_probs_low_level():

# Initial fid set is empty () and we check baseline p_safe
assert acqs.fid_set == ()
assert np.allclose(np.log10(acqs.calc_p_safe()), -4.0,
assert np.allclose(np.log10(acqs.calc_p_safe()), -2.4,
rtol=0, atol=0.1)

# This is the acq star spoiled by fid_id=2
Expand All @@ -777,7 +777,7 @@ def test_acq_fid_catalog_probs_low_level():
# spoils an acq star. This makes the p_safe value much worse.
acqs.fid_set = (4, 3, 2)
assert acqs.fid_set == (2, 3, 4) # gets sorted when set
assert np.allclose(np.log10(acqs.calc_p_safe()), -2.6,
assert np.allclose(np.log10(acqs.calc_p_safe()), -1.3,
rtol=0, atol=0.1)

# With fid_set = (1, 2, 4), the probability multiplier for catalog
Expand All @@ -790,7 +790,7 @@ def test_acq_fid_catalog_probs_low_level():
# set does not spoil an acq star.
for fid_set in ((1, 3, 4), ()):
acqs.fid_set = fid_set
assert np.allclose(np.log10(acqs.calc_p_safe()), -4.0,
assert np.allclose(np.log10(acqs.calc_p_safe()), -2.4,
rtol=0, atol=0.1)

# Check that p_acqs() method responds to fid_set in expected way
Expand Down Expand Up @@ -925,7 +925,7 @@ def test_acq_fid_catalog_one_cand_fid():
aca = get_aca_catalog(**kwargs)

assert aca.acqs['id'].tolist() == [1, 100, 101, 102, 103]
assert aca.acqs['halfw'].tolist() == [80, 160, 160, 160, 140]
assert aca.acqs['halfw'].tolist() == [80, 160, 160, 160, 120]

assert aca.n_fid == 3
assert aca.fids['id'].tolist() == [6]
Expand Down Expand Up @@ -976,7 +976,7 @@ def test_acq_fid_catalog_two_cand_fid(n_fid):
aca = get_aca_catalog(**kwargs)

assert aca.acqs['id'].tolist() == [1, 100, 101, 102, 103]
assert aca.acqs['halfw'].tolist() == [80, 160, 160, 160, 140]
assert aca.acqs['halfw'].tolist() == [80, 160, 160, 160, 120]

assert aca.n_fid == n_fid
assert aca.fids['id'].tolist() == [1, 2]
Expand Down
6 changes: 3 additions & 3 deletions proseco/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ def test_get_aca_catalog_20603():
'---- --- --------- ---- --- -------- -------- --- --- -----',
' 0 1 4 FID 8x8 2140.23 166.63 1 1 25',
' 1 2 5 FID 8x8 -1826.28 160.17 1 1 25',
' 2 3 40112304 BOT 6x6 -1644.35 2032.47 20 1 160',
' 2 3 40112304 BOT 6x6 -1644.35 2032.47 20 1 80',
' 3 4 40114416 BOT 6x6 394.22 1204.43 20 1 140',
' 4 5 116791824 BOT 6x6 622.00 -953.60 20 1 160',
' 5 6 116923528 BOT 6x6 -2418.65 1088.40 20 1 160',
' 6 7 40113544 GUI 6x6 102.74 1133.37 1 1 25',
' 6 8 116923496 ACQ 6x6 -1337.79 1049.27 20 1 120',
' 7 9 116791744 ACQ 6x6 985.38 -1210.19 20 1 160',
' 0 10 40108048 ACQ 6x6 2.21 1619.17 20 1 60']
' 7 9 116791744 ACQ 6x6 985.38 -1210.19 20 1 140',
' 0 10 40108048 ACQ 6x6 2.21 1619.17 20 1 140']

repr(aca) # Apply default formats
assert aca[TEST_COLS].pformat(max_width=-1) == exp
Expand Down