-
Notifications
You must be signed in to change notification settings - Fork 31
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
Inconsistent Normalization of Cartesian Coordinates in node_x
, node_y
, and node_z
#872
Comments
I'd prefer if we had an option to select the normalization, either as a parameter to As of now, this would only impact any MPAS, EXODUS, or UGRID files that contain Cartesian coordinates. # Option 1: parameter
uxgrid = ux.open_grid(..., normalize_cartesian_coordinates=True)
# Option2 : Grid method
uxgrid.normalize_cartesian_coordinates() We can support both options as well Wondering what @erogluorhan and @rajeeja think about this design. |
Sounds good, we can keep |
Can you elaborate on what you are envisioning the debug mode looking like? |
simple logging, with say prints are simple and good, our Numba dependency might prevent us from having logging calls directly because Numba transforms Python code into machine code. logging is expensive, but shouldn't be used in production envs, but, can be very useful to trace bugs. |
I like the parameter or method options (or both) @philipc2 suggested, but when they are in place, there would be a confusion with the case @hongyuchen1030 pointed, i.e. when user wants them not to be normalized but after some point calls one of the functions @hongyuchen1030 mentioned, coords still being forced normalized does not seem ideal to me. @hongyuchen1030 isn't there a way to use their normalized values but not change the actual data? |
That's the things I pointed out initially in this comment to create an extra variable I would like to re-emphasize the following points:
|
Wondering if you have any specific examples of this, especially any documentation from the grid definitions or model output that could corroborate this. From the grids that I've worked with (and the UGRID / CF conventions more generally), I haven't encountered any indicators that would tells us that the coordinates we are working with is normalized or not. This is something we could add a validation function for that would check whether coordinates are normalized if there are no other indicators from the files that we read.
Agreed. Once the coordinates are normalized, they should be still linked to the
I don't believe this is an issue with most of the grids that we work with, since they are taken from climate models and not observations. But this is a fair point if we are working with other types of data. |
Since @hongyuchen1030's functionality expects the coordinates to ne normalized, an exception should be raised, mentioning that the user needs to normalize the coordinates before calling the function.
Agreed. We should avoid any unnecessary processing of the grid when loading it in, especially since normalization is only required for a subset of our functionality. |
I think the best route forward would be some combination of the following design features. Normalization ChecksHave a validation function that can quickly determine whether the stored coordinates are normalized. @rajeeja has already put together a few of these for other purposes. In-Place Normalization MethodsHave a This would look like what I mentioned above: uxgrid.normalize_cartesian_coordinates() After calling this method, all of the I personally don't think this is an issue, since the user is expected to normalize the coordinates themselves and we don't automatically do any of it. What do you all think? We could even add an attribute to each of the data arrays (i.e. |
As far as I am aware, it is not just my functionalities that require data to be on a perfect sphere. Functions such as Welz' algorithm, area calculation, and edge distance computation—all of which are related to geometry—are based on the premise that we are operating on a perfectly spherical surface.
For a perfectly spherical surface, it is straightforward to convert between normalized and unnormalized data by simply multiplying by the actual radius, which, in our case, is the Earth's radius. A simple way to test this is by multiplying our normalized values by the Earth's radius and checking if they match the input. If the user's data didn't match, that means their original data are not on a perfectly spherical surface, and we don't suggest they to reply on all our analysis results. Last but not least, as Paul mentioned, the UXarray project description and the associated paper define that we are operating on the unit sphere. |
This sounds good to me. Just a reminder: what if the user calls We can set it up like |
The |
After our discussions, it seems crucial to emphasize that the fundamental premise of our project is based on a spherical surface. Users should not expect our calculations to apply to any other surfaces, such as the actual shape of the Earth. By clearly highlighting this premise, users can make informed choices: they can either use the normalized node coordinates or simply multiply them by the Earth's radius. |
I agree, and I believe the majority of our user base already uses data that is on a spherical surface (i.e. climate model output) |
Version
v2024.06
How did you install UXarray?
Conda
What happened?
Our project performs geometric operations on unstructured grids on a unit sphere, which means all points on the sphere should be normalized. The normalized Cartesian coordinates are stored in the
node_x
,node_y
, andnode_z
variables.However, while in most cases the
node_x
,node_y
, andnode_z
variables are normalized as they should be, when reading in the MPAS data, these variables are not normalized. This inconsistency leads to breakdowns in subsequent operations.What did you expect to happen?
the
node_x
,node_y
, andnode_z
variables to be consistently normalized across all datasets, including the MPAS data.It is crucial to emphasize and document that
node_x
,node_y
, andnode_z
must always represent normalized points on the sphere. Ensuring these variables are normalized as required is essential for the robustness and reliability of our project.Can you provide a MCVE to repoduce the bug?
No response
The text was updated successfully, but these errors were encountered: