From 31d1ead43f759c76f16b77a6feb845e46246c251 Mon Sep 17 00:00:00 2001 From: David Stark Date: Wed, 28 Feb 2024 14:35:41 -0500 Subject: [PATCH 01/11] update_dq routine can now rescale input mask dimensions --- acstools/utils_findsat_mrt.py | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/acstools/utils_findsat_mrt.py b/acstools/utils_findsat_mrt.py index 51637cd..d1ff099 100644 --- a/acstools/utils_findsat_mrt.py +++ b/acstools/utils_findsat_mrt.py @@ -10,7 +10,7 @@ from astropy.convolution import convolve, Gaussian2DKernel from astropy.io import fits from astropy.modeling import models, fitting -from astropy.nddata import Cutout2D +from astropy.nddata import Cutout2D, block_replicate from astropy.stats import sigma_clip from astropy.table import Table, vstack from astropy.utils.exceptions import AstropyUserWarning @@ -1179,7 +1179,7 @@ def radon(image, theta=None, circle=False, *, preserve_range=False, return radon_image -def update_dq(filename, ext, mask, dqval=16384, verbose=True): +def update_dq(filename, ext, mask, dqval=16384, verbose=True, expand_mask=False): """Update the given image and DQ extension with the given satellite trails mask and flag. @@ -1199,10 +1199,48 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True): tailored for ACS/WFC. verbose : bool, optional Print extra information to the terminal. + expand_mask: int, optional + Allows the mask to be expanded to match the size of the original mask. + This is relevant for masks that were generated used binned versions of + the original image """ with fits.open(filename, mode='update') as pf: dqarr = pf[ext].data + + # check that the old mask and new mask are the same size + same_size = mask.shape == dqarr.shape + + if not same_size: + LOG.info('Inconsistent mask sizes: \n' + 'Input mask: {} \n' + 'DQ array: {}'.format(mask.shape, dqarr.shape)) + if not expand_mask: + LOG.warning('Cannot proceed due to size mismatch.\n' + 'Set expand_mask=True if the mask was generated with \n' + 'binned data and needs to be enlarged to the original size') + return + else: + LOG.info('Enlarging mask to original size') + factor_x = np.floor(dqarr.shape[1]/mask.shape[1]).astype(int) + factor_y = np.floor(dqarr.shape[0]/mask.shape[0]).astype(int) + mask = block_replicate(mask, [factor_y,factor_x], conserve_sum=False) + + # for original data that had odd dimensions before binning, the + # mask still will not match the original. Duplicate end rows/columns in this case + + same_size = mask.shape == dqarr.shape + if not same_size: + LOG.info('Still inconsistent mask sizes: \n' + 'Input mask: {} \n' + 'DQ array: {}'.format(mask.shape, dqarr.shape)) + LOG.info('Duplicating end rows/columns to match original size') + while mask.shape[0] != dqarr.shape[0]: + mask = np.vstack([mask,mask[-1,:]]) + + while mask.shape[1] != dqarr.shape[1]: + mask = np.hstack([mask,mask[:,-1].reshape(mask.shape[0],1)]) + old_mask = (dqval & dqarr) != 0 # Existing flagged trails new_mask = mask & ~old_mask # Only flag previously unflagged trails npix_updated = np.count_nonzero(new_mask) From b06935d9c6ae843d00d407e16496b32878daa75e Mon Sep 17 00:00:00 2001 From: David Stark Date: Wed, 28 Feb 2024 14:42:26 -0500 Subject: [PATCH 02/11] added warning about odd image dimensions when rebinning --- acstools/findsat_mrt.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/acstools/findsat_mrt.py b/acstools/findsat_mrt.py index 43a3d43..c1d41e2 100644 --- a/acstools/findsat_mrt.py +++ b/acstools/findsat_mrt.py @@ -1360,6 +1360,11 @@ def rebin(self): LOG.info('Rebinning the data by {}'.format(self.binsize)) + # trigger a warning if the image dimensions are not even + if (self.image.shape[0] % self.binsize != 0) | (self.image.shape[1] % self.binsize != 0): + LOG.warning('Warning: image dimensions do not evenly divide by bin size.\n' + 'Extra rows/columns will be trimmed first') + # setting a warning filter for the nansum calculations. These # warnings are inconsequential and already accounted for in the code with warnings.catch_warnings(): From dda458b3cb2dd2e93ecfa20ecf15216a59656cfa Mon Sep 17 00:00:00 2001 From: David Stark Date: Wed, 28 Feb 2024 15:30:18 -0500 Subject: [PATCH 03/11] formatting fixes --- acstools/findsat_mrt.py | 9 +++++---- acstools/utils_findsat_mrt.py | 33 ++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/acstools/findsat_mrt.py b/acstools/findsat_mrt.py index c1d41e2..5bce7bd 100644 --- a/acstools/findsat_mrt.py +++ b/acstools/findsat_mrt.py @@ -1361,9 +1361,10 @@ def rebin(self): LOG.info('Rebinning the data by {}'.format(self.binsize)) # trigger a warning if the image dimensions are not even - if (self.image.shape[0] % self.binsize != 0) | (self.image.shape[1] % self.binsize != 0): - LOG.warning('Warning: image dimensions do not evenly divide by bin size.\n' - 'Extra rows/columns will be trimmed first') + if ((self.image.shape[0] % self.binsize != 0)) | \ + ((self.image.shape[1] % self.binsize != 0)): + LOG.warning('Warning: image dimensions do not evenly divide by bin' + 'size.\n Extra rows/columns will be trimmed first') # setting a warning filter for the nansum calculations. These # warnings are inconsequential and already accounted for in the code @@ -1411,4 +1412,4 @@ def update_dq(self, dqval=16384, verbose=True): raise ValueError(f'DQ array can only be updated for FLC/FLT images, not {self.image_type}') # noqa update_dq(self.image_file, self.extension + 2, self.mask, dqval=dqval, - verbose=verbose) + verbose=verbose, expand_mask=True) diff --git a/acstools/utils_findsat_mrt.py b/acstools/utils_findsat_mrt.py index d1ff099..66cb490 100644 --- a/acstools/utils_findsat_mrt.py +++ b/acstools/utils_findsat_mrt.py @@ -1179,7 +1179,8 @@ def radon(image, theta=None, circle=False, *, preserve_range=False, return radon_image -def update_dq(filename, ext, mask, dqval=16384, verbose=True, expand_mask=False): +def update_dq(filename, ext, mask, dqval=16384, verbose=True, + expand_mask=False): """Update the given image and DQ extension with the given satellite trails mask and flag. @@ -1212,34 +1213,40 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, expand_mask=False) same_size = mask.shape == dqarr.shape if not same_size: - LOG.info('Inconsistent mask sizes: \n' - 'Input mask: {} \n' + LOG.info('Inconsistent mask sizes: \n' + 'Input mask: {} \n' 'DQ array: {}'.format(mask.shape, dqarr.shape)) if not expand_mask: LOG.warning('Cannot proceed due to size mismatch.\n' - 'Set expand_mask=True if the mask was generated with \n' - 'binned data and needs to be enlarged to the original size') + 'Set expand_mask=True if the mask was generated' + 'with binned data and needs to be enlarged to the' + 'original size') return else: LOG.info('Enlarging mask to original size') factor_x = np.floor(dqarr.shape[1]/mask.shape[1]).astype(int) factor_y = np.floor(dqarr.shape[0]/mask.shape[0]).astype(int) - mask = block_replicate(mask, [factor_y,factor_x], conserve_sum=False) + mask = block_replicate(mask, [factor_y, factor_x], + conserve_sum=False) - # for original data that had odd dimensions before binning, the - # mask still will not match the original. Duplicate end rows/columns in this case + # for original data that had odd dimensions before binning, the + # mask still will not match the original. Duplicate end + # rows/columns in this case same_size = mask.shape == dqarr.shape if not same_size: - LOG.info('Still inconsistent mask sizes: \n' - 'Input mask: {} \n' + LOG.info('Still inconsistent mask sizes: \n' + 'Input mask: {} \n' 'DQ array: {}'.format(mask.shape, dqarr.shape)) - LOG.info('Duplicating end rows/columns to match original size') + LOG.info('Duplicating end rows/columns to match orig size') while mask.shape[0] != dqarr.shape[0]: - mask = np.vstack([mask,mask[-1,:]]) + mask = np.vstack([mask, + mask[-1, :]]) while mask.shape[1] != dqarr.shape[1]: - mask = np.hstack([mask,mask[:,-1].reshape(mask.shape[0],1)]) + mask = np.hstack([mask, + mask[:, -1].reshape(mask.shape[0], + 1)]) old_mask = (dqval & dqarr) != 0 # Existing flagged trails new_mask = mask & ~old_mask # Only flag previously unflagged trails From 5747a009aae10ebc12907559bf9340cfd28dda23 Mon Sep 17 00:00:00 2001 From: David Stark Date: Thu, 29 Feb 2024 10:04:17 -0500 Subject: [PATCH 04/11] minor formatting fixes --- acstools/utils_findsat_mrt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acstools/utils_findsat_mrt.py b/acstools/utils_findsat_mrt.py index 66cb490..376eea6 100644 --- a/acstools/utils_findsat_mrt.py +++ b/acstools/utils_findsat_mrt.py @@ -1218,8 +1218,8 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, 'DQ array: {}'.format(mask.shape, dqarr.shape)) if not expand_mask: LOG.warning('Cannot proceed due to size mismatch.\n' - 'Set expand_mask=True if the mask was generated' - 'with binned data and needs to be enlarged to the' + 'Set expand_mask=True if the mask was generated ' + 'with binned data and needs to be enlarged to the ' 'original size') return else: From 2464d47c524b56c79cd3fb7c2ba1a1830d193bbb Mon Sep 17 00:00:00 2001 From: David Stark Date: Mon, 11 Mar 2024 14:23:45 -0400 Subject: [PATCH 05/11] minor fixes to findsat_mrt and utils_findsat_mrt --- acstools/findsat_mrt.py | 6 +++--- acstools/utils_findsat_mrt.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/acstools/findsat_mrt.py b/acstools/findsat_mrt.py index 5bce7bd..27a8ca5 100644 --- a/acstools/findsat_mrt.py +++ b/acstools/findsat_mrt.py @@ -1361,10 +1361,10 @@ def rebin(self): LOG.info('Rebinning the data by {}'.format(self.binsize)) # trigger a warning if the image dimensions are not even - if ((self.image.shape[0] % self.binsize != 0)) | \ + if ((self.image.shape[0] % self.binsize != 0)) | ((self.image.shape[1] % self.binsize != 0)): - LOG.warning('Warning: image dimensions do not evenly divide by bin' - 'size.\n Extra rows/columns will be trimmed first') + LOG.warning('Image dimensions do not evenly divide by bin size.' + '\nExtra rows/columns will be trimmed first.') # setting a warning filter for the nansum calculations. These # warnings are inconsequential and already accounted for in the code diff --git a/acstools/utils_findsat_mrt.py b/acstools/utils_findsat_mrt.py index 376eea6..cbbb339 100644 --- a/acstools/utils_findsat_mrt.py +++ b/acstools/utils_findsat_mrt.py @@ -1200,10 +1200,10 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, tailored for ACS/WFC. verbose : bool, optional Print extra information to the terminal. - expand_mask: int, optional + expand_mask: bool, optional Allows the mask to be expanded to match the size of the original mask. This is relevant for masks that were generated used binned versions of - the original image + the original image. """ with fits.open(filename, mode='update') as pf: @@ -1220,10 +1220,10 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, LOG.warning('Cannot proceed due to size mismatch.\n' 'Set expand_mask=True if the mask was generated ' 'with binned data and needs to be enlarged to the ' - 'original size') + 'original size.') return else: - LOG.info('Enlarging mask to original size') + LOG.info('Enlarging mask to original size.') factor_x = np.floor(dqarr.shape[1]/mask.shape[1]).astype(int) factor_y = np.floor(dqarr.shape[0]/mask.shape[0]).astype(int) mask = block_replicate(mask, [factor_y, factor_x], From 41b2b66698fb54132e5d71b0062074bd0d00b6f9 Mon Sep 17 00:00:00 2001 From: David Stark Date: Mon, 11 Mar 2024 14:34:18 -0400 Subject: [PATCH 06/11] added binsize>=1 requirement to binsize setter --- acstools/findsat_mrt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/acstools/findsat_mrt.py b/acstools/findsat_mrt.py index 27a8ca5..b1a81ed 100644 --- a/acstools/findsat_mrt.py +++ b/acstools/findsat_mrt.py @@ -1290,8 +1290,8 @@ def binsize(self): @binsize.setter def binsize(self, value): - if value is not None and not isinstance(value, int): - raise ValueError(f"binsize must be None or int but got: {value}") + if value is not None and not (isinstance(value, int) and value >= 1): + raise ValueError(f"binsize must be None or int >= 1 but got: {value}") # noqa self._binsize = value @property @@ -1361,8 +1361,8 @@ def rebin(self): LOG.info('Rebinning the data by {}'.format(self.binsize)) # trigger a warning if the image dimensions are not even - if ((self.image.shape[0] % self.binsize != 0)) | - ((self.image.shape[1] % self.binsize != 0)): + if (((self.image.shape[0] % self.binsize != 0)) | + ((self.image.shape[1] % self.binsize != 0))): LOG.warning('Image dimensions do not evenly divide by bin size.' '\nExtra rows/columns will be trimmed first.') From 84b69d0b115bcdbb01c6dc938e1b0b269723e786 Mon Sep 17 00:00:00 2001 From: David Stark Date: Mon, 11 Mar 2024 15:00:13 -0400 Subject: [PATCH 07/11] extra checks/errors added to update_dq for cases where mask is larger than dq array --- acstools/utils_findsat_mrt.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/acstools/utils_findsat_mrt.py b/acstools/utils_findsat_mrt.py index cbbb339..67397b3 100644 --- a/acstools/utils_findsat_mrt.py +++ b/acstools/utils_findsat_mrt.py @@ -1203,7 +1203,7 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, expand_mask: bool, optional Allows the mask to be expanded to match the size of the original mask. This is relevant for masks that were generated used binned versions of - the original image. + the original image. """ with fits.open(filename, mode='update') as pf: @@ -1211,13 +1211,23 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, # check that the old mask and new mask are the same size same_size = mask.shape == dqarr.shape + mask_larger = np.any([mask.shape[i] > dqarr.shape[i] + for i in range(mask.ndim)]) + # provide informative error messages depending on mask/dqarr size if not same_size: LOG.info('Inconsistent mask sizes: \n' 'Input mask: {} \n' 'DQ array: {}'.format(mask.shape, dqarr.shape)) - if not expand_mask: - LOG.warning('Cannot proceed due to size mismatch.\n' + + if mask_larger: + LOG.error('Mask is larger than the DQ array in one or more ' + 'dimensions.\nThis routine cannot currently rescale' + 'masks that are larger than the origin input image') + return + + elif not mask_larger and not expand_mask: + LOG.error('Cannot proceed due to size mismatch.\n' 'Set expand_mask=True if the mask was generated ' 'with binned data and needs to be enlarged to the ' 'original size.') From b4e0301984eb17d1c560a1d71d4796c0f66af64b Mon Sep 17 00:00:00 2001 From: David Stark Date: Mon, 11 Mar 2024 16:29:01 -0400 Subject: [PATCH 08/11] reworked the step to enlarge mask to match dq array --- acstools/utils_findsat_mrt.py | 42 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/acstools/utils_findsat_mrt.py b/acstools/utils_findsat_mrt.py index 67397b3..0c3d8f4 100644 --- a/acstools/utils_findsat_mrt.py +++ b/acstools/utils_findsat_mrt.py @@ -1234,29 +1234,41 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, return else: LOG.info('Enlarging mask to original size.') + + # Determine factor by which to scale-up the image. Scales should + # be the same for the x and y dimensions, after we round down + # to the nearest integer in case there are extra rows/columns + # that do not divide evenly. These extra rows/columns will be + # added back at the end. This approach is the reverse of + # astropy.nddata.block_reduce, which trims extra rows/cols + # first. + factor_x = np.floor(dqarr.shape[1]/mask.shape[1]).astype(int) factor_y = np.floor(dqarr.shape[0]/mask.shape[0]).astype(int) - mask = block_replicate(mask, [factor_y, factor_x], + if factor_x != factor_y: + raise ValueError('Mask dimensions require scaling by' + 'different amounts in order to match the DQ' + 'array but this is not allowed.') + else: + factor = factor_x + + # assess whether there will be extra rows/columns after scaling + extra_cols = dqarr.shape[1] - mask.shape[1]*factor + extra_rows = dqarr.shape[0] - mask.shape[0]*factor + + mask = block_replicate(mask, factor, conserve_sum=False) - # for original data that had odd dimensions before binning, the - # mask still will not match the original. Duplicate end - # rows/columns in this case - - same_size = mask.shape == dqarr.shape - if not same_size: - LOG.info('Still inconsistent mask sizes: \n' - 'Input mask: {} \n' - 'DQ array: {}'.format(mask.shape, dqarr.shape)) - LOG.info('Duplicating end rows/columns to match orig size') + if extra_rows > 0: + LOG.info('Duplicating end rows to match orig size') while mask.shape[0] != dqarr.shape[0]: - mask = np.vstack([mask, - mask[-1, :]]) + mask = np.vstack([mask, mask[-1, :]]) + if extra_cols > 0: + LOG.info('Duplicating end columns to match orig size') while mask.shape[1] != dqarr.shape[1]: mask = np.hstack([mask, - mask[:, -1].reshape(mask.shape[0], - 1)]) + mask[:, -1].reshape(mask.shape[0],1)]) old_mask = (dqval & dqarr) != 0 # Existing flagged trails new_mask = mask & ~old_mask # Only flag previously unflagged trails From 6336676e2c9f17cea79cdc1861b0684d4d56e070 Mon Sep 17 00:00:00 2001 From: David Stark Date: Tue, 12 Mar 2024 15:20:06 -0400 Subject: [PATCH 09/11] flake8 fixes for utils_findsat_mrt --- acstools/utils_findsat_mrt.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/acstools/utils_findsat_mrt.py b/acstools/utils_findsat_mrt.py index 0c3d8f4..e6a4121 100644 --- a/acstools/utils_findsat_mrt.py +++ b/acstools/utils_findsat_mrt.py @@ -21,7 +21,7 @@ from skimage.transform._warps import warp from skimage._shared.utils import convert_to_float except ImportError as e: - warnings.warn(f'skimage not installed. MRT calculation will not work: {repr(e)}') + warnings.warn(f'skimage not installed. MRT calculation will not work: {repr(e)}') # noqa # check for scipy try: @@ -108,8 +108,8 @@ def merge_tables(tbls, theta_sep=10, rho_sep=10): drho = np.abs(t['ycentroid'] - s['ycentroid']) sel = (dtheta < theta_sep) & (drho < rho_sep) keep[sel] = False - # Silence MergeConflictWarning for "date" metadata because - # the tables were created with different timestamps. The last entry is kept. + # Silence MergeConflictWarning for "date" metadata because the tables + # were created with different timestamps. The last entry is kept. src = vstack([src, t[keep]], metadata_conflicts="silent") return src @@ -1203,7 +1203,7 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, expand_mask: bool, optional Allows the mask to be expanded to match the size of the original mask. This is relevant for masks that were generated used binned versions of - the original image. + the original image. """ with fits.open(filename, mode='update') as pf: @@ -1211,7 +1211,7 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, # check that the old mask and new mask are the same size same_size = mask.shape == dqarr.shape - mask_larger = np.any([mask.shape[i] > dqarr.shape[i] + mask_larger = np.any([mask.shape[i] > dqarr.shape[i] for i in range(mask.ndim)]) # provide informative error messages depending on mask/dqarr size @@ -1219,7 +1219,7 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, LOG.info('Inconsistent mask sizes: \n' 'Input mask: {} \n' 'DQ array: {}'.format(mask.shape, dqarr.shape)) - + if mask_larger: LOG.error('Mask is larger than the DQ array in one or more ' 'dimensions.\nThis routine cannot currently rescale' @@ -1228,27 +1228,27 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, elif not mask_larger and not expand_mask: LOG.error('Cannot proceed due to size mismatch.\n' - 'Set expand_mask=True if the mask was generated ' - 'with binned data and needs to be enlarged to the ' - 'original size.') + 'Set expand_mask=True if the mask was generated ' + 'with binned data and needs to be enlarged to the ' + 'original size.') return else: LOG.info('Enlarging mask to original size.') - # Determine factor by which to scale-up the image. Scales should + # Determine factor by which to scale-up image. Scales should # be the same for the x and y dimensions, after we round down - # to the nearest integer in case there are extra rows/columns - # that do not divide evenly. These extra rows/columns will be + # to the nearest integer in case there are extra rows/columns + # that do not divide evenly. These extra rows/columns will be # added back at the end. This approach is the reverse of # astropy.nddata.block_reduce, which trims extra rows/cols - # first. + # first. factor_x = np.floor(dqarr.shape[1]/mask.shape[1]).astype(int) factor_y = np.floor(dqarr.shape[0]/mask.shape[0]).astype(int) if factor_x != factor_y: raise ValueError('Mask dimensions require scaling by' - 'different amounts in order to match the DQ' - 'array but this is not allowed.') + 'different amounts in order to match the' + 'DQ array but this is not allowed.') else: factor = factor_x @@ -1267,8 +1267,7 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, if extra_cols > 0: LOG.info('Duplicating end columns to match orig size') while mask.shape[1] != dqarr.shape[1]: - mask = np.hstack([mask, - mask[:, -1].reshape(mask.shape[0],1)]) + mask = np.hstack([mask, mask[:, -1].reshape(mask.shape[0], 1)]) # noqa old_mask = (dqval & dqarr) != 0 # Existing flagged trails new_mask = mask & ~old_mask # Only flag previously unflagged trails From 5fb0cca1100b35837d24d41cf0cb14f44843c828 Mon Sep 17 00:00:00 2001 From: David Stark Date: Thu, 14 Mar 2024 12:15:28 -0400 Subject: [PATCH 10/11] formatting fixes, rewrote mask/dq aspect ratio error --- acstools/utils_findsat_mrt.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/acstools/utils_findsat_mrt.py b/acstools/utils_findsat_mrt.py index e6a4121..d2523b5 100644 --- a/acstools/utils_findsat_mrt.py +++ b/acstools/utils_findsat_mrt.py @@ -1222,7 +1222,7 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, if mask_larger: LOG.error('Mask is larger than the DQ array in one or more ' - 'dimensions.\nThis routine cannot currently rescale' + 'dimensions.\nThis routine cannot currently rescale ' 'masks that are larger than the origin input image') return @@ -1246,9 +1246,19 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, factor_x = np.floor(dqarr.shape[1]/mask.shape[1]).astype(int) factor_y = np.floor(dqarr.shape[0]/mask.shape[0]).astype(int) if factor_x != factor_y: - raise ValueError('Mask dimensions require scaling by' - 'different amounts in order to match the' - 'DQ array but this is not allowed.') + + mask_aspect = mask.shape[1]/mask.shape[0] + dq_aspect = dqarr.shape[1]/dqarr.shape[0] + + raise ValueError('Mask and DQ array axis aspect ratios are' + ' too different\n' + 'Mask dimensions (x,y) = {}\n' + 'Mask aspect ratio (x/y) = {}\n' + 'DQ array dimensions (y,x) = {}\n' + 'DQ array aspect ratio (x/y) = {}' + .format(mask.shape, mask_aspect, + dqarr.shape, dq_aspect)) + else: factor = factor_x From b4540a225b0af799a17fa6f7a8c7ca6eab6b770b Mon Sep 17 00:00:00 2001 From: dvstark Date: Thu, 14 Mar 2024 12:58:17 -0400 Subject: [PATCH 11/11] sphinx formatting fix Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> --- acstools/utils_findsat_mrt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acstools/utils_findsat_mrt.py b/acstools/utils_findsat_mrt.py index d2523b5..ea4a2a7 100644 --- a/acstools/utils_findsat_mrt.py +++ b/acstools/utils_findsat_mrt.py @@ -1200,7 +1200,7 @@ def update_dq(filename, ext, mask, dqval=16384, verbose=True, tailored for ACS/WFC. verbose : bool, optional Print extra information to the terminal. - expand_mask: bool, optional + expand_mask : bool, optional Allows the mask to be expanded to match the size of the original mask. This is relevant for masks that were generated used binned versions of the original image.