def main(): jd_start, jd_end, number = eph_manager.ephem_open() output({}, """\ 'Auto-generated accuracy tests vs NOVAS (see build_novas_tests.py).' from numpy import abs, array, einsum, max from skyfield import (earthlib, framelib, nutationlib, positionlib, precessionlib, starlib, timelib) from skyfield.api import Topos, load from skyfield.constants import AU_KM, AU_M from skyfield.data import hipparcos from skyfield.functions import length_of OLD_AU_KM = 149597870.691 # TODO: load from de405 OLD_AU = AU_KM / OLD_AU_KM one_second = 1.0 / 24.0 / 60.0 / 60.0 arcsecond = 1.0 / 60.0 / 60.0 ra_arcsecond = 24.0 / 360.0 / 60.0 / 60.0 meter = 1.0 / AU_M def ts(): yield load.timescale() def compare(value, expected_value, epsilon): if hasattr(value, 'shape') or hasattr(expected_value, 'shape'): assert max(abs(value - expected_value)) <= epsilon else: assert abs(value - expected_value) <= epsilon def de405(): yield load('de405.bsp') def earth(): eph = load('de405.bsp') yield eph[399] def reduce_precision(t): # The NOVAS library uses only 64-bit precision for Julian dates. # Some of these tests are so sensitive they can see the difference! # So we need to collapse the Julian dates back into single floats. delta = t.tdb - t.tt t.whole = t.tdb t.tt_fraction = delta t.tdb_fraction = 0.0 """) moon_landing = novas.julian_date(1969, 7, 20, 20.0 + 18.0 / 60.0) first_hubble_image = novas.julian_date(1990, 5, 20) voyager_intersellar = novas.julian_date(2012, 8, 25) date_vector = [moon_landing, first_hubble_image, T0, voyager_intersellar] dates = date_vector + [date_vector] output_subroutine_tests(dates) output_ephemeris_tests() output_geocentric_tests(dates) output_topocentric_tests(dates) output_catalog_tests(dates)
def __init__(self, latitude, longitude, height = HEIGHT_DEFAULT, ephem_filepath = None, deltat_preds_filepath = None ): ephem_open(ephem_filepath) #locate the ephemeris data, needed for subsequent NOVAS calls dummy_star = make_cat_entry('DUMMY', 'xxx', 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) self._sun = make_object(0, 10, 'Sun', dummy_star) #type 0, number 10 denotes the Sun self._latitude = latitude self._longitude = longitude self._height = height self._temperature = TEMPERATURE_DEFAULT self._pressure = PRESSURE_DEFAULT self._update_geo_loc() self._julian_clock = JulianClock(deltat_preds_filepath)
def getOwlt(utc_time): '''Uses novas module to compute One Way Light Time at given UTC time.''' jd_start, jd_end, number = eph_manager.ephem_open() jd_tt = novas.julian_date(utc_time.tm_year, utc_time.tm_mon, utc_time.tm_mday, utc_time.tm_hour) mars = novas.make_object(0, 4, 'Mars', None) ra, dec, dis = novas.astro_planet(jd_tt, mars) au_sec = 499.0047838061 # Light-time for one astronomical unit (AU) in seconds, from DE-405 owlt = dis * au_sec return owlt
def main(): filename = "JPLEPH" file = eph_manager.ephem_open(filename) print(file) print((file[1] - file[0]) / 365.24) time.sleep(.1) input("What dates " + \ "are you: ") print(eph_manager.planet_ephemeris((2444911.0, .1), center=2, target=9)) eph_manager.ephem_close()
def main(): jd_start, jd_end, number = eph_manager.ephem_open() output({}, """\ 'Auto-generated accuracy tests vs NOVAS (see build_novas_tests.py).' from numpy import abs, array, einsum, max from skyfield import (earthlib, framelib, nutationlib, positionlib, precessionlib, starlib, timelib) from skyfield.api import Topos, load from skyfield.constants import AU_KM, AU_M from skyfield.data import hipparcos from skyfield.functions import length_of OLD_AU_KM = 149597870.691 # TODO: load from de405 OLD_AU = AU_KM / OLD_AU_KM one_second = 1.0 / 24.0 / 60.0 / 60.0 arcsecond = 1.0 / 60.0 / 60.0 ra_arcsecond = 24.0 / 360.0 / 60.0 / 60.0 meter = 1.0 / AU_M def ts(): yield load.timescale() def compare(value, expected_value, epsilon): if hasattr(value, 'shape') or hasattr(expected_value, 'shape'): assert max(abs(value - expected_value)) <= epsilon else: assert abs(value - expected_value) <= epsilon def de405(): yield load('de405.bsp') def earth(): eph = load('de405.bsp') yield eph[399] """) moon_landing = novas.julian_date(1969, 7, 20, 20.0 + 18.0/60.0) first_hubble_image = novas.julian_date(1990, 5, 20) voyager_intersellar = novas.julian_date(2012, 8, 25) date_vector = [moon_landing, first_hubble_image, T0, voyager_intersellar] dates = date_vector + [date_vector] output_subroutine_tests(dates) output_ephemeris_tests() output_geocentric_tests(dates) output_topocentric_tests(dates) output_catalog_tests(dates)
def main(): jd_start, jd_end, number = eph_manager.ephem_open() output({}, """\ 'Auto-generated accuracy tests vs NOVAS (see build_novas_tests.py).' from numpy import abs, array, einsum, max from skyfield import (earthlib, framelib, nutationlib, positionlib, precessionlib, starlib, timelib) from skyfield.api import load from skyfield.constants import AU_KM, AU_M from skyfield.data import hipparcos from skyfield.functions import length_of OLD_AU_KM = 149597870.691 # TODO: load from de405 OLD_AU = AU_KM / OLD_AU_KM one_second = 1.0 / 24.0 / 60.0 / 60.0 arcsecond = 1.0 / 60.0 / 60.0 ra_arcsecond = 24.0 / 360.0 / 60.0 / 60.0 meter = 1.0 / AU_M def ts(): yield load.timescale() def compare(value, expected_value, epsilon): if hasattr(value, 'shape') or hasattr(expected_value, 'shape'): assert max(abs(value - expected_value)) <= epsilon else: assert abs(value - expected_value) <= epsilon def de405(): yield load('de405.bsp') def earth(): eph = load('de405.bsp') yield eph[399] """) moon_landing = novas.julian_date(1969, 7, 20, 20.0 + 18.0 / 60.0) first_hubble_image = novas.julian_date(1990, 5, 20) voyager_intersellar = novas.julian_date(2012, 8, 25) date_vector = [moon_landing, first_hubble_image, T0, voyager_intersellar] dates = date_vector + [date_vector] output_subroutine_tests(dates) output_geocentric_tests(dates) output_topocentric_tests(dates) output_catalog_tests(dates)
def main(): jd_start, jd_end, number = eph_manager.ephem_open() output({}, """\ 'Auto-generated accuracy tests vs NOVAS (see build_novas_tests.py).' import pytest from numpy import abs, array, einsum, max from skyfield import (earthlib, framelib, nutationlib, positionlib, precessionlib, starlib, timelib) from skyfield.api import JulianDate from skyfield.constants import AU_M from skyfield.functions import length_of from skyfield.jpllib import Ephemeris try: import de405 de405 = Ephemeris(de405) except ImportError: pytestmark = pytest.mark.skipif(True, reason='de405 unavailable') one_second = 1.0 / 24.0 / 60.0 / 60.0 arcsecond = 1.0 / 60.0 / 60.0 ra_arcsecond = 24.0 / 360.0 / 60.0 / 60.0 meter = 1.0 / AU_M def compare(value, expected_value, epsilon): if hasattr(value, 'shape') or hasattr(expected_value, 'shape'): assert max(abs(value - expected_value)) <= epsilon else: assert abs(value - expected_value) <= epsilon """) moon_landing = novas.julian_date(1969, 7, 20, 20.0 + 18.0/60.0) first_hubble_image = novas.julian_date(1990, 5, 20) voyager_intersellar = novas.julian_date(2012, 8, 25) date_vector = [moon_landing, first_hubble_image, T0, voyager_intersellar] dates = date_vector + [date_vector] output_subroutine_tests(dates) output_geocentric_tests(dates) output_topocentric_tests(dates)
def main(): jd_start, jd_end, number = eph_manager.ephem_open() output({}, """\ 'Auto-generated accuracy tests vs NOVAS (see build_novas_tests.py).' from numpy import abs, array, einsum, max from skyfield import (earthlib, framelib, nutationlib, positionlib, precessionlib, starlib, timelib) from skyfield.api import JulianDate from skyfield.constants import AU_M from skyfield.data import hipparcos from skyfield.functions import length_of from skyfield.jpllib import Ephemeris from skyfield.positionlib import Apparent import de405 de405 = Ephemeris(de405) one_second = 1.0 / 24.0 / 60.0 / 60.0 arcsecond = 1.0 / 60.0 / 60.0 ra_arcsecond = 24.0 / 360.0 / 60.0 / 60.0 meter = 1.0 / AU_M def compare(value, expected_value, epsilon): if hasattr(value, 'shape') or hasattr(expected_value, 'shape'): assert max(abs(value - expected_value)) <= epsilon else: assert abs(value - expected_value) <= epsilon """) moon_landing = novas.julian_date(1969, 7, 20, 20.0 + 18.0 / 60.0) first_hubble_image = novas.julian_date(1990, 5, 20) voyager_intersellar = novas.julian_date(2012, 8, 25) date_vector = [moon_landing, first_hubble_image, T0, voyager_intersellar] dates = date_vector + [date_vector] output_subroutine_tests(dates) output_geocentric_tests(dates) output_topocentric_tests(dates) output_catalog_tests(dates)
leap_second = 37 #闰秒 tt_tai = 32.184 #tt和国际原子时tai之差 #EOP参数 ut1_utc = 0.06723 x_pole = -0.002 y_pole = +0.529 #tt-ut1 delta_t = tt_tai + leap_second - ut1_utc #构造不同的儒略日时间变量 jd_utc = novas.julian_date(year, month, day, hour) #utc jd_ut1 = jd_utc + ut1_utc / 86400.0 #ut1 jd_tt = jd_utc + (leap_second + tt_tai) / 86400.0 #tt jd = (jd_tt, 0.0) jd0 = (jd_tt - ta / 86400, 0.0) #打开de历表 jd_s, jd_e, num = eph_manager.ephem_open() #太阳和地球构造 sun = novas.make_object(0, 10, 'sun', None) moon = novas.make_object(0, 11, 'moon', None) earth = novas.make_object(0, 3, 'earth', None) #位置构造 location1 = novas.make_on_surface(latitude, longitude, height, 25.0, 1013) location = novas.make_observer_on_surface(latitude, longitude, height, 25.0, 1013) #矢量和夹角初始化 O1_S1 = [0.0, 0.0, 0.0] #月球半影锥点到太阳质心矢量坐标 O2_S1 = [0.0, 0.0, 0.0] #月球全影锥点到太阳质心矢量坐标 O1_E = [0.0, 0.0, 0.0] #月球半影锥点到地心距离矢量坐标 O1_T = [0.0, 0.0, 0.0] #月球半影锥点到地球某一点距离矢量坐标 O2_E = [0.0, 0.0, 0.0] #月球全影锥点到地心距离矢量坐标 O2_T = [0.0, 0.0, 0.0] #月球全影锥点到地球某一点距离矢量坐标
import unittest from math import sqrt, sin, cos import novas from novas.compat import * from novas.compat.eph_manager import ephem_open from novas.constants import T0, DEG2RAD #try: # import novas_de405 #except ImportError: # raise Exception('please run `pip install novas_de405` before running' # ' these tests') jd_begin, jd_end, de_number = ephem_open( novas.default_ephemeris_file() ) year = 2008 month = 4 day = 24 leap_secs = 33.0 accuracy = 0 error = 0 hour = 10.605 ut1_utc = -0.387845 latitude = 42.0 longitude = -70.0 height = 0.0 temperature = 10.0
def __init__(self, siteXYZ, leapsec, ephem_name=None): eph_manager.ephem_open(ephem_name) self.siteXYZ = siteXYZ self.leapsec = leapsec self.cache = {}
from novas import compat as novas from novas.compat import eph_manager jd_start, jd_end, number = eph_manager.ephem_open() jd_tt = novas.julian_date(2013, 12, 27, 6.0) print jd_tt def print_planet(planet_name, planet_num): # make_object(type, number, name, star) # type = 0;major planet, Pluto, Sun, or Moon # type = 1; minor planet # type = 2; object located outside the soloar system # number; Mercury = 1, ..., Pluto = 9, Sun = 10, Moon = 11 print planet_name planet = novas.make_object(0, planet_num, planet_name, None) ra, dec, dis = novas.astro_planet(jd_tt, planet) print 'R.A. %d:%02f' % (ra, abs(ra) % 1. * 60.) print 'dec. %d:%02f' % (dec, abs(dec) % 1. * 60.) print 'distance %f AU' % (dis,) # Where is mars located. print_planet('Mars', 4) print_planet('Mercury', 1) print_planet('Pluto', 9) print_planet('Sun', 10) print_planet('Moon', 11)
) # Obliquity of ecliptic at J2000 speed_of_light = 2.99792458e5 * 86400. / au_km def rotate_matrix(ecl): ce = np.cos(ecl) se = np.sin(-ecl) rotmat = np.array([[1.0, 0.0, 0.0], [0.0, ce, se], [0.0, -se, ce]]) return rotmat from novas import compat as novas from novas.compat import eph_manager from novas.compat import solsys # This opens DE405 by default. jd_start, jd_end, number = eph_manager.ephem_open() class Observatory: # Parses a line from the MPC's ObsCode.txt file def parseObsCode(self, line): code, longitude, rhocos, rhosin, ObsName = line[0:3], line[4:13], line[ 13:21], line[21:30], line[30:].rstrip('\n') if longitude.isspace(): longitude = None if rhocos.isspace(): rhocos = None if rhosin.isspace(): rhosin = None return code, longitude, rhocos, rhosin, ObsName
# -*- coding: utf-8 -*- from novas.compat import topo_star, CatEntry, OnSurface from novas.compat.eph_manager import ephem_open jd_begin, jd_end, de_number = ephem_open() print( "JPL Ephemeris DE{de_number} open. jd_beg = {jd_begin:9.2f} jd_end = {jd_end:9.2f}\n" .format(de_number=de_number, jd_begin=jd_begin, jd_end=jd_end)) deltat = 60.0 tjds = [2450203.5, 2450203.5, 2450417.5, 2450300.5] stars = [ CatEntry("POLARIS".encode(), "HIP".encode(), 0, 2.530301028, 89.264109444, 44.22, -11.75, 7.56, -17.4), CatEntry("Delta ORI".encode(), "HIP".encode(), 1, 5.533444639, -0.299091944, 1.67, 0.56, 3.56, 16.0), CatEntry("Theta CAR".encode(), "HIP".encode(), 2, 10.715944806, -64.394450000, -18.87, 12.06, 7.43, 24.0) ] geo_loc = OnSurface(45.0, -75.0, 0.0, 10.0, 1010.0) for date in tjds: for star in stars: ra, dec = topo_star(date, deltat, star, geo_loc) print("JD = {jd:14.6f} Star = {star}".format(
#!/usr/bin/env python # -*- coding: utf-8 -*- from novas.compat import topo_star, CatEntry, OnSurface from novas.compat.eph_manager import ephem_open jd_begin, jd_end, de_number = ephem_open() print("JPL Ephemeris DE%i open. jd_beg = %9.2f jd_end = %9.2f\n" % (de_number, jd_begin, jd_end) ) deltat = 60.0 tjds = [2450203.5, 2450203.5, 2450417.5, 2450300.5] stars = [ CatEntry("POLARIS", "HIP", 0, 2.530301028, 89.264109444, 44.22, -11.75, 7.56, -17.4), CatEntry("Delta ORI", "HIP", 1, 5.533444639, -0.299091944, 1.67, 0.56, 3.56, 16.0), CatEntry("Theta CAR", "HIP", 2, 10.715944806, -64.394450000, -18.87, 12.06, 7.43, 24.0) ] geo_loc = OnSurface(45.0, -75.0, 0.0, 10.0, 1010.0) for date in tjds: for star in stars: ra, dec = topo_star(date, deltat, star, geo_loc) print("JD = %14.6f Star = %s" % (date, star.starname)) print("RA = % 12.9f Dec = % 12.8f\n" % (ra, dec))
plt.savefig(filebase+"_DEC.png") plt.close() else: plt.show() if __name__ == "__main__": if len(sys.argv) != 4: print "Usage: %s <timing .par file> <VLBI pmpar.in file> <initial values + ranges file>" % sys.argv[0] sys.exit() parfile = sys.argv[1] pmparfile = sys.argv[2] initsfile = sys.argv[3] # Import DE421 for NOVAS ephem_open(os.path.join(os.getenv("TEMPO"), "ephem/DE421.1950.2050")) # Read in the starting values for parameters and their allowed ranges initvals = yaml.load(open(initsfile)) try: sourcename = initvals['name'] mu_a = float(initvals['pmra']) mu_d = float(initvals['pmdec']) px = float(initvals['px']) Omega = float(initvals['Omega']) inc = float(initvals['inc']) ra = initvals['ra'] dec = initvals['dec'] posstring = ra + " " + dec except KeyError as e: print "Missing required key ", str(e), " in ", initsfile
# -*- coding: utf-8 -*- """ Created on Wed Sep 12 10:36:34 2018 @author: Rachel Street based on code by Markus Hundertmark """ from sys import argv from novas.compat import make_on_surface, julian_date, app_planet from novas.compat import make_cat_entry, make_object, topo_star, equ2hor from novas.compat.eph_manager import ephem_open ephem_open('JPLEPH') from astropy import units as u from astropy.coordinates import SkyCoord import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates from datetime import datetime, timedelta def calc_hours_visibility_from_LSST(pointing, start_date, end_date, n_exp_visit, cadence, exp_time): """Function to calculate the number of hours a given pointing is visible from LSST between specified dates. :param tuple pointing: Field name, field center RA, Dec J2000.0, sexigesimal :param string start_date: Start of visibility window, YYYY-MM-DD :param string end_date: End of visibility window, YYYY-MM-DD """ accuracy = 0 # Full accuracy = 0, reduced accuracy = 1