cheminfo / chromatography

Tools for storing, search and analyze GC/MS spectra
https://cheminfo.github.io/chromatography
MIT License
9 stars 5 forks source link

Create a class for Serie #16

Closed lpatiny closed 7 years ago

maasencioh commented 7 years ago

What could be the advantage of this?

lpatiny commented 7 years ago

The advantage would be to have methods related to a serie. Tic is actually a kind of reduce of a 2D serie. This could be a method of serie therefore.

If we want to be fast it would not use the array.reduce however.

I think we could add like that more and more methods at the level of the serie.

lpatiny commented 7 years ago

At the debugging point of view it would also allow to see that it is a 'Serie' which makes it more clear. It also force you to create a serie with the right variables. Currently I had no clue how to create a Serie.

I would see a code to create from scratch a chromatogram:

var chromatogram = new Chromatogram();
chromatogram.setTimes([1,2,3]);
var tic = new Serie(1);
tic.setData([10,20,30]);
chromatogram.putSerie('tic',tic);
function putSerie(name, serie) {
 series[name]=serie;
}

So you could have: