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

NMRJCAMPReader->getShiftReferencePoint(JCAMPBlock block) #4

Closed cheminux closed 8 years ago

cheminux commented 8 years ago

The function getShiftReferencePoint() should throw a JCAMPException if ldrShiftReference == null and not return 0:

private int getShiftReferencePoint(JCAMPBlock block) throws JCAMPException {
    JCAMPDataRecord ldrShiftReference = block
            .getDataRecord(".SHIFTREFERENCE");
    if (ldrShiftReference == null) {
        if (log.isWarnEnabled()) {
            log.warn("Missing data record .SHIFTREFERENCE, assuming 0");
        }
        return 0;
    ...

because in the function NMRSpectrum createFS(JCAMPBlock block) the reference is set to refPoint=0 if the ##.SHIFTREFERENCE variable is not available which mess the x range up. If a JCAMPException would be thrown the reference would be set correctly by getShiftReference(block) in the catch clause...

  protected NMRSpectrum createFS(JCAMPBlock block) throws JCAMPException {
        ...
        ...
                    double reference = Double.NaN;
        try {
            int refPoint = getShiftReferencePoint(block);
            reference = x.pointAt(refPoint);
        } catch (JCAMPException e) {
            reference = getShiftReference(block);
        }
        double freq = getFrequency(block);
        ...
        ...

Best regards, Sven

Sorry it is not a pull request, it should be issue for kerne1000:master.