Created
December 9, 2011 05:36
-
-
Save dfm/1450336 to your computer and use it in GitHub Desktop.
Object oriented Python for Ross
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
class Catalog(object): | |
def __init__(self): | |
self.stars = [] | |
def add_star(self, star): | |
self.stars.append(star) | |
@property | |
def fluxes(self): | |
return np.array([[s.ra, s.flux] for s in self.stars]) | |
@fluxes.setter | |
def fluxes(self, fluxes): | |
for i, s in enumerate(self.stars): | |
s.flux = fluxes[i] | |
def __getitem__(self, ind): | |
return self.stars[ind] | |
class Star(object): | |
def __init__(self, ra, dec, flux): | |
self.ra = ra | |
self.dec = dec | |
self.flux = flux | |
class RRLyrae(Star): | |
def __init__(self, period, *args, **kwargs): | |
super(RRLyrae, self).__init__(*args, **kwargs) | |
self.period = period |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment