fracpete / jcamp-dx

Reference implemention of the IUPAC JCAMP-DX spectroscopy data standard. Fork of https://sourceforge.net/projects/jcamp-dx/
Other
7 stars 7 forks source link

PeakTable Marshaller produce a XX-Table and not a XY-Table #2

Closed cheminux closed 8 years ago

cheminux commented 8 years ago

After reading jcamp file with nmr data. I add a peaktable manually by

          Peak1D[] peaks = new Peak1D[peakdata.length];
            for (int i = 0; i < peakdata.length; i++) {
                peaks[i] = new Peak1D(peakdata[i][x], peakdata[i][x]);
            }
           NMRSpectrum.setPeakTable(peaks);

Afterward NMRSpectrum object look ok in the debugger. But the JCAMPWriter produce a file with a peaktable containing only x,x pairs:

PEAKTABLE=(XY..XY)

x1,x1 x2,x2 .....

Regards Sven

cheminux commented 8 years ago

Changing the NMRJCAMPWriter.java:

buildPeakTable(int block, NMRSpectrum nmr){ ... jcamp.append("##PEAKTABLE=(XY..XY)").append(CRLF); for (int i = 0; i < n; i++) { double x = peaks[i].getPosition()[0]; double y = peaks[i].getPosition()[1]; jcamp.append(x).append(',').append(y).append(CRLF); } jcamp.append("##END=").append(CRLF); ... }

to

buildPeakTable(int block, NMRSpectrum nmr){ ... jcamp.append("##PEAKTABLE=(XY..XY)").append(CRLF); for (int i = 0; i < n; i++) { double x = peaks[i].getPosition()[0]; double y = peaks[i].getHeight(); jcamp.append(x).append(',').append(y).append(CRLF); } jcamp.append("##END=").append(CRLF); ... }

fix my problem.

But I do not know how you would like to write a X-Range!?

fracpete commented 8 years ago

I only use it for NIR, not NMR. Have you had a look at the specs? http://www.jcamp-dx.org/protocols.html

cheminux commented 8 years ago

Thanks againt for the very fast answer!

I checked the specs... In JCAMP-DX for NMR there is a peaktable definition in chapter 5.4.3. Do I misinterpret the definition?

fracpete commented 8 years ago

Here's how I understand it. The peaktable merely lists the coordinates where there is a peak. It doesn't actually store the peak height, as the height can be obtained from the spectral data (at the specified position). NMR data is two-dimensional, x and height. Other spectra might be three-dimensional, with x, y and height. To cut a long story short, I think it is correct that for NMR data, the peak table stores x,x in the file, as there is no X..X format available.

cheminux commented 8 years ago

But in the peak table definition from (5.4.3@JCAMP-DX for NMR;http://www.jcamp-dx.org/protocols.html) is written:

(5.4.3) ##PEAK TABLE= (STRING). Contains a table of peaks. For abscissa against intensity, the variable list (XY..XY) should be used. For peak position, intensity, and width, the variable list would be (XYW..XYW) ?

I tested the kerner100 sources and there the peak table is written as I expect?

fracpete commented 8 years ago

Sorry, you're right about the definition. However, if you do a diff on the NMRJCAMPWriter writers, then you'll see that there is no difference between kerner1000 and this one here.

cheminux commented 8 years ago

OK thnaks for the definition confirmation.

And yes you are right there is now difference between the orignal code...I changed the kerner1000 code before I did the diff ;-)

fracpete commented 8 years ago

Committed your proposed fix, using double y = peaks[i].getHeight(); instead of double y = peaks[i].getPosition()[1];.