From 8f77f297b664c9f17ba3e0fd4800b44bfb2da179 Mon Sep 17 00:00:00 2001 From: radicamc Date: Tue, 28 Nov 2023 10:33:50 -0500 Subject: [PATCH] Upgrade to v2.1.0 --- applesoss/edgetrigger_centroids.py | 26 +++++++++++++++++--------- applesoss/edgetrigger_utils.py | 2 ++ changelog.md | 4 ++++ setup.py | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/applesoss/edgetrigger_centroids.py b/applesoss/edgetrigger_centroids.py index abbb24a..35400d1 100644 --- a/applesoss/edgetrigger_centroids.py +++ b/applesoss/edgetrigger_centroids.py @@ -291,16 +291,24 @@ def get_centroids_edgetrigger(image, header=None, mask=None, poly_order=11, if mask is None: mask = np.zeros_like(image, dtype='bool') - # Call the script that determines the dimensions of the image. - result = get_image_dim(image, header=header, verbose=verbose) - dimx, dimy, xos, yos, xnative, ynative, padding, refpix_mask = result - - # Replace masked pixel values with NaNs. - image_masked = np.where(mask | ~refpix_mask, np.nan, image) + try: + # Call the script that determines the dimensions of the image -- SOSS + # specific code. + result = get_image_dim(image, header=header, verbose=verbose) + dimx, dimy, xos, yos, xnative, ynative, padding, refpix_mask = result + # Replace masked pixel values with NaNs. + image_masked = np.where(mask | ~refpix_mask, np.nan, image) + # Use edge trigger to compute the edges and center of the trace. + fkwargs = dict(halfwidth=halfwidth, yos=yos, verbose=verbose, + outdir=outdir) + except ValueError: + # Will work for any data frame. + dimy, dimx = np.shape(image) + image_masked = image + # Use edge trigger to compute the edges and center of the trace. + fkwargs = dict(halfwidth=halfwidth, yos=1, verbose=verbose, + outdir=outdir) - # Use edge trigger to compute the edges and center of the trace. - fkwargs = dict(halfwidth=halfwidth, yos=yos, verbose=verbose, - outdir=outdir) edge_outs = edge_trigger(image_masked, **fkwargs) ytrace_max, ytrace_min, ytrace_best, widths_best = edge_outs diff --git a/applesoss/edgetrigger_utils.py b/applesoss/edgetrigger_utils.py index 698aa5b..8a24428 100644 --- a/applesoss/edgetrigger_utils.py +++ b/applesoss/edgetrigger_utils.py @@ -65,6 +65,8 @@ def _poly_res(p, x, y): """ return np.polyval(p, x) - y + ii = np.where(np.isfinite(y)) + x, y = x[ii], y[ii] mask = np.ones_like(x, dtype='bool') for niter in range(maxiter): diff --git a/changelog.md b/changelog.md index 560643b..09866b4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +### [2.1.0] -- 2023-11-28 +#### Added +- Edits to edgetrigger functions to allow its use for non-SOSS data. + ### [2.0.2] -- 2023-07-24 #### Added - Streamline installation process. diff --git a/setup.py b/setup.py index c44b160..71c699e 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup setup(name='applesoss', - version='2.0.2', + version='2.1.0', license='MIT', author='Michael Radica', author_email='michael.radica@umontreal.ca',