From 6ca69603ba167e630758ad2a8c51c55676fa5f2d Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Sat, 18 Feb 2023 13:44:08 -0500 Subject: [PATCH 01/16] add gridded psf wrapper [WIP] --- crowdsource/psf.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index a98601d..c0c6034 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1222,3 +1222,63 @@ def wise_psf_fit(x, y, xcen, ycen, stamp, imstamp, modstamp, return SimplePSF(newstamp) else: return GridInterpPSF(newstamp, psfstamp[1], psfstamp[2]) + + +class WrappedPSFModel(crowdsource.psf.SimplePSF): + """ + wrapper for photutils GriddedPSFModel + """ + def __init__(self, psfgridmodel, shape): + self.psfgridmodel = psfgridmodel + self.stampsz = shape + + @property + def stampsz(self): + return self.shape + + @stampsz.setter + def stampsz(self, shape): + if np.isscalar(shape): + shape = [shape, shape] + for val in shape: + if val % 2 == 0: + raise ValueError("Use only odd-dimension PSF stamps") + self.shape = shape + + @property + @cache + def deriv(self): + self._deriv = np.gradient(-self.render_model(0, 0)) + return self._deriv + + def __call__(self, col, row, stampsz=None, deriv=False): + if stampsz is not None: + self.stampsz = stampsz + + # numpy uses row, column notation + rows, cols = np.indices(self.stampsz) - (np.array(self.stampsz)-1)[:, None, None] / 2. + + # explicitly broadcast + col = np.atleast_1d(col) + row = np.atleast_1d(row) + rows = rows[:, :, None] + row[None, None, :] + cols = cols[:, :, None] + col[None, None, :] + + # photutils seems to use column, row notation + stamps = grid.evaluate(cols, rows, 1, col, row).T + # it returns something in (nstamps, row, col) shape + # pretty sure that ought to be (col, row, nstamps) for crowdsource + + return stamps.squeeze() + + + def render_model(self, col, row, stampsz=None): + """ + this function likely does nothing? + """ + if stampsz is not None: + self.stampsz = stampsz + + rows, cols = np.indices(self.stampsz, dtype=float) - (np.array(self.stampsz)-1)[:, None, None] / 2. + + return self.psfgridmodel.evaluate(cols, rows, 1, col, row).T.squeeze() From 7aa1e3c57334a1721ed2743f567ed90c3d696b52 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Sat, 18 Feb 2023 13:48:47 -0500 Subject: [PATCH 02/16] use the parshape/tparsshape strucutre and fix a ... no, nothing is fixed. --- crowdsource/psf.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index c0c6034..cda8e68 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1252,6 +1252,10 @@ def deriv(self): return self._deriv def __call__(self, col, row, stampsz=None, deriv=False): + + parshape = numpy.broadcast(col, row).shape + tparshape = parshape if len(parshape) > 0 else (1,) + if stampsz is not None: self.stampsz = stampsz @@ -1265,11 +1269,14 @@ def __call__(self, col, row, stampsz=None, deriv=False): cols = cols[:, :, None] + col[None, None, :] # photutils seems to use column, row notation - stamps = grid.evaluate(cols, rows, 1, col, row).T + ret = stamps = grid.evaluate(cols, rows, 1, col, row).T # it returns something in (nstamps, row, col) shape # pretty sure that ought to be (col, row, nstamps) for crowdsource - return stamps.squeeze() + if parshape != tparshape: + ret = ret.reshape(stampsz, stampsz) + + return ret def render_model(self, col, row, stampsz=None): From c5dfeaf739aadbb55eed4f8c3170f1a1fddd50f6 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Sat, 18 Feb 2023 13:56:22 -0500 Subject: [PATCH 03/16] implement derivative --- crowdsource/psf.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index cda8e68..6c7c204 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1245,12 +1245,6 @@ def stampsz(self, shape): raise ValueError("Use only odd-dimension PSF stamps") self.shape = shape - @property - @cache - def deriv(self): - self._deriv = np.gradient(-self.render_model(0, 0)) - return self._deriv - def __call__(self, col, row, stampsz=None, deriv=False): parshape = numpy.broadcast(col, row).shape @@ -1269,12 +1263,21 @@ def __call__(self, col, row, stampsz=None, deriv=False): cols = cols[:, :, None] + col[None, None, :] # photutils seems to use column, row notation - ret = stamps = grid.evaluate(cols, rows, 1, col, row).T + stamps = grid.evaluate(cols, rows, 1, col, row) # it returns something in (nstamps, row, col) shape # pretty sure that ought to be (col, row, nstamps) for crowdsource + if deriv: + dpsfdrow, dpsfdcol = np.gradient(stamps, axis=(0, 1)) + dpsfdrow = dpsfdrow.T + dpsfdcol = dpsfdcol.T + + ret = stamps.T if parshape != tparshape: - ret = ret.reshape(stampsz, stampsz) + ret = ret.reshape(self.stampsz) + if deriv: + dpsfdx = dpsfdx.reshape(self.stampsz) + dpsfdy = dpsfdy.reshape(self.stampsz) return ret From 28f67d3023b18f19a44d3bf116c755eafaaad9d2 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Sat, 18 Feb 2023 14:07:58 -0500 Subject: [PATCH 04/16] this version works (needed to modify returns for deriv) --- crowdsource/psf.py | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index 6c7c204..df03bf6 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1228,33 +1228,20 @@ class WrappedPSFModel(crowdsource.psf.SimplePSF): """ wrapper for photutils GriddedPSFModel """ - def __init__(self, psfgridmodel, shape): + def __init__(self, psfgridmodel, stampsz=19): self.psfgridmodel = psfgridmodel - self.stampsz = shape - - @property - def stampsz(self): - return self.shape - - @stampsz.setter - def stampsz(self, shape): - if np.isscalar(shape): - shape = [shape, shape] - for val in shape: - if val % 2 == 0: - raise ValueError("Use only odd-dimension PSF stamps") - self.shape = shape + self.default_stampsz = stampsz def __call__(self, col, row, stampsz=None, deriv=False): + if stampsz is None: + stampsz = self.default_stampsz + parshape = numpy.broadcast(col, row).shape tparshape = parshape if len(parshape) > 0 else (1,) - if stampsz is not None: - self.stampsz = stampsz - # numpy uses row, column notation - rows, cols = np.indices(self.stampsz) - (np.array(self.stampsz)-1)[:, None, None] / 2. + rows, cols = np.indices((stampsz, stampsz)) - (np.array([stampsz, stampsz])-1)[:, None, None] / 2. # explicitly broadcast col = np.atleast_1d(col) @@ -1274,10 +1261,12 @@ def __call__(self, col, row, stampsz=None, deriv=False): ret = stamps.T if parshape != tparshape: - ret = ret.reshape(self.stampsz) + ret = ret.reshape(stampsz, stampsz) if deriv: - dpsfdx = dpsfdx.reshape(self.stampsz) - dpsfdy = dpsfdy.reshape(self.stampsz) + dpsfdrow = dpsfdrow.reshape(stampsz, stampsz) + dpsfdcol = dpsfdcol.reshape(stampsz, stampsz) + if deriv: + ret = (ret, dpsfdcol, dpsfdrow) return ret From 715b10e91a03f98f62761a24a18850123ea93d64 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Thu, 11 May 2023 13:10:17 -0400 Subject: [PATCH 05/16] bugfix --- crowdsource/psf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index df03bf6..d0620e2 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1224,7 +1224,7 @@ def wise_psf_fit(x, y, xcen, ycen, stamp, imstamp, modstamp, return GridInterpPSF(newstamp, psfstamp[1], psfstamp[2]) -class WrappedPSFModel(crowdsource.psf.SimplePSF): +class WrappedPSFModel(SimplePSF): """ wrapper for photutils GriddedPSFModel """ From c859dd69daf951ed5d0febac3c9a63d842eafadd Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Wed, 24 May 2023 12:37:59 -0400 Subject: [PATCH 06/16] fix bad variable name --- crowdsource/psf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index d0620e2..0691f93 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1250,7 +1250,7 @@ def __call__(self, col, row, stampsz=None, deriv=False): cols = cols[:, :, None] + col[None, None, :] # photutils seems to use column, row notation - stamps = grid.evaluate(cols, rows, 1, col, row) + stamps = self.psfgridmodel.evaluate(cols, rows, 1, col, row) # it returns something in (nstamps, row, col) shape # pretty sure that ought to be (col, row, nstamps) for crowdsource From 1ac020d987e07e8de3ac474aa4a46721f56838bf Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Tue, 7 Nov 2023 15:18:01 -0500 Subject: [PATCH 07/16] add some debug print statements --- crowdsource/crowdsource_base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crowdsource/crowdsource_base.py b/crowdsource/crowdsource_base.py index 079987e..7ad50bf 100644 --- a/crowdsource/crowdsource_base.py +++ b/crowdsource/crowdsource_base.py @@ -302,6 +302,7 @@ def fit_once(im, x, y, psfs, weight=None, 'Number of pixels being fit is too large (>2**32); ' 'failing early. This usually indicates a problem with ' 'the choice of PSF size & too many sources.') + print(f"zsz = {zsz}") xloc = numpy.zeros(zsz, dtype='i4') values = numpy.zeros(len(xloc), dtype='f4') colnorm = numpy.zeros(len(x)*repeat+nskypar, dtype='f4') @@ -908,6 +909,8 @@ def fit_im(im, psf, weight=None, dq=None, psfderiv=True, # i.e., 50k saturates, so we can cut there. brightenough = (guessflux/fluxunc > threshold*3/5.) | (guessflux > 1e5) isolatedenough = cull_near(xa, ya, guessflux) + if verbose: + print(f"threshold={threshold}, median fluxunc={np.nanmedian(fluxunc)}, median flux={np.nanmedian(guessflux)}") keep = brightenough & isolatedenough xa, ya = (c[keep] for c in (xa, ya)) From 444a0b73afba927563b493400a8d99e72d09b1ef Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Tue, 7 Nov 2023 15:42:39 -0500 Subject: [PATCH 08/16] np->numpy --- crowdsource/crowdsource_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsource/crowdsource_base.py b/crowdsource/crowdsource_base.py index 7ad50bf..420e233 100644 --- a/crowdsource/crowdsource_base.py +++ b/crowdsource/crowdsource_base.py @@ -910,7 +910,7 @@ def fit_im(im, psf, weight=None, dq=None, psfderiv=True, brightenough = (guessflux/fluxunc > threshold*3/5.) | (guessflux > 1e5) isolatedenough = cull_near(xa, ya, guessflux) if verbose: - print(f"threshold={threshold}, median fluxunc={np.nanmedian(fluxunc)}, median flux={np.nanmedian(guessflux)}") + print(f"threshold={threshold}, median fluxunc={numpy.nanmedian(fluxunc)}, median flux={numpy.nanmedian(guessflux)}") keep = brightenough & isolatedenough xa, ya = (c[keep] for c in (xa, ya)) From 063f5cf219fd3302e0f7cfd5e77960a5dda752d2 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Sat, 18 Nov 2023 21:35:45 -0500 Subject: [PATCH 09/16] add @andrew-saydjari's version, slightly modified since unnecessary calculations were being performed --- crowdsource/psf.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index 0691f93..13711fa 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1246,20 +1246,24 @@ def __call__(self, col, row, stampsz=None, deriv=False): # explicitly broadcast col = np.atleast_1d(col) row = np.atleast_1d(row) - rows = rows[:, :, None] + row[None, None, :] - cols = cols[:, :, None] + col[None, None, :] + #rows = rows[:, :, None] + row[None, None, :] + #cols = cols[:, :, None] + col[None, None, :] # photutils seems to use column, row notation - stamps = self.psfgridmodel.evaluate(cols, rows, 1, col, row) + #stamps = self.psfgridmodel.evaluate(cols, rows, 1, col, row) # it returns something in (nstamps, row, col) shape # pretty sure that ought to be (col, row, nstamps) for crowdsource + for i in range(len(col)): + stamps.append(self.psfgridmodel.evaluate(cols+col[i], rows+row[i], 1, col[i], row[i])) + stampsS = np.stack(stamps,axis=0) + stamps = np.transpose(stampsS,axes=(0,2,1)) if deriv: dpsfdrow, dpsfdcol = np.gradient(stamps, axis=(0, 1)) dpsfdrow = dpsfdrow.T dpsfdcol = dpsfdcol.T - ret = stamps.T + ret = stamps if parshape != tparshape: ret = ret.reshape(stampsz, stampsz) if deriv: From 5c516c20ca522bc89ef06c8e757d9e1c8a529ecf Mon Sep 17 00:00:00 2001 From: Adam Ginsburg Date: Sun, 19 Nov 2023 20:30:22 -0500 Subject: [PATCH 10/16] Update psf.py --- crowdsource/psf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index 13711fa..0947c42 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1259,7 +1259,7 @@ def __call__(self, col, row, stampsz=None, deriv=False): stamps = np.transpose(stampsS,axes=(0,2,1)) if deriv: - dpsfdrow, dpsfdcol = np.gradient(stamps, axis=(0, 1)) + dpsfdrow, dpsfdcol = np.gradient(stamps, axis=(1, 2)) dpsfdrow = dpsfdrow.T dpsfdcol = dpsfdcol.T From aa1d14b5cfb735e639d202cfa270f63a42d5b42b Mon Sep 17 00:00:00 2001 From: Adam Ginsburg Date: Sun, 19 Nov 2023 20:32:27 -0500 Subject: [PATCH 11/16] Update psf.py --- crowdsource/psf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index 0947c42..5e2d90a 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1253,10 +1253,12 @@ def __call__(self, col, row, stampsz=None, deriv=False): #stamps = self.psfgridmodel.evaluate(cols, rows, 1, col, row) # it returns something in (nstamps, row, col) shape # pretty sure that ought to be (col, row, nstamps) for crowdsource + stamps = [] for i in range(len(col)): stamps.append(self.psfgridmodel.evaluate(cols+col[i], rows+row[i], 1, col[i], row[i])) - stampsS = np.stack(stamps,axis=0) - stamps = np.transpose(stampsS,axes=(0,2,1)) + + # swap (z,y,x) -> (z,x,y) + stamps = np.transpose(stamps, axes=(0,2,1)) if deriv: dpsfdrow, dpsfdcol = np.gradient(stamps, axis=(1, 2)) From 941e28a5b842c52a8841359cd5f1be5b15255feb Mon Sep 17 00:00:00 2001 From: Adam Ginsburg Date: Sun, 19 Nov 2023 20:33:14 -0500 Subject: [PATCH 12/16] Update psf.py --- crowdsource/psf.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/crowdsource/psf.py b/crowdsource/psf.py index 5e2d90a..7b4aead 100644 --- a/crowdsource/psf.py +++ b/crowdsource/psf.py @@ -1262,8 +1262,6 @@ def __call__(self, col, row, stampsz=None, deriv=False): if deriv: dpsfdrow, dpsfdcol = np.gradient(stamps, axis=(1, 2)) - dpsfdrow = dpsfdrow.T - dpsfdcol = dpsfdcol.T ret = stamps if parshape != tparshape: From 6242c1cdfc8a4661659c160bc4e85bab6e59e351 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Thu, 30 Nov 2023 15:34:09 -0500 Subject: [PATCH 13/16] debug --- crowdsource/crowdsource_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsource/crowdsource_base.py b/crowdsource/crowdsource_base.py index 420e233..cc1ebd4 100644 --- a/crowdsource/crowdsource_base.py +++ b/crowdsource/crowdsource_base.py @@ -302,7 +302,7 @@ def fit_once(im, x, y, psfs, weight=None, 'Number of pixels being fit is too large (>2**32); ' 'failing early. This usually indicates a problem with ' 'the choice of PSF size & too many sources.') - print(f"zsz = {zsz}") + print(f"zsz = {zsz}, sz={sz}, nskypar={nskypar}, npixim={npixim}, repeat={repeat}") xloc = numpy.zeros(zsz, dtype='i4') values = numpy.zeros(len(xloc), dtype='f4') colnorm = numpy.zeros(len(x)*repeat+nskypar, dtype='f4') From 31f1fa536ca9fe71b7027e409c18c8c9e9e75292 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Thu, 30 Nov 2023 21:26:48 -0500 Subject: [PATCH 14/16] change i4->i8 --- crowdsource/crowdsource_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsource/crowdsource_base.py b/crowdsource/crowdsource_base.py index cc1ebd4..38ac814 100644 --- a/crowdsource/crowdsource_base.py +++ b/crowdsource/crowdsource_base.py @@ -296,7 +296,7 @@ def fit_once(im, x, y, psfs, weight=None, repeat = 1 if not psfderiv else 3 nskypar = nskyx * nskyy npixim = im.shape[0]*im.shape[1] - zsz = (repeat*numpy.sum(sz*sz) + nskypar*npixim).astype('i4') + zsz = (repeat*numpy.sum(sz*sz) + nskypar*npixim).astype('i8') if zsz >= 2**32: raise ValueError( 'Number of pixels being fit is too large (>2**32); ' From aea508d93eb0948541a80c55af147f160551e681 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Tue, 18 Jun 2024 11:42:52 -0400 Subject: [PATCH 15/16] comment out excess verbosity --- crowdsource/crowdsource_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsource/crowdsource_base.py b/crowdsource/crowdsource_base.py index 38ac814..cbfcbe8 100644 --- a/crowdsource/crowdsource_base.py +++ b/crowdsource/crowdsource_base.py @@ -302,7 +302,7 @@ def fit_once(im, x, y, psfs, weight=None, 'Number of pixels being fit is too large (>2**32); ' 'failing early. This usually indicates a problem with ' 'the choice of PSF size & too many sources.') - print(f"zsz = {zsz}, sz={sz}, nskypar={nskypar}, npixim={npixim}, repeat={repeat}") + # DEBUG print(f"zsz = {zsz}, sz={sz}, nskypar={nskypar}, npixim={npixim}, repeat={repeat}") xloc = numpy.zeros(zsz, dtype='i4') values = numpy.zeros(len(xloc), dtype='f4') colnorm = numpy.zeros(len(x)*repeat+nskypar, dtype='f4') From d3d9ace49a3ec42773de86b2a9d3c3d685313833 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Wed, 31 Jul 2024 14:04:53 -0400 Subject: [PATCH 16/16] verbosity things and some tweaks from working with Saydjari --- crowdsource/crowdsource_base.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/crowdsource/crowdsource_base.py b/crowdsource/crowdsource_base.py index cbfcbe8..2505055 100644 --- a/crowdsource/crowdsource_base.py +++ b/crowdsource/crowdsource_base.py @@ -297,9 +297,9 @@ def fit_once(im, x, y, psfs, weight=None, nskypar = nskyx * nskyy npixim = im.shape[0]*im.shape[1] zsz = (repeat*numpy.sum(sz*sz) + nskypar*npixim).astype('i8') - if zsz >= 2**32: + if zsz >= 2**33: raise ValueError( - 'Number of pixels being fit is too large (>2**32); ' + 'Number of pixels being fit is too large (>2**33); ' 'failing early. This usually indicates a problem with ' 'the choice of PSF size & too many sources.') # DEBUG print(f"zsz = {zsz}, sz={sz}, nskypar={nskypar}, npixim={npixim}, repeat={repeat}") @@ -747,7 +747,8 @@ def fit_im(im, psf, weight=None, dq=None, psfderiv=True, maxstars=40000, derivcentroids=False, ntilex=1, ntiley=1, fewstars=100, threshold=5, ccd=None, plot=False, titer_thresh=2, blendthreshu=2, - psfvalsharpcutfac=0.7, psfsharpsat=0.7): + psfvalsharpcutfac=0.7, psfsharpsat=0.7, + add_new_peaks_every_other_iteration=False): if isinstance(weight, int): weight = numpy.ones_like(im)*weight @@ -770,7 +771,7 @@ def fit_im(im, psf, weight=None, dq=None, psfderiv=True, titer += 1 hsky = sky_im(im-model, weight=weight, npix=20) lsky = sky_im(im-model, weight=weight, npix=50*roughfwhm) - if titer != lastiter: + if titer != lastiter and not ((titer % 2 == 0) and add_new_peaks_every_other_iteration): # in first passes, do not split sources! blendthresh = blendthreshu if titer < titer_thresh else 0.2 xn, yn = peakfind(im-model-hsky, @@ -825,10 +826,6 @@ def fit_im(im, psf, weight=None, dq=None, psfderiv=True, print("Starting subregion iterations") for (bdxf, bdxl, bdxaf, bdxal, bdyf, bdyl, bdyaf, bdyal) in ( subregions(im.shape, ntilex, ntiley)): - if verbose: - print(f"Subregion iteration {subreg_iter} starting; " - f"dt={time.time()-t0}", flush=True) - subreg_iter += 1 mbda = in_bounds(xa, ya, [bdxaf-0.5, bdxal-0.5], [bdyaf-0.5, bdyal-0.5]) mbd = in_bounds(xa, ya, [bdxf-0.5, bdxl-0.5], @@ -871,6 +868,11 @@ def fit_im(im, psf, weight=None, dq=None, psfderiv=True, import gc gc.collect() + if verbose: + print(f"Subregion iteration {subreg_iter} finished; " + f"dt={time.time()-t0}", flush=True) + subreg_iter += 1 + centroids = compute_centroids(xa, ya, psfs, flux, im-(sky+msky), im-model-sky, weight, derivcentroids=derivcentroids) @@ -910,7 +912,7 @@ def fit_im(im, psf, weight=None, dq=None, psfderiv=True, brightenough = (guessflux/fluxunc > threshold*3/5.) | (guessflux > 1e5) isolatedenough = cull_near(xa, ya, guessflux) if verbose: - print(f"threshold={threshold}, median fluxunc={numpy.nanmedian(fluxunc)}, median flux={numpy.nanmedian(guessflux)}") + print(f"threshold={threshold}, median fluxunc={numpy.nanmedian(fluxunc)}, median flux={numpy.nanmedian(guessflux)} time={time.time()-t0}") keep = brightenough & isolatedenough xa, ya = (c[keep] for c in (xa, ya))