Skip to content

Commit bbc1c00

Browse files
author
Arthur Glowacki
committed
Fixed issue not loading detector greater than 3
1 parent 32c7756 commit bbc1c00

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/io/file/netcdf_io.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
179179

180180
size_t col_idx = 0;
181181

182+
size_t idx_detector = detector;
182183
if (detector > 3)
183184
{
184-
detector -= MAX_NUM_SUPPORTED_DETECOTRS_PER_COL; // 4,5,6,7 = 0,1,2,3
185+
idx_detector -= MAX_NUM_SUPPORTED_DETECOTRS_PER_COL; // 4,5,6,7 = 0,1,2,3
185186
}
186187

187188
size_t spec_cntr = 0;
@@ -235,7 +236,7 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
235236
cols_before_inc = _data_in[0][0][8]; //sum all across the first dim looking at value 8
236237
spectra_size = _data_in[0][0][20];
237238

238-
//size_t inc_size = ((header_size + (spectra_size * detector)) + (spectra_size * (MAX_NUM_SUPPORTED_DETECOTRS_PER_COL - detector)) );
239+
//size_t inc_size = ((header_size + (spectra_size * idx_detector)) + (spectra_size * (MAX_NUM_SUPPORTED_DETECOTRS_PER_COL - idx_detector)) );
239240
size_t inc_size = header_size + (spectra_size * MAX_NUM_SUPPORTED_DETECOTRS_PER_COL);
240241
for(size_t m1 = 0; m1 < cols_before_inc; m1++)
241242
{
@@ -264,8 +265,8 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
264265
}
265266

266267

267-
unsigned short i1 = _data_in[0][0][l+ELAPSED_LIVETIME_OFFSET+(detector*8)];
268-
unsigned short i2 = _data_in[0][0][l+ELAPSED_LIVETIME_OFFSET+(detector*8)+1];
268+
unsigned short i1 = _data_in[0][0][l+ELAPSED_LIVETIME_OFFSET+(idx_detector*8)];
269+
unsigned short i2 = _data_in[0][0][l+ELAPSED_LIVETIME_OFFSET+(idx_detector*8)+1];
269270
unsigned int ii = i1 | i2<<16;
270271
elapsed_livetime = ((T_real)ii) * 320e-9f; // need to multiply by this value becuase of the way it is saved
271272
if (ltype == E_load_type::LINE)
@@ -297,8 +298,8 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
297298
callback_spectra->elapsed_livetime(elapsed_livetime);
298299
}
299300

300-
i1 = _data_in[0][0][l+ELAPSED_REALTIME_OFFSET+(detector*8)];
301-
i2 = _data_in[0][0][l+ELAPSED_REALTIME_OFFSET+(detector*8)+1];
301+
i1 = _data_in[0][0][l+ELAPSED_REALTIME_OFFSET+(idx_detector*8)];
302+
i2 = _data_in[0][0][l+ELAPSED_REALTIME_OFFSET+(idx_detector*8)+1];
302303
ii = i1 | i2<<16;
303304
elapsed_realtime = ((T_real)ii) * 320e-9f; // need to multiply by this value becuase of the way it is saved
304305
if (ltype == E_load_type::LINE)
@@ -330,8 +331,8 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
330331
callback_spectra->elapsed_realtime(elapsed_realtime);
331332
}
332333

333-
i1 = _data_in[0][0][l+INPUT_COUNTS_OFFSET+(detector*8)];
334-
i2 = _data_in[0][0][l+INPUT_COUNTS_OFFSET+(detector*8)+1];
334+
i1 = _data_in[0][0][l+INPUT_COUNTS_OFFSET+(idx_detector*8)];
335+
i2 = _data_in[0][0][l+INPUT_COUNTS_OFFSET+(idx_detector*8)+1];
335336
ii = i1 | i2<<16;
336337
input_counts = ((T_real)ii) / elapsed_livetime;
337338
if (ltype == E_load_type::LINE)
@@ -364,8 +365,8 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
364365
}
365366

366367

367-
i1 = _data_in[0][0][l+OUTPUT_COUNTS_OFFSET+(detector*8)];
368-
i2 = _data_in[0][0][l+OUTPUT_COUNTS_OFFSET+(detector*8)+1];
368+
i1 = _data_in[0][0][l+OUTPUT_COUNTS_OFFSET+(idx_detector*8)];
369+
i2 = _data_in[0][0][l+OUTPUT_COUNTS_OFFSET+(idx_detector*8)+1];
369370
ii = i1 | i2<<16;
370371
output_counts = ((T_real)ii) / elapsed_realtime;
371372
if (ltype == E_load_type::LINE)
@@ -397,7 +398,7 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
397398
callback_spectra->output_counts(output_counts);
398399
}
399400

400-
l += header_size + (spectra_size * detector);
401+
l += header_size + (spectra_size * idx_detector);
401402
if (ltype == E_load_type::LINE)
402403
{
403404
// recalculate elapsed lifetime

0 commit comments

Comments
 (0)