Skip to content

Commit 606a219

Browse files
authored
update roadmap, fix perioddata block writing (#251)
fix #227 by special casing "perioddata" blocks. not a permanent solution. also update the roadmap, the v2 dfn stuff is probably out of scope for the demo, being mostly developer-facing.
1 parent 2aca28b commit 606a219

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

docs/dev/map.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
Showcase a limited set of core functionality, such as:
66

7-
- the v2 DFN specification schema and format
87
- object model, data model, user-facing APIs
98
- IO framework and ASCII file loading/writing
109
- constructing, running, modifying simulations
1110

12-
Design and implementation are provisional. Implementation may take shortcuts, e.g. components hand-written instead of generated from the DFN specification.
11+
Design and implementation are provisional. Implementation may take shortcuts, e.g. components hand-written instead of generated from the DFN specification. Demonstration is a guided tour with guardrails.
1312

1413
Release to demo participants via `pip install` from github URL.
1514

flopy4/mf6/converter/unstructure.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ def unstructure_component(value: Component) -> dict[str, Any]:
156156
field_value,
157157
structured_grid_dims=value.parent.data.dims, # type: ignore
158158
)
159-
if "period" in block_name:
160-
period_block_name = block_name
159+
if block_name == "period":
161160
period_data[field_name] = {
162161
kper: field_value.isel(nper=kper)
163162
for kper in range(field_value.sizes["nper"])
@@ -177,16 +176,20 @@ def unstructure_component(value: Component) -> dict[str, Any]:
177176

178177
# setup indexed period blocks, combine arrays into datasets
179178
for kper, block in period_blocks.items():
180-
assert isinstance(period_block_name, str)
181-
blocks[f"{period_block_name} {kper + 1}"] = {
182-
period_block_name: xr.Dataset(block, coords=block[arr_name].coords)
179+
blocks[f"period {kper + 1}"] = {
180+
"period": xr.Dataset(block, coords=block[arr_name].coords)
183181
}
184182

183+
# combine "perioddata" block arrays (tdis, ats) into datasets
184+
# so they render as lists. temp hack TODO do this generically
185+
if perioddata := blocks.get("perioddata", None):
186+
blocks["perioddata"] = {"perioddata": xr.Dataset(perioddata)}
187+
185188
# total temporary hack! manually set solutiongroup 1.
186189
# TODO still need to support multiple..
187190
if "solutiongroup" in blocks:
188191
sg = blocks["solutiongroup"]
189192
blocks["solutiongroup 1"] = sg
190193
del blocks["solutiongroup"]
191194

192-
return {name: block for name, block in blocks.items() if name != period_block_name}
195+
return {name: block for name, block in blocks.items() if name != "period"}

test/test_mf6_codec.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,10 @@ def test_dumps_tdis():
130130
print("TDIS dump:")
131131
print(dumped)
132132
assert dumped
133-
assert "BEGIN PERIODDATA 1" in dumped
133+
assert "BEGIN PERIODDATA" in dumped
134134
assert " 1.0 1 1.0" in dumped
135-
assert "END PERIODDATA 1" in dumped
136-
assert "BEGIN PERIODDATA 2" in dumped
137135
assert " 2.0 2 1.0" in dumped
138-
assert "END PERIODDATA 2" in dumped
136+
assert "END PERIODDATA" in dumped
139137

140138
loaded = loads(dumped)
141139
print("TDIS load:")

0 commit comments

Comments
 (0)