Repository navigation
fix(weather): physically correct EPW radiation and sky fields (F1) - #212
Merged
Merged
Conversation
SAM.Weather.Query.DataString wrote global horizontal and horizontal infrared as 0 and put the horizontal beam (global - diffuse) into the direct-normal field, so every embedded-weather export (Convert.ToEPW, OpenStudio EmbeddedAnnualWeatherPath) carried wrong solar and sky inputs (SAM_UI PR HoareLea#239, finding F1). - Global horizontal: the stated value (or direct + diffuse). - Direct normal: horizontal beam / hour-mean cos zenith on the EPW time base (hour ending, local standard time), NOAA/Spencer solar position averaged over 60 sub-steps; bounded by the pure-Rayleigh-atmosphere beam (Kasten-Young air mass, Kasten 1996 optical thickness), which only binds at grazing sun. Needs latitude, longitude and time zone; without them it is written as missing (9999). - Extraterrestrial horizontal / normal: astronomical values. - Horizontal IR: missing (9999), so EnergyPlus derives it; SAM holds no IR. - Dew point: stated value, else derived from DBT and RH (Magnus). - Sky cover: SAM cloud cover 0-1 written in tenths (it was written as 0-1, losing a factor of 10 on every export/import cycle) to total and opaque sky cover. - Missing radiation/sky values use the EPW missing codes, never 0. Existing public overloads are kept; location-aware overloads are added. Tests: 38 new (5 TMYx reference EPWs, independent Michalsky 1988 geometry, facade beam, low sun, night, hemispheres, half-hour zones, missing data, leap year, round trip). Full SAM.Tests 3721/3721. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
michaldengusiak
marked this pull request as ready for review
October 19, 2026 08:57
… (F1 review) Adds RayleighBound_BindsOnlyAtGrazingSun_AndRemovesLittleEnergy over the five reference EPWs. The writer's own hour geometry is read back from the export (ETR horizontal / ETR normal), so "bound" counts exactly the hours the bound changed. The bound never binds for the self-consistent datasets (Sydney, Singapore, Fairbanks); for the half-hour-inconsistent Budapest and Phoenix files it binds in 4.0 % and 6.0 % of beam hours and removes 0.18 % and 0.38 % of the stated horizontal beam. Evidence: rayleigh-bound-activation.txt, and two EnergyPlus box variants isolating the opaque-sky-cover proxy (real opaque cover; dataset IR). Test-only and docs; no production change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…CI (PR record) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…smatch (PR record) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
michaldengusiak
added a commit
that referenced
this pull request
Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes finding F1 from SAM_UI PR HoareLea#239 (SAM-BIM/SAM_UI#239).
SAM.Weather.Query.DataString, whichConvert.ToEPWand SAM_OpenStudioEmbeddedAnnualWeatherPathuse, wrote global horizontal = 0, horizontal IR = 0, and the horizontal beam (GHI − DHI) into the direct-normal field. It also wrote sky cover as a 0–1 fraction where EPW expects tenths, and missing radiation as 0.Record:
documentation/EPW-Weather-Radiation-F1-PR.md. Evidence:documentation/evidence/epw-weather-f1/. Tested content SHA:a2cb16cf. Production code is unchanged sinceb721c5f4;a2cb16cfadds one review test and evidence, anda55c39b8and8de08069change only the record.What the writer now does
The public API is preserved: all existing
DataStringoverloads keep their signatures, and location-aware overloads are added. The SAM importer and the explicit-EPW route are unchanged. TAS/OpenStudio ventilation, comparison tolerances and HVAC work are not touched.Independent verification
5 committed TMYx reference EPWs (Budapest, Fairbanks, Sydney, Singapore, Phoenix) with an independent solar position (Michalsky 1988) in the tests.
Self-consistent datasets (Sydney, Singapore, Fairbanks): annual DNI within +0.3 %, sun-up median error ≤ 0.3 % (P90 ≤ 0.6 %), beam on N/E/S/W facades within 0.4 %.
Budapest and Phoenix are internally inconsistent. Their own DNI closes with their own GHI − DHI only when the geometry is taken about 30 minutes earlier (closure error 9 % on the EPW time base). The tests measure this and require energy closure, which holds within −0.4 %. This is a source-data limitation, documented in the record.
Fail-first: against the original writer, 34 of 38 new tests fail.
Box-model check (EnergyPlus 25.2, the e0
in.idffrom PR bug ExtendExternalPanels HoareLea/SAM#239). The control with the old export reproduces PR bug ExtendExternalPanels HoareLea/SAM#239's 2810.0 / 3832.5 kWh exactly. Corrected embedded weather vs explicit EPW:Engine agreement between TAS and EnergyPlus is not an acceptance criterion.
Checks (local)
dotnet test SAM/SAM.Tests/SAM.Tests.csproj: 3726/3726 in both Release and Debug ata2cb16cf(3721/3721 atb721c5f4).MSBuild SAM.sln /t:Rebuild /p:Configuration=Release: 0 errors. It ran sandboxed, with APPDATA/USERPROFILE redirected.git diff --check: clean.90822facand ata55c39b8; final head8de08069(docs only).Risks and open points
Final review (2026-10-19): no blocking issues
RayleighBound_BindsOnlyAtGrazingSun_AndRemovesLittleEnergy, evidencerayleigh-bound-activation.txt): it binds in 0 hours for Sydney, Singapore and Fairbanks (0.00 % change in DNI and on every facade). It binds only for the half-hour-inconsistent files: Budapest in 4.0 % of beam hours (sun below ~4.7°), Phoenix in 6.0 % (below ~21°). There the stated beam implies impossible DNI, up to 2450 W/m² against a Rayleigh limit of ~1080 W/m². It removes 0.18 % and 0.38 % of the stated horizontal beam; east facades are unchanged, and the west facade beam goes down by 16 % and 6 %.90822fac; mergeable and CLEAN against an unchanged base618db819.Recommended for owner approval and merge. Not merged automatically.
🤖 Generated with Claude Code