ixdat / ixdat

The In-situ Experimental Data Tool
https://ixdat.readthedocs.io
MIT License
23 stars 13 forks source link

Add option to NOT draw lines between individual datasets in plot_measurement() #49

Open AnnaWiniwarter opened 2 years ago

AnnaWiniwarter commented 2 years ago

Adding together datasets and then plotting the combined data has the irritating side effect that the last datapoint of the first dataset is connected with the first datapoint of a new dataset with a straight line. This is especially annoying if there is a break between two types of electrochemical measurements where no EC data is recorded, but the MS data is still relevant (eg because of a gas exchange at OCV). Of course, in some cases connecting the data is actually desired, so I would aim at having this somehow available as an option.

Additionally, it would also be nice if MS data where mass spectra are recorded at certain times would be plotted like Zilien does (i.e. with vertical lines when the spectrum starts and ends), but I can see how this is more tricky to implement, as the information is not necessarily available in the datafile (or is it?)

ScottSoren commented 2 years ago

Hi Anna,

I think for this, the best way is not to append the measurements. You can plot them on a shared axis by:

axes = meas_1.plot()
meas_2.plot(axes=axes)

I think that results in the plot you want.

I thought a bit about how to do this after appending the measurement, and it's annoying. The priority for ixdat is to seamlessly join data together. To keep that functionality, but have plotting not draw the connecting line, you'd have to change Measurement.grab() and Measurement.__getitem__() to behave in two different ways, appending data series sometimes and not other times, or (I'd prefer) make a copy of each of them that didn't append and use the latter in the plotting functions (except those other times when the user does want it to look continuous). Let me know if the above suggestion to coplot the measurements without appending them is acceptable.

AnnaWiniwarter commented 2 years ago

Hi Soren, Thanks for the suggestion. Yes, it works for me for now. But it does make my workflow more cumbersome. I usually start by importing and combining all the data from one experiment into one big object and then select the bits and pieces I want to treat separately. It would just be nice if ixdat could remember for me which of the files were separate at the beginning and I don't have to work with both the combined and separate datasets.

On the other hand, eventually I'm aiming for importing the full EC-MS dataset from the tsv file exported from Zilien instead of adding Zilien and ECLab files. The Zilien file of course doesn't have the information when an ECLab file starts and stops, so in that case I suppose I have to separate the files manually anyway. So then maybe I just have to live with the solution you suggested above...

ScottSoren commented 2 years ago

Oh, I see. And since you're making and EC-MS plot, the code is more cumbersome:

ecms_meas = ec_meas_1 + ms_meas
axes = ecms_meas.plot()
ec_meas_2.plot(axes=[axes[1], axes[3]])    # ixdat v0.2+. For v0.1.x, it's [axes[1], axes[2]].
...

But I also wonder if yours might be a special case?

Usually, at least with a Biologic potentiostat, one can design a compound measurement (which is conveniently imported with Measruement.read_set()) so that there are no gaps. If you want to change gas on OCV, you can just have an OCV step and a loop in the Biologic program. (And if you're in the stage of your project where you don't know exactly what Biologic program you want at the onset, maybe you're also in a stage where the plots don't have to be perfect?)

Forgive me for feeling a case of the Zen's "Now is better than never, although never is often better than right now", haha. Lets leave this open.

AnnaWiniwarter commented 2 years ago

I think I have a slightly different opinion on this one here: "And if you're in the stage of your project where you don't know exactly what Biologic program you want at the onset, maybe you're also in a stage where the plots don't have to be perfect?"

But I see that it might just be a lot of effort for something that will only help few users in very special cases, so I'll go with the workaround for now and we can continue this discussion at a later stage. :)