Skip to content

Commit 4033472

Browse files
author
Arthur Glowacki
committed
Fix for MacOS release mode not reading in values as short causing ELT to be bad
1 parent 41e16ed commit 4033472

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

src/io/file/netcdf_io.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,14 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
265265
}
266266

267267

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];
270-
unsigned int ii = i1 | i2<<16;
268+
unsigned int i1 = static_cast<unsigned int>(_data_in[0][0][l+ELAPSED_LIVETIME_OFFSET+(idx_detector*8)]);
269+
unsigned int i2 = static_cast<unsigned int>(_data_in[0][0][l+ELAPSED_LIVETIME_OFFSET+(idx_detector*8)+1]);
270+
i1 = (0x0000ffff & i1);
271+
i2 = (i2 << 16) & 0xffff0000;
272+
unsigned int ii = i1 | i2;
271273
elapsed_livetime = ((T_real)ii) * 320e-9f; // need to multiply by this value becuase of the way it is saved
274+
logE<<_data_in[0][0][l+ELAPSED_LIVETIME_OFFSET+(idx_detector*8)]<<" :: "<<ii<<"\n";
275+
logW<<"i1["<<l+ELAPSED_LIVETIME_OFFSET+(idx_detector*8)<<"] : "<<i1<<" :: ii2 : "<<i2<<" :: elt : "<<elapsed_livetime<<" ---- \n";
272276
if (ltype == E_load_type::LINE)
273277
{
274278
if (elapsed_livetime == 0)
@@ -298,9 +302,11 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
298302
callback_spectra->elapsed_livetime(elapsed_livetime);
299303
}
300304

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];
303-
ii = i1 | i2<<16;
305+
i1 = static_cast<unsigned int>(_data_in[0][0][l+ELAPSED_REALTIME_OFFSET+(idx_detector*8)]);
306+
i2 = static_cast<unsigned int>(_data_in[0][0][l+ELAPSED_REALTIME_OFFSET+(idx_detector*8)+1]);
307+
i1 = (0x0000ffff & i1);
308+
i2 = (i2 << 16) & 0xffff0000;
309+
ii = i1 | i2;
304310
elapsed_realtime = ((T_real)ii) * 320e-9f; // need to multiply by this value becuase of the way it is saved
305311
if (ltype == E_load_type::LINE)
306312
{
@@ -331,9 +337,11 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
331337
callback_spectra->elapsed_realtime(elapsed_realtime);
332338
}
333339

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];
336-
ii = i1 | i2<<16;
340+
i1 = static_cast<unsigned int>(_data_in[0][0][l+INPUT_COUNTS_OFFSET+(idx_detector*8)]);
341+
i2 = static_cast<unsigned int>(_data_in[0][0][l+INPUT_COUNTS_OFFSET+(idx_detector*8)+1]);
342+
i1 = (0x0000ffff & i1);
343+
i2 = (i2 << 16) & 0xffff0000;
344+
ii = i1 | i2;
337345
input_counts = ((T_real)ii) / elapsed_livetime;
338346
if (ltype == E_load_type::LINE)
339347
{
@@ -365,9 +373,11 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
365373
}
366374

367375

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];
370-
ii = i1 | i2<<16;
376+
i1 = static_cast<unsigned int>(_data_in[0][0][l+OUTPUT_COUNTS_OFFSET+(idx_detector*8)]);
377+
i2 = static_cast<unsigned int>(_data_in[0][0][l+OUTPUT_COUNTS_OFFSET+(idx_detector*8)+1]);
378+
i1 = (0x0000ffff & i1);
379+
i2 = (i2 << 16) & 0xffff0000;
380+
ii = i1 | i2;
371381
output_counts = ((T_real)ii) / elapsed_realtime;
372382
if (ltype == E_load_type::LINE)
373383
{

0 commit comments

Comments
 (0)