Skip to content

Switching precipitation to Gridded may need a Mode line for every met variable #324

Description

@jacobrbeatty

When HEC-RAS 7.0 computes a plan whose precipitation is Gridded, it appears to require an explicit Met BC=<variable>|Mode= line for every meteorological variable, not just precipitation. A source unsteady file converted from a model whose precipitation was point or constant may carry no Mode line for evapotranspiration, and the run then fails as:

Writing Event Conditions ...
Error processing event conditions

RAS writes a 12,872-byte plan HDF containing only Results/Summary — no Results/Unsteady — and exits 0.

What I proved, and what I did not

Proved, by single-variable bisect on HEC-RAS 7.0 April 2026:

Converting a Montevallo 2D plan to gridded imported-raster precipitation, adding or removing one line flipped the outcome. The two flow files differ only by that line and a cosmetic Flow Title:

$ diff u10 u12
1c1
< Flow Title=u09_plus_u11_tail
---
> Flow Title=u10_minus_ET_mode
17d16
< Met BC=Evapotranspiration|Mode=None
Flow file Result HDF
u10, with the line 110,564,922 bytes — 63,927 cells, 241 timesteps
u12, without it 12,872 bytes — no Results/Unsteady, exit 0

A working RAS-authored reference (CityBirmingham.u08/u10/u11, all gridded) carries Met BC=Evapotranspiration|Mode=None, Met BC=Air Density|Mode=Constant and Met BC=Air Pressure|Mode=Constant. The one gridded file there that lacks the ET line, u09, is not referenced by any plan.

Not proved: I hit this on the imported-raster path (Gridded Source = GDAL Raster File(s)). configure_gridded_dss_precipitation is the DSS variant. The code gap is the same in both — it sets five precipitation entries and nothing for the other variables:

desired_entries = [
    ("Precipitation Mode", "Enable"),
    ("Met BC=Precipitation|Mode", "Gridded"),
    ("Met BC=Precipitation|Gridded Source", "DSS"),
    # + Gridded Interpolation, Gridded DSS Filename, Gridded DSS Pathname
]
RasUnsteady._replace_met_precipitation_keys(unsteady_path, desired_entries)

But I have not run the DSS path and am not claiming the same failure there. It writes the same Met BC=Precipitation|Mode=Gridded block, so the same parser requirement plausibly applies.

Note on the existing test

tests/test_rasunsteady_gridded_dss_precipitation.py asserts the precipitation block is written correctly, and its fixture starts from Met BC=Precipitation|Mode=Constant with no ET line. Since it never runs HEC-RAS, a file RAS would reject still passes. Not a criticism of the test — it tests what it says it tests — just worth knowing the gap isn't covered.

Suggested fix

After writing the precipitation entries, ensure a Mode exists for the other met variables without overwriting one the source already set:

for variable, default in (
    ("Evapotranspiration", "None"),
    ("Air Density", "Constant"),
    ("Air Pressure", "Constant"),
):
    if RasUnsteady._get_met_bc_value(lines, variable, "Mode") is None:
        RasUnsteady._set_met_bc_line(lines, variable, "Mode", default)

_set_met_bc_line already places these correctly — it replaces in place, else inserts after the last Met BC=<variable>| line — on every realistic flow file I checked (31 of them).

Ordering caution, learned the hard way: the Met BC block must stay contiguous and sit after Wave Mode=. I split it during development and HEC-RAS abandoned the project, created a blank one with a steady flow file, and appended a second project block to the .prj — silently, exit 0. Worth a comment wherever these lines get written.

One observation rather than a defect: _set_met_bc_line's fallback is insert_idx = len(lines), so a file with no Met BC=<variable>| lines at all would append at end of file, after the Non-Newtonian block. I could not find a genuine flow file that hits this — the only candidate on my machine was a 113-byte "Geometry Only" stub — so it's latent. Might be worth hardening if flow files are ever generated from scratch.

Environment

HEC-RAS 7.0 April 2026 · ras-commander 0.98.2 · Windows 11 · Python 3.14
Model: Montevallo 2D, 63,927 cells, State Plane Alabama West (ft)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions