-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
combine_by_coords could use allclose instead of equal to compare coordinates #4465
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
Comments
You can totally skip this comparison by specifying Adding |
See #2217 for related discussion about adding a I think adding a |
Interesting discussion #2217. As far as I understand, it solves a wider problem than using a tolerance on and a member by member comparison... but more complex to implement. Here is the simple solution that works for me (combine.py:70):
I've not tested in depth, I can make a PR, tests, doc if you agree with this solution. Regarding the name of the arg. "tolerance" is nice, but allclose has atol and rtol. My solution above only set atol, but both may be useful. Should we use: |
I would suggest only specifying Is there a case where you think |
Is your feature request related to a problem? Please describe.
When a coordinate in different dataset / netcdf files has slightly different values, combine_by_coords considers the coordinate are different and attempts a concatenation of the coordinates.
Concretely, I produce netcdf with (lat, lon, time) coordinates, annually. Apparently the lat is not the same in all the files (difference is 1e-14), which I suspect is due to different pyproj version used to produce the lon,lat grid. Reprocessing all the annual netcdf is not an option. When using open_mfdataset on these netcdf, the lat coordinate is concatenated which leads to a MemoryError in my case.
Describe the solution you'd like
Two options:
add a coord_tolerance argument to xr.combine_by_coords and use np.allclose to compare the coordinates. In line 69 combine.py the comparison uses strict equality "if not all(index.equals(indexes[0]) for index in indexes[1:]):". This does not break the compatibility because coord_tolerance=0 should be the default.
add an argument to explicity list the coordinates to NOT concatenate. I tried to play with the coords argument to solve my problem, but was not succesfull.
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: