Skip to content

Fix year-range validation for start/end years (#306, #335)#458

Open
brianpm wants to merge 1 commit into
NCAR:mainfrom
brianpm:fix-year-range-validation
Open

Fix year-range validation for start/end years (#306, #335)#458
brianpm wants to merge 1 commit into
NCAR:mainfrom
brianpm:fix-year-range-validation

Conversation

@brianpm

@brianpm brianpm commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Validate user-supplied start_year/end_year against the discovered [found_syear, found_eyear] range instead of membership in a constructed collection, at all four sites (test/baseline x timeseries/history).

  • Incorrect year span on plots #306: the timeseries paths used np.arange(found_syear, found_eyear, 1), which is end-exclusive, so a config end_year equal to the last available year was wrongly rejected and silently overridden (shrinking the plotted span by one). Replaced with an inclusive range comparison and removed the now-unused found_yr_range.
  • file indexing for files containing more than 1yr of data fails if start or end year are not named in files #335: the history paths tested membership in case_climo_yrs/base_climo_yrs (the set of years parsed from filenames, one per file). When files span more than one year, an in-range year not literally named in a filename was wrongly rejected. Replaced with a range comparison against the found min/max years.

Also corrected the baseline timeseries end-year warning ("first" -> "last"). The warn-and-override fallback is retained; it now fires only for genuinely out-of-range requests.

Validate user-supplied start_year/end_year against the discovered
[found_syear, found_eyear] range instead of membership in a constructed
collection, at all four sites (test/baseline x timeseries/history).

- NCAR#306: the timeseries paths used np.arange(found_syear, found_eyear, 1),
  which is end-exclusive, so a config end_year equal to the last available
  year was wrongly rejected and silently overridden (shrinking the plotted
  span by one). Replaced with an inclusive range comparison and removed the
  now-unused found_yr_range.
- NCAR#335: the history paths tested membership in case_climo_yrs/base_climo_yrs
  (the set of years parsed from filenames, one per file). When files span
  more than one year, an in-range year not literally named in a filename was
  wrongly rejected. Replaced with a range comparison against the found
  min/max years.

Also corrected the baseline timeseries end-year warning ("first" -> "last").
The warn-and-override fallback is retained; it now fires only for genuinely
out-of-range requests.
@brianpm brianpm force-pushed the fix-year-range-validation branch from c26e8e9 to 9adbccb Compare June 25, 2026 22:18

@nusbaume nusbaume left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @brianpm!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants