def make_ra_dec_target(ra, dec, ra_proper_motion=None, dec_proper_motion=None, parallax=None, rad_vel=None, epoch=None): """ Creates a rise-set target with an ra and dec Creates a dictionary rise-set formatted target that must at least have an ra/dec, but can optionally have ra/dec proper motion, radial velocity, parallax, and epoch. Args: ra (Angle): A rise-set Angle for the target ra dec (Angle): A rise-set Angle for the target dec ra_proper_motion (ProperMotion): ra proper motion for the target dec_proper_motion (ProperMotion): dec proper motion for the target parallax (float): target parallax value rad_vel (float): target radial velocity value epoch (float): target coordinates epoch (2000 default) Returns: dict: A dictionary of target details to use as input to other rise-set functions """ target = { 'ra': ra, 'dec': dec, 'ra_proper_motion': ra_proper_motion or ProperMotion(RightAscension(0), time='year'), 'dec_proper_motion': dec_proper_motion or ProperMotion(Declination(0), time='year'), 'parallax': parallax or 0.0, 'rad_vel': rad_vel or 0.0, 'epoch': epoch or 2000, } return target
def test_validate_ra_invalid_hr_too_small(self): self.angle = RightAscension('-12:00:00')
def test_in_degrees_per_century_from_year_dec_radians(self): dec = Declination(radians=pi / 4) proper_motion = ProperMotion(dec) assert_equal(proper_motion.in_degrees_per_century(), 45 * 100)
def test_in_radians_per_century_dec_radians(self): dec = Declination(radians=pi / 4) proper_motion = ProperMotion(dec, time='century') assert_equal(proper_motion.in_radians_per_century(), pi / 4)
def test_in_degrees_per_century_from_year_dec_time(self): dec = Declination(degrees=6, units='time') proper_motion = ProperMotion(dec) assert_equal(proper_motion.in_degrees_per_century(), 90 * 100)
def test_in_radians_per_century_dec_time(self): dec = Declination(degrees=6, units='time') proper_motion = ProperMotion(dec, time='century') assert_equal(proper_motion.in_radians_per_century(), pi / 2)
def test_in_degrees_per_century_from_year_dec_deg_arc(self): dec = Declination(degrees=90) proper_motion = ProperMotion(dec) assert_equal(proper_motion.in_degrees_per_century(), 90 * 100)
def test_in_degrees_per_century_dec_deg_arc(self): dec = Declination(degrees=90) proper_motion = ProperMotion(dec, time='century') assert_equal(proper_motion.in_degrees_per_century(), 90)
def test_validate_dec_invalid_min_too_big(self): self.angle = Declination(degrees = '89:61:00')
def test_validate_dec_invalid_deg_too_big_rad(self): self.angle = Declination(radians = pi)
def test_validate_dec_invalid_deg_too_big(self): self.angle = Declination(degrees = 91)
def test_validate_dec_invalid_deg_too_small(self): self.angle = Declination(-91)
def test_validate_ra_invalid_min_too_big(self): self.angle = RightAscension('23:61:00')
def test_validate_ra_invalid_hr_too_big_rad(self): self.angle = RightAscension(radians = 2*pi)
def test_validate_ra_invalid_hr_too_big(self): self.angle = RightAscension('24:00:00')
def set_dec(self, dec): # TODO: Check units are accurate self._dec = Declination(float(dec))
def test_in_radians_per_year_dec_deg_arc(self): dec = Declination(degrees=90) proper_motion = ProperMotion(dec) assert_equal(proper_motion.in_radians_per_year(), pi / 2)
def test_validate_ra_valid_at_zero_degrees(self): self.angle = RightAscension(degrees = 0) assert(self.angle.validate_ra())
def test_in_radians_per_year_from_century_dec_deg_arc(self): dec = Declination(degrees=90) proper_motion = ProperMotion(dec, time='century') assert_equal(proper_motion.in_radians_per_year(), pi / 2 / 100)
def test_validate_ra_valid_at_zero_radians(self): self.angle = RightAscension(radians = 0) assert(self.angle.validate_ra())
def test_in_radians_per_year_dec_time(self): dec = Declination(degrees=6, units='time') proper_motion = ProperMotion(dec) assert_equal(proper_motion.in_radians_per_year(), pi / 2)
def test_validate_ra_valid_at_middle(self): self.angle = RightAscension(degrees = 180) assert(self.angle.validate_ra())
def test_in_degrees_per_year_from_century_dec_time(self): dec = Declination(degrees=6, units='time') proper_motion = ProperMotion(dec, time='century') assert_equal(proper_motion.in_degrees_per_year(), 90 / 100)
def test_validate_ra_valid_at_middle_rad(self): self.angle = RightAscension(radians = pi) assert(self.angle.validate_ra())
def test_in_radians_per_year_dec_radians(self): dec = Declination(radians=pi / 4) proper_motion = ProperMotion(dec) assert_equal(proper_motion.in_radians_per_year(), pi / 4)
def test_validate_dec_valid_at_zero(self): self.angle = Declination(degrees = 0) assert(self.angle.validate_dec())
def test_in_degrees_per_year_from_century_dec_radians(self): dec = Declination(radians=pi / 4) proper_motion = ProperMotion(dec, time='century') assert_equal(proper_motion.in_degrees_per_year(), 45 / 100)
def test_validate_dec_valid_at_middle(self): self.angle = Declination(degrees = 45) assert(self.angle.validate_dec())
def test_validate_dec_valid_at_middle_rad(self): self.angle = Declination(radians = pi/4) assert(self.angle.validate_dec())
class TestCoordinateSystem(object): '''Unit tests for the sky_coordinates.RightAscension and sky_coordinates.Declination classes. Note: These classes inherit from the angle.Angle class''' # Test invalid inputs for RA @raises(InvalidAngleError) def test_validate_ra_invalid_hr_too_small(self): self.angle = RightAscension('-12:00:00') @raises(InvalidAngleError) def test_validate_ra_invalid_hr_too_big(self): self.angle = RightAscension('24:00:00') @raises(InvalidAngleError) def test_validate_ra_invalid_hr_too_big_rad(self): self.angle = RightAscension(radians = 2*pi) @raises(InvalidAngleError) def test_validate_ra_invalid_min_too_big(self): self.angle = RightAscension('23:61:00') # Test invalid inputs for Dec @raises(InvalidAngleError) def test_validate_dec_invalid_deg_too_small(self): self.angle = Declination(-91) @raises(InvalidAngleError) def test_validate_dec_invalid_deg_too_big(self): self.angle = Declination(degrees = 91) @raises(InvalidAngleError) def test_validate_dec_invalid_deg_too_big_rad(self): self.angle = Declination(radians = pi) @raises(InvalidAngleError) def test_validate_dec_invalid_min_too_big(self): self.angle = Declination(degrees = '89:61:00') # Test valid inputs for RA def test_validate_ra_valid_at_zero_degrees(self): self.angle = RightAscension(degrees = 0) assert(self.angle.validate_ra()) def test_validate_ra_valid_at_zero_radians(self): self.angle = RightAscension(radians = 0) assert(self.angle.validate_ra()) def test_validate_ra_valid_at_middle2(self): self.angle = RightAscension(degrees = 24) assert(self.angle.validate_ra()) def test_validate_ra_valid_at_middle(self): self.angle = RightAscension(degrees = 180) assert(self.angle.validate_ra()) def test_validate_ra_valid_at_middle_rad(self): self.angle = RightAscension(radians = pi) assert(self.angle.validate_ra()) # Test valid inputs for Dec def test_validate_dec_valid_at_zero(self): self.angle = Declination(degrees = 0) assert(self.angle.validate_dec()) def test_validate_dec_valid_at_middle(self): self.angle = Declination(degrees = 45) assert(self.angle.validate_dec()) def test_validate_dec_valid_at_middle_rad(self): self.angle = Declination(radians = pi/4) assert(self.angle.validate_dec())