@@ -100,7 +100,7 @@ NetCDF_IO<T_real>* NetCDF_IO<T_real>::inst()
100100
101101template <typename T_real>
102102size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
103- std::string path,
103+ const std::string& path,
104104 size_t detector,
105105 data_struct::Spectra_Line<T_real>* spec_line,
106106 size_t line_size,
@@ -117,7 +117,6 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
117117 size_t start[] = {0 , 0 , 0 };
118118 size_t count[] = {1 , 1 , 1047808 };
119119 ptrdiff_t stride[] = {1 , 1 , 1 };
120- T_real data_in[1 ][1 ][1050000 ] = {0 };
121120 size_t spectra_size = 0 ;
122121 nc_type rh_type;
123122 int rh_ndims = 0 ;
@@ -200,14 +199,14 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
200199 {
201200 start[0 ] = m0;
202201 // read header
203- if ( (retval = _nc_get_vars_real (ncid, varid, start, count, stride, &data_in [0 ][0 ][0 ]) ) != 0 )
202+ if ( (retval = _nc_get_vars_real (ncid, varid, start, count, stride, &_data_in [0 ][0 ][0 ]) ) != 0 )
204203 {
205204 logE<< nc_strerror (retval)<<" \n " ;
206205 nc_close (ncid);
207206 return col_idx;
208207 }
209208
210- if (data_in [0 ][0 ][0 ] != 21930 || data_in [0 ][0 ][1 ] != -21931 )
209+ if (_data_in [0 ][0 ][0 ] != 21930 || _data_in [0 ][0 ][1 ] != -21931 )
211210 {
212211 logE<<" NetCDF header [0][0][0] not found! Stopping load : " <<path<<" \n " ;
213212 nc_close (ncid);
@@ -224,17 +223,17 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
224223 d_idx += 2 * detector;
225224 }
226225
227- size_t dset_det = size_t (data_in [0 ][0 ][d_idx]);
226+ size_t dset_det = size_t (_data_in [0 ][0 ][d_idx]);
228227 if (dset_det != detector)
229228 {
230229 logE << " detector not found! " << dset_det <<" != " <<detector<<" Stopping load : " << path << " \n " ;
231230 nc_close (ncid);
232231 return (size_t )-1 ;
233232 }
234233
235- header_size = data_in [0 ][0 ][2 ];
236- cols_before_inc = data_in [0 ][0 ][8 ]; // sum all across the first dim looking at value 8
237- spectra_size = data_in [0 ][0 ][20 ];
234+ header_size = _data_in [0 ][0 ][2 ];
235+ cols_before_inc = _data_in [0 ][0 ][8 ]; // sum all across the first dim looking at value 8
236+ spectra_size = _data_in [0 ][0 ][20 ];
238237
239238 // size_t inc_size = ((header_size + (spectra_size * detector)) + (spectra_size * (MAX_NUM_SUPPORTED_DETECOTRS_PER_COL - detector)) );
240239 size_t inc_size = header_size + (spectra_size * MAX_NUM_SUPPORTED_DETECOTRS_PER_COL);
@@ -250,7 +249,7 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
250249 callback_spectra = new data_struct::Spectra<T_real>(spectra_size);
251250 }
252251
253- if (data_in [0 ][0 ][l] != 13260 || data_in [0 ][0 ][l+1 ] != -13261 )
252+ if (_data_in [0 ][0 ][l] != 13260 || _data_in [0 ][0 ][l+1 ] != -13261 )
254253 {
255254 if (col_idx < spec_cntr -2 )
256255 {
@@ -265,8 +264,8 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
265264 }
266265
267266
268- unsigned short i1 = data_in [0 ][0 ][l+ELAPSED_LIVETIME_OFFSET+(detector*8 )];
269- unsigned short i2 = data_in [0 ][0 ][l+ELAPSED_LIVETIME_OFFSET+(detector*8 )+1 ];
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 ];
270269 unsigned int ii = i1 | i2<<16 ;
271270 elapsed_livetime = ((float )ii) * 320e-9f ; // need to multiply by this value becuase of the way it is saved
272271 if (ltype == E_load_type::LINE)
@@ -298,8 +297,8 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
298297 callback_spectra->elapsed_livetime (elapsed_livetime);
299298 }
300299
301- i1 = data_in [0 ][0 ][l+ELAPSED_REALTIME_OFFSET+(detector*8 )];
302- i2 = data_in [0 ][0 ][l+ELAPSED_REALTIME_OFFSET+(detector*8 )+1 ];
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 ];
303302 ii = i1 | i2<<16 ;
304303 elapsed_realtime = ((float )ii) * 320e-9f ; // need to multiply by this value becuase of the way it is saved
305304 if (ltype == E_load_type::LINE)
@@ -331,8 +330,8 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
331330 callback_spectra->elapsed_realtime (elapsed_realtime);
332331 }
333332
334- i1 = data_in [0 ][0 ][l+INPUT_COUNTS_OFFSET+(detector*8 )];
335- i2 = data_in [0 ][0 ][l+INPUT_COUNTS_OFFSET+(detector*8 )+1 ];
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 ];
336335 ii = i1 | i2<<16 ;
337336 input_counts = ((float )ii) / elapsed_livetime;
338337 if (ltype == E_load_type::LINE)
@@ -365,8 +364,8 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
365364 }
366365
367366
368- i1 = data_in [0 ][0 ][l+OUTPUT_COUNTS_OFFSET+(detector*8 )];
369- i2 = data_in [0 ][0 ][l+OUTPUT_COUNTS_OFFSET+(detector*8 )+1 ];
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 ];
370369 ii = i1 | i2<<16 ;
371370 output_counts = ((float )ii) / elapsed_realtime;
372371 if (ltype == E_load_type::LINE)
@@ -405,22 +404,22 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
405404 (*spec_line)[col_idx].recalc_elapsed_livetime ();
406405 for (size_t k = 0 ; k < spectra_size; k++)
407406 {
408- (*spec_line)[col_idx][k] = data_in [0 ][0 ][l+k];
407+ (*spec_line)[col_idx][k] = _data_in [0 ][0 ][l+k];
409408 }
410409 }
411410 else if (ltype == E_load_type::INTEGRATED)
412411 {
413412 for (size_t k = 0 ; k < spectra_size; k++)
414413 {
415- (*spectra)(k) += data_in [0 ][0 ][l+k];
414+ (*spectra)(k) += _data_in [0 ][0 ][l+k];
416415 }
417416 }
418417 else if (ltype == E_load_type::CALLBACKF && callback_fun != nullptr )
419418 {
420419 callback_spectra->recalc_elapsed_livetime ();
421420 for (size_t k = 0 ; k < spectra_size; k++)
422421 {
423- (*callback_spectra)[k] = data_in [0 ][0 ][l+k];
422+ (*callback_spectra)[k] = _data_in [0 ][0 ][l+k];
424423 }
425424 (*callback_fun)(cur_row, col_idx, max_rows, line_size, detector, callback_spectra, user_data);
426425 }
@@ -458,23 +457,25 @@ size_t NetCDF_IO<T_real>::_load_spectra(E_load_type ltype,
458457// -----------------------------------------------------------------------------
459458
460459template <typename T_real>
461- size_t NetCDF_IO<T_real>::load_spectra_line(std::string path, size_t detector, data_struct::Spectra_Line<T_real>* spec_line)
460+ size_t NetCDF_IO<T_real>::load_spectra_line(const std::string& path, size_t detector, data_struct::Spectra_Line<T_real>* spec_line)
462461{
462+
463463 return _load_spectra (E_load_type::LINE, path, detector, spec_line, (size_t )-1 , nullptr , 0 , 0 , nullptr , nullptr );
464+
464465}
465466
466467// -----------------------------------------------------------------------------
467468
468469template <typename T_real>
469- size_t NetCDF_IO<T_real>::load_spectra_line_integrated(std::string path, size_t detector, size_t line_size, data_struct::Spectra<T_real>* spectra)
470+ size_t NetCDF_IO<T_real>::load_spectra_line_integrated(const std::string& path, size_t detector, size_t line_size, data_struct::Spectra<T_real>* spectra)
470471{
471472 return _load_spectra (E_load_type::INTEGRATED, path, detector, nullptr , line_size, spectra, 0 , 0 , nullptr , nullptr );
472473}
473474
474475// -----------------------------------------------------------------------------
475476
476477template <typename T_real>
477- bool NetCDF_IO<T_real>::load_spectra_line_with_callback(std::string path,
478+ bool NetCDF_IO<T_real>::load_spectra_line_with_callback(const std::string& path,
478479 const std::vector<size_t >& detector_num_arr,
479480 int row,
480481 size_t max_rows,
@@ -493,15 +494,14 @@ bool NetCDF_IO<T_real>::load_spectra_line_with_callback(std::string path,
493494// -----------------------------------------------------------------------------
494495
495496template <typename T_real>
496- size_t NetCDF_IO<T_real>::load_scalers_line(std::string path, std::string tag, size_t row, data_struct::Scan_Info<T_real>* scan_info, data_struct::Params_Override<T_real> * params_override)
497+ size_t NetCDF_IO<T_real>::load_scalers_line(const std::string& path, std::string tag, size_t row, data_struct::Scan_Info<T_real>* scan_info, data_struct::Params_Override<T_real> * params_override)
497498{
498499 std::lock_guard<std::mutex> lock (_mutex);
499500
500501 int ncid = 0 , varid = 0 , retval = 0 ;
501502 size_t start[] = {0 , 0 , 0 };
502503 size_t count[] = {1 , 1 , 1 };
503504 ptrdiff_t stride[] = {1 , 1 , 1 };
504- // T_real data_in[10000][1][11];
505505 T_real *data_in = nullptr ;
506506 size_t dim2size[NC_MAX_VAR_DIMS] = {0 };
507507 nc_type rh_type;
0 commit comments