コード例 #1
0
ファイル: shifter.py プロジェクト: johnsonho/msumastro
def shift_images(files, source_dir, output_file='_shifted'):
    """Align images based on astrometry."""

    ref = files[0] # TODO: make reference image an input
    ref_im = ImageWithWCS(path.join(source_dir,ref))
    ref_pix = np.int32(np.array(ref_im.data.shape)/2)
    ref_ra_dec = ref_im.wcs_pix2sky(ref_pix)
    for fil in files[1:]:
        img = ImageWithWCS(path.join(source_dir,fil))
        ra_dec_pix = img.wcs_sky2pix(ref_ra_dec)
        shift = ref_pix - np.int32(ra_dec_pix)
        print shift
        img.shift(shift, in_place=True)
        base, ext = path.splitext(fil)
        img.save(path.join(source_dir,base+output_file+ext))
コード例 #2
0
ファイル: run_astrometry.py プロジェクト: johnsonho/msumastro
        try:
            ra = img.header['ra']
            dec = img.header['dec']
            ra_dec = (ra, dec)
        except KeyError:
            ra_dec = None

        if ra_dec is None:
            original_fname = path.join(currentDir,light_file['file'])
            root, ext = path.splitext(original_fname)
            f = open(root+'.blind','wb')
            f.close()
            continue
            
        astrometry = ast.add_astrometry(img.fitsfile.filename(), ra_dec=ra_dec,
                                        note_failure=True, overwrite=True)
        if astrometry and ra_dec is None:
            original_fname = path.join(currentDir,light_file['file'])
            root, ext = path.splitext(original_fname)
            #astrometry_fname = root+'.new'
            #new_fname = root+'_new.fit'
            # print new_fname, astrometry_fname
            #rename( astrometry_fname, new_fname)
            img_new = ImageWithWCS(original_fname)
            ra_dec = img_new.wcs_pix2sky(np.trunc(np.array(img_new.shape)/2))
            img_new.header.update('RA',ra_dec[0])
            img_new.header.update('DEC',ra_dec[1])
            img_new.save(img_new.fitsfile.filename(), clobber=True)