Skip to content

climateYear: per-year .vrt instead of .tif copy; record climate used (climateYearsUsed); fix single-year samplingRange - #3

Closed
eliotmcintire wants to merge 6 commits into
developmentfrom
fix/climate-year-file-leak
Closed

eliotmcintire wants to merge 6 commits into
developmentfrom
fix/climate-year-file-leak

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Each simulated year used to make a large copy of its climate data and kept no record of which historical year was used. It now writes a tiny pointer file instead and keeps a table of which climate year was used for each simulated year, so runs can be traced and checked later. It also fixes a bug where asking for one specific climate year gave a random different year.

Affects: much less disk use per run, a new record of the climate years used, and correct results when a single climate year is requested.

Technical details

The getClimate event (climateYear.R:98-102 on development) wrote each year's currentClimateRasters to a ~72 MB .tif copy next to the shared source stacks and kept no record of which source layer it came from. It now writes a ~1 KB climate_simYear<sim year>_climYear<climate year>.vrt per simulation year to outputPath(sim)/climate/ (one band per variable, absolute source paths, so a reused climate year still gets its own file), reads currentClimateRasters from it, and records one row per simulation year and variable (climate year, historical or projected, source file, source md5 computed once per file per run, layer, .vrt path) in a new output climateYearsUsed. That table is rewritten to climateYearsUsed.csv in outputPath(sim) every year, to a temporary file then renamed, so a killed run keeps every finished year and a restart does not duplicate rows (appending could do both); sources that are not single files on disk still fall back to a .tif. It also fixes sampleYear() (climateYear.R:156): sample(Range, size = 1) draws from 1:Range for a single-year samplingRange, so 2003 returned e.g. 1974; it now uses Range[sample.int(length(Range), 1L)]. New tests (fail on development) check the expected .vrt per simulation year, CSV rows equal to the table, values/names/extent/crs equal to a copy at tolerance 0, a fresh callr process recovering each year's climate from the CSV and .vrt alone, md5s, .robustDigest() differing by year and matching for a rebuilt VRT, and a single-year range.

The Rmd render job was red on this and the previous PR because the repo's own copy of the workflow (pinned to actions@v0.2) called Require:: before installing Require; it now calls the org's shared render-module-rmd.yaml@main, like the fireSense modules.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv

eliotmcintire and others added 2 commits September 30, 2026 19:03
@eliotmcintire eliotmcintire changed the title getClimate: remove the previous year's raster file getClimate: remove previous year's raster file; sampleYear single-year range Oct 1, 2026
… year's file

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
@eliotmcintire eliotmcintire changed the title getClimate: remove previous year's raster file; sampleYear single-year range climateYear: record the climate used each year (climateYearsUsed); fix single-year samplingRange Oct 1, 2026
…if copy; record source md5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
@eliotmcintire eliotmcintire changed the title climateYear: record the climate used each year (climateYearsUsed); fix single-year samplingRange climateYear: per-year .vrt instead of .tif copy; record climate used (climateYearsUsed); fix single-year samplingRange Oct 1, 2026
eliotmcintire and others added 2 commits September 30, 2026 19:45
…rsUsed.csv every year

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
The per-repo copy pinned actions@v0.2 and ran install-Rmd-pkgs (which calls
Require::) before install-Require, so the job failed with 'there is no package
called Require' (also on the previous PR).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
achubaty pushed a commit to FOR-CAST/climateYear that referenced this pull request Oct 5, 2026
…rFireSense

climateYear: per-year .vrt instead of .tif copy; record climate used (climateYearsUsed); fix single-year samplingRange

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
achubaty added a commit to FOR-CAST/climateYear that referenced this pull request Oct 5, 2026
@eliotmcintire eliotmcintire added bug Something isn't working enhancement New feature or request backwards compatible Existing code and results keep working unchanged labels Oct 6, 2026
@eliotmcintire

Copy link
Copy Markdown
Contributor Author

Closing: this change is carried on modsForFireSense and offered upstream together with our other FireSense fixes in #9. That PR lists it; the discussion here stays for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant