Repository Public
1#!/usr/bin/env python32# =============================================================================3# SP BOUCHER | SOFTWARE & RESEARCH4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# PROJECT METADATA8# -----------------------------------------------------------------------------9# Project : ORIX Cosmos10# File : DataPipeline/time/make_spice_fixtures.py11# Module : DataPipeline12# Repository : https://git.spboucher.ai/orix-cosmos13# Project Website : https://www.orixlab.dev14# Created : 2026-11-2415# Last Modified : 2026-11-2416#17# =============================================================================18# AUTHOR & PROFESSIONAL AFFILIATION19# =============================================================================20#21# Author : Simon-Pierre Boucher22# Position : Professor of Finance23# Institution : Université du Québec en Outaouais (UQO)24# Department : Département des sciences administratives25# Organization : SP Boucher26#27# Website : https://spboucher.ai28# Git : https://git.spboucher.ai29#30# =============================================================================31# OFFICIAL CONTACT DIRECTORY32# =============================================================================33#34# General : info@spboucher.ai35# Professional : contact@spboucher.ai36# Direct : simon@spboucher.ai37# Research : research@spboucher.ai38# Development : dev@spboucher.ai39# Support : support@spboucher.ai40# Security/Admin : admin@spboucher.ai41# Notifications : notifications@spboucher.ai42#43# Preferred Contact: support@spboucher.ai44#45# =============================================================================46# COPYRIGHT & INTELLECTUAL PROPERTY47# =============================================================================48#49# Copyright (c) 202650# Simon-Pierre Boucher51#52# All rights reserved where applicable.53#54# This file is governed by the applicable project license,55# copyright notices, institutional agreements and relevant law.56#57# Unless expressly authorized by the applicable license or58# rights holder, copying, redistribution, sublicensing,59# publication and commercial exploitation are not permitted.60#61# Existing third-party rights and notices remain unaffected.62#63# =============================================================================64# CONFIDENTIALITY & SECURITY65# =============================================================================66#67# Classification : Public68# Distribution : Public repository; use is governed by the project license69# Security Contact : admin@spboucher.ai70#71# Access to this source does not independently grant permission72# to redistribute or disclose confidential materials.73#74# Do not embed credentials, private keys, access tokens,75# certificates or confidential personal information.76#77# =============================================================================78# LICENSE & MAINTENANCE79# =============================================================================80#81# License : None specified (no license file in this repository)82# Maintainer : Simon-Pierre Boucher83# Technical Contact: dev@spboucher.ai84#85# =============================================================================86# END OF SP BOUCHER SOURCE HEADER87# =============================================================================8889# ORIX Cosmos90# File: DataPipeline/time/make_spice_fixtures.py91# Description: Generates test reference values (UTC<->TDB, TDB-TT, constant frame matrices) with the NAIF CSPICE toolkit via spiceypy. Output goes to Tests/Fixtures only; it is never production data.92#93# Author: Simon-Pierre Boucher94# Contact: contact@spboucher.ai95#96# Usage: python3 make_spice_fixtures.py <path/to/naif0012.tls> <time-fixture.json> <frames-fixture.json>97# Requires: pip install spiceypy (wraps the NAIF CSPICE toolkit, https://naif.jpl.nasa.gov/naif/toolkit.html).98import datetime99import json100import sys101102import spiceypy as sp103104lsk, out_time, out_frames = sys.argv[1:4]105sp.furnsh(lsk)106meta = {107 "generator": "DataPipeline/time/make_spice_fixtures.py",108 "toolkit": sp.tkvrsn("TOOLKIT"),109 "leapseconds_kernel": "naif0012.tls (https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls)",110 "generated": datetime.date.today().isoformat(),111}112113utc_strings = [114 "1972-01-01T00:00:00", "1972-06-30T23:59:60", "1972-07-01T00:00:00",115 "1980-02-29T13:14:15.5", "1985-06-30T23:59:59.25", "1985-06-30T23:59:60.75",116 "1985-07-01T00:00:00", "1998-12-31T23:59:60.5", "1999-01-01T00:00:00",117 "2000-01-01T11:58:55.816", "2000-01-01T12:00:00", "2005-12-31T23:59:60",118 "2012-06-30T23:59:60.123", "2015-06-30T23:59:59", "2015-06-30T23:59:60",119 "2015-07-01T00:00:00", "2016-12-31T23:59:59.999", "2016-12-31T23:59:60",120 "2016-12-31T23:59:60.999", "2017-01-01T00:00:00", "2024-06-15T09:30:00",121 "2026-11-24T00:00:00", "2040-03-01T06:00:00",122]123utc = []124for s in utc_strings:125 et = sp.str2et(s)126 utc.append({127 "utc": s,128 "et": repr(et),129 "tdb_minus_utc": repr(sp.deltet(et, "ET")),130 "tt_seconds": repr(sp.unitim(et, "ET", "TDT")),131 "tai_seconds": repr(sp.unitim(et, "ET", "TAI")),132 "jd_tdb": repr(sp.unitim(et, "ET", "JDTDB")),133 "jd_tt": repr(sp.unitim(et, "ET", "JDTDT")),134 })135# ET -> UTC calendar strings (ISO calendar, 6 decimals), including instants inside leap seconds.136ets = [-883655957.816072, -86399.5, 0.0, 189345665.5, 189345666.0, 536500868.25, 536500869.0, 536500869.75,137 772191669.184, 1e9, -8.5e8]138back = [{"et": repr(e), "utc": sp.et2utc(e, "ISOC", 6)} for e in ets]139json.dump({"meta": meta, "utc_to_et": utc, "et_to_utc": back}, open(out_time, "w"), indent=1)140141def mat(a, b):142 m = sp.pxform(a, b, 0.0)143 return [[repr(float(m[i][j])) for j in range(3)] for i in range(3)]144145frames = {146 "meta": meta,147 "note": "Row-major 3x3 matrices M such that v_to = M * v_from (spiceypy.pxform(from, to, 0)).",148 "J2000_to_ECLIPJ2000": mat("J2000", "ECLIPJ2000"),149 "J2000_to_GALACTIC": mat("J2000", "GALACTIC"),150 "ECLIPJ2000_to_GALACTIC": mat("ECLIPJ2000", "GALACTIC"),151}152json.dump(frames, open(out_frames, "w"), indent=1)153