-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Last week I updated my idefix repository to version 2.2.00, which adds native coordinates to vtk files. Since then, I've had a problem when I try to load an idefix-vtk file: when yt_idefix wants to calculate the cell_widths, a shape error occurs:
ValueError: could not broadcast input array from shape (N-1,) into shape (N,)
where N is the number of cells in the first dimension of my grid, at this line
yt_idefix/src/yt_idefix/data_structures.py
Line 209 in 89d9471
| cell_widths[idir][:] = np.ediff1d(edges) |
Looking at the code, I noticed that the read_grid_coordinates() method, which is supposed to return the coordinates of the cell edges (if I understood correctly), actually returns the coordinates of the cell centers when the native coordinates are in the metadata :
yt_idefix/src/yt_idefix/_io/vtk_io.py
Lines 234 to 241 in 89d9471
| if "native_coordinates" in md: | |
| nc = md["native_coordinates"] | |
| return Coordinates( | |
| nc["X1C_NATIVE_COORDINATES"], | |
| nc["X2C_NATIVE_COORDINATES"], | |
| nc["X3C_NATIVE_COORDINATES"], | |
| array_shape, | |
| ) |
I tried replacing XkC_NATIVE_COORDINATES with XkL_NATIVE_COORDINATES and this avoided the problem in my case. Does this work, or would another solution be more appropriate?
Thanks in advance for the help.