From 4ddcd9a44ece6317d543895b48018210694c5c39 Mon Sep 17 00:00:00 2001 From: dpieterse Date: Mon, 1 Jun 2026 16:58:40 +0200 Subject: [PATCH 1/3] Fixed numpy chained indexing bug Due to an indexing bug, a copy of the mask was updated instead of the mask_rej itself. This resulted in no pixels being discarded in the optimal photometry for sources with S/N <= 100 with too many outlier pixels, rather than rejecting the fraction of pixels with the highest deviation. This bug caused (seeing-dependent) jumps in light curves. --- zogy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zogy.py b/zogy.py index efbd305..9a963e2 100644 --- a/zogy.py +++ b/zogy.py @@ -8705,7 +8705,9 @@ def flux_optimal_iter (P, D, bkg_var, mask_use, nsigma_inn, nsigma_out, idx_limfrac = idx_sort[mask_use_inn][:npix_limfrac] # update inner mask_rej - mask_rej[mask_inn][idx_limfrac] = True + inner_indices = np.where(mask_inn)[0] + mask_rej[mask_inn] = False # reset mask + mask_rej[inner_indices[idx_limfrac]] = True if False: log.warning ( From 43f73f8eb74cf94d3bca1f022ba4b3da6cf148ed Mon Sep 17 00:00:00 2001 From: dpieterse Date: Wed, 15 Jul 2026 21:43:30 +0200 Subject: [PATCH 2/3] Change path header table MeerLICHT --- force_phot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/force_phot.py b/force_phot.py index a42aeff..22a6dd0 100644 --- a/force_phot.py +++ b/force_phot.py @@ -2808,7 +2808,7 @@ def str2None (value): # able to infer the table description used futher down below if tel == 'ML1': - fits_hdrtable_list = ['/idia/projects/meerlicht/Headers/' + fits_hdrtable_list = ['/idia/projects/meerlicht/data/hdrtables/' 'ML1_headers_cat.fits'] else: From 0a8294034dbc219b58139018c085953889bc36af Mon Sep 17 00:00:00 2001 From: dpieterse Date: Fri, 17 Jul 2026 23:34:25 +0200 Subject: [PATCH 3/3] Permission errors prevent copying metadata over when updated files are made by a different user than the original files. Catch this in an exception. --- zogy.py | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/zogy.py b/zogy.py index 9a963e2..6955ead 100644 --- a/zogy.py +++ b/zogy.py @@ -1641,8 +1641,12 @@ def prep_fits (fits_in, header, gain, satlevel, str2add): elif str2add is not None: # name was updated; copy (unzipped) fits_in to fits_out - shutil.copy2 (fits_in, fits_out) - + try: + shutil.copy2 (fits_in, fits_out) + except PermissionError as e: + log.warning('could not copy timestamps/metadata/permissions for ' + '{} -> {} ({}). file data was copied successfully though' + .format(fits_in, fits_out, e)) return fits_out, header @@ -3625,7 +3629,12 @@ def format_cat (cat_in, cat_out, cat_type=None, header2add=None, if get_par(set_zogy.keep_tmp,tel): # save catalog before formatting cat_preformat = cat_in.replace('.fits', '_preformat.fits') - shutil.copy2 (cat_in, cat_preformat) + try: + shutil.copy2 (cat_in, cat_preformat) + except PermissionError as e: + log.warning('could not copy timestamps/metadata/permissions for' + ' {} -> {} ({}). file data was copied successfully though' + .format(cat_in, cat_preformat, e)) # read data and header of [cat_in] @@ -4322,8 +4331,12 @@ def get_trans (fits_new, fits_ref_remap, fits_D, fits_Scorr, fits_Fpsf, # keep a copy of the original Scorr image if keep_tmp is True if get_par(set_zogy.keep_tmp,tel): fits_Scorr_orig = '{}_Scorr_orig.fits'.format(base) - shutil.copy2 (fits_Scorr, fits_Scorr_orig) - + try: + shutil.copy2 (fits_Scorr, fits_Scorr_orig) + except PermissionError as e: + log.warning('could not copy timestamps/metadata/permissions for ' + '{} -> {} ({}). file data was copied successfully though' + .format(fits_Scorr, fits_Scorr_orig, e)) if trim_image: # trim_image: write smaller relevant section of Scorr and the @@ -4337,7 +4350,12 @@ def get_trans (fits_new, fits_ref_remap, fits_D, fits_Scorr, fits_Fpsf, # same for mask, but save original fits_newref_mask_orig = '{}_mask_newref_orig.fits'.format(base) - shutil.copy2 (fits_newref_mask, fits_newref_mask_orig) + try: + shutil.copy2 (fits_newref_mask, fits_newref_mask_orig) + except PermissionError as e: + log.warning('could not copy timestamps/metadata/permissions for ' + '{} -> {} ({}). file data was copied successfully though' + .format(fits_newref_mask, fits_newref_mask_orig, e)) data_newref_mask = read_hdulist (fits_newref_mask, dtype='uint8') fits.writeto (fits_newref_mask, data_newref_mask[y1:y2+1,x1:x2+1], overwrite=True) @@ -9474,7 +9492,12 @@ def help_swarp (fits2remap, data2remap, header2remap=header, # overwriting it with the Gaia forced-photometry catalog sexcat = '{}_sexcat.fits'.format(base) if os.path.exists(fits_cat): - shutil.copy2 (fits_cat, sexcat) + try: + shutil.copy2 (fits_cat, sexcat) + except PermissionError as e: + log.warning('could not copy timestamps/metadata/permissions' + ' for {} -> {} ({}). file data was copied successfully ' + 'though'.format(fits_cat, sexcat, e)) # write fits table to file @@ -18143,8 +18166,12 @@ def run_sextractor (image, cat_out, file_config, file_params, pixscale, if get_par(set_zogy.keep_tmp,tel): image_orig = '{}_orig.fits'.format(base) if not isfile(image_orig): - shutil.copy2 (image, image_orig) - + try: + shutil.copy2 (image, image_orig) + except PermissionError as e: + log.warning('could not copy timestamps/metadata/permissions for ' + '{} -> {} ({}). file data was copied successfully though' + .format(image, image_orig, e)) # if fraction less than one, run SExtractor on specified fraction of # the image @@ -18191,7 +18218,12 @@ def run_sextractor (image, cat_out, file_config, file_params, pixscale, # create updated parameters file starting from original file file_params_edited = '{}_params.txt'.format(base) - shutil.copy2(file_params, file_params_edited) + try: + shutil.copy2 (file_params, file_params_edited) + except PermissionError as e: + log.warning('could not copy timestamps/metadata/permissions for ' + '{} -> {} ({}). file data was copied successfully though' + .format(file_params, file_params_edited, e)) # update size of VIGNET if psfex_mode: