climateLayers(): let the caller choose the years; add latestHistoricalYear() - #24
Open
eliotmcintire wants to merge 2 commits into
Open
climateLayers(): let the caller choose the years; add latestHistoricalYear()#24eliotmcintire wants to merge 2 commits into
eliotmcintire wants to merge 2 commits into
Conversation
…lYear() climateLayers() always requested historical years 1991:2022 and projected years 2011:2100. It gains historicalYears and projectedYears arguments with those defaults, so existing callers are unchanged. latestHistoricalYear() returns the last year the bundled tile index lists for every requested tile, without network access, so a project can ask for the latest year it can fetch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T5BZwHeHMMhjzRK8eGCTp3
eliotmcintire
commented
Sep 11, 2026
eliotmcintire
left a comment
Collaborator
Author
There was a problem hiding this comment.
This is entirely backwards compatible as 2 hard coded date ranges are moved to arguments with those same data ranges as defaults.
The 2020-decade Drive archives have contained Year_2023MSY and Year_2024MSY since they were re-uploaded (b6f2845, "add 2023, 2024 data"), and available("historical") already reports 1901:2024, but that commit updated the zips without adding the matching rows to inst/extdata/ClimateNA_tiles.sqlite. The index therefore stopped at 2022, so getClimateURLs() returned no Drive id for 2023/2024 and latestHistoricalYear() reported 2022 -- capping downstream fits at 2022 even though the data was already on disk. Each new row copies its tile/msy 2022 row and changes only the year: within a decade every year shares one zipfile and gid, so no new uploads are involved. 492 rows (2 years x 82 tiles x {M, MSY, Y}); historical goes 30012 -> 30504. Verified: latestHistoricalYear() now returns 2024; climateLayers() accepts historicalYears = 1985:2024; getClimateURLs(type = "historical", years = 2023:2024) returns the same Drive ids as 2022. The two prepClimateLayers test errors are pre-existing Google Drive auth failures in a non-interactive session -- identical with and without this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small additions so a project can use more climate years.
climateLayers()gainshistoricalYears(default1991:2022) andprojectedYears(default2011:2100). The defaults are the years it used before, so existing calls are unchanged.latestHistoricalYear()returns the last year the bundled tile index lists for every tile (2022 today). It only reads the bundled index, so it needs no network.Tests:
tests/testthat/test-climateLayers.R.Some things I noticed but did not change, since they concern the data rather than the code:
getClimateURLs(years = 2023:2024)returns nothing, while1991:2024works only because the 2020-2022 rows point to the same zip. With rows for 2023 and 2024,latestHistoricalYear()would return 2024.available("historical")says 1901:2024. Taking it from the index would keep the two in step.getClimateURLs()could stop with a message when some requested years have no rows, instead of quietly returning fewer.Happy to help with any of these.
🤖 Generated with Claude Code
https://claude.ai/code/session_01T5BZwHeHMMhjzRK8eGCTp3