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

Regridder error: cannot reshape array of size {} into shape {} #315

Open
tmurakami7 opened this issue Nov 17, 2023 · 1 comment
Open

Regridder error: cannot reshape array of size {} into shape {} #315

tmurakami7 opened this issue Nov 17, 2023 · 1 comment

Comments

@tmurakami7
Copy link

Specific error:
ValueError: cannot reshape array of size 67184640000 into shape (360, 720, 360, 720).

  • We attempted to regrid a (360, 720) to a different (360, 720) and this was the error I got. We went inside the xESMF core.py and realized the error was on line 1052 where it did the comparison:

if self.size != reduce(operator.mul, shape, 1): raise ValueError( "cannot reshape array of size {} into shape {}".format(self.size, shape) )

  • But actually the multiplication of (360, 720, 360, 720) is 67184640000 so it should not have failed in this part. We realized that shapes elements were np.int32 and so the 'reduce (mul=' was giving an overflow error.

Result:

  • We fixed this by changing the shape tuple into np.int64 elements and it worked.
  • This should be fixed to allow larger operation.
@huard
Copy link
Contributor

huard commented Nov 17, 2023

Thanks for the detailed report and fix. Would you be willing to submit a Pull Request ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants