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

only load patch table when needed #1367

Merged
merged 2 commits into from
Aug 26, 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
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