Skip to content

Prevent blank CSV fields in generated AMY EPW files - #75

Open
ericmartinpe wants to merge 1 commit into
mainfrom
fix_empty
Open

Prevent blank CSV fields in generated AMY EPW files#75
ericmartinpe wants to merge 1 commit into
mainfrom
fix_empty

Conversation

@ericmartinpe

@ericmartinpe ericmartinpe commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

create_amy_epw_file could write blank fields into the output EPW file when AMY values were missing and not fully resolved by interpolation/imputation, producing malformed CSV rows (double commas). This PR ensures every observation field is always populated, and fixes a related issue where the output directory wasn't created if it didn't already exist.

Changes

  • create_amy_epw_file.py:
    • Auto-create amy_epw_dir via os.makedirs if it doesn't already exist, instead of failing.
    • Forward/backward-fill the TMY Flags column so synthesized leap-day rows don't leave the EPW flag field empty.
    • For Tdb, Tdew, Patm, Wdir, and Wspeed: any AMY value still missing after interpolation/imputation now falls back first to the corresponding TMY observation, then to forward/backward fill, and finally to the EPW-standard missing-value sentinel (e.g. 99.9, 999999, 999) as a last resort — so no field is ever left blank.
  • tests/test_create_amy_epw_file.py:
    • Added test_no_empty_fields_in_observation_rows, which generates a file and asserts no observation row contains a ,, (empty field).
    • Added test_creates_missing_output_directory, which verifies amy_epw_dir is created automatically (including nested paths) and the resulting file is valid.

Test plan

  • New unit tests added and pass
  • Full existing test suite run to confirm no regressions (21/21 passed)

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.

1 participant