Skip to content

Fix uniform grid violation of POLA#31

Open
ljlamarche wants to merge 1 commit into
gemini3d:mainfrom
ljlamarche:bugfix_uniform_grid
Open

Fix uniform grid violation of POLA#31
ljlamarche wants to merge 1 commit into
gemini3d:mainfrom
ljlamarche:bugfix_uniform_grid

Conversation

@ljlamarche
Copy link
Copy Markdown
Contributor

Due to how numpy.linspace handles endpoints, the grid setup script was violating the Principle of Least Astonishment (POLA). When the length of the grid dimension is set to 128 km and the number of grid cells to 128, the resulting grid cells have a dimension of 1007 m rather than 1000 m. This has been fixed.

Note that I have not adjusted Line 40 which deals with the degenerate dimension case.

@ljlamarche
Copy link
Copy Markdown
Contributor Author

This change may not be necessary. The original setup matches the MATLAB function.

@ljlamarche
Copy link
Copy Markdown
Contributor Author

I think the question here just comes down to how you want the grid to be defined by the user. The default linespace in both MATLAB and Python puts the first point at xmin, the last point at xmax, and n-2 points evenly spaced in-between them. If these points are supposed to be the grid centers, the correct number of grid cells are returned, but they're slightly further apart than expected because the endpoint are the center of the first and last grid cell, not it's edges.

I think you can still make whatever grid you want with the right combination of the number of cells and extent, it's just a question of what convention makes the most sense.

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

Successfully merging this pull request may close these issues.

1 participant