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

Refactoring of parse_subarray_map_step and test #69

Merged
merged 3 commits into from
Jul 9, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -677,4 +677,22 @@ properties:
title: Number of pixels in detector y-axis direction
type: integer
fits_keyword: DETYSIZ
blend_table: True
blend_table: True
subarray_map:
title: Subarray map
type: array
items:
type: object
properties:
xstart:
title: Starting pixel in axis 1 direction
type: integer
ystart:
title: Starting pixel in axis 2 direction
type: integer
xsize:
title: Number of pixels in axis 1 direction
type: integer
ysize:
title: Number of pixels in axis 2 direction
type: integer
41 changes: 26 additions & 15 deletions liger_iris_pipeline/parse_subarray_map/parse_subarray_map_step.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import numpy as np

from jwst.stpipe import Step
from jwst import datamodels
from .. import datamodels
import stdatamodels

__all__ = ["ParseSubarrayMapStep"]

SUBARRAY_DQ_BIT = 4


# NOTE: xstart/ystart use 1-based indexing
def parse_subarray_map(subarray_map):
subarray_metadata = []
for subarray_id in range(1, 10 + 1):
Expand All @@ -34,18 +35,28 @@ class ParseSubarrayMapStep(Step):

def process(self, input):

with datamodels.open(input) as input_model:

if "subarr_map" in input_model:
self.log.info("Parsing the SUBARR_MAP extension")
result = input_model.copy()
for each in parse_subarray_map(result["subarr_map"]):
result.meta.subarray_map.append(each)
result.dq[result["subarr_map"] != 0] = np.bitwise_or(
result.dq[result["subarr_map"] != 0], 2 ** SUBARRAY_DQ_BIT
)
else:
self.log.info("No SUBARR_MAP extension found")
result = input_model
if isinstance(input, str):
input_model = datamodels.open(input)
else:
input_model = input

if "subarr_map" in input_model:

self.log.info("Parsing the SUBARR_MAP extension")

result = input_model.copy()

# Create metadata from image ID map
for each in parse_subarray_map(result["subarr_map"]):
result.meta.subarray_map.append(each)

# Indicate subarrays in dq flags
result.dq[result["subarr_map"] != 0] = np.bitwise_or(
result.dq[result["subarr_map"] != 0],
2 ** SUBARRAY_DQ_BIT
)
else:
self.log.info("No SUBARR_MAP extension found")
result = input_model

return result
259 changes: 0 additions & 259 deletions liger_iris_pipeline/tests/test_parse_subarray_map.ipynb

This file was deleted.

Loading
Loading