Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : ORIX Cosmos8# File : DataPipeline/textures/fetch_facts.sh9# Module : DataPipeline10# Repository : https://git.spboucher.ai/orix-cosmos11# Project Website : https://www.orixlab.dev12# Created : 2026-11-2413# Last Modified : 2026-11-2414#15# Author : Simon-Pierre Boucher16# Position : Professor of Finance17# Institution : Université du Québec en Outaouais (UQO)18# Organization : SP Boucher19# Website : https://spboucher.ai20# Git : https://git.spboucher.ai21#22# Preferred Contact: support@spboucher.ai23# Technical Contact: dev@spboucher.ai24# Security/Admin : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License : None specified (no license file in this repository)33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041# ORIX Cosmos42# File: DataPipeline/textures/fetch_facts.sh43# Description: Downloads the public pages the planetary description is parsed from (NASA NSSDCA fact sheets, JPL SSD physical-parameter tables, JPL SBDB API records, PDS Ring-Moon Systems Node ring tables) into the git-ignored raw cache DataPipeline/raw/facts, with SHA-256 and retrieval date.44#45# Author: Simon-Pierre Boucher46# Contact: contact@spboucher.ai47#48# Usage: DataPipeline/textures/fetch_facts.sh [--refresh]49# Without --refresh a file already present and non-empty is kept (the cache is the reproducible input of50# parse_facts.py); with --refresh every page is downloaded again.51# Network: nssdc.gsfc.nasa.gov, ssd.jpl.nasa.gov, ssd-api.jpl.nasa.gov, pds-rings.seti.org only (official public52# archives). No personal data is sent; the User-Agent is generic. Then run: parse_facts.py <repository root>.53set -euo pipefail5455HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"56ROOT="$(cd "$HERE/../.." && pwd)"57RAW="$ROOT/DataPipeline/raw/facts"58UA="orix-cosmos-pipeline/1.0"59REFRESH=060[ "${1:-}" = "--refresh" ] && REFRESH=16162NSSDCA="https://nssdc.gsfc.nasa.gov/planetary/factsheet"63SBDB="https://ssd-api.jpl.nasa.gov/sbdb.api"64RMS="https://pds-rings.seti.org"6566# name|url (names are the cache file names read by parse_facts.py)67FILES=(68 "nssdca_index.html|https://nssdc.gsfc.nasa.gov/planetary/planetfact.html"69 "nssdca_fact_notes.html|$NSSDCA/fact_notes.html"70 "nssdca_sunfact.html|$NSSDCA/sunfact.html"71 "nssdca_mercuryfact.html|$NSSDCA/mercuryfact.html"72 "nssdca_venusfact.html|$NSSDCA/venusfact.html"73 "nssdca_earthfact.html|$NSSDCA/earthfact.html"74 "nssdca_moonfact.html|$NSSDCA/moonfact.html"75 "nssdca_marsfact.html|$NSSDCA/marsfact.html"76 "nssdca_jupiterfact.html|$NSSDCA/jupiterfact.html"77 "nssdca_saturnfact.html|$NSSDCA/saturnfact.html"78 "nssdca_uranusfact.html|$NSSDCA/uranusfact.html"79 "nssdca_neptunefact.html|$NSSDCA/neptunefact.html"80 "nssdca_plutofact.html|$NSSDCA/plutofact.html"81 "nssdca_joviansatfact.html|$NSSDCA/joviansatfact.html"82 "nssdca_galileanfact_table.html|$NSSDCA/galileanfact_table.html"83 "nssdca_saturniansatfact.html|$NSSDCA/saturniansatfact.html"84 "nssdca_uraniansatfact.html|$NSSDCA/uraniansatfact.html"85 "nssdca_neptuniansatfact.html|$NSSDCA/neptuniansatfact.html"86 "nssdca_jupringfact.html|$NSSDCA/jupringfact.html"87 "nssdca_satringfact.html|$NSSDCA/satringfact.html"88 "nssdca_uranringfact.html|$NSSDCA/uranringfact.html"89 "nssdca_nepringfact.html|$NSSDCA/nepringfact.html"90 "nssdca_asteroidfact.html|$NSSDCA/asteroidfact.html"91 "nssdca_cometfact.html|$NSSDCA/cometfact.html"92 "nssdca_chironfact.html|$NSSDCA/chironfact.html"93 "jpl_planets_phys_par.html|https://ssd.jpl.nasa.gov/planets/phys_par.html"94 "jpl_sats_phys_par.html|https://ssd.jpl.nasa.gov/sats/phys_par/"95 "sbdb_ceres.json|$SBDB?sstr=1&phys-par=1&full-prec=1"96 "sbdb_vesta.json|$SBDB?sstr=4&phys-par=1&full-prec=1"97 "sbdb_eros.json|$SBDB?sstr=433&phys-par=1&full-prec=1"98 "sbdb_pluto.json|$SBDB?sstr=134340&phys-par=1&full-prec=1"99 "sbdb_eris.json|$SBDB?sstr=136199&phys-par=1&full-prec=1"100 "sbdb_haumea.json|$SBDB?sstr=136108&phys-par=1&full-prec=1"101 "sbdb_makemake.json|$SBDB?sstr=136472&phys-par=1&full-prec=1"102 "sbdb_halley.json|$SBDB?sstr=1P&phys-par=1&full-prec=1"103 "sbdb_67p.json|$SBDB?sstr=67P&phys-par=1&full-prec=1"104 "rms_saturn_tables.html|$RMS/saturn/saturn_tables.html"105 "rms_jupiter_tables.html|$RMS/jupiter/jupiter_tables.html"106 "rms_uranus_tables.html|$RMS/uranus/uranus_tables.html"107 "rms_neptune_tables.html|$RMS/neptune/neptune_tables.html"108 "pds_citing.html|https://pds.nasa.gov/datastandards/citing/"109 "jpl_ssd_about.html|https://ssd.jpl.nasa.gov/about/"110 "jpl_sbdb_api_doc.html|https://ssd-api.jpl.nasa.gov/doc/sbdb.html"111 "nasa_media_guidelines.html|https://www.nasa.gov/nasa-brand-center/images-and-media/"112)113114mkdir -p "$RAW"115fail=0116: > "$RAW/SOURCES.tmp"117for entry in "${FILES[@]}"; do118 name="${entry%%|*}"; url="${entry#*|}"119 dest="$RAW/$name"120 printf '%s\t%s\n' "$name" "$url" >> "$RAW/SOURCES.tmp"121 if [ "$REFRESH" = 0 ] && [ -s "$dest" ]; then122 echo "ok $name (cached)"123 continue124 fi125 # Small pages: download to a temporary file (resumed with -C - if a partial one is left), then move atomically.126 if curl -fsSL --retry 4 --retry-delay 3 -m 120 -C - -A "$UA" -o "$dest.part" "$url"; then127 mv -f "$dest.part" "$dest"128 echo "fetched $name ($(stat -f %z "$dest" 2>/dev/null || stat -c %s "$dest") bytes)"129 else130 rm -f "$dest.part"131 echo "FAILED $name <- $url" >&2132 case "$name" in133 # Informational pages (licence statements): absence does not block the parser.134 pds_citing.html|jpl_ssd_about.html|jpl_sbdb_api_doc.html|nasa_media_guidelines.html|nssdca_chironfact.html) ;;135 *) fail=1 ;;136 esac137 fi138done139mv -f "$RAW/SOURCES.tmp" "$RAW/SOURCES.tsv"140141# Retrieval date: kept when everything came from the cache, so that re-parsing is reproducible.142if [ ! -f "$RAW/RETRIEVED" ] || [ "$REFRESH" = 1 ]; then143 date -u +%Y-%m-%d > "$RAW/RETRIEVED"144fi145( cd "$RAW" && shasum -a 256 $(cut -f1 SOURCES.tsv | while read -r n; do [ -s "$n" ] && echo "$n"; done) > SHA256SUMS )146echo "retrieved $(cat "$RAW/RETRIEVED"); $(wc -l < "$RAW/SHA256SUMS" | tr -d ' ') files in $RAW"147[ "$fail" = 0 ] || { echo "some required pages could not be downloaded" >&2; exit 1; }148