# integrate pixel data from matplotlib import pyplot as plt import numpy as np star="s62" print(star) print() infile=open("/content/drive/MyDrive/data/input_star_data.csv") datalist=infile.readlines() infile.close() n=len(datalist) istar=-1 for i in range(n): indata=datalist[i].split(",") if indata[0] == star: istar=i break if istar<0: print("no-data") exit() xcent=int(indata[1]) ycent=int(indata[2]) radius=int(indata[3]) r_backgr=int(indata[4]) g_backgr=int(indata[5]) b_backgr=int(indata[6]) infile=open("/content/drive/MyDrive/data/star_images/"+star+".pnm") datalist=infile.readlines() infile.close() n=len(datalist) del datalist[0:4] npdatalist=np.array(datalist) datalist1=npdatalist.reshape(400,3) r=[] g=[] b=[] i=0 while i < 400: r.append(int(datalist1[i][0])) g.append(int(datalist1[i][1])) b.append(int(datalist1[i][2])) i+=1 npr=np.array(r) npg=np.array(g) npb=np.array(b) r1=npr.reshape(20,20) g1=npg.reshape(20,20) b1=npb.reshape(20,20) r_total=0 g_total=0 b_total=0 for j in range(20): if jycent+radius: continue for i in range(20): if ixcent+radius: continue r_total+=r1[j][i]-r_backgr print("{:>3d}".format(r1[j][i]-r_backgr),end="") print(" |",end="") for i in range(20): if ixcent+radius: continue g_total+=g1[j][i]-g_backgr print("{:>3d}".format(g1[j][i]-g_backgr),end="") print(" |",end="") for i in range(20): if ixcent+radius: continue b_total+=b1[j][i]-b_backgr print("{:>3d}".format(b1[j][i]-b_backgr),end="") print() print() print(r_total, g_total, b_total)