fix: NetCDF forcing month-range off-by-one + CSV quantization matching#78
Merged
Conversation
- NetcdfForcingProvider::initCmfdMonths: use nextafter(sim_end_min, -inf) to avoid requesting the month of the exclusive END boundary (fixes 201901 file-not-found when END=730 days from 20170101) - Add CSV-matching quantization in loadTimeStep: precip 4dp, temp 2dp, RH 4dp, wind 2dp+0.05 min, radiation integer — matches AutoSHUD baseline - maxTimeMin(): account for step-function semantics (last record covers one more interval beyond its timestamp) - TimeSeriesData: add getMaxTimeCovered() for CSV forcing coverage check - MD_readin: use getMaxTimeCovered() in validateTimeStamps()
Owner
Author
Review: SHUD PR #78initCmfdMonths nextafter fix (L781-791)Correct. END is exclusive; loadTimeStep quantization (L1260-1325)Rounding matches AutoSHUD R CSV output. Order correct: clamp NaN/negative → round → threshold. maxTimeMin step-function (L1762-1779)Backward scan for last positive dt is robust. Correctly extends coverage for step-function semantics. TimeSeriesData::getMaxTimeCoveredClean addition. Verification10-day QHH: all 5 forcing vars max_abs_diff=0, output .dat binary identical, baseline unbroken. |
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.
Summary
Fixes the off-by-one bug in
NetcdfForcingProvider::initCmfdMonths()that caused a fatal error whenENDfalls exactly on a month boundary (e.g. END=730 days from 20170101 → requests non-existent 201901 file).Adds CSV-matching quantization in
loadTimeStep()so that NetCDF forcing values are bit-identical to AutoSHUD-generated baseline CSV forcing.Changes
NetcdfForcingProvider.cpp
initCmfdMonths(): usenextafter(sim_end_min, -inf)to treat END as exclusive bound for file discoveryloadTimeStep(): add rounding to match AutoSHUD CSV quantization (precip 4dp, temp 2dp, RH 4dp, wind 2dp + 0.05 min clamp, radiation integer)maxTimeMin(): account for step-function semantics — last record covers one more interval beyond its timestampTimeSeriesData.cpp/hpp
getMaxTimeCovered()that returnsmaxTime + lastDtfor step-function coverageMD_readin.cpp
getMaxTimeCovered()invalidateTimeStamps()for CSV forcing coverage checkVerification
10-day QHH run (END=730, START=1):
compare_forcing.py: all 5 variables max_abs_diff = 0 (exact match).datfiles: binary identical (md5sum match)