Skip to content

Commit 79732e9

Browse files
committed
Fix types, make sure x, y is defined.
1 parent 352277f commit 79732e9

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

bris/outputs/netcdf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _interpolate(self) -> bool:
145145
"""Should interpolation to a regular lat/lon grid be performed?"""
146146
return self.interp_res is not None
147147

148-
def write(self, filename: str, times: list, pred: np.ndarray):
148+
def write(self, filename: str, times: np.datetime64, pred: np.ndarray):
149149
"""Write prediction to NetCDF
150150
Args:
151151
times: List of np.datetime64 objects that this forecast is for
@@ -167,6 +167,9 @@ def c(x):
167167
frt_ut = times_ut[0]
168168
coords[c("time")] = np.array(times_ut).astype(np.double)
169169

170+
x: np.ndarray | None = None
171+
y: np.ndarray | None = None
172+
170173
if self._is_gridded:
171174
if self._interpolate:
172175
# Find a bounding-box for interpolation
@@ -287,7 +290,7 @@ def c(x):
287290

288291
else:
289292
if self._is_masked:
290-
self._not_gridded_masked(spatial_dims)
293+
self._not_gridded_masked(spatial_dims, x, y)
291294
else:
292295
self._not_gridded_not_masked(spatial_dims)
293296

@@ -296,7 +299,7 @@ def c(x):
296299
self._set_attrs()
297300
self._write_files(filename)
298301

299-
def _not_gridded_masked(self, spatial_dims: tuple):
302+
def _not_gridded_masked(self, spatial_dims: tuple, y, x):
300303
t0 = pytime.perf_counter()
301304
if hasattr(self.ds_mask, "lat") and hasattr(self.ds_mask, "lon"):
302305
lat = self.ds_mask.lat.values

bris/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def setup_logging(config: DotDict) -> None:
163163
)
164164

165165

166-
def datetime_to_unixtime(dt: np.datetime64) -> np.ndarray[int]:
166+
def datetime_to_unixtime(dt: np.datetime64) -> np.ndarray:
167167
"""Convert a np.datetime64 object or list of objects to unixtime"""
168168
return np.array(dt).astype("datetime64[s]").astype("int")
169169

0 commit comments

Comments
 (0)