diff --git a/CHANGES.rst b/CHANGES.rst index 2d3daac62..166b2a524 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,11 @@ +0.16.3 (unreleased) +=================== + +mosaic_pipeline +--------------- + +- Only load patch table when needed. [#1367] + 0.16.2 (2024-08-23) =================== diff --git a/romancal/patch_match/patch_match.py b/romancal/patch_match/patch_match.py index 1eeac86eb..d456a238d 100644 --- a/romancal/patch_match/patch_match.py +++ b/romancal/patch_match/patch_match.py @@ -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): @@ -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() diff --git a/romancal/pipeline/mosaic_pipeline.py b/romancal/pipeline/mosaic_pipeline.py index 707faa0ac..6ea40e26f 100644 --- a/romancal/pipeline/mosaic_pipeline.py +++ b/romancal/pipeline/mosaic_pipeline.py @@ -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] ]