# How to use the skyfield.functions.rot_z function in skyfield

## To help you get started, we’ve selected a few skyfield examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

skyfielders / python-skyfield / skyfield / toposlib.py View on Github
def _altaz_rotation(self, t):
"""Compute the rotation from the ICRF into the alt-az system."""
R_lon = rot_z(- self.longitude.radians - t.gast * tau / 24.0)
return mxmxm(self.R_lat, R_lon, t.M)
skyfielders / python-skyfield / skyfield / timelib.py View on Github
def C(self):
# Calculate the Equation of Origins in cycles
eq_origins = (earth_rotation_angle(self.ut1) - self.gast / 24.0)
R = rot_z(2 * pi * eq_origins)
return mxm(R, self.M)
skyfielders / python-skyfield / skyfield / positionlib.py View on Github
def ITRF_to_GCRS2(t, rITRF, vITRF, _high_accuracy=False):
# TODO: wobble

spin = rot_z(t.gast / 24.0 * tau)
position = mxv(spin, array(rITRF))
velocity = mxv(spin, array(vITRF))

# TODO: This is expensive, and should be extensively trimmed to only
# include the most important terms underlying GAST.  But it improves
# the precision by something like 1e5 times when compared to using
# the round number skyfield.constants.ANGVEL!
#
# See the test `test_velocity_in_ITRF_to_GCRS2()`.
#
if _high_accuracy:
_one_second = 1.0 / DAY_S
t_later = t.ts.tt_jd(t.whole, t.tt_fraction + _one_second)
angvel = (t_later.gast - t.gast) / 24.0 * tau
else:
angvel = ANGVEL
skyfielders / python-skyfield / skyfield / planetarylib.py View on Github
def from_latlon_distance(cls, frame, latitude, longitude, distance):
r = array((distance.au, 0.0, 0.0))

self = cls(frame, r)
self.latitude = latitude
self.longitude = longitude
return self
skyfielders / python-skyfield / skyfield / sgp4lib.py View on Github
This converts a position and velocity vector in the idiosyncratic
True Equator Mean Equinox (TEME) frame of reference used by the SGP4
theory into vectors into the more standard ITRS frame of reference.
The velocity should be provided in units per day, not per second.

From AIAA 2006-6753 Appendix C.

"""
# TODO: are xp and yp the values from the IERS?  Or from general
# nutation theory?

theta, theta_dot = theta_GMST1982(jd_ut1, fraction_ut1)
angular_velocity = multiply.outer(_zero_zero_minus_one, theta_dot)

R = rot_z(-theta)

if len(rTEME.shape) == 1:
rPEF = (R).dot(rTEME)
vPEF = (R).dot(vTEME) + _cross(angular_velocity, rPEF)
else:
rPEF = mxv(R, rTEME)
vPEF = mxv(R, vTEME) + _cross(angular_velocity, rPEF)

if xp == 0.0 and yp == 0.0:
rITRF = rPEF
vITRF = vPEF
else:
W = (rot_x(yp)).dot(rot_y(xp))
rITRF = (W).dot(rPEF)
vITRF = (W).dot(vPEF)
return rITRF, vITRF
skyfielders / python-skyfield / skyfield / planetarylib.py View on Github
return Frame(center, segment, matrix)

def build_latlon_degrees(self, frame, latitude_degrees, longitude_degrees,
elevation_m=0.0):
"""Build an object representing a location on a body's surface."""
lat = Angle.from_degrees(latitude_degrees)
lon = Angle.from_degrees(longitude_degrees)
raise ValueError('only spherical bodies are supported,'
au = (radii[0] + elevation_m * 1e-3) / AU_KM
distance = Distance(au)
return PlanetTopos.from_latlon_distance(frame, lat, lon, distance)

_rotations = None, rot_x, rot_y, rot_z
_missing_name_message = """unknown planetary constant {0!r}

additional "*.tf" PCK text file that defines the missing name, or
manually provide a value by adding the name and value to the this
object's `.assignments` dictionary."""

class Frame(object):
"""Planetary constants frame, for building rotation matrices."""

def __init__(self, center, segment, matrix):
self.center = center
self._segment = segment
self._matrix = matrix
skyfielders / python-skyfield / skyfield / positionlib.py View on Github
def ITRF_to_GCRS(t, rITRF):

# Todo: wobble

spin = rot_z(t.gast / 24.0 * tau)
position = mxv(spin, array(rITRF))
return mxv(t.MT, position)
skyfielders / python-skyfield / builders / build_spice.py View on Github
#!/usr/bin/env python
"""Print the code for the skyfield/data/spice.py file.

"""
import re
import os
import sys
from pprint import pformat
from textwrap import dedent

import numpy as np
from skyfield.functions import rot_x, rot_y, rot_z

axes = {'1': rot_x, '2': rot_y, '3': rot_z}

template = """\
# Machine generated - see build_spice.py

from numpy import array

inertial_frames = [
%s,
]

inertial_frames = dict((key, array(value)) for key, value in inertial_frames)
"""

if __name__ == '__main__':
if len(sys.argv) != 2:
print("usage: build_spice_rotations.py /path/to/spice/toolkit/",

## skyfield

Elegant astronomy for Python

MIT