Skip to content

Shape error when reading idefix-vtk V2.2.00 #366

Closed
@aborderies

Description

@aborderies

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

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 :

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcode: IdefixSpecific to Idefixio: vtkSpecific to vtk files

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions