Mapping exoplanets in our region of the galaxy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.9 KiB

import numpy
from galsim.catalog import FieldSet
regions = [
'Andes Line', 'Rocky Mountain Line', 'Kunlun Line',
'Ural Line', 'Atlas Line', 'Himalaya Line',
'Altai Line', 'Carpathian Line', 'Sierra Madre Line',
'Karakoram Line', 'Cascade Line', 'Annamite Line',
]
class Planet:
def __init__(self, row):
self._data = {
field: numpy.array(row[field]).item()
for field in row.colnames
}
self.name = self._data['pl_name']
self.distance = self._data['sy_dist']
self.latitude = self._data['glat']
self.longitude = self._data['glon']
@property
def coordinates(self):
'''
return cartesian coordinates [x, y, z]
x : positive axis toward the galactic core
y : positive axis away from galactic spin direction
z : positive axis "up" toward the galactic north pole
'''
el = numpy.pi * self.latitude / 180.0
az = numpy.pi * self.longitude / 180.0
x = self.distance * numpy.cos(az) * numpy.cos(el)
y = self.distance * numpy.sin(az) * numpy.cos(el)
z = self.distance * numpy.sin(el)
return numpy.array([x, y, z])
@property
def x(self):
return self.coordinates[0]
@property
def y(self):
return self.coordinates[1]
@property
def z(self):
return self.coordinates[2]
def get_data(self, field_set):
return {field: self._data[field] for field in field_set.value}
def to_dict(self, *field_sets):
out = {
'name': self.name,
'distance': self.distance,
'latitude': self.latitude,
'longitude': self.longitude,
'x': self.x,
'y': self.y,
'z': self.z,
}
for field_set in field_sets:
out.update(self.get_data(field_set))
return out