Esempio n. 1
0
def subtract_images(image_list, subtraction_type):
    """Subtract images given in list generated by fakeimage"""

    outstring = ''
    for subtraction in subtraction_type:
        images = open(image_list)
        for image in images:
            files = image[:-1].split()
            science_image = files[0]
            science_psf = files[1]
            science_mask = files[2]
            reference_image = files[3]
            reference_psf = files[4]
            reference_mask = files[5]

            output = science_image.split('/')[-1].replace(
                '.fits', '.diff.fits')

            if subtraction == 'PyZOGY':

                run_subtraction(science_image,
                                reference_image,
                                science_psf,
                                reference_psf,
                                output=output,
                                n_stamps=10,
                                science_saturation=50000,
                                reference_saturation=50000,
                                science_mask=science_mask,
                                reference_mask=reference_mask,
                                normalization='science',
                                photometry=True,
                                matched_filter=False)

            elif subtraction == 'hotpants':
                command = 'hotpants -inim {0} -tmplim {1} -outim {2}'.format(
                    science_image, reference_image, output)
                print(command)
                os.system(command)

            flux = do_photometry(output, science_image)
            outstring += '{0} {1} {2}\n'.format(output, subtraction, flux)
    outfile = open('results.txt', 'w')
    outfile.write(outstring)
    outfile.close()
Esempio n. 2
0
                                iraf.seepsf(
                                    imgtarg_path.replace('.fits', '.psf.fits'),
                                    psftarg)
                                iraf.seepsf(
                                    imgtemp_path.replace('.fits', '.psf.fits'),
                                    psftemp)
                            try:
                                print 'Passing images to PyZOGY'
                                run_subtraction(
                                    imgtarg,
                                    imgtemp,
                                    psftarg,
                                    psftemp,
                                    science_mask=targmask,
                                    reference_mask=tempmask,
                                    science_saturation=sat_targ,
                                    reference_saturation=sat_temp,
                                    n_stamps=1,
                                    output=imgout,
                                    normalization=args.normalize,
                                    show=args.show,
                                    use_mask_for_gain=args.use_mask,
                                    pixstack_limit=args.pixstack_limit)
                            except Exception as e:
                                print e
                                print 'PyZOGY failed on', imgtarg0
                                continue

                            # create fields in header that hotpants does
                            hotpants_fields = {
                                'TARGET': (imgtarg_path, 'target image'),
Esempio n. 3
0
                            os.system('rm {0} {1}'.format(psftarg, psftemp))
                            iraf.seepsf(
                                imgtarg_path.replace('.fits', '.psf.fits'),
                                psftarg)
                            iraf.seepsf(
                                imgtemp_path.replace('.fits', '.psf.fits'),
                                psftemp)
                            try:
                                print 'Passing images to PyZOGY'
                                run_subtraction(
                                    imgtarg,
                                    imgtemp,
                                    psftarg,
                                    psftemp,
                                    science_mask='_targmask.fits',
                                    reference_mask='_tempmask.fits',
                                    science_saturation=sat_targ,
                                    reference_saturation=sat_temp,
                                    n_stamps=1,
                                    output=imgout,
                                    normalization=args.normalize,
                                    show=args.show,
                                    use_mask_for_gain=args.use_mask)
                            except Exception as e:
                                print e
                                print 'PyZOGY failed on', imgtarg0
                                continue

                            # create fields in header that hotpants does
                            hotpants_fields = {
                                'TARGET': (imgtarg_path, 'target image'),
                                'TEMPLATE': (imgtemp_path, 'template image'),
Esempio n. 4
0
                                substamplist) + ' -afssc 1 '
                        else:
                            _afssc = ''

                        if _difftype == '1':
                            #do subtraction
                            psftarg = imgtarg_path.replace(
                                '.fits', '.psf.fits')
                            psftemp = imgtemp_path.replace(
                                '.fits', '.psf.fits')
                            run_subtraction(imgtarg,
                                            imgtemp,
                                            psftarg,
                                            psftemp,
                                            science_mask='_targmask.fits',
                                            reference_mask='_tempmask.fits',
                                            science_saturation=sat_targ,
                                            reference_saturation=sat_temp,
                                            n_stamps=4,
                                            output=imgout,
                                            normalization=normalize)

                            # create fields in header that hotpants does
                            hotpants_fields = {
                                'TARGET': (imgtarg_path, 'target image'),
                                'TEMPLATE': (imgtemp_path, 'template image'),
                                'DIFFIM': (imgout, 'Difference Image'),
                                'NREGION':
                                (1, 'Number of independent regions'),
                                'MASKVAL': (1e-30, 'Value of Masked Pixels')
                            }