def test_get_pyephem_instance_for_non_sidereal(self): hb = ephem.readdb( 'C/1995 O1 (Hale-Bopp),e,89.4245,282.4515,130.5641,183.6816,' '0.0003959,0.995026,0.1825,07/06.0/1998,2000,g -2.0,4.0') target_ephem = get_pyephem_instance_for_type(self.nst) location = ephem.city('Los Angeles') location.date = ephem.date(datetime.now()) hb.compute(location) target_ephem.compute(location) self.assertLess(math.fabs(target_ephem.ra - hb.ra), 0.5) self.assertLess(math.fabs(target_ephem.dec - hb.dec), 0.5)
def get_24hr_airmass(target, start_time, interval, airmass_limit): end_time = start_time + datetime.timedelta(days=1) visibility = {} sun = ephem.Sun() body = utils.get_pyephem_instance_for_type(target) for observing_facility in facility.get_service_classes(): if observing_facility != 'LCO': continue observing_facility_class = facility.get_service_class( observing_facility) sites = observing_facility_class().get_observing_sites() for site, site_details in sites.items(): positions = [[], []] observer = utils.observer_for_site(site_details) sun_up_times = get_up_times(observer, sun, start_time, end_time, interval) obj_up_times = get_up_times(observer, body, start_time, end_time, interval) good_times = sorted(list(obj_up_times - sun_up_times)) for time in good_times: observer.date = time body.compute(observer) alt = Angle(str(body.alt), unit=u.degree) az = Angle(str(body.az), unit=u.degree) altaz = AltAz(alt=alt.to_string(unit=u.rad), az=az.to_string(unit=u.rad)) airmass = altaz.secz positions[0].append(time) positions[1].append(airmass.value if ( airmass.value > 1 and airmass.value <= airmass_limit ) else None) visibility['({0}) {1}'.format(observing_facility, site)] = positions return visibility
def test_get_pyephem_instance_invalid_type(self): self.st.type = 'Fake Type' with self.assertRaises(Exception): get_pyephem_instance_for_type(self.st)
def test_get_pyephem_instance_for_sidereal(self): target_ephem = get_pyephem_instance_for_type(self.st) target_ephem.compute(self.time) self.assertIsInstance(target_ephem, type(ephem.FixedBody())) self.assertLess(math.fabs(target_ephem.ra - self.mars.ra), 0.5) self.assertLess(math.fabs(target_ephem.dec - self.mars.dec), 0.5)