From 6888b586dc60c2766c66463fce5626976b5f47f7 Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Thu, 15 Oct 2026 10:08:41 -0400 Subject: [PATCH] Updated moon fetch script to use less memory --- .gitignore | 1 + scripts/fetch-moon.py | 83 ++++++++++++++++++++++++++++++------------- 2 files changed, 59 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 123d8d7..f5c5a9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target /examples/models/nasa/ /data/ +__pycache__/ diff --git a/scripts/fetch-moon.py b/scripts/fetch-moon.py index 91b4153..65b3d25 100644 --- a/scripts/fetch-moon.py +++ b/scripts/fetch-moon.py @@ -22,7 +22,8 @@ bands relative to 643 nm over the whole mosaic, weighted by area: it downloads e tile of every band in turn (56 files, 8 GB) and keeps none of them. That is how the spectrum in crates/resolved/src/moon.rs was found. -Needs numpy and Pillow. +Needs numpy and Pillow. Building the image takes about 20 s and 2.6 GB of memory once +the tiles are downloaded (about a minute at 50 MB/s, with a pause between files). """ import hashlib @@ -67,6 +68,7 @@ LINES = {"N": 5321, "S": 5320} ROWS = 70 * PPD # 5320 lines from the equator to 70 degrees OUT_W, OUT_H = 16384, 8192 SCALE = 100_000 # stored value per unit I/F +STRIP = 512 # rows or columns resampled at a time def url(band, tile): @@ -106,18 +108,24 @@ def fetch(band, tile, sha, directory): return path -def read_tile(path, hemisphere): - """The tile's 5320 lines from the equator outward, as rows from north to south.""" - data = np.fromfile(path, dtype="