pmvreeswijk / ZOGY

a Python implementation of proper image subtraction (Zackay, Ofek & Gal-Yam 2016, ApJ, 830, 27)
MIT License
37 stars 16 forks source link

Bug in ZOGY? #17

Open plirat opened 2 years ago

plirat commented 2 years ago

Hello,

I seem to have found a bug in ZOGY when run without providing mask images. The problem results when trying to update the header of the mask fits file during remapping since although the data for the mask is created the fits file is not. My solution was to change prep_optimal_subtraction as follows :

# create new mask or modify an existing one
# determine data_mask
if fits_mask is not None:
    # read in mask image
    data_mask = read_hdulist (fits_mask, dtype='uint8')
    data_mask = create_modify_mask (data_wcs, satlevel, data_mask=data_mask)
else:
    data_mask = None
    data_mask = create_modify_mask (data_wcs, satlevel, data_mask=data_mask)
    fits_mask = input_fits.replace('.fits', '_mask.fits')
    header_mask = read_hdulist (input_fits, get_data=False, get_header=True)
    fits.writeto (fits_mask, data_mask, header_mask, overwrite=True) 

Please, let me know if you have any comments.

Cheers, Paulina

pmvreeswijk commented 2 years ago

Dear Paulina,

Thanks very much for pointing out this bug! I’ve just updated zogy.py with your suggestions and pushed it to the GitHub repository.

Best wishes, Paul

On 23 Dec 2021, at 18:22, plirat @.***> wrote:

Hello,

I seem to have found a bug in ZOGY when run without providing mask images. The problem results when trying to update the header of the mask fits file during remapping since although the data for the mask is created the fits file is not. My solution was to change prep_optimal_subtraction as follows :

create new mask or modify an existing one

determine data_mask

if fits_mask is not None:

read in mask image

data_mask = read_hdulist (fits_mask, dtype='uint8')
data_mask = create_modify_mask (data_wcs, satlevel, data_mask=data_mask)

else: data_mask = None data_mask = create_modify_mask (data_wcs, satlevel, data_mask=data_mask) fits_mask = input_fits.replace('.fits', '_mask.fits') header_mask = read_hdulist (input_fits, get_data=False, get_header=True) fits.writeto (fits_mask, data_mask, header_mask, overwrite=True)

Please, let me know if you have any comments.

Cheers, Paulina

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.