@@ -501,9 +501,10 @@ public void ImportDocumentGBS(DocEnergySpectrum doc, string filePath)
501
501
doc . Filename = fileName + ".xml" ;
502
502
doc . Text = fileName ;
503
503
504
- // $SPEC_ID:
504
+ // From https://www.gbs-elektronik.de/media/download_gallery/Ritecdat_e.pdf
505
+ // $SPEC_ID: or $APPLICATION_ID: or $DEVICE_ID:
505
506
string fileheader = streamReader . ReadLine ( ) ;
506
- if ( fileheader != "$SPEC_ID:" )
507
+ if ( fileheader != "$SPEC_ID:" && fileheader != "$APPLICATION_ID:" && fileheader != "$DEVICE_ID:" )
507
508
{
508
509
throw new Exception ( String . Format ( Resources . ERROpenGBSFormat , fileheader ) ) ;
509
510
}
@@ -571,16 +572,15 @@ public void ImportDocumentGBS(DocEnergySpectrum doc, string filePath)
571
572
fileheader = streamReader . ReadLine ( ) ;
572
573
while ( true )
573
574
{
574
- if ( fileheader == "$ENER_DATA :" ) break ;
575
+ if ( fileheader == "$ENER_DATA_X :" ) break ;
575
576
fileheader = streamReader . ReadLine ( ) ;
576
577
}
577
578
578
- // skip first string
579
- streamReader . ReadLine ( ) ;
579
+ int numpoints = XmlConvert . ToInt32 ( streamReader . ReadLine ( ) . Trim ( ) ) ;
580
580
581
581
// read base calibration
582
582
List < CalibrationPoint > points = new List < CalibrationPoint > ( ) ;
583
- for ( int i = 0 ; i < 3 ; i ++ )
583
+ for ( int i = 0 ; i < numpoints ; i ++ )
584
584
{
585
585
string calibrationData = streamReader . ReadLine ( ) ;
586
586
int channel = XmlConvert . ToInt32 ( calibrationData . Split ( new string [ ] { " " } , StringSplitOptions . RemoveEmptyEntries ) [ 0 ] . Trim ( ) ) ;
@@ -590,7 +590,7 @@ public void ImportDocumentGBS(DocEnergySpectrum doc, string filePath)
590
590
points . Add ( point ) ;
591
591
}
592
592
593
- double [ ] matrix = Utils . CalibrationSolver . Solve ( points , 2 ) ;
593
+ double [ ] matrix = Utils . CalibrationSolver . Solve ( points , numpoints - 1 ) ;
594
594
PolynomialEnergyCalibration energyCalibration = ( PolynomialEnergyCalibration ) energySpectrum . EnergyCalibration ;
595
595
energyCalibration . Coefficients = new double [ matrix . Length ] ;
596
596
energyCalibration . PolynomialOrder = matrix . Length - 1 ;
@@ -611,7 +611,7 @@ public void ImportDocumentGBS(DocEnergySpectrum doc, string filePath)
611
611
612
612
int TotalPulseCount = XmlConvert . ToInt32 ( streamReader . ReadLine ( ) . Trim ( ) ) ;
613
613
energySpectrum . TotalPulseCount = TotalPulseCount ;
614
- energySpectrum . ValidPulseCount = energySpectrum . Spectrum . Sum ( ) ;
614
+ energySpectrum . ValidPulseCount = TotalPulseCount ;
615
615
616
616
streamReader . Close ( ) ;
617
617
}
0 commit comments