Skip to content

Commit

Permalink
only load patch table when needed (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Aug 26, 2024
2 parents 482ef5c + 1993203 commit 26d0393
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.16.3 (unreleased)
===================

mosaic_pipeline
---------------

- Only load patch table when needed. [#1367]

0.16.2 (2024-08-23)
===================

Expand Down
5 changes: 2 additions & 3 deletions romancal/patch_match/patch_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def find_patch_matches(image_corners, image_shape=None):
necessary information about the patches.
"""

if PATCH_TABLE is None:
load_patch_table()
if PATCH_TABLE is None:
raise RuntimeError("No patch table has been loaded")
if isinstance(image_corners, wcs.WCS):
Expand Down Expand Up @@ -250,6 +252,3 @@ def veccoords_to_tangent_plane(vertices, tangent_point_vec):
x_coords = np.dot(x_axis, avertices) * RAD_TO_ARCSEC
y_coords = np.dot(y_axis, avertices) * RAD_TO_ARCSEC
return x_coords, y_coords


load_patch_table()
4 changes: 4 additions & 0 deletions romancal/pipeline/mosaic_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def process(self, input):

# if this is a valid skycell name load the database and get the skycell record
if re.match(r"r\d{3}\w{2}\d{2}x\d{2}y\d{2}", skycell_name):
if patch_match.PATCH_TABLE is None:
patch_match.load_patch_table()
if patch_match.PATCH_TABLE is None:
raise RuntimeError("No patch table has been loaded")
skycell_record = patch_match.PATCH_TABLE[
np.where(patch_match.PATCH_TABLE["name"][:] == skycell_name)[0][0]
]
Expand Down

0 comments on commit 26d0393

Please sign in to comment.