@@ -634,10 +634,79 @@ DLL_EXPORT bool load_and_integrate_spectra_volume(std::string dataset_directory,
634634 integrated_spectra->setZero (2048 );
635635 }
636636
637+ integrated_spectra->elapsed_livetime ((T_real)0.0 );
638+ integrated_spectra->elapsed_realtime ((T_real)0.0 );
639+ integrated_spectra->input_counts ((T_real)0.0 );
640+ integrated_spectra->output_counts ((T_real)0.0 );
637641
638- if (hasNetcdf)
642+ if (hasNetcdf)
639643 {
640644 dims[1 ] -= 2 ; // remove 2 for the scaler channels flys scan hardware trigger bug
645+ }
646+
647+ // tetramm is scalers only
648+ if (hasTetraMM)
649+ {
650+ // tetramm has 2 files it can save scalers. filename_tetra1_0.nc or filename_tetra2_0.nc
651+ std::ifstream file_io (dataset_directory + " tetramm" + DIR_END_CHAR + tmp_dataset_file + " _0.nc" );
652+ if (file_io.is_open ())
653+ {
654+ file_io.close ();
655+ std::string full_filename;
656+ for (size_t i = 0 ; i < dims[0 ]; i++)
657+ {
658+ full_filename = dataset_directory + " tetramm" + DIR_END_CHAR + tmp_dataset_file + " _" + std::to_string (i) + " .nc" ;
659+ // todo: add verbose option
660+ // logI<<"Loading file "<<full_filename<<"\n";
661+ // if tetramm tag is missing in file name, we assume it is tetra1
662+ size_t spec_size = io::file::NetCDF_IO<T_real>::inst ()->load_scalers_line (full_filename, " tetra1_" , i, mda_io.get_scan_info (), params_override);
663+ }
664+ }
665+ std::ifstream file_io1 (dataset_directory + " tetramm" + DIR_END_CHAR + tmp_dataset_file + " _tetra1_0.nc" );
666+ if (file_io1.is_open ())
667+ {
668+ file_io1.close ();
669+ std::string full_filename;
670+ for (size_t i = 0 ; i < dims[0 ]; i++)
671+ {
672+ full_filename = dataset_directory + " tetramm" + DIR_END_CHAR + tmp_dataset_file + " _tetra1_" + std::to_string (i) + " .nc" ;
673+ // todo: add verbose option
674+ // logI<<"Loading file "<<full_filename<<"\n";
675+ size_t spec_size = io::file::NetCDF_IO<T_real>::inst ()->load_scalers_line (full_filename, " tetra1_" , i, mda_io.get_scan_info (), params_override);
676+ }
677+ }
678+ std::ifstream file_io2 (dataset_directory + " tetramm" + DIR_END_CHAR + tmp_dataset_file + " _tetra2_0.nc" );
679+ if (file_io2.is_open ())
680+ {
681+ file_io2.close ();
682+ std::string full_filename;
683+ for (size_t i = 0 ; i < dims[0 ]; i++)
684+ {
685+ full_filename = dataset_directory + " tetramm" + DIR_END_CHAR + tmp_dataset_file + " _tetra2_" + std::to_string (i) + " .nc" ;
686+ // todo: add verbose option
687+ // logI<<"Loading file "<<full_filename<<"\n";
688+ size_t spec_size = io::file::NetCDF_IO<T_real>::inst ()->load_scalers_line (full_filename, " tetra2_" , i, mda_io.get_scan_info (), params_override);
689+ }
690+ }
691+ T_real val = mda_io.get_scan_info ()->scaler_avg_value (STR_US_IC);
692+ if (val > (T_real)0.0 )
693+ {
694+ params_override->US_IC = val;
695+ }
696+ val = mda_io.get_scan_info ()->scaler_avg_value (STR_DS_IC);
697+ if (val > (T_real)0.0 )
698+ {
699+ params_override->DS_IC = val;
700+ }
701+ val = mda_io.get_scan_info ()->scaler_avg_value (STR_US_FM);
702+ if (val > (T_real)0.0 )
703+ {
704+ params_override->US_FM = val;
705+ }
706+
707+ }
708+ if (hasNetcdf)
709+ {
641710 std::ifstream file_io (dataset_directory + " flyXRF" + DIR_END_CHAR + tmp_dataset_file + file_middle + " 0.nc" );
642711 if (file_io.is_open ())
643712 {
@@ -984,6 +1053,18 @@ DLL_EXPORT bool load_spectra_volume(std::string dataset_directory,
9841053 if (true == io::file::HDF5_IO::inst ()->load_spectra_vol_apsu (dataset_directory, dataset_file, detector_num, spectra_volume, scan_info_edf))
9851054 {
9861055 scan_type = scan_info_edf.meta_info .scan_type ;
1056+ if (save_scalers)
1057+ {
1058+ io::file::HDF5_IO::inst ()->start_save_seq (true );
1059+
1060+ // add ELT, ERT, INCNT, OUTCNT to scaler map
1061+ if (spectra_volume != nullptr )
1062+ {
1063+ spectra_volume->generate_scaler_maps (&(scan_info_edf.scaler_maps ));
1064+ }
1065+
1066+ io::file::HDF5_IO::inst ()->save_scan_scalers (&scan_info_edf, params_override);
1067+ }
9871068 return true ;
9881069 }
9891070 // try ESRF dataset
0 commit comments