pyresample icon indicating copy to clipboard operation
pyresample copied to clipboard

Add check or force Boundary lons/lats to be 1D

Open djhoese opened this issue 4 years ago • 4 comments

Code Sample, a minimal, complete, and verifiable piece of code

from pyresample.boundary import Boundary
b = Boundary(my_lons, my_lats)
print(b.contour_poly.area())

Problem description

The above code doesn't fail if the provided lons/lats are 2D (not sure on 3D+), but the class and all functions/utilities underneath it assume 1D arrays. The end results are incorrect because of this.

Expected Output

Either an exception or a .ravel() on the provided lons/lats so the rest of the calculations work fine.

Actual Result, Traceback if applicable

Incorrect area and other operations.

djhoese avatar Feb 22 '21 21:02 djhoese

@pnuu @mraspaud Any preference on .ravel() or assert or something else?

djhoese avatar Feb 22 '21 21:02 djhoese

Flatten?

mraspaud avatar Feb 24 '21 06:02 mraspaud

I believe flatten forces a copy of the array every time. ravel() will only copy if it needs to.

djhoese avatar Feb 24 '21 14:02 djhoese

ah true, I had them mixed up. ravel returns a view

mraspaud avatar Feb 24 '21 15:02 mraspaud