Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
VeckoTheGecko committed Dec 5, 2024
1 parent 9013062 commit 508006d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions parcels/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@

from parcels.fieldset import FieldSet

T_SanitizedFilenames = list[str] | dict[str, list[str]]
T_Dimensions = Literal["lon", "lat", "depth", "data"]
T_SanitizedFilenames = list[str] | dict[T_Dimensions, list[str]]

__all__ = ["Field", "NestedField", "VectorField"]

Expand Down Expand Up @@ -600,10 +601,10 @@ def from_netcdf(
)
lonlat_filename = lonlat_filename_lst[0]
if "depth" in dimensions:
depth_filename = _get_dim_filenames(filenames, "depth")
if isinstance(filenames, dict) and len(depth_filename) != 1:
depth_filename_lst = _get_dim_filenames(filenames, "depth")
if isinstance(filenames, dict) and len(depth_filename_lst) != 1:
raise NotImplementedError("Vertically adaptive meshes not implemented for from_netcdf()")
depth_filename = depth_filename[0]
depth_filename = depth_filename_lst[0]

netcdf_engine = kwargs.pop("netcdf_engine", "netcdf4")
gridindexingtype = kwargs.get("gridindexingtype", "nemo")
Expand Down Expand Up @@ -2578,7 +2579,7 @@ def __getitem__(self, key):
return val


def _get_dim_filenames(filenames: T_SanitizedFilenames, dim: str) -> list[str]:
def _get_dim_filenames(filenames: T_SanitizedFilenames, dim: T_Dimensions) -> list[str]:
"""Get's the relevant filenames for a given dimension."""
if isinstance(filenames, list):
return filenames
Expand Down

0 comments on commit 508006d

Please sign in to comment.