diff --git a/flopy4/mf6/decorators.py b/flopy4/mf6/decorators.py new file mode 100644 index 00000000..8d45ade8 --- /dev/null +++ b/flopy4/mf6/decorators.py @@ -0,0 +1,103 @@ +from attrs import NOTHING +from xattree import array as xattree_array +from xattree import coord as xattree_coord +from xattree import dim as xattree_dim +from xattree import field as xattree_field + + +def field( + default=NOTHING, + validator=None, + converter=None, + repr=True, + eq=True, + init=True, + metadata=None, + block: str | None = None, +): + """Create a field.""" + if block: + metadata = metadata or {} + metadata["block"] = block + return xattree_field( + default=default, + validator=validator, + converter=converter, + repr=repr, + eq=eq, + init=init, + metadata=metadata, + ) + + +def dim( + scope=None, + coord: bool | str = True, + default=NOTHING, + repr=True, + eq=True, + init=True, + metadata=None, + block: str | None = None, +): + """Create a dimension field.""" + if block: + metadata = metadata or {} + metadata["block"] = block + return xattree_dim( + scope=scope, + coord=coord, + default=default, + repr=repr, + eq=eq, + init=init, + metadata=metadata, + ) + + +def coord( + scope=None, + default=NOTHING, + repr=True, + eq=True, + metadata=None, + block: str | None = None, +): + """Create a coordinate field.""" + if block: + metadata = metadata or {} + metadata["block"] = block + return xattree_coord( + scope=scope, + default=default, + repr=repr, + eq=eq, + metadata=metadata, + ) + + +def array( + cls=None, + dims=None, + default=NOTHING, + validator=None, + converter=None, + repr=True, + eq=None, + metadata=None, + block: str | None = None, +): + """Create an array field.""" + if block: + metadata = metadata or {} + metadata["block"] = block + return xattree_array( + cls=cls, + dims=dims, + default=default, + validator=validator, + converter=converter, + repr=repr, + eq=eq, + metadata=metadata, + ) diff --git a/flopy4/mf6/gwf/__init__.py b/flopy4/mf6/gwf/__init__.py index ee720d59..e39be265 100644 --- a/flopy4/mf6/gwf/__init__.py +++ b/flopy4/mf6/gwf/__init__.py @@ -6,8 +6,9 @@ import xarray as xr from attrs import define from flopy.discretization.grid import Grid -from xattree import field, xattree +from xattree import xattree +from flopy4.mf6.decorators import field from flopy4.mf6.gwf.chd import Chd from flopy4.mf6.gwf.dis import Dis from flopy4.mf6.gwf.ic import Ic @@ -64,22 +65,14 @@ class NewtonOptions: newton: bool = field() under_relaxation: bool = field() - list: Optional[str] = field(default=None, metadata={"block": "options"}) - print_input: bool = field(default=False, metadata={"block": "options"}) - print_flows: bool = field(default=False, metadata={"block": "options"}) - save_flows: bool = field(default=False, metadata={"block": "options"}) - newtonoptions: Optional[NewtonOptions] = field( - default=None, metadata={"block": "options"} - ) - nc_mesh2d_filerecord: Optional[Path] = field( - default=None, metadata={"block": "options"} - ) - nc_structured_filerecord: Optional[Path] = field( - default=None, metadata={"block": "options"} - ) - nc_filerecord: Optional[Path] = field( - default=None, metadata={"block": "options"} - ) + list: Optional[str] = field(block="options", default=None) + print_input: bool = field(block="options", default=False) + print_flows: bool = field(block="options", default=False) + save_flows: bool = field(block="options", default=False) + newtonoptions: Optional[NewtonOptions] = field(block="options", default=None) + nc_mesh2d_filerecord: Optional[Path] = field(block="options", default=None) + nc_structured_filerecord: Optional[Path] = field(block="options", default=None) + nc_filerecord: Optional[Path] = field(block="options", default=None) @property def grid(self) -> Grid: diff --git a/flopy4/mf6/gwf/chd.py b/flopy4/mf6/gwf/chd.py index a8c91a11..d2478d96 100644 --- a/flopy4/mf6/gwf/chd.py +++ b/flopy4/mf6/gwf/chd.py @@ -4,9 +4,10 @@ import numpy as np from attrs import Converter, define from numpy.typing import NDArray -from xattree import array, field, xattree +from xattree import xattree from flopy4.mf6.converters import convert_array +from flopy4.mf6.decorators import array, field from flopy4.mf6.package import Package @@ -20,57 +21,47 @@ class Steps: steps: list[int] = field() frequency: int = field() - auxiliary: Optional[list[str]] = array( - default=None, metadata={"block": "options"} - ) - auxmultname: Optional[str] = field( - default=None, metadata={"block": "options"} - ) - boundnames: bool = field(default=False, metadata={"block": "options"}) - print_input: bool = field(default=False, metadata={"block": "options"}) - print_flows: bool = field(default=False, metadata={"block": "options"}) - save_flows: bool = field(default=False, metadata={"block": "options"}) - ts_filerecord: Optional[Path] = field( - default=None, metadata={"block": "options"} - ) - obs_filerecord: Optional[Path] = field( - default=None, metadata={"block": "options"} - ) + auxiliary: Optional[list[str]] = array(block="options", default=None) + auxmultname: Optional[str] = field(block="options", default=None) + boundnames: bool = field(block="options", default=False) + print_input: bool = field(block="options", default=False) + print_flows: bool = field(block="options", default=False) + save_flows: bool = field(block="options", default=False) + ts_filerecord: Optional[Path] = field(block="options", default=None) + obs_filerecord: Optional[Path] = field(block="options", default=None) dev_no_newton: bool = field(default=False, metadata={"block": "options"}) - maxbound: Optional[int] = field( - default=None, metadata={"block": "dimensions"} - ) + maxbound: Optional[int] = field(block="dimensions", default=None) head: Optional[NDArray[np.floating]] = array( + block="period", dims=( "nper", "nnodes", ), default=None, - metadata={"block": "period"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) aux: Optional[NDArray[np.floating]] = array( + block="period", dims=( "nper", "nnodes", ), default=None, - metadata={"block": "period"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) boundname: Optional[NDArray[np.str_]] = array( + block="period", dims=( "nper", "nnodes", ), default=None, - metadata={"block": "period"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) steps: Optional[NDArray[np.object_]] = array( Steps, + block="period", dims=("nper", "nnodes"), default=None, - metadata={"block": "period"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) diff --git a/flopy4/mf6/gwf/dis.py b/flopy4/mf6/gwf/dis.py index a44be7bc..efad4ab7 100644 --- a/flopy4/mf6/gwf/dis.py +++ b/flopy4/mf6/gwf/dis.py @@ -2,9 +2,10 @@ from attrs import Converter from flopy.discretization.structuredgrid import StructuredGrid from numpy.typing import NDArray -from xattree import array, dim, field, xattree +from xattree import xattree from flopy4.mf6.converters import convert_array +from flopy4.mf6.decorators import array, dim, field from flopy4.mf6.package import Package @@ -14,65 +15,57 @@ class Dis(Package): default=None, metadata={"block": "options"}, ) - nogrb: bool = field(default=False, metadata={"block": "options"}) - xorigin: float = field(default=None, metadata={"block": "options"}) - yorigin: float = field(default=None, metadata={"block": "options"}) - angrot: float = field(default=None, metadata={"block": "options"}) - export_array_netcdf: bool = field( - default=False, metadata={"block": "options"} - ) + nogrb: bool = field(block="options", default=False) + xorigin: float = field(block="options", default=None) + yorigin: float = field(block="options", default=None) + angrot: float = field(block="options", default=None) + export_array_netcdf: bool = field(block="options", default=False) nlay: int = dim( + block="dimensions", coord="lay", scope="gwf", default=1, - metadata={ - "block": "dimensions", - }, ) ncol: int = dim( + block="dimensions", coord="col", scope="gwf", default=2, - metadata={ - "block": "dimensions", - }, ) nrow: int = dim( + block="dimensions", coord="row", scope="gwf", default=2, - metadata={ - "block": "dimensions", - }, ) delr: NDArray[np.floating] = array( + block="griddata", default=1.0, dims=("ncol",), - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) delc: NDArray[np.floating] = array( + block="griddata", default=1.0, dims=("nrow",), - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) top: NDArray[np.floating] = array( + block="griddata", default=1.0, dims=("ncol", "nrow"), - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) botm: NDArray[np.floating] = array( + block="griddata", default=0.0, dims=("ncol", "nrow", "nlay"), - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) idomain: NDArray[np.integer] = array( + block="griddata", default=1, dims=("ncol", "nrow", "nlay"), - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) nnodes: int = dim( diff --git a/flopy4/mf6/gwf/ic.py b/flopy4/mf6/gwf/ic.py index 940faa3b..97b2ff41 100644 --- a/flopy4/mf6/gwf/ic.py +++ b/flopy4/mf6/gwf/ic.py @@ -1,24 +1,20 @@ import numpy as np from attrs import Converter from numpy.typing import NDArray -from xattree import array, field, xattree +from xattree import xattree from flopy4.mf6.converters import convert_array +from flopy4.mf6.decorators import array, field from flopy4.mf6.package import Package @xattree class Ic(Package): strt: NDArray[np.floating] = array( + block="packagedata", dims=("nnodes",), default=1.0, - metadata={"block": "packagedata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) - export_array_ascii: bool = field( - default=False, metadata={"block": "options"} - ) - export_array_netcdf: bool = field( - default=False, - metadata={"block": "options"}, - ) + export_array_ascii: bool = field(block="options", default=False) + export_array_netcdf: bool = field(block="options", default=False) diff --git a/flopy4/mf6/gwf/npf.py b/flopy4/mf6/gwf/npf.py index 68ee26be..3e2cc1ff 100644 --- a/flopy4/mf6/gwf/npf.py +++ b/flopy4/mf6/gwf/npf.py @@ -4,9 +4,10 @@ import numpy as np from attrs import Converter, define from numpy.typing import NDArray -from xattree import array, field, xattree +from xattree import xattree from flopy4.mf6.converters import convert_array +from flopy4.mf6.decorators import array, field from flopy4.mf6.package import Package @@ -29,86 +30,68 @@ class Xt3dOptions: xt3d: bool = field() rhs: bool = field() - save_flows: bool = field(default=False, metadata={"block": "options"}) - print_flows: bool = field(default=False, metadata={"block": "options"}) - alternative_cell_averaging: Optional[str] = field( - default=None, metadata={"block": "options"} - ) - thickstrt: bool = field(default=False, metadata={"block": "options"}) - cvoptions: Optional[CvOptions] = field( - default=None, metadata={"block": "options"} - ) - perched: bool = field(default=False, metadata={"block": "options"}) - rewet_record: Optional[RewetRecord] = field( - default=None, metadata={"block": "options"} - ) - xt3d_options: Optional[Xt3dOptions] = field( - default=None, metadata={"block": "options"} - ) - save_specific_discharge: bool = field( - default=None, metadata={"block": "options"} - ) - save_saturation: bool = field(default=None, metadata={"block": "options"}) - k22overk: bool = field(default=None, metadata={"block": "options"}) - k33overk: bool = field(default=None, metadata={"block": "options"}) - tvk_filerecord: Optional[Path] = field( - default=None, metadata={"block": "options"} - ) - export_array_ascii: bool = field( - default=False, metadata={"block": "options"} - ) - export_array_netcdf: bool = field( - default=False, metadata={"block": "options"} - ) - dev_no_newton: bool = field(default=False, metadata={"block": "options"}) - dev_omega: Optional[float] = field( - default=None, metadata={"block": "options"} - ) + save_flows: bool = field(block="options", default=False) + print_flows: bool = field(block="options", default=False) + alternative_cell_averaging: Optional[str] = field(block="options", default=None) + thickstrt: bool = field(block="options", default=False) + cvoptions: Optional[CvOptions] = field(block="options", default=None) + perched: bool = field(block="options", default=False) + rewet_record: Optional[RewetRecord] = field(block="options", default=None) + xt3d_options: Optional[Xt3dOptions] = field(block="options", default=None) + save_specific_discharge: bool = field(block="options", default=None) + save_saturation: bool = field(block="options", default=None) + k22overk: bool = field(block="options", default=None) + k33overk: bool = field(block="options", default=None) + tvk_filerecord: Optional[Path] = field(block="options", default=None) + export_array_ascii: bool = field(block="options", default=False) + 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( + block="griddata", dims=("nnodes",), default=0, - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) k: NDArray[np.floating] = array( + block="griddata", dims=("nnodes",), default=1.0, - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) k22: Optional[NDArray[np.floating]] = array( + block="griddata", dims=("nnodes",), default=None, - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) k33: Optional[NDArray[np.floating]] = array( + block="griddata", dims=("nnodes",), default=None, - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) angle1: Optional[NDArray[np.floating]] = array( + block="griddata", dims=("nnodes",), default=None, - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) angle2: Optional[NDArray[np.floating]] = array( + block="griddata", dims=("nnodes",), default=None, - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) angle3: Optional[NDArray[np.floating]] = array( + block="griddata", dims=("nnodes",), default=None, - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) wetdry: Optional[NDArray[np.floating]] = array( + block="griddata", dims=("nnodes",), default=None, - metadata={"block": "griddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) diff --git a/flopy4/mf6/gwf/oc.py b/flopy4/mf6/gwf/oc.py index 2322760a..6423dad4 100644 --- a/flopy4/mf6/gwf/oc.py +++ b/flopy4/mf6/gwf/oc.py @@ -4,9 +4,10 @@ import numpy as np from attrs import Converter, define from numpy.typing import NDArray -from xattree import array, field, xattree +from xattree import xattree from flopy4.mf6.converters import convert_array +from flopy4.mf6.decorators import array, field from flopy4.mf6.package import Package from flopy4.utils import to_path @@ -18,9 +19,7 @@ class Format: columns: int = field(default=10) width: int = field(default=11) digits: int = field(default=4) - format: Literal["exponential", "fixed", "general", "scientific"] = ( - field(default="general") - ) + format: Literal["exponential", "fixed", "general", "scientific"] = field(default="general") @define(slots=False) class Steps: @@ -36,48 +35,46 @@ class Period: steps: "Oc.Steps" = field() budget_file: Optional[Path] = field( + block="options", converter=to_path, default=None, - metadata={"block": "options"}, ) budget_csv_file: Optional[Path] = field( + block="options", converter=to_path, default=None, - metadata={"block": "options"}, ) head_file: Optional[Path] = field( + block="options", converter=to_path, default=None, - metadata={"block": "options"}, - ) - format: Optional[Format] = field( - default=None, init=False, metadata={"block": "options"} ) + format: Optional[Format] = field(block="options", default=None, init=False) save_head: Optional[NDArray[np.object_]] = array( Steps, + block="perioddata", default="all", dims=("nper",), - metadata={"block": "perioddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) save_budget: Optional[NDArray[np.object_]] = array( Steps, + block="perioddata", default="all", dims=("nper",), - metadata={"block": "perioddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) print_head: Optional[NDArray[np.object_]] = array( Steps, + block="perioddata", default="all", dims=("nper",), - metadata={"block": "perioddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) print_budget: Optional[NDArray[np.object_]] = array( Steps, + block="perioddata", default="all", dims=("nper",), - metadata={"block": "perioddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) diff --git a/flopy4/mf6/ims.py b/flopy4/mf6/ims.py index e345b0cf..cce99931 100644 --- a/flopy4/mf6/ims.py +++ b/flopy4/mf6/ims.py @@ -1,88 +1,39 @@ from pathlib import Path from typing import Optional -from xattree import field, xattree +from xattree import xattree +from flopy4.mf6.decorators import field from flopy4.mf6.solution import Solution @xattree class Ims(Solution): - print_option: bool = field(default=False, metadata={"block": "options"}) - complexity: str = field(default="simple", metadata={"block": "options"}) - csv_outer_output_file: Optional[Path] = field( - default=None, metadata={"block": "options"} - ) - csv_inner_output_file: Optional[Path] = field( - default=None, metadata={"block": "options"} - ) - no_ptc: bool = field(default=False, metadata={"block": "options"}) - no_ptc_option: Optional[str] = field( - default=None, metadata={"block": "options"} - ) - ats_outer_maximum_fraction: Optional[float] = field( - default=None, metadata={"block": "options"} - ) - outer_dvclose: Optional[float] = field( - default=None, metadata={"block": "options"} - ) - outer_maximum: Optional[int] = field( - default=None, metadata={"block": "options"} - ) - under_relaxation: Optional[str] = field( - default=None, metadata={"block": "options"} - ) - under_relaxation_gamma: Optional[float] = field( - default=None, metadata={"block": "nonlinear"} - ) - under_relaxation_theta: Optional[float] = field( - default=None, metadata={"block": "nonlinear"} - ) - under_relaxation_kappa: Optional[float] = field( - default=None, metadata={"block": "nonlinear"} - ) - under_relaxation_momentum: Optional[float] = field( - default=None, metadata={"block": "nonlinear"} - ) - backtracking_tolerance: Optional[float] = field( - default=None, metadata={"block": "nonlinear"} - ) - backtracking_reduction_factor: Optional[float] = field( - default=None, metadata={"block": "nonlinear"} - ) - backtracking_residual_limit: Optional[float] = field( - default=None, metadata={"block": "nonlinear"} - ) - inner_maximum: Optional[int] = field( - default=None, metadata={"block": "linear"} - ) - inner_dvclose: Optional[float] = field( - default=None, metadata={"block": "linear"} - ) - inner_rclose: Optional[float] = field( - default=None, metadata={"block": "linear"} - ) - rclose_option: Optional[str] = field( - default=None, metadata={"block": "linear"} - ) - linear_acceleration: Optional[str] = field( - default=None, metadata={"block": "linear"} - ) - relaxation_factor: Optional[float] = field( - default=None, metadata={"block": "linear"} - ) - preconditioner_levels: Optional[int] = field( - default=None, metadata={"block": "linear"} - ) - preconditioner_drop_tolerance: Optional[float] = field( - default=None, metadata={"block": "linear"} - ) - number_orthogonalizations: Optional[int] = field( - default=None, metadata={"block": "linear"} - ) - scaling_method: Optional[str] = field( - default=None, metadata={"block": "linear"} - ) - reordering_method: Optional[str] = field( - default=None, metadata={"block": "linear"} - ) + print_option: bool = field(block="options", default=False) + complexity: str = field(block="options", default="simple") + csv_outer_output_file: Optional[Path] = field(default=None, block="options") + csv_inner_output_file: Optional[Path] = field(block="options", default=None) + no_ptc: bool = field(default=False, block="options") + no_ptc_option: Optional[str] = field(default=None, block="options") + ats_outer_maximum_fraction: Optional[float] = field(block="options", default=None) + outer_dvclose: Optional[float] = field(default=None, block="options") + outer_maximum: Optional[int] = field(default=None, block="options") + under_relaxation: Optional[str] = field(default=None, block="options") + under_relaxation_gamma: Optional[float] = field(block="nonlinear", default=None) + under_relaxation_theta: Optional[float] = field(block="nonlinear", default=None) + under_relaxation_kappa: Optional[float] = field(block="nonlinear", default=None) + under_relaxation_momentum: Optional[float] = field(block="nonlinear", default=None) + backtracking_tolerance: Optional[float] = field(block="nonlinear", default=None) + backtracking_reduction_factor: Optional[float] = field(block="nonlinear", default=None) + backtracking_residual_limit: Optional[float] = field(block="nonlinear", default=None) + inner_maximum: Optional[int] = field(block="linear", default=None) + inner_dvclose: Optional[float] = field(block="linear", default=None) + inner_rclose: Optional[float] = field(block="linear", default=None) + rclose_option: Optional[str] = field(block="linear", default=None) + linear_acceleration: Optional[str] = field(block="linear", default=None) + relaxation_factor: Optional[float] = field(block="linear", default=None) + preconditioner_levels: Optional[int] = field(block="linear", default=None) + preconditioner_drop_tolerance: Optional[float] = field(block="linear", default=None) + number_orthogonalizations: Optional[int] = field(block="linear", default=None) + scaling_method: Optional[str] = field(block="linear", default=None) + reordering_method: Optional[str] = field(block="linear", default=None) diff --git a/flopy4/mf6/indexes.py b/flopy4/mf6/indexes.py index 5312a746..2bd0329d 100644 --- a/flopy4/mf6/indexes.py +++ b/flopy4/mf6/indexes.py @@ -27,9 +27,7 @@ def __init__(self, indices): @classmethod def from_variables(cls, variables): - return { - k: PandasIndex.from_variables({k: v}) for k, v in variables.items() - } + return {k: PandasIndex.from_variables({k: v}) for k, v in variables.items()} def create_variables(self, variables=None): idx_vars = {} diff --git a/flopy4/mf6/tdis.py b/flopy4/mf6/tdis.py index e9e2b163..a294ab17 100644 --- a/flopy4/mf6/tdis.py +++ b/flopy4/mf6/tdis.py @@ -5,9 +5,10 @@ from attrs import Converter, define from flopy.discretization.modeltime import ModelTime from numpy.typing import NDArray -from xattree import ROOT, array, dim, field, xattree +from xattree import ROOT, xattree from flopy4.mf6.converters import convert_array +from flopy4.mf6.decorators import array, dim, field from flopy4.mf6.package import Package @@ -20,33 +21,29 @@ class PeriodData: tsmult: float nper: int = dim( + block="dimensions", coord="per", default=1, scope=ROOT, - metadata={"block": "dimensions"}, - ) - time_units: Optional[str] = field( - default=None, metadata={"block": "options"} - ) - start_date_time: Optional[datetime] = field( - default=None, metadata={"block": "options"} ) + time_units: Optional[str] = field(block="options", default=None) + start_date_time: Optional[datetime] = field(block="options", default=None) perlen: NDArray[np.floating] = array( + block="perioddata", default=1.0, dims=("nper",), - metadata={"block": "perioddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) nstp: NDArray[np.integer] = array( + block="perioddata", default=1, dims=("nper",), - metadata={"block": "perioddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) tsmult: NDArray[np.floating] = array( + block="perioddata", default=1.0, dims=("nper",), - metadata={"block": "perioddata"}, converter=Converter(convert_array, takes_self=True, takes_field=True), ) diff --git a/flopy4/mf6/utils/heads_reader.py b/flopy4/mf6/utils/heads_reader.py index aec239d6..d5ff7758 100644 --- a/flopy4/mf6/utils/heads_reader.py +++ b/flopy4/mf6/utils/heads_reader.py @@ -57,9 +57,7 @@ def open_hds( head: xr.DataArray """ grid = StructuredGrid.from_binary_grid_file(grb_path) - return _open_hds_dis( - hds_path, grid, dry_nan, simulation_start_time, time_unit - ) + return _open_hds_dis(hds_path, grid, dry_nan, simulation_start_time, time_unit) def _open_hds_dis( @@ -84,22 +82,14 @@ def _open_hds_dis( for i in range(ntime): # TODO verify dimension order pos = i * (nlayer * (52 + nrow * ncol * 8)) - a = dask.delayed(read_hds_timestep)( - path, nlayer, nrow, ncol, dry_nan, pos - ) - x = dask.array.from_delayed( - a, shape=(nlayer, nrow, ncol), dtype=np.float64 - ) + a = dask.delayed(read_hds_timestep)(path, nlayer, nrow, ncol, dry_nan, pos) + x = dask.array.from_delayed(a, shape=(nlayer, nrow, ncol), dtype=np.float64) dask_list.append(x) daskarr = dask.array.stack(dask_list, axis=0) - data_array = xr.DataArray( - daskarr, coords, ("time", "layer", "y", "x"), name="head" - ) + data_array = xr.DataArray(daskarr, coords, ("time", "layer", "y", "x"), name="head") if simulation_start_time is not None: - data_array = assign_datetime_coords( - data_array, simulation_start_time, time_unit - ) + data_array = assign_datetime_coords(data_array, simulation_start_time, time_unit) return data_array @@ -131,9 +121,7 @@ def get_coords(grid: StructuredGrid) -> dict[str, Any]: return coords -def read_times( - path: Path, ntime: int, nlayer: int, nrow: int, ncol: int -) -> np.ndarray: +def read_times(path: Path, ntime: int, nlayer: int, nrow: int, ncol: int) -> np.ndarray: """ Reads all total simulation times. """ @@ -154,9 +142,7 @@ def read_times( with open(path, "rb") as f: f.seek(start_of_header) for i in range(ntime): - times[i] = struct.unpack("d", f.read(8))[ - 0 - ] # total simulation time + times[i] = struct.unpack("d", f.read(8))[0] # total simulation time f.seek(nskip, 1) return times @@ -187,14 +173,9 @@ def assign_datetime_coords( time_unit: str | None = "d", ) -> xr.DataArray: if "time" not in da.coords: - raise ValueError( - "cannot convert time column," - " because a time column could not be found" - ) + raise ValueError("cannot convert time column, because a time column could not be found") - time = pd.Timestamp(simulation_start_time) + pd.to_timedelta( - da["time"], unit=time_unit - ) + time = pd.Timestamp(simulation_start_time) + pd.to_timedelta(da["time"], unit=time_unit) return da.assign_coords(time=time) diff --git a/pixi.lock b/pixi.lock index f94c1036..5b5a0c85 100644 --- a/pixi.lock +++ b/pixi.lock @@ -108,7 +108,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5c/23/c7abc0ca0a1526a0774eca151daeb8de62ec457e77262b66b359c3c7679e/tzdata-2025.2-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/6b/11/cc635220681e93a0183390e26485430ca2c7b5f9d33b15c74c2861cb8091/urllib3-2.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -209,7 +209,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5c/23/c7abc0ca0a1526a0774eca151daeb8de62ec457e77262b66b359c3c7679e/tzdata-2025.2-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/6b/11/cc635220681e93a0183390e26485430ca2c7b5f9d33b15c74c2861cb8091/urllib3-2.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -313,7 +313,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/6b/11/cc635220681e93a0183390e26485430ca2c7b5f9d33b15c74c2861cb8091/urllib3-2.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/e1/07/c6fe3ad3e685340704d314d765b7912993bcb8dc198f0e7a89382d37974b/win32_setctime-1.2.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -550,7 +550,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -771,7 +771,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -995,7 +995,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/e1/07/c6fe3ad3e685340704d314d765b7912993bcb8dc198f0e7a89382d37974b/win32_setctime-1.2.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -1206,7 +1206,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -1403,7 +1403,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -1602,7 +1602,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/e1/07/c6fe3ad3e685340704d314d765b7912993bcb8dc198f0e7a89382d37974b/win32_setctime-1.2.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -1812,7 +1812,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -2007,7 +2007,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -2204,7 +2204,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/e1/07/c6fe3ad3e685340704d314d765b7912993bcb8dc198f0e7a89382d37974b/win32_setctime-1.2.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -2413,7 +2413,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -2610,7 +2610,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -2809,7 +2809,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/e1/07/c6fe3ad3e685340704d314d765b7912993bcb8dc198f0e7a89382d37974b/win32_setctime-1.2.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/a4/1e/96fd96419fec1a37da998a1ca3d558f2cae2f6f3cd5015170371b05a2b6b/xarray-2025.4.0-py3-none-any.whl - - pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 + - pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a - pypi: https://files.pythonhosted.org/packages/75/5b/bde22ca13b4db9ff8696a610c919c98475bd22e258729de33464c551c325/xugrid-0.14.1-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/d6/7d/b77455d7c7c51255b2992b429107fab811b2e36ceaf76da1e55a045dc568/xyzservices-2025.4.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/0d/67/971d9a661b66cc1c2fe2472e38085f5025a393ee1c1822b0155cc3f357b7/zarr-3.0.7-py3-none-any.whl @@ -4175,7 +4175,7 @@ packages: - pypi: . name: flopy4 version: 0.0.1.dev0 - sha256: fef07d40d33ef5c596bfc477efb352e194546d10b8126731cbdd53455363f7fd + sha256: 548a8f0e706b6acb5b22177d1536a0f5e0018612968852255a5ec20b23063400 requires_dist: - attrs - cattrs @@ -10311,7 +10311,7 @@ packages: - types-pytz ; extra == 'types' - types-setuptools ; extra == 'types' requires_python: '>=3.10' -- pypi: git+https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95 +- pypi: git+https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a name: xattree version: 0.1.0.dev0 requires_dist: diff --git a/pyproject.toml b/pyproject.toml index b15495ca..87bb63c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,7 +84,7 @@ include = ["flopy4", "flopy4.*"] "flopy4.toml" = ["dfns/toml/*.toml"] [tool.ruff] -line-length = 79 +line-length = 100 target-version = "py311" include = ["pyproject.toml", "flopy4/**/*.py", "test/**/*.py", "docs/**/*.py"] extend-include = ["docs/**/*.ipynb"] diff --git a/test/conftest.py b/test/conftest.py index 419c1847..5a43042d 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -13,6 +13,4 @@ def pytest_generate_tests(metafunc): for file in sorted(EXAMPLES_PATH.glob("*example.py")) if file.stem not in EXCLUDED_EXAMPLES } - metafunc.parametrize( - "example_script", scripts.values(), ids=scripts.keys() - ) + metafunc.parametrize("example_script", scripts.values(), ids=scripts.keys()) diff --git a/test/test_cattrs.py b/test/test_cattrs.py index f77e8927..823f25b1 100644 --- a/test/test_cattrs.py +++ b/test/test_cattrs.py @@ -50,9 +50,7 @@ def test_unstructure_xarray_tree_to_ascii(): f = Baz(x=x_tree) converter = Converter() - converter.register_unstructure_hook( - Baz, lambda b: " ".join(b.x["x"].data.astype(str)) - ) + converter.register_unstructure_hook(Baz, lambda b: " ".join(b.x["x"].data.astype(str))) f_dict = converter.unstructure(f) # The data is formatted in ascii format. diff --git a/test/test_component.py b/test/test_component.py index 10edbe9c..4f7ef840 100644 --- a/test/test_component.py +++ b/test/test_component.py @@ -141,16 +141,12 @@ def test_init_gwf_top_down_misaligned(): "ncol": grid.ncol, } gwf = Gwf() - with pytest.raises( - ValueError, match=r"group '/dis' is not aligned with its parents" - ): + with pytest.raises(ValueError, match=r"group '/dis' is not aligned with its parents"): Dis(parent=gwf, **dims) # passing dims explicitly to gwf doesn't work either. # one MUST create the component declaring dims first. - with pytest.raises( - ValueError, match=r"group '/dis' is not aligned with its parents" - ): + with pytest.raises(ValueError, match=r"group '/dis' is not aligned with its parents"): Gwf(dims=dims) @@ -224,12 +220,8 @@ def test_init_big_sim(): assert np.array_equal(sim.models["gwf"].npf.data.k, np.ones(10000)) assert chd.head[0, 0] == 1.0 assert chd.head[0, 9999] == 0.0 - assert np.array_equal( - chd.head[0, 1:9999].data.todense(), np.full((9998,), FILL_DNODATA) - ) - assert np.array_equal( - chd.head.data.todense(), chd.data.head.data.todense() - ) + assert np.array_equal(chd.head[0, 1:9999].data.todense(), np.full((9998,), FILL_DNODATA)) + assert np.array_equal(chd.head.data.todense(), chd.data.head.data.todense()) assert np.array_equal( chd.head.data.todense(), sim.models["gwf"].chd[0].data.head.data.todense(), diff --git a/uv.lock b/uv.lock index e4667b4e..b4062ee2 100644 --- a/uv.lock +++ b/uv.lock @@ -3583,7 +3583,7 @@ parallel = [ [[package]] name = "xattree" version = "0.1.0.dev0" -source = { git = "https://github.com/modflowpy/xattree.git#56cbd85c30a2d8a871d51f1999244e36f8185d95" } +source = { git = "https://github.com/modflowpy/xattree.git#30b15917c24d29583ab8a166d2a7d0b0a9d3a84a" } dependencies = [ { name = "attrs" }, { name = "cattrs" },