from astropy.io import fits
import sys

filename='Gaia_unWISE_Coma.fits.catalog'
fout=filename.replace(".fits.catalog", ".reg")

hdul = fits.open(filename)
#hdul.info()

tbdata = hdul[1].data
hdul.close()


with open("./{}".format(fout), 'w') as writer:
    for rec in tbdata:
        print("fk5;circle({}, {}, 0.008)".format(rec['RA'],rec['DEC']))
        writer.write("fk5;circle({}, {}, {})\n".format(rec['RA'],rec['DEC'],0.0080000))

