From c6cae7fe5860c6107463c49e47dad803dd29014d Mon Sep 17 00:00:00 2001 From: Arun Kannawadi Date: Thu, 31 Oct 2024 14:27:55 -0700 Subject: [PATCH] Move imports to the top of the file --- metadetect/lsst/measure.py | 3 +-- metadetect/lsst/metadetect.py | 3 +-- metadetect/lsst/skysub.py | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/metadetect/lsst/measure.py b/metadetect/lsst/measure.py index df3930e1..ded53f29 100644 --- a/metadetect/lsst/measure.py +++ b/metadetect/lsst/measure.py @@ -27,7 +27,7 @@ from ..fitting import fit_mbobs_wavg, get_wavg_output_struct from . import util -from .util import ContextNoiseReplacer +from .util import ContextNoiseReplacer, get_jacobian from . import vis from .defaults import DEFAULT_THRESH @@ -657,7 +657,6 @@ def _extract_jacobian_at_source(exp, source): Jacobian: ngmix.Jacobian The local jacobian """ - from .util import get_jacobian orig_cen = exp.getWcs().skyToPixel(source.getCoord()) diff --git a/metadetect/lsst/metadetect.py b/metadetect/lsst/metadetect.py index b3d136e2..e8527dc1 100644 --- a/metadetect/lsst/metadetect.py +++ b/metadetect/lsst/metadetect.py @@ -608,7 +608,6 @@ def fit_original_psfs_mbexp(mbexp, rng, wgts): This can fail and flags will be set, but we proceed """ - from .measure import extract_psf_image assert len(wgts) == len(mbexp) wsum = sum(wgts) @@ -634,7 +633,7 @@ def fit_original_psfs_mbexp(mbexp, rng, wgts): ) jac = get_jacobian(exp=exp, cen=cen) - psf_im = extract_psf_image(exp, cen) + psf_im = measure.extract_psf_image(exp, cen) psf_cen = (np.array(psf_im.shape)-1.0)/2.0 psf_jacob = jac.copy() diff --git a/metadetect/lsst/skysub.py b/metadetect/lsst/skysub.py index 05df3e56..72297916 100644 --- a/metadetect/lsst/skysub.py +++ b/metadetect/lsst/skysub.py @@ -6,8 +6,8 @@ ) from lsst.meas.algorithms import SourceDetectionConfig as OriginalSourceDetectionConfig from lsst.pex.config import Config, ConfigurableField, Field -from lsst.pipe.base import Task - +from lsst.pex.exceptions import RuntimeError as LSSTRuntimeError +from lsst.pipe.base import Task, TaskError from .defaults import DEFAULT_THRESH from . import util @@ -64,8 +64,6 @@ def __init__(self, *args, **kwargs): self.makeSubtask("back") def run(self, exposure): - from lsst.pex.exceptions import RuntimeError as LSSTRuntimeError - from lsst.pipe.base.task import TaskError if self.config.niter < 1: raise ValueError(f'niter {self.config.niter} is less than 1')