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

JCAMPWriter (complex NMR Data) corrupts the ##XYDATA Block #3

Open cheminux opened 8 years ago

cheminux commented 8 years ago

Its me again, sorry for annoying you!

I read a jcamp file with complex nmr data (which works like a charm!) and write directly the produced data with the JCAMPWriter:

       Spectrum jcampSpectrum = null;
       nmrspectrum = (NMRSpectrum) jcampSpectrum;
       JCAMPWriter jwriter = JCAMPWriter.getInstance();
       FileWriter writer = new FileWriter(file);
       writer.write(jwriter.toJCAMP(nmrspectrum));

... Reading again the new jcamp file lead to multiple messages like:

WARNUNG: x check failed in line1: expected x = 1325727.744000001 but got 7716.745205020741 SCHWERWIEGEND: bad x check value

and

WARNUNG: incorrect ##NPOINTS= or bad ##XYDATA= found 154130, but ##NPOINTS= 131072, setting NPOINTS to 154130

In the end the spectrum is corrupt.

I get the same multiple messages from your test on compiling your source code.

What can I do to write correct nmr jcamp file?

Anyway I would like to thank you for the fantastic work with jcamp-dx. I appreciate your project and would like to use it intensively.

Best regards,

Sven

fracpete commented 8 years ago

This project is just a fork of the orphaned project on sf.net (https://sourceforge.net/projects/jcamp-dx/). Never used NMR data before. Have you tried this fork: https://github.com/kerner1000/jcamp-dx ?

cheminux commented 8 years ago

Mayn thanks for the hint.

But my first try with the above mentioned fork failed, I could not even read my data and I do not have time to look in detail.

Anyway I will use your code for my purpos and save my calculated data in separat file.

fracpete commented 8 years ago

Thanks for letting me know. Can you send through an example NMR file that exhibits this behavior?

cheminux commented 8 years ago

Any example show this behavior. E.g. in your test data with jcamp60.jdx (you have to remove all lines with starting with %% because the parser does not like them)

fracpete commented 8 years ago

The library only supports version 5.01 (at least according to NMRJCAMPWriter), not version 6.0. jcamp60.jdx is version 6.0, however.

laeubi commented 5 years ago

I also get corrupt (FID) data, try to read it back results in

org.jcamp.parser.JCAMPException: parsing failed
expecting EOL, found '-7'
    at org.jcamp.parser.ASDFDecoder.decode(ASDFDecoder.java:60)
    at org.jcamp.parser.JCAMPNTuplePage.getXYData(JCAMPNTuplePage.java:224)
    at org.jcamp.parser.NMRJCAMPReader.createFID(NMRJCAMPReader.java:130)
    at org.jcamp.parser.NMRJCAMPReader.createSpectrum(NMRJCAMPReader.java:325)
    at org.jcamp.parser.JCAMPReader.createSpectrum(JCAMPReader.java:109)
fracpete commented 5 years ago

I only use the library for NIR data.

laeubi commented 5 years ago

I have debugged a little bit and it seems that either the parser or the generator for the compressed data has some problem, I had to read the spec a little bit more to understand what happens. It might also be good to have a uncompressed version of data available but currently all that stuff is hardcoded.