from astropy.io import fits
import sys

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

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

tbdata = hdul[1].data

with open("../../products/{}".format(fout), 'w') as writer:
    for rec in tbdata:
        text="{}{}".format(rec['__UWS2008_'],rec['Note'])
        #writer.write("fk5;point({}, {})\n".format(rec['sc_ra'],rec['sc_dec']))
        writer.write("fk5;circle({}, {}, {}) # text={{{}}}\n".format(rec['RAJ2000'],rec['DEJ2000'],rec['e_pos']/3600,text))
