Ich habe eine Liste von Punkten, die alle Pixel in dem Bild beschreiben, das ich angehängt habe. Allerdings wollen nur die Pixel in der kreisförmigen Region zählen. Ich verstehe, wie man das macht, wenn die Region ein Quadrat ist, aber wenn man versucht, dies mit einem Kreis zu tun, ist es ein wenig hängen geblieben.Werte zählen Eine bestimmte Entfernung von der Mitte einer kreisförmigen Region in Python
Hier ist, was ich bisher habe:
#Count the photons within a certain region
from collections import Counter
#Read in Data
RA = []
DEC = []
with open('ChandraXraysources2.txt') as f:
for row in f.readlines():
row.strip('\n')
if not row.startswith("#"):
spaces=row.split(',')
RA.append(float(spaces[0]))
DEC.append(float(spaces[1]))
list_a = RA
list_b = DEC
coord_list=zip(list_a, list_b)
#This is the most important part I think. Above is just reading my data in.
#Basically what I tried to do was specify the center of the circle, then count
#only the points a certain distance from that center.
points=[]
[(x,y) for x,y in coord_list if x==3984.9634 and y==4146.6652]
if i in coord_list:
d in 5664.85124
points.append(i)
wenn Sie wissen, wo die Mitte ist, und Sie wissen, was Ihr Radius ist, es wird einfach. Ich kann nicht ganz von Ihrem Code verstehen, wenn Sie diese Werte haben – Nullman
Errate ich richtig, dass (3984.9634, 4146.6652) Koordinaten des Mittelpunkts Ihres Kreises sind und 5664.85124 der Radius ist? –