"""Reproduce SpaceTRC9.0 length/unit/light-interval calculations with stdlib only. Usage: python reproduce-scale.py.txt scales.json This does not recover a measured3D map or a cosmological lookback-time integral. """ from pathlib import Path from decimal import Decimal, getcontext import hashlib,json,math,sys getcontext().prec=40 path=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_name('scales.json') raw=path.read_bytes();d=json.loads(raw,parse_float=Decimal) c=Decimal('299792.458');year=Decimal('31557600');au=Decimal('149597870.7') # pi is the platform double approximation; errors are below displayed precision. pc=au*Decimal(648000)/Decimal(str(math.pi));ly=c*year factors={'km':Decimal(1),'au':au,'ly':ly,'pc':pc,'Mpc':pc*1000000} print('source_sha256='+hashlib.sha256(raw).hexdigest()) print('station_id,quantity_kind,length_km,static_light_interval_s,earth_diameter_ratio') for station in d['stations']: length=Decimal(str(station['sourceValue']))*factors[station['sourceUnit']] expected=Decimal(str(station['lengthKm'])) assert abs(length-expected)<=length*Decimal('1e-14') interval='' if station['lightTimeMode']=='none' else format(length/c,'.12g') print(','.join([station['id'],station['kind'],format(length,'.12g'),interval,format(length/Decimal(12742),'.12g')]))