# star position of catalog to x,y coordinate of photo import math infile=open('/content/drive/MyDrive/data/star_position.txt') datalist=infile.readlines() infile.close() n=len(datalist) print(n) print() num=[] r=[] th=[] i=0 while i < n: templist=datalist[i].split() num_a=int(templist[0]) r_a=float(templist[1]) th_a=float(templist[2]) num.append(num_a) r.append(r_a) th.append(th_a) i+=1 # r,th to x,y x0=253.0 # center x,y of photo (myu Cep) y0=419.0 th0=12.7 # rotation angle (deg) of photo sf=0.0493 # arcmin per pixel pai=3.14159 x=[] y=[] i=0 while i < n: x.append(int(x0 - r[i]*math.sin(pai*(th[i]+th0)/180.0)/sf)) y.append(int(y0 - r[i]*math.cos(pai*(th[i]+th0)/180.0)/sf)) i+=1 i=0 while i < 68: print(num[i], r[i], th[i], x[i], y[i]) i+=1 ------------------------------------------------------- # from matplotlib import pyplot as plt import math infile=open('/content/drive/MyDrive/data/star_position.txt') datalist=infile.readlines() infile.close() n=len(datalist) print(n) print() num=[] r=[] th=[] i=0 while i < n: templist=datalist[i].split() num.append(int(templist[0])) r.append(float(templist[1])) th.append(float(templist[2])) i+=1 # r,th to x,y x0=253.0 # center x,y of photo (myu Cep) y0=419.0 th0=12.7 # rotation angle (deg) of photo sf=0.0493 # arcmin per pixel pai=3.14159 x=[] y=[] i=0 while i < n: x.append(int( - r[i]*math.sin(pai*(th[i]+th0)/180.0)/sf)) y.append(-int( - r[i]*math.cos(pai*(th[i]+th0)/180.0)/sf)) i+=1 # plt.scatter(x,y) -------------------------------------------------------- import math infile=open('/content/drive/MyDrive/data/star_position.txt') datalist=infile.readlines() infile.close() n=len(datalist) print(n) print() num=[] r=[] th=[] i=0 while i < n: templist=datalist[i].split() num.append(int(templist[0])) r.append(float(templist[1])) th.append(float(templist[2])) i+=1 # r,th to x,y x0=253.0 # center x,y of photo (myu Cep) y0=418.0 th0=12.7 # rotation angle (deg) of photo sf=0.0493 # arcmin per pixel pai=3.14159 x=[] y=[] i=0 while i < n: x.append(int(x0 - r[i]*math.sin(pai*(th[i]+th0)/180.0)/sf)) y.append(int(y0 - r[i]*math.cos(pai*(th[i]+th0)/180.0)/sf)) i+=1 # outfile=open('/content/drive/MyDrive/pixel_xy.txt', 'w') i=0 while i < n: outlist=str(num[i])+" "+str(x[i])+" "+str(y[i])+"\n" print(outlist, end="") outfile.write(outlist) i+=1 outfile.close() -------------------------------------------------------------