Pyorbital
repository·main·Indexed 42 days ago
https://github.com/pytroll/pyorbitalA Python library for scheduling satellite passes, computing orbital parameters from Two-Line Element (TLE) files, and performing astronomical calculations. It provides tools for calculating satellite position, velocity, and geolocation, as well as computing solar angles and observer ECI positions.
What's inside Pyorbital
- Pyorbital is a Python package designed for computing orbital parameters from Two-Line Element (TLE) files and performing various astronomical computations. It is a component of the Pytroll project.
Configure geolocation conventions
mainGeolocation in Pyorbital is affected by two main settings: Nadir Convention and Rotation Order. You can set these per function call or globally.
Available Options
Nadir Convention (defines 'down'):
"legacy"(Default): The direction used in previous Pyorbital versions. Not re-orthogonalised against velocity."geocentric": Straight at the center of the Earth. More accurate for most orbits."geodetic": Along the ellipsoid normal.
Rotation Order (defines roll/pitch application):
"legacy"(Default): Roll first, then pitch. The along-track component is compressed bycos(scan_angle)."pitch_first": Pitch first, then roll. The along-track component is independent of the scan angle.
Setting Conventions
1. Per function call (highest precedence):
from pyorbital.geoloc import geolocate lons, lats, alts = geolocate(orbital, scan_geometry, times, nadir_convention="geocentric", rotation_order="pitch_first")2. Process-wide via context manager:
import pyorbital with pyorbital.config.set(nadir_convention="geocentric", rotation_order="pitch_first"): # All calls within this block use the new settings reprocess()3. Via Environment Variables: Set
PYORBITAL_NADIR_CONVENTIONandPYORBITAL_ROTATION_ORDERin your shell.IMPORTANT To reproduce existing Pyorbital products exactly (e.g., for archive reprocessing), you must pin both to
"legacy". Mixing"legacy"nadir with"pitch_first"rotation will not reproduce legacy output.from pyorbital.geoloc import geolocate lons, lats, alts = geolocate(orbital, scan_geometry, times, # doctest: +SKIP nadir_convention="geocentric", rotation_order="pitch_first")Install Pyorbital from source
mainYou can install the latest in-development version from GitHub using
pip:pip install git+https://github.com/pytroll/pyorbital.gitIf you are developing Pyorbital and want changes to reflect immediately, clone the repository and install it in "editable" mode:
git clone git://github.com/pytroll/pyorbital.git cd pyorbital pip install -e .Install Pyorbital via pip or conda
mainPyorbital can be installed from PyPI using
pipor from theconda-forgechannel usingconda.To install from PyPI:
pip install pyorbitalTo install in an existing conda environment:
conda install -c conda-forge pyorbitalAdd missing satellite platforms
mainPyorbital uses a
platforms.txtfile to map satellite names to NORAD identifiers. If your satellite is not supported, you can add it by:- Copying the existing
platforms.txtfile. - Adding your satellite name and its NORAD identifier (the first number in a TLE file).
- Placing the modified file in a directory specified by the
PYORBITAL_CONFIG_PATHenvironment variable.
You can use the
check_platform.pyscript to verify if a satellite is already supported:python -m pyorbital.check_platform -s SATELLITE_NAMEpython -m pyorbital.check_platform -s NOAA-21- Copying the existing
Parse TLE files with tlefile
mainThe
pyorbital.tlefilemodule allows you to parse NORAD Two-Line Element (TLE) files.If no path is provided to the read function, Pyorbital attempts to find local TLE files using the glob pattern defined in the
TLESenvironment variable. IfTLESis not set, it attempts to download TLEs from Celestrak.To use a specific local TLE file:
from pyorbital import tlefile tle = tlefile.read('satellite_name', '/path/to/my/tle_file.txt') print(tle.inclination)from pyorbital import tlefile tle = tlefile.read('noaa 18', '/path/to/my/tle_file.txt') print(tle.inclination)Perform orbital computations with pyorbital.orbital
mainUse thepyorbital.orbitalmodule to perform satellite position and velocity computations. This module provides the core logic for calculating where a satellite is in space based on orbital elements or TLEs.Perform astronomical computations with pyorbital.astronomy
mainUse thepyorbital.astronomymodule to compute astronomical parameters. This module provides tools for calculations related to celestial mechanics and astronomical positioning.Compute astronomical parameters
mainThe
pyorbital.astronomymodule provides functions for satellite remote sensing parameters, such as the Sun-zenith angle.from pyorbital import astronomy import datetime as dt # Parameters utc_time = dt.datetime(2012, 5, 15, 15, 45) lon, lat = 12, 56 # Compute Sun-zenith angle angle = astronomy.sun_zenith_angle(utc_time, lon, lat)from pyorbital import astronomy import datetime as dt utc_time = dt.datetime(2012, 5, 15, 15, 45) lon, lat = 12, 56 print(astronomy.sun_zenith_angle(utc_time, lon, lat))Handle TLE files with pyorbital.tlefile
mainUse thepyorbital.tlefilemodule to manage Two-Line Element (TLE) data. This module is responsible for parsing and handling TLE files, which are required to accurately track satellite orbits.Compute satellite position and velocity with Orbital
mainThe
pyorbital.orbital.Orbitalclass is used to compute a satellite's position, velocity, and geolocation at a specific time.Using current TLEs (Internet-based)
By default, initializing
Orbitalwith just a name will attempt to use the most recent TLEs from the internet.from pyorbital.orbital import Orbital import datetime as dt # Initialize with satellite name orb = Orbital("Suomi NPP") now = dt.datetime.now(dt.timezone.utc) # Get normalized position and velocity pos, vel = orb.get_position(now) # Get longitude, latitude, and altitude lon, lat, alt = orb.get_lonlatalt(now)Using specific TLE files for accuracy
For historical data or higher accuracy, provide a specific TLE file path to the
Orbitalconstructor:from pyorbital.orbital import Orbital import datetime as dt dtobj = dt.datetime(2015, 2, 7, 3, 0) snpp = Orbital('Suomi NPP', tle_file='/path/to/tle/files/tle-20150207.txt') lon, lat, alt = snpp.get_lonlatalt(dtobj)from pyorbital.orbital import Orbital import datetime as dt # Use current TLEs from the internet: orb = Orbital("Suomi NPP") now = dt.datetime.now(dt.timezone.utc) # Get normalized position and velocity of the satellite: pos, vel = orb.get_position(now) # Get longitude, latitude and altitude of the satellite: lon, lat, alt = orb.get_lonlatalt(now)Configure the Pyorbital configuration path
mainPyorbital looks for configuration files (like
platforms.txt) in a specific directory. You can control this directory using environment variables:PYORBITAL_CONFIG_PATH: Use this to specify a custom directory for configuration files. This is the preferred method.PPP_CONFIG_DIR: This is deprecated and no longer supported. UsePYORBITAL_CONFIG_PATHinstead.
The
platforms.txtfile within this directory should contain satellite names and their NORAD numbers, one per line, ignoring lines starting with#.