Fundamental change in sel and seltime methods - now not masking NaN-v…#187
Fundamental change in sel and seltime methods - now not masking NaN-v…#187knutfrode merged 5 commits intoOpenDrift:mainfrom
Conversation
…alues, as these from now on will have significant meaning as dividing trajectories into segments. to_1d() is now also not removing NaN-values.
|
@gauteh It would be good to have your check of this before proceeding.
|
…found on local machine)
|
Inserting these two lines before 54 (concat) solves the Doc-build problem. But this is quite strange, since no duplicates are found locally. |
trajan/traj1d.py
Outdated
| ds_dropped_selected = ds_dropped.sel(*args, **kwargs) | ||
|
|
||
| # Find indices of original trajectory corresponding to selected range | ||
| ind_start = np.where(self.ds[self.obs_dim] == ds_dropped_selected[self.obs_dim][0])[0][0] |
There was a problem hiding this comment.
What if obs_dim is unordered? I think this has to work on indices, not the values of the obs_dim. I guess obs_dim is time since this is 1d, but comparing floats is not so safe. To find the first/last value matching argmax is better.
|
Feels like we have to try this one out for a bit, I guess we could merge and potentially revert... It's nice to be able to use standard Now you're slicing on first and last match, but sel doesn't need to always be a slice. It can be an arbitrary list. So the new sel is more of a slice than a sel :) |
|
You are of course right, I simply forgot other options than selecting a slice... |
…om traj.sel to traj.seltime, and traj.sel again corresponds to xarray.sel. Also adding missing obs-coordinates after e.g. padding of arrays in obs-dimension
|
@gauteh Now One note: for several methods that e.g. padded/added items along the obs-dimension I have now re-written the obs-dim coordinate as integers from 0 to N before returning. |
…alues, as these from now on will have significant meaning as dividing trajectories into segments. to_1d() is now also not removing NaN-values.