fix: make Instant::Now independent of the local time zone (#408)
Instant::Nowmeasured the current time from a J2000 reference (2000-01-01 12:00:00) built withstd::mktime, which interprets a calendar date in the local time zone of the machine. “Now” was therefore off by the UTC offset of the host: -8 h in Los Angeles, +5.5 h in Kolkata, and correct only where the clock is set to UTC (which is why production containers were unaffected). The error showed when “now” was compared with TLE epochs, parsed strings or files, e.g. in the data managers’ “is my data stale?” check.Compute the J2000 Unix timestamp arithmetically instead (10957 days * 86400 s + 12 h = 946728000 s), reusing the existing
daysFromUnixEpochTo2000constant.std::time_tcounts Unix time on every supported platform, sofrom_time_tputs the epoch at the right point ofsystem_clock.The new
Now_LocalTimeZonetest sets TZ to several POSIX zones (no tz database needed) and comparesInstant::Now()with an instant built fromgmtime_r. Before the fix it fails by 5 h, 5.5 h and 12 h.Co-authored-by: Claude Opus 5.5 noreply@anthropic.com
Open Space Toolkit 物理组件(环境、大气、坐标系统)。镜像收录自 https://github.com/open-space-collective/open-space-toolkit-physics,License:Apache-2.0
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
Open Space Toolkit ▸ Physics
Physical units, time, reference frames, environment modeling.
Gravitational field anomaly between EGM96 and WGS84 models.
Getting Started
Want to get started? This is the simplest and quickest way:
Nothing to download or install! This will automatically start a JupyterLab environment in your browser with Open Space Toolkit libraries and example notebooks ready to use.
Alternatives
Docker Images
Docker must be installed on your system.
iPython
The following command will start an iPython shell within a container where the OSTk components are already installed:
Once the shell is up and running, playing with it is easy:
By default, OSTk fetches the ephemeris from JPL, Earth Orientation Parameters (EOP) and leap second count from IERS.
As a result, when running OSTk for the first time, it may take a minute to fetch all the necessary data.
Tip: Use tab for auto-completion!
JupyterLab
The following command will start a JupyterLab server within a container where the OSTk components are already installed:
Once the container is running, access http://localhost:8888/lab and create a Python 3 Notebook.
Installation
C++
The binary packages are hosted using GitHub Releases:
open-space-toolkit-physics-X.Y.Z-1.x86_64-runtimeopen-space-toolkit-physics-X.Y.Z-1.x86_64-developen-space-toolkit-physics-X.Y.Z-1.x86_64-pythonDebian / Ubuntu
After downloading the relevant
.debbinary packages, install:Python
Install from PyPI:
Documentation
Documentation is available here:
Structure
The library exhibits the following structure:
Data Management
OSTk Physics uses input data from various sources to determine the state of the space environment at any given time. The following input data is used:
None of these files are shipped with the source code of this library. OSTk Physics has the capability to fetch the required files at runtime if they are not present or if they are outdated. This is done using file Manager classes (see any file named
Manager.hpp). Data for any use-case is queried through the Manager class rather than directly, which allows the Manager to handle file loading and fetching. The managers have two modes, which can be configured via environment variables (explained below).Automatic: Will load the data from the provided directories, if the data does not exist it will be fetched.Manual: Will load the data from the provided directories, if the data does not exist it will raise an error.If you would like to seed the ostk data generation so that you already have an initial copy of all the data files (to avoid a large initial fetch at runtime), then we recommend running the following commands to set up your environment.
For users that are installing OSTk into docker images, here is what we recommend you add to your dockerfiles.
If you have a multi-stage dockerfile, then you can easily just copy the ostk-data repo install from one build stage (in the example below that’s
build-env) to the next, so that you don’t have to reinstall it on every build stage.The following table shows the availabe data source settings with the different environment variables you can set:
OSTK_PHYSICS_DATA_LOCAL_REPOSITORY./.open-space-toolkit/physics/data[Bulk setting. Overridden by specific repository settings below.]OSTK_PHYSICS_COORDINATE_FRAME_PROVIDER_IERS_MANAGER_MODEAutomaticOSTK_PHYSICS_COORDINATE_FRAME_PROVIDER_IERS_MANAGER_LOCAL_REPOSITORY./.open-space-toolkit/physics/data/coordinate/frame/provider/iersOSTK_PHYSICS_COORDINATE_FRAME_PROVIDER_IERS_MANAGER_LOCAL_REPOSITORY_LOCK_TIMEOUT60OSTK_PHYSICS_ENVIRONMENT_EPHEMERIS_SPICE_ENGINE_MODEAutomaticOSTK_PHYSICS_ENVIRONMENT_EPHEMERIS_SPICE_MANAGER_LOCAL_REPOSITORY./.open-space-toolkit/physics/data/environment/ephemeris/spiceOSTK_PHYSICS_ENVIRONMENT_EPHEMERIS_SPICE_MANAGER_LOCAL_REPOSITORY_LOCK_TIMEOUT60OSTK_PHYSICS_ENVIRONMENT_GRAVITATIONAL_EARTH_MANAGER_MODEAutomaticOSTK_PHYSICS_ENVIRONMENT_GRAVITATIONAL_EARTH_MANAGER_LOCAL_REPOSITORY./.open-space-toolkit/physics/data/environment/gravitational/earthOSTK_PHYSICS_ENVIRONMENT_GRAVITATIONAL_EARTH_MANAGER_LOCAL_REPOSITORY_LOCK_TIMEOUT60OSTK_PHYSICS_ENVIRONMENT_MAGNETIC_EARTH_MANAGER_MODEAutomaticOSTK_PHYSICS_ENVIRONMENT_MAGNETIC_EARTH_MANAGER_LOCAL_REPOSITORY./.open-space-toolkit/physics/data/environment/magnetic/earthOSTK_PHYSICS_ENVIRONMENT_MAGNETIC_EARTH_MANAGER_LOCAL_REPOSITORY_LOCK_TIMEOUT60OSTK_PHYSICS_ENVIRONMENT_ATMOSPHERIC_EARTH_MANAGER_MODEAutomaticOSTK_PHYSICS_ENVIRONMENT_ATMOSPHERIC_EARTH_MANAGER_LOCAL_REPOSITORY./.open-space-toolkit/physics/data/environment/atmospheric/earthOSTK_PHYSICS_ENVIRONMENT_ATMOSPHERIC_EARTH_MANAGER_LOCAL_REPOSITORY_LOCK_TIMEOUT60OSTK_PHYSICS_DATA_REMOTE_URLhttps://github.com/open-space-collective/open-space-toolkit-data/raw/v1/data/OSTK_PHYSICS_DATA_MANIFEST_MANAGER_MODEAutomaticOSTK_PHYSICS_DATA_MANIFEST_LOCAL_REPOSITORY./.open-space-toolkit/physics/data/OSTK_PHYSICS_DATA_MANIFEST_LOCAL_REPOSITORY_LOCK_TIMEOUT60OSTK_PHYSICS_FRAME_MANAGER_MAX_TRANSFORM_CACHE_SIZE1000OSTK_PHYSICS_COORDINATE_FRAME_PROVIDER_CIRF_XYS_INTERPOLATIONFalseTutorials
Tutorials are available here:
Setup
Development Environment
Using Docker for development is recommended, to simplify the installation of the necessary build tools and dependencies. Instructions on how to install Docker are available here.
To start the development environment:
This will:
openspacecollective/open-space-toolkit-physics-developmentDocker image.bashshell from the./buildworking directory.If installing Docker is not an option, you can manually install the development tools (GCC, CMake) and all required dependencies, by following a procedure similar to the one described in the Development Dockerfile.
Build
From the
./builddirectory:Tip: The
ostk-buildcommand simplifies building from within the development environment.Test
To start a container to build and run the tests:
Or to run them manually:
Tip: The
ostk-testcommand simplifies running tests from within the development environment.Dependencies
2.10.15.2.00.6.03.3.72023-10-11N00671.52mainmainmainContribution
Contributions are more than welcome!
Please read our contributing guide to learn about our development process, how to propose fixes and improvements, and how to build and test the code.
Special Thanks
License
Apache License 2.0