Skip to content

Commit 19d4404

Browse files
committed
fill object to be able to produce a netcdf file
1 parent 1ba589b commit 19d4404

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/py_eddy_tracker/dataset/grid.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def __init__(
293293
self.interpolators = dict()
294294
if centered is None:
295295
logger.warning(
296-
"We assume the position of grid is the center corner for %s", filename,
296+
"We assume pixel position of grid is center for %s", filename,
297297
)
298298
if not unset:
299299
self.load_general_features()
@@ -1062,6 +1062,7 @@ def _low_filter(self, grid_name, w_cut, factor=8.0):
10621062
self.coordinates[0]: x_array[:-1],
10631063
self.coordinates[1]: y_array[:-1],
10641064
},
1065+
centered=False,
10651066
)
10661067
regular_grid.bessel_low_filter(grid_name, w_cut, order=1)
10671068
z_filtered = regular_grid.grid(grid_name)
@@ -1113,13 +1114,26 @@ def setup_coordinates(self):
11131114
self._y_step = (self.y_c[1:] - self.y_c[:-1]).mean()
11141115

11151116
@classmethod
1116-
def with_array(cls, coordinates, datas):
1117+
def with_array(cls, coordinates, datas, variables_description=None, **kwargs):
11171118
x_name, y_name = coordinates[0], coordinates[1]
1118-
obj = cls("array", x_name, y_name, unset=True, centered=False)
1119+
obj = cls("array", x_name, y_name, unset=True, **kwargs)
11191120
obj.x_dim = (x_name,)
11201121
obj.y_dim = (y_name,)
1122+
obj.variables_description = dict()
1123+
obj.dimensions = {i: v.shape[0] for i, v in datas.items() if i in coordinates}
11211124
for k, v in datas.items():
11221125
obj.vars[k] = v
1126+
obj.variables_description[k] = dict(
1127+
attrs=variables_description.get(k, dict()),
1128+
args=(k, v.dtype),
1129+
kwargs=dict(
1130+
dimensions=coordinates if k not in coordinates else (k,),
1131+
complevel=1,
1132+
zlib=True,
1133+
),
1134+
infos=dict(),
1135+
)
1136+
obj.global_attrs = dict(history="Grid setup with an array")
11231137
obj.setup_coordinates()
11241138
return obj
11251139

0 commit comments

Comments
 (0)