Skip to content

Commit afab5df

Browse files
committed
fix: return correct cell-centered coordinate for slice orientation dimension (closes #92)
1 parent 74b5aca commit afab5df

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

fdsreader/slcf/slice.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,14 @@ def get_coordinates(self, ignore_cell_centered: bool = False) -> Dict[Literal["x
337337
coords = {"x": list(), "y": list(), "z": list()}
338338
for dim in ("x", "y", "z"):
339339
if orientation == dim:
340-
coords[dim] = np.array([self.extent[dim][0]])
340+
coord = self.extent[dim][0]
341+
if self.cell_centered and not ignore_cell_centered:
342+
mesh = next(iter(self._subslices.keys()))
343+
mesh_co = mesh.coordinates[dim]
344+
idx = int(np.argmin(np.abs(mesh_co - coord)))
345+
if idx > 0:
346+
coord = (float(mesh_co[idx - 1]) + float(mesh_co[idx])) / 2
347+
coords[dim] = np.array([coord])
341348
continue
342349
for slc in self._subslices.values():
343350
co = slc.get_coordinates(ignore_cell_centered)[dim]

0 commit comments

Comments
 (0)