You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behaviour
Both methods in the above example should return 'velocity'. This also affects every other derived variable, such as displacement, acceleration, head_direction etc.
The matter can me easily fixed by setting the name attribute inside the function that computes the variable.
Having an appropriate name is quite handy for printing, plotting, etc.
The text was updated successfully, but these errors were encountered:
Arguments in favour of setting an appropriate name for every derived variable:
The name will appear when using built-in xarray plots
We will reduce probability of conflicts when using xr.merge (merging objects that have the same name may cause issues).
For some built-in saving functions, like to_netcdf() (an .h5-based format) the variable names in the saved file will be meanigful (though we don't really use that file format)
We get the chance to nudge users towards "standardised" naming conventions (users may be inclined to stick with these when adding arrays to datasets)
Arguments in favour of setting an empty name for every derived variable:
users have full freedom to set that to whatever they like later, we make no assumed choices for them (though they could always override our choice anyway)
we reduce the risk of setting the "wrong" name, or these names becoming outdated after downstream operations. No plots with inadvertently wrong names.
we don't have to decide what that name should be when writing a new function
Full disclosure:
I personally currently favour the first approach, but both are better than the status quo.
Describe the bug
When assigning a derived array (e.g. velocity) as a dataset variable, it's
name
attribute is automatically set to the name we assign to that variable.However, if we keep it as a standalone array, it's
name
stays the same as that of the input array from which it was derived.To Reproduce
Expected behaviour
Both methods in the above example should return 'velocity'. This also affects every other derived variable, such as
displacement
,acceleration
,head_direction
etc.The matter can me easily fixed by setting the
name
attribute inside the function that computes the variable.Having an appropriate name is quite handy for printing, plotting, etc.
The text was updated successfully, but these errors were encountered: