Skip to content

Restore genForeFireCase.py as a general landscape writer - #179

Open
HugoFara wants to merge 1 commit into
devfrom
fix/restore-genforefirecase
Open

Restore genForeFireCase.py as a general landscape writer#179
HugoFara wants to merge 1 commit into
devfrom
fix/restore-genforefirecase

Conversation

@HugoFara

@HugoFara HugoFara commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Addresses #167. @filippi is the reviewer because he removed this script, and this proposes putting it back — that call is his.

The removal was intentional

I filed #167 framing the missing script as an oversight. The history says otherwise:

fd4b1c8  2023-10-12  FiretoNC copied into prealCF2Case.py
ac0baba  2023-12-18  genForeFireCase.py deleted ("clean more post-processing")

Consumer first, two months apart: the function was inlined where it was used, then the standalone file removed as dead code. This pull request undoes that.

prealCF2Case.py's copy has since diverged into the back half of the Meso-NH PGD → case pipeline, and needs a PGD file to do anything. So the repository has no general-purpose landscape writer, while landscape_file.rst, tools/README.md, READMEscripts.md and the legacy user guide all describe one.

The cheaper alternative is to delete the four references. That respects ac0baba most directly and takes minutes. If that is the answer, say so and I will close this and send that patch instead.

What is in here

Restored from ac0baba^ with three fixes, since it was not usable as it stood:

  • The 3-D and 4-D paths were broken. Dimensions were read as (NY, NX, NZ, NT) while the variable was created as (NT, NZ, NY, NX) and assigned without transposing, which only succeeds when NY == NT and NX == NZ. Fields are now indexed outermost axis first, matching prealCF2Case.py.
  • scipy.io.netcdf is deprecated and scipy is not a dependency. Now uses netCDF4, writing the same NETCDF3_CLASSIC format.
  • parametersProperties has seven required keys that tools/README.md called optional. Omitting one raised a bare KeyError over a half-written file; they are now checked before the file is opened.

Verification

tests/python/test_genforefirecase.py (new), four cases: builds a landscape, hands it to ForeFire, ignites and steps; checks the 3-D and 4-D shapes using four different lengths, since NY == NT and NX == NZ is what let the old broadcast succeed by accident; checks that a missing key is reported before anything is written.

Unifying the two implementations is not attempted here — choosing between the combined wind variable and separate windU/windV is a question about what ForeFire should read.


This pull request, including its code changes and this description, was generated by Claude Opus 5, and reviewed manually before submitting.

EDIT: rewrote for human readability.

The script that writes the NetCDF landscape file was deleted in ac0baba
while four documents kept describing it, so anyone following the docs to
build their first case hit a file that was not there.

Restored from ac0baba^ with three fixes, since it was not usable as it
stood:

- The 3-D and 4-D paths were broken. Dimensions were read off the array
  as (NY, NX, NZ, NT) while the variable was created as (NT, NZ, NY, NX)
  and assigned untransposed, so a 4-D field raised a broadcast error and
  a 3-D one never had its NT dimension created. Fields are now indexed
  outermost axis first, which is what prealCF2Case.py in the same
  directory settled on when it fixed its own copy.
- scipy.io.netcdf is deprecated and scipy is not a project dependency.
  Uses netCDF4, which the tests already require, writing the same
  NETCDF3_CLASSIC format prealCF2Case.py writes.
- parametersProperties has seven required keys and the docs called them
  optional. They are checked before the file is opened, and named in the
  error, rather than raising a bare KeyError over a half-written file.

tests/python/test_genforefirecase.py builds a landscape, loads it in
ForeFire, ignites and steps, and pins the 3-D and 4-D shapes. The four
documents now describe what exists.

prealCF2Case.py still carries its own copy of both functions. Merging
them is a change to a working script and is left for its own commit.

Closes #167
@HugoFara
HugoFara force-pushed the fix/restore-genforefirecase branch from be2af01 to 41af42e Compare August 12, 2026 19:17
@HugoFara HugoFara changed the title Restore genForeFireCase.py, with the axis order fixed Restore genForeFireCase.py as a general landscape writer Aug 12, 2026
@HugoFara
HugoFara marked this pull request as draft August 12, 2026 19:19
@HugoFara
HugoFara marked this pull request as ready for review August 12, 2026 19:19
@HugoFara
HugoFara requested a review from filippi August 12, 2026 19:19
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