From cc4ab13e00ad2440b94b3f270407fd95c7d0ffda Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Mon, 10 Jun 2019 16:50:25 -0400 Subject: [PATCH] Implement clipping of catalog MAXMAG to 11.2 mag --- proseco/acq.py | 2 +- proseco/catalog.py | 4 ++-- proseco/characteristics.py | 4 ++++ proseco/tests/test_catalog.py | 26 ++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/proseco/acq.py b/proseco/acq.py index 0e447ea3..dbae720e 100644 --- a/proseco/acq.py +++ b/proseco/acq.py @@ -614,7 +614,7 @@ def calc_p_brightest(self, acq, box_size, man_err=0, bgd=0): # Imposters ext_box_size = box_size + dither kwargs = dict(star_row=acq['row'], star_col=acq['col'], - maxmag=acq['mag'] + acq['mag_err'], # + 1.5, TO DO: put to characteristics + maxmag=acq['mag'] + acq['mag_err'], box_size=ext_box_size, dark=dark, bgd=bgd, # TO DO deal with this diff --git a/proseco/catalog.py b/proseco/catalog.py index 4b02a1d5..7e2885eb 100644 --- a/proseco/catalog.py +++ b/proseco/catalog.py @@ -425,7 +425,7 @@ def merge_cats(fids=None, guides=None, acqs=None): if len(guides) > 0: guides['slot'] = 0 # Filled in later guides['type'] = 'GUI' - guides['maxmag'] = guides['mag'] + 1.5 + guides['maxmag'] = (guides['mag'] + 1.5).clip(None, ACA.max_maxmag) guides['p_acq'] = 0 guides['dim'] = 1 guides['res'] = 1 @@ -434,7 +434,7 @@ def merge_cats(fids=None, guides=None, acqs=None): if len(acqs) > 0: acqs['type'] = 'ACQ' - acqs['maxmag'] = acqs['mag'] + 1.5 + acqs['maxmag'] = (acqs['mag'] + 1.5).clip(None, ACA.max_maxmag) acqs['dim'] = 20 acqs['sz'] = guide_size acqs['res'] = 1 diff --git a/proseco/characteristics.py b/proseco/characteristics.py index a477da6c..c0723525 100644 --- a/proseco/characteristics.py +++ b/proseco/characteristics.py @@ -17,6 +17,10 @@ PIX_2_ARC = 4.96289 ARC_2_PIX = 1.0 / PIX_2_ARC +# Maximum value of star catalog MAXMAG parameter. Clip value and implications +# of clipping discussed in emails circa June 7, 2019 with search key "maxmag". +max_maxmag = 11.2 + # Convenience characteristics max_ccd_row = CCD['row_max'] - CCD['row_pad'] # Max allowed row for stars (SOURCE?) max_ccd_col = CCD['col_max'] - CCD['col_pad'] # Max allow col for stars (SOURCE?) diff --git a/proseco/tests/test_catalog.py b/proseco/tests/test_catalog.py index a2eda594..c039d5cf 100644 --- a/proseco/tests/test_catalog.py +++ b/proseco/tests/test_catalog.py @@ -261,6 +261,32 @@ def test_copy_deepcopy_pickle(): assert val is not val2 +def test_clip_maxmag(): + """Test that clipping maxmag for guide and acq stars works + """ + stars = StarsTable.empty() + mag0 = ACA.max_maxmag - 1.5 # nominal star mag when clipping occurs (11.2 - 1.5 = 9.7) + mags_acq = np.array([-1.5, -1, -0.5, -0.01, 0.01, 0.2, 0.3, 0.4]) + mag0 + mags_guide = np.array([-0.5, -0.01, 0.01, 0.2, 0.3]) + mag0 + stars.add_fake_constellation(mag=mags_acq, n_stars=8, size=2000) + stars.add_fake_constellation(mag=mags_guide, n_stars=5, size=1000) + aca = get_aca_catalog(stars=stars, dark=DARK40, raise_exc=True, + exclude_ids_guide=np.arange(100, 108), + exclude_ids_acq=np.arange(108, 113), + **STD_INFO) + + assert np.all(aca['maxmag'] <= ACA.max_maxmag) + + ok = aca['type'] == 'FID' + assert np.allclose(aca['maxmag'][ok], 8.0) + + ok = aca['type'] == 'GUI' + assert np.allclose(aca['maxmag'][ok], (mags_guide + 1.5).clip(None, ACA.max_maxmag)) + + ok = aca['type'] == 'ACQ' + assert np.allclose(aca['maxmag'][ok], (mags_acq + 1.5).clip(None, ACA.max_maxmag)) + + def test_big_sim_offset(): """ Check getting a catalog for a large SIM offset that means there are