Handle NaN in display devices#17
Handle NaN in display devices#17D4vidH4mm3r wants to merge 9 commits intophilsmt:fix/forward-compatfrom
Conversation
| nan_replacement = 0 | ||
| if isinstance(self.ch_data, xr.DataArray): | ||
| self.idx_data = self.ch_data.data[self.index] | ||
| if "replace_nan" in self.ch_data.attrs: | ||
| nan_replacement = self.ch_data.attrs["replace_nan"] |
There was a problem hiding this comment.
One could also allow specifying and utilizing the various dropna / fillna etc. available for DataArray. They don't handle inf, though. Also, dropping is tricky.
| self.idx_data = np.nan_to_num(self.idx_data, copy=True, | ||
| nan=nan_replacement) | ||
|
|
There was a problem hiding this comment.
Note: would like to avoid copy.
Cannot replace in-place as destination is not writable.
Ideally, would only copy if any value needs replacing - but first checking that and then copying doesn't seem clever either.
Also: I considered if we could drop instead of replacing.
However, if self.idx_data.shape[0] > 1, then we cannot do a simple 1d mask and np.compress on x and ys.
And stacking seems tricky.
Unless we drop by logical OR across axis=0.
There was a problem hiding this comment.
Hmmm, this is likely due to the no-copy mechanism used with pyzmq. Generally though, I'd also like to avoid encoding metropc-specific details in the display devices.
We could either implement it directly in the rendering code, replacing NaN by something else, or move this specific into the euxfel.metropc device. Another advantage of the rendering code would be that we can actually render gaps rather than replace it. And one could present np.inf by an infinite slope before and after.
| if not numpy.isfinite(d): | ||
| return | ||
|
|
There was a problem hiding this comment.
Here it's easy to just drop a given value. The plot was almost working as-is: NaN values would cause an exception and just not get plotted, so there would be gap. The curve would break, though.
There was a problem hiding this comment.
Similar to fast_plot, I wonder if it would be useful to visualize this by a gap?
6aef942 to
1e250a9
Compare
This was just part of preparation before adding clipping to draw_line, but I got significant performance boost from, presumably, the noexcept. We can drop the C++ part if it's not wanted; I just found references easier to work with (syntactically) than more pointers.
As I'm not very familiar with the code base yet, I'll just post this to record which parts I've gotten to so far. In any plot, one should decide between replacing nan with some value or dropping it. Same goes for +-infinity values.
Have so far looked at:
fast_plotndarraywithndim==1ndarraywithndim>1ndarraywithndim>1andself.with_xxr.DataArrayhist1dhist2dimageplotpolar_plotsortedvaluewaveformDeveloping against
fix/forward-compatas that allowed me to install locally for testing, but can (rebase and) switch to point tomasterlater.