From b292a459d3c97dc70e037c37c8ed09177db3cd77 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Wed, 10 May 2023 16:30:49 -0400 Subject: [PATCH 1/5] in maude_decom, do not even try to add pixels if IMGTYPE==3 --- chandra_aca/maude_decom.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/chandra_aca/maude_decom.py b/chandra_aca/maude_decom.py index 9b642c5..44fc25e 100644 --- a/chandra_aca/maude_decom.py +++ b/chandra_aca/maude_decom.py @@ -521,12 +521,11 @@ def _combine_aca_packets(aca_packets): pixels = np.ma.masked_all((8, 8)) pixels.data[:] = np.nan for f in aca_packets: - i0, i1 = _IMG_INDICES[f["IMGTYPE"]] - pixels[i0, i1] = f["pixels"] # IMGTYPE 3 is not a real image. It means the pixels are used to download engineering data - # We set the pixel values to the values in telemetry, but mask them. - if f["IMGTYPE"] == 3: - pixels.mask[i0, i1] = True + # if IMGTYPE == 3, do nothing. All pixels will be masked + if f["IMGTYPE"] != 3: + i0, i1 = _IMG_INDICES[f["IMGTYPE"]] + pixels[i0, i1] = f["pixels"] for f in aca_packets: res.update(f) From 317b60f2db52f897ccba24c72209f7fdeba18ccc Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Wed, 31 May 2023 12:37:52 -0400 Subject: [PATCH 2/5] add unit test for IMGTYPE==3 images in the blob case --- chandra_aca/tests/test_maude_decom.py | 35 ++++++++++++--------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/chandra_aca/tests/test_maude_decom.py b/chandra_aca/tests/test_maude_decom.py index 006a0fe..778e3fd 100755 --- a/chandra_aca/tests/test_maude_decom.py +++ b/chandra_aca/tests/test_maude_decom.py @@ -753,27 +753,24 @@ def test_get_aca_packets_blobs(): assert blobs == ref_blobs -def test_imgtype_dnld(): +@pytest.mark.parametrize("source", ["blobs", "frames"]) +def test_imgtype_dnld(source): """ - Tests for the case when IMGTYPE is DNLD + Tests for the case when IMGTYPE is DNLD (from blobs) """ - - start = "2023:047:02:58:13.213" - stop = "2023:047:02:58:14.239" - maude_result = maude.get_frames(start, stop, channel="FLIGHT") - raw_aca_packets = maude_decom.get_raw_aca_packets( - start, stop, maude_result=maude_result - ) - # decom_packets = [maude_decom.unpack_aca_telemetry(a) for a in raw_aca_packets["packets"]] - # assert 3 not in [p['IMGTYPE'] for packet in decom_packets for p in packet] - - img = maude_decom._get_aca_packets( - raw_aca_packets, - start, - stop, - combine=False, - adjust_time=False, - calibrate=False, + from cxotime import CxoTime + + start = CxoTime("2023:047:02:58:13.213") + stop = CxoTime("2023:047:02:58:14.239") + if source == "blobs": + maude_result = maude.get_blobs(start, stop, channel="FLIGHT") + args = {"blobs": maude_result} + else: + maude_result = maude.get_frames(start, stop, channel="FLIGHT") + args = {"frames": maude_result} + + img = maude_decom.get_aca_packets( + start, stop, combine=False, adjust_time=False, calibrate=False, **args ) all_masked = np.array([np.all(row["IMG"].mask) for row in img]) From 2add1701d14852c076aaf5ed6f87cbb2216ecfda Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Thu, 1 Jun 2023 10:17:04 -0400 Subject: [PATCH 3/5] fix comments related to IMGTYPE==3 --- chandra_aca/maude_decom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chandra_aca/maude_decom.py b/chandra_aca/maude_decom.py index 44fc25e..339818c 100644 --- a/chandra_aca/maude_decom.py +++ b/chandra_aca/maude_decom.py @@ -324,7 +324,7 @@ def _aca_image_msid_list(pea): # - Type 0 is 4x4, # - Types 1 (first batch of 6x6) and 4 (first batch of 8x8) use the same pixel IDs as 4x4. # - Type 3 is not a real image type. It occurs when the image telemetry is used to download -# engineering data. In this case, the image is treated as 4x4, but the values will be giberish. +# memory dump data. In this case, the image is treated as 4x4, but the values might be giberish. # - Types 2 (second batch of 6x6) and 5 (second batch of 8x8) use the same pixel IDs. _IMG_INDICES = [ np.array([PIXEL_MAP_INV["4x4"][f"{k}1"] for k in _a2p]).T, @@ -521,7 +521,7 @@ def _combine_aca_packets(aca_packets): pixels = np.ma.masked_all((8, 8)) pixels.data[:] = np.nan for f in aca_packets: - # IMGTYPE 3 is not a real image. It means the pixels are used to download engineering data + # IMGTYPE 3 is not a real image. It means the pixels are used to download memory dump data # if IMGTYPE == 3, do nothing. All pixels will be masked if f["IMGTYPE"] != 3: i0, i1 = _IMG_INDICES[f["IMGTYPE"]] From 0a133c5938059d81a9469d2113f8cde436cd157d Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Mon, 5 Jun 2023 09:52:12 -0400 Subject: [PATCH 4/5] test IMGTYP=DNLD for more one minute --- chandra_aca/tests/test_maude_decom.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chandra_aca/tests/test_maude_decom.py b/chandra_aca/tests/test_maude_decom.py index 778e3fd..f1e2c69 100755 --- a/chandra_aca/tests/test_maude_decom.py +++ b/chandra_aca/tests/test_maude_decom.py @@ -760,8 +760,8 @@ def test_imgtype_dnld(source): """ from cxotime import CxoTime - start = CxoTime("2023:047:02:58:13.213") - stop = CxoTime("2023:047:02:58:14.239") + start = CxoTime("2023:047:02:57") + stop = CxoTime("2023:047:02:58") if source == "blobs": maude_result = maude.get_blobs(start, stop, channel="FLIGHT") args = {"blobs": maude_result} @@ -775,4 +775,5 @@ def test_imgtype_dnld(source): all_masked = np.array([np.all(row["IMG"].mask) for row in img]) img_dnld = img["IMGTYPE"] == 3 + assert img_dnld.shape[0] > 0 assert np.all(all_masked == img_dnld) From dab93884a70d0cea71ca82e95be0d2e8b99ac50a Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Mon, 5 Jun 2023 10:36:49 -0400 Subject: [PATCH 5/5] docstring fixup --- chandra_aca/tests/test_maude_decom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chandra_aca/tests/test_maude_decom.py b/chandra_aca/tests/test_maude_decom.py index f1e2c69..4153d7f 100755 --- a/chandra_aca/tests/test_maude_decom.py +++ b/chandra_aca/tests/test_maude_decom.py @@ -756,7 +756,7 @@ def test_get_aca_packets_blobs(): @pytest.mark.parametrize("source", ["blobs", "frames"]) def test_imgtype_dnld(source): """ - Tests for the case when IMGTYPE is DNLD (from blobs) + Tests for the case when IMGTYPE is DNLD. """ from cxotime import CxoTime