silx
silx copied to clipboard
[curveplot] Improve *.dat export
Feedback from a user. That's not a high priority at all.
Tested with silx 2.1.1.
The dat export with multi curves is like exporting multiple scans instead of multiple curves.
- Run
examples/plotCurveLegendWidget.py - Export as dat
- Import the dat file with pymca
- Notice that there is 3 scans, and 2 counters per scans.
They would expect a single scan, with the 4 counters (3 counters + 1 axes).
BTW during the export we can notice that:
(bliss2.2) valls@lvalls:~/workspace/silx.git(fix-get-display-mode)$ python examples/plotCurveLegendWidget.py
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Qt: Session management error: None of the authentication protocols specified are supported
X ['Y'] %.7g 2 [-3.14159265 -3.14120843 -3.14082421 ... 3.14082421 3.14120843
3.14159265] [[-0.56797773 0.67579871 -0.03870308 ... -0.52785258 -0.67234882
-0.98853755]]
X ['Y'] %.7g 2 [-3.14159265 -3.14120843 -3.14082421 ... 3.14082421 3.14120843
3.14159265] [[-1.22464680e-16 -3.84222170e-04 -7.68444284e-04 ... 7.68444284e-04
3.84222170e-04 1.22464680e-16]]
X ['Y'] %.7g 2 [-3.14159265 -3.14120843 -3.14082421 ... 3.14082421 3.14120843
3.14159265] [[-1. -0.99999993 -0.9999997 ... -0.9999997 -0.99999993
-1. ]]
There is an extra print somewhere.
This part of the code hasn't changed much in the last 6/7 years, so it's a bit risky to change the behavior now... The most recent relevant change looks to be "Save error-bars when saving a plot" #3199 (from 2020...)
I guess it was saved with different scans rather than counters because it allows for each curves to have a different number of points.
What could be done is:
- check that all curves have the same number of points (+ probably no error bars) and then save as a single scan... but that's kind of obscure behavior IMO
- provide yet another save options that save all curves as one scan eventually clipping the curves that are longer or filling the ones that are too shorts
BTW, there is indeed a print:
+++ b/src/silx/io/utils.py
@@ -423,7 +423,6 @@ def savespec(
ncol = data.shape[0]
assert len(labels) == ncol
- print(xlabel, ylabel, fmt, ncol, x_array, y_array)
if isinstance(fmt, str) and fmt.count("%") == 1:
full_fmt_string = " ".join([fmt] * ncol)
elif isinstance(fmt, (list, tuple)) and len(fmt) == ncol:
In this case maybe you can close this issue, until somebody else request that. As i said, the user will use the HDF5 reader from PyMCA anyway, and will not export anymore to .dat.
Just remove the print.
PR #4192 removes the print.
I'm closing this issue then