-
Notifications
You must be signed in to change notification settings - Fork 7
How to retain metadata #27
Comments
The f2py functions written based on the boilderplate in linint2 should all retain metadata. |
@pilotchute thanks for looking into this! I did not fully disclose my thinkings since I initiated this issue as a self note for not to forget bringing into team's discussion. Let me elaborate it a bit, also cc'ing @anissa111 and @michaelavs :
Different functions might have slight differences in such a code block for sure, based on input to output dimension comparison or so. Thoughts? |
We do not use fi.coords in the linint2 output, rather we use fo_coords, made to reflect the changed geometry of the data. in fact the linint2 implementation of fo_coords is functionally the same as the one in geocat-ncomp, just re-written to be more human readable. |
Ah, my bad, thanks @pilotchute ! I did not realize Do you have any idea on part (1) of discussion, whether to always retain metadata (any cost with it) or introduce a user-request input argument such as |
I think we always retain fi. metadata for any thing that isn't modified by the function. And in cases where we understand the changes made to an axis, we should make an effort to update the information for that axis. Carrying data from fi. to fo. doesn't significantly increase memory usage, since we are only copying attributes from one xarray object to another. |
We could add an optional |
I agree with you. Once we know retaining metadata is memory-costless, just retain it in the code and do not deal with |
Any ideas on how we can test metadata retention memory cost? |
I am not sure how to test but there is chances it would be memory costly in such a scenario (or please correct me if I am getting it wrong): We are copying |
This issue: pydata/xarray#1614 has relevant discussions about metadata preservation in xarray that may be of interest to you. |
Thanks @andersy005 |
NCL functions have counterpart functions with a name extension "_Wrap" where the metadata is retained, e.g. "rcm2rgrid" and "rcm2rgrid_Wrap". We need to check if our code retains xarray metadata. Checking it from geocat-ncomp would also help.
The text was updated successfully, but these errors were encountered: