Skip to content

Commit 3e02b35

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d004bf7 commit 3e02b35

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/parcels/convert.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
Xarray dataset so that users can further provide any missing metadata that was unable to
1010
be determined before they pass it to the FieldSet constructor.
1111
"""
12+
1213
from __future__ import annotations
13-
import warnings
1414

1515
import typing
16+
import warnings
1617

1718
import numpy as np
1819
import xarray as xr
@@ -25,7 +26,19 @@
2526

2627
_NEMO_EXPECTED_COORDS = ["glamf", "gphif", "depthw"]
2728

28-
_NEMO_DIMENSION_COORD_NAMES = ["x", "y", "time", "x", "x_center", "y", "y_center", "depth", "depth_center", "glamf", "gphif"]
29+
_NEMO_DIMENSION_COORD_NAMES = [
30+
"x",
31+
"y",
32+
"time",
33+
"x",
34+
"x_center",
35+
"y",
36+
"y_center",
37+
"depth",
38+
"depth_center",
39+
"glamf",
40+
"gphif",
41+
]
2942

3043
_NEMO_AXIS_VARNAMES = {
3144
"x": "X",
@@ -104,13 +117,13 @@ def _maybe_bring_other_depths_to_depth(ds):
104117
]:
105118
if old_depth in ds[var].dims:
106119
ds[var] = ds[var].rename({old_depth: target})
107-
120+
108121
if "depth" not in ds.dims:
109122
warnings.warn("No depth dimension found in your dataset. Assuming no depth (i.e., surface data).", stacklevel=1)
110123
ds = ds.expand_dims({"depth": [0]})
111124
ds["depth"] = xr.DataArray([0], dims=["depth"])
112125
return ds
113-
126+
114127

115128
def _maybe_rename_coords(ds, axis_varnames):
116129
try:
@@ -288,8 +301,10 @@ def nemo_to_sgrid(*, fields: dict[str, xr.Dataset | xr.DataArray], coords: xr.Da
288301
if coords.sizes["time"] != 1:
289302
raise ValueError("Time dimension in coords must be length 1 (i.e., no time-varying grid).")
290303
coords = coords.isel(time=0).drop("time")
291-
292-
if len(coords.dims) == 3: #! This should really be looking at the dimensionality of the lons and lats arrays. Currently having 2D lon lat and 1D depth triggers this `if` clause
304+
305+
if (
306+
len(coords.dims) == 3
307+
): #! This should really be looking at the dimensionality of the lons and lats arrays. Currently having 2D lon lat and 1D depth triggers this `if` clause
293308
for dim, len_ in coords.sizes.items():
294309
if len_ == 1:
295310
# TODO: log statement about selecting along z dim of 1

0 commit comments

Comments
 (0)