reductus / reductus

Web-based, visual dataflow data reduction for neutron scattering instruments
The Unlicense
9 stars 11 forks source link

strip inf/nan from data before feeding to d3 #80

Open pkienzle opened 4 years ago

pkienzle commented 4 years ago

To avoid errors like the ones below, inf and NaN need to be stripped from the data before feeding them to d3 for plotting. This could happen server-side when building the plottable or client-side when building the plot.

d3.v4.min.js:2 Error: <path> attribute d: Expected number, "M661.621,NaNL661.621,NaNM…".
(anonymous) @ d3.v4.min.js:2
each @ d3.v4.min.js:2
attr @ d3.v4.min.js:2
chart.draw_errorbars @ xy-chart.js:509
update @ xy-chart.js:529
zoomed @ xy-chart.js:106
apply @ d3.v4.min.js:2
it @ d3.v4.min.js:2
emit @ d3.v4.min.js:2
zoom @ d3.v4.min.js:2
(anonymous) @ d3.v4.min.js:2
each @ d3.v4.min.js:2
n.transform @ d3.v4.min.js:2
call @ d3.v4.min.js:2
chart.resetzoom @ xy-chart.js:626
chart.ytransform @ xy-chart.js:754
(anonymous) @ editor.js:939
(anonymous) @ d3.v4.min.js:2
d3.v4.min.js:2 Error: <path> attribute d: Expected number, "M36.485,InfinityL36.485,…".
(anonymous) @ d3.v4.min.js:2
each @ d3.v4.min.js:2
attr @ d3.v4.min.js:2
chart.draw_errorbars @ xy-chart.js:509
update @ xy-chart.js:529
zoomed @ xy-chart.js:106
apply @ d3.v4.min.js:2
it @ d3.v4.min.js:2
emit @ d3.v4.min.js:2
zoom @ d3.v4.min.js:2
(anonymous) @ d3.v4.min.js:2
each @ d3.v4.min.js:2
n.transform @ d3.v4.min.js:2
call @ d3.v4.min.js:2
chart.resetzoom @ xy-chart.js:626
(anonymous) @ xy-chart.js:325
each @ d3.v4.min.js:2
chart @ xy-chart.js:187
call @ d3.v4.min.js:2
webreduce.editor.show_plots_nd @ editor.js:1028
webreduce.editor.show_plots @ editor.js:448
(anonymous) @ editor.js:266
Promise.then (async)
module_clicked_single @ editor.js:256
(anonymous) @ editor.js:224
(anonymous) @ editor.js:82
(anonymous) @ d3.v4.min.js:2
bmaranville commented 3 years ago

Quite a bit of NaN/Inf handling is done in the plotting libraries themselves - particularly because these pop up dynamically when you change scales, for instance. I can catch these errors or better yet suppress the draw function when the errorbars have undefined vertices.