Skip to content
Merged

misc #219

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ venv/
.pixi
*.egg-info
temp/
.coverage
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"source.fixAll": "explicit"
}
},
"mypy-type-checker.importStrategy": "fromEnvironment",
"python.analysis.typeCheckingMode": "off",
"debugpy.debugJustMyCode": false,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
Expand Down
1 change: 1 addition & 0 deletions flopy4/mf6/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
MF6 = "mf6"
FILL_DEFAULT = np.nan
FILL_DNODATA = 1e30
LENBOUNDNAME = 40
6 changes: 1 addition & 5 deletions flopy4/mf6/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def unstructure_component(value: Component) -> dict[str, Any]:
for kper in range(field_value.sizes["nper"])
}
else:
# TODO why not putting in block here but doing below? how does this even work
if np.issubdtype(field_value.dtype, np.str_):
period_data[field_name] = {
kper: field_value[kper] for kper in range(field_value.sizes["nper"])
Expand Down Expand Up @@ -187,11 +188,6 @@ def unstructure_component(value: Component) -> dict[str, Any]:
dataset = xr.Dataset(block)
blocks[f"{block_name} {kper + 1}"] = {block_name: dataset}

# make sure options block always comes first
if "options" in blocks:
options_block = blocks.pop("options")
blocks = {"options": options_block, **blocks}

# total temporary hack! manually set solutiongroup 1. still need to support multiple..
if "solutiongroup" in blocks:
sg = blocks["solutiongroup"]
Expand Down
2 changes: 2 additions & 0 deletions flopy4/mf6/gwf/chd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from xattree import xattree

from flopy4.mf6.component import update_maxbound
from flopy4.mf6.constants import LENBOUNDNAME
from flopy4.mf6.converter import dict_to_array
from flopy4.mf6.package import Package
from flopy4.mf6.spec import array, field, path
Expand Down Expand Up @@ -51,6 +52,7 @@ class Chd(Package):
on_setattr=update_maxbound,
)
boundname: Optional[NDArray[np.str_]] = array(
dtype=f"<U{LENBOUNDNAME}",
block="period",
dims=(
"nper",
Expand Down
2 changes: 1 addition & 1 deletion flopy4/mf6/gwf/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Dis(Package):
dims=("nlay", "nrow", "ncol"),
converter=Converter(dict_to_array, takes_self=True, takes_field=True),
)
idomain: Optional[NDArray[np.int32]] = array(
idomain: Optional[NDArray[np.int64]] = array(
block="griddata",
default=1,
dims=("nlay", "nrow", "ncol"),
Expand Down
2 changes: 2 additions & 0 deletions flopy4/mf6/gwf/drn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from xattree import xattree

from flopy4.mf6.component import update_maxbound
from flopy4.mf6.constants import LENBOUNDNAME
from flopy4.mf6.converter import dict_to_array
from flopy4.mf6.package import Package
from flopy4.mf6.spec import array, field, path
Expand Down Expand Up @@ -57,6 +58,7 @@ class Drn(Package):
on_setattr=update_maxbound,
)
boundname: Optional[NDArray[np.str_]] = array(
dtype=f"<U{LENBOUNDNAME}",
block="period",
dims=(
"nper",
Expand Down
2 changes: 1 addition & 1 deletion flopy4/mf6/gwf/npf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Xt3dOptions:
export_array_netcdf: bool = field(block="options", default=False)
dev_no_newton: bool = field(block="options", default=False)
dev_omega: Optional[float] = field(block="options", default=None)
icelltype: NDArray[np.integer] = array(
icelltype: NDArray[np.int64] = array(
block="griddata",
dims=("nodes",),
default=0,
Expand Down
16 changes: 8 additions & 8 deletions flopy4/mf6/gwf/oc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ class Period:
)
# TODO: needs coverter and then rename?
head: Optional[Format] = field(block="options", default=None)
save_head: Optional[NDArray[np.object_]] = array(
object,
save_head: Optional[NDArray[np.str_]] = array(
dtype=np.dtypes.StringDType(),
block="period",
default="all",
dims=("nper",),
converter=Converter(dict_to_array, takes_self=True, takes_field=True),
)
save_budget: Optional[NDArray[np.object_]] = array(
object,
save_budget: Optional[NDArray[np.str_]] = array(
dtype=np.dtypes.StringDType(),
block="period",
default="all",
dims=("nper",),
converter=Converter(dict_to_array, takes_self=True, takes_field=True),
)
print_head: Optional[NDArray[np.object_]] = array(
object,
print_head: Optional[NDArray[np.str_]] = array(
dtype=np.dtypes.StringDType(),
block="period",
default="all",
dims=("nper",),
converter=Converter(dict_to_array, takes_self=True, takes_field=True),
)
print_budget: Optional[NDArray[np.object_]] = array(
object,
print_budget: Optional[NDArray[np.str_]] = array(
dtype=np.dtypes.StringDType(),
block="period",
default="all",
dims=("nper",),
Expand Down
2 changes: 2 additions & 0 deletions flopy4/mf6/gwf/rch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from xattree import xattree

from flopy4.mf6.component import update_maxbound
from flopy4.mf6.constants import LENBOUNDNAME
from flopy4.mf6.converter import dict_to_array
from flopy4.mf6.package import Package
from flopy4.mf6.spec import array, field, path
Expand Down Expand Up @@ -51,6 +52,7 @@ class Rch(Package):
on_setattr=update_maxbound,
)
boundname: Optional[NDArray[np.str_]] = array(
dtype=f"<U{LENBOUNDNAME}",
block="period",
dims=(
"nper",
Expand Down
2 changes: 1 addition & 1 deletion flopy4/mf6/gwf/sto.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Sto(Package):
export_array_netcdf: bool = field(block="options", default=False)
dev_original_specific_storage: bool = field(block="options", default=False)
dev_oldstorageformulation: bool = field(block="options", default=False)
iconvert: NDArray[np.int32] = array(
iconvert: NDArray[np.int64] = array(
block="griddata",
dims=("nodes",),
default=0,
Expand Down
2 changes: 2 additions & 0 deletions flopy4/mf6/gwf/wel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from xattree import xattree

from flopy4.mf6.component import update_maxbound
from flopy4.mf6.constants import LENBOUNDNAME
from flopy4.mf6.converter import dict_to_array
from flopy4.mf6.package import Package
from flopy4.mf6.spec import array, field, path
Expand Down Expand Up @@ -55,6 +56,7 @@ class Wel(Package):
on_setattr=update_maxbound,
)
boundname: Optional[NDArray[np.str_]] = array(
dtype=f"<U{LENBOUNDNAME}",
block="period",
dims=(
"nper",
Expand Down
4 changes: 2 additions & 2 deletions flopy4/mf6/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def coord(


def array(
cls=None,
dtype: np.dtype | str | type | None = None,
dims=None,
default=NOTHING,
validator=None,
Expand All @@ -146,7 +146,7 @@ def array(
metadata = metadata or {}
metadata["block"] = block
return flopy_array(
cls=cls,
dtype=dtype,
dims=dims,
default=default,
validator=validator,
Expand Down
2 changes: 1 addition & 1 deletion flopy4/mf6/tdis.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PeriodData:
dims=("nper",),
converter=Converter(dict_to_array, takes_self=True, takes_field=True),
)
nstp: NDArray[np.integer] = array(
nstp: NDArray[np.int64] = array(
block="perioddata",
default=1,
dims=("nper",),
Expand Down
5 changes: 3 additions & 2 deletions flopy4/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
to any field indicating it is not part of the formal spec?
"""

import numpy as np
from attrs import NOTHING, Attribute
from xattree import array as xattree_array
from xattree import coord as xattree_coord
Expand Down Expand Up @@ -75,7 +76,7 @@ def coord(


def array(
cls=None,
dtype: np.dtype | str | type | None = None,
dims=None,
default=NOTHING,
validator=None,
Expand All @@ -87,7 +88,7 @@ def array(
):
"""Define an array field."""
return xattree_array(
cls=cls,
dtype=dtype,
dims=dims,
default=default,
validator=validator,
Expand Down
Loading
Loading