sandialabs / SpecUtils

A library for opening, manipulating, and exporting gamma spectral files
GNU Lesser General Public License v2.1
27 stars 9 forks source link

BecqMoni files not loading #16

Closed ckuethe closed 1 year ago

ckuethe commented 1 year ago

@Am6er reported in commitcomment-131492754 that there are some files that don't load correctly in InterSpec.

When I use my n42validate tool, the files all fail to validate against the N42 schema. It appears that calibration polynomials can only go up to quadratic. I made the same assumption when loading radiacode generated files. I can probably do a quick patch to not reject files with higher order calibration polynomials, but maybe emit a warning.

n42validate Calibration\ 13.01.2023.N42 
[ERROR] Calibration 13.01.2023.N42
failed validating [-5.90955288142523, 0.375881542623178, 8.4487324360803e-06, -5.64086320297731e-10, 1.22453656607698e-14] with XsdLengthFacet(value=3, fixed=True):

Reason: length has to be 3

Schema:

  <xsd:length xmlns:xsd="http://www.w3.org/2001/XMLSchema" value="3" fixed="true">
    <xsd:annotation>
      <xsd:documentation>Three and only three coefficient values are allowed.</xsd:documentation>
    </xsd:annotation>
  </xsd:length>

Instance:

  <n42:CoefficientValues xmlns:n42="http://physics.nist.gov/N42/2011/N42">-5.90955288142523 0.375881542623178 8.4487324360803E-06 -5.64086320297731E-10 1.22453656607698E-14 </n42:CoefficientValues>

Path: /{http://physics.nist.gov/N42/2011/N42}RadInstrumentData/{http://physics.nist.gov/N42/2011/N42}EnergyCalibration[1]/{http://physics.nist.gov/N42/2011/N42}CoefficientValues

---------------------------------------------------------------------------
Am6er commented 1 year ago

@ckuethe yes, that is true. N42 doesn't have object definition for extra polynom coefficients up to 4 and this is bad. Because we about 2 years used this calibration for CsI spectrometers to achieve calibration with 3% error at low energies (about 30keV - 400 keV)

wcjohns commented 1 year ago

In my opinion, this is a defect in the N42 specification - more coefficients should be allowed.

However, if you are using more than three coefficients, you should instead consider using non-linear deviation pairs; this way changes in temperature, or over time, can be accommodated with just the gain (linear) coefficient. However, this brings up another deficiency in the specification, that the non-linear deviation coefficients are not defined - for this, see https://github.com/sandialabs/SpecUtils/blob/36283b39a2292bd7baeac0daeb6f86c3701abc80/SpecUtils/EnergyCalibration.h#L444

wcjohns commented 1 year ago

Also, see issue #12 . Specifically, there are a few other issues in N42 files output by SpecUtils/InterSpec.

Commit 36283b39a2292bd7baeac0daeb6f86c3701abc80 fixed opening BecqMoni files (hopefully all of them), and issue #12 covers the remaining portions of this issue.

@ckuethe Thanks for linking to your XSD validation tool!