import numpy import math def modulus(vec): tmp = 0 for comp in vec: tmp += comp**2 return math.sqrt(tmp) import string import sys def cat2reg(InputFile,OutFile): x = [] y = [] fwhm = [] for line in open(InputFile,'r'): if (line[0] != '#'): spl_line = string.split(line) x.append(float(spl_line[1])) y.append(float(spl_line[2])) fwhm.append(float(spl_line[6])) of = open(OutputFile,'w') of.write("# Region file format: DS9 version 4.0\n") of.write("# Filename: check.fits\n") of.write("global color=green font=\"helvetica 10 normal\" select=1 highlite=1edit=1 move=1 delete=1 include=1 fixed=0 source\n") of.write("physical\n") for i in range(len(x)): outs = "circle(%f,%f,%f)\n" %(x[i],y[i],fwhm[i]) of.write(outs) of.close()