Closed andresgur closed 3 years ago
fixed
def write_annuli(ctr_coord, radii):
out_reg = '# Region file format: DS9 version 4.1\n'\
+ '#global color=green dashlist=8 3 width=1 font="helvetica 10 normal roman" select=1'\
+ ' highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1\nfk5\n'
out_reg += 'annulus(%d:%d:%.4f,%d:%d:%.4f,' % (ctr_coord.ra.hms[0], ctr_coord.ra.hms[1],
ctr_coord.ra.hms[2], ctr_coord.dec.dms[0], np.abs(ctr_coord.dec.dms[1]), np.abs(ctr_coord.dec.dms[2]))
for radius in radii[1:-1]:
out_reg += '%.3f",' % radius
out_reg += '%.3f")' % radii[-1]
f_reg = open('annuli.reg', 'w+')
f_reg.write(out_reg)
f_reg.close()
``f_reg = open('annuli.reg', 'w+') The current writting of the region file is not optimal f_reg.write( '# Region file format: DS9 version 4.1\n'\ +'#global color=green dashlist=8 3 width=1 font="helvetica 10 normal roman" select=1'\ +' highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1\nfk5\n')
for i in range(nbins):
`f_reg.close()```
it can be written much easily using something like
radii_string = "" for radius in radii[1:]: radii_string += ",%.4f" radius.value 'annulus(%i:%i:%s,%i:%i:%s' %(center, radii_string)
plus the final region will be stored as a real annulus instead of a composite of regions