Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with raw fields when there is no ghost cells #2586

Merged
merged 1 commit into from
May 8, 2020

Conversation

NeilZaim
Copy link
Contributor

@NeilZaim NeilZaim commented May 7, 2020

I was trying to read raw fields from a plotfiles coming from a WarpX simulation and I encountered a bug occuring when there is no ghost cells. The bug occurs when doing something like:

import yt
ds = yt.load("diags/diag100200")
ad = ds.all_data()
Ex_raw = ad['raw','Ex_aux']

And the error message is:

Traceback (most recent call last):
  File "./analysis_reduced_diags.py", line 58, in <module>
    Ex_raw = ad['raw','Ex_aux'].to_ndarray()[:,0]
  File ".../yt/data_objects/data_containers.py", line 256, in __getitem__
    self.get_data(f)
  File ".../yt/data_objects/data_containers.py", line 1571, in get_data
    fluids, self, self._current_chunk)
  File ".../yt/geometry/geometry_handler.py", line 244, in _read_fluid_fields
    chunk_size)
  File ".../yt/frontends/boxlib/io.py", line 66, in _read_fluid_selection
    nd = g.select(selector, ds, rv[field], ind)
  File ".../yt/data_objects/grid_patch.py", line 421, in select
    dest[offset:offset+count, i] = source[sl][np.squeeze(mask)]
IndexError: boolean index did not match indexed array along dimension 0; dimension is 0 but corresponding boolean dimension is 32

The bug happens with yt 3.6 but the same code was running well with version 3.5.1.

After backtracing the error, it seems to be coming from using slice(nghost[dim],-nghost[dim]) to trim the ghost cells in the function _read_raw_fields, which fails when nghost[dim]=0. I propose a simple fix in this PR which worked for me.

@welcome
Copy link

welcome bot commented May 7, 2020

Hi! Welcome, and thanks for opening this pull request. We have some guidelines for new pull requests, and soon you'll hear back about the results of our tests and continuous integration checks. Thank you for your contribution!

@atmyers atmyers self-requested a review May 7, 2020 15:30
@atmyers atmyers added the bug label May 7, 2020
@atmyers
Copy link
Member

atmyers commented May 7, 2020

This looks good to me - thanks for the catch and the fix!

@Xarthisius Xarthisius added the code frontends Things related to specific frontends label May 7, 2020
@munkm munkm merged commit 1a23e72 into yt-project:master May 8, 2020
@welcome
Copy link

welcome bot commented May 8, 2020

Hooray! Congratulations on your first merged pull request! We hope we keep seeing you around! 🎆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug code frontends Things related to specific frontends
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants