def get_mask_hotpix(sp) : if sp.mask_hotpix != None : return sp.mask_hotpix sp.mask_hotpix = gu.get_array_from_file(fnm.path_hotpix_mask()) if sp.mask_hotpix != None and cp.mask_hot_is_used.value() : logger.info('HOTPIX mask is taken from file ' + fnm.path_hotpix_mask(), __name__) else : sp.mask_hotpix = np.ones((sp.rows,sp.cols), dtype=np.uint8) #sp.mask_hotpix = sp.get_random_binomial_img(p=0.99) logger.info('HOTPIX mask is not applied', __name__) return sp.mask_hotpix
def get_mask_hotpix(sp) : if sp.mask_hotpix != None : return sp.mask_hotpix sp.mask_hotpix = gu.get_array_from_file(fnm.path_hotpix_mask()) if sp.mask_hotpix != None : logger.info('HOTPIX mask is taken from file ' + fnm.path_hotpix_mask(), __name__) else : sp.mask_hotpix = np.ones((sp.rows,sp.cols), dtype=np.uint8) #sp.mask_hotpix = sp.get_random_binomial_img(p=0.99) logger.info('HOTPIX mask is not applied', __name__) return sp.mask_hotpix
def get_list_of_deploy_commands_and_sources_dark(str_run_number, str_run_range): """Get list of deploy commands for all detectors of the same type""" cp.str_run_number.setValue(str_run_number) #cp.blsp.print_list_of_types_and_sources() list_of_dtypes, list_of_sources, list_of_ctypes = cp.blsp.list_of_types_and_sources_for_selected_detectors( ) # list_of_dtypes : ['CsPad::DataV1', 'CsPad::DataV1'] # list_of_sources : ['CxiDs1.0:Cspad.0', 'CxiDsd.0:Cspad.0'] # list_of_ctypes : ['CsPad::CalibV1', 'CsPad::CalibV1'] #print 'list_of_dtypes :', list_of_dtypes #print 'list_of_sources:', list_of_sources #print 'list_of_ctypes :', list_of_ctypes list_of_deploy_commands = get_list_of_deploy_commands_for_calibtype( list_of_ctypes, list_of_dtypes, list_of_sources, fnm.path_peds_ave(), 'pedestals', str_run_range) list_of_deploy_commands += get_list_of_deploy_commands_for_calibtype( list_of_ctypes, list_of_dtypes, list_of_sources, fnm.path_peds_rms(), 'pixel_rms', str_run_range) if cp.dark_deploy_hotpix.value(): list_of_deploy_commands += get_list_of_deploy_commands_for_calibtype( list_of_ctypes, list_of_dtypes, list_of_sources, fnm.path_hotpix_mask(), 'pixel_status', str_run_range) return list_of_deploy_commands, list_of_sources
def make_psana_cfg_file_for_peds_aver_v1 (self) : self.path_in = apputils.AppDataPath('CorAna/scripts/psana-peds-aver.cfg').path() self.path_out = fnm.path_peds_aver_psana_cfg() self.d_subs = {'FNAME_XTC' : fnm.path_dark_xtc_cond(), 'SKIP' : str( cp.bat_dark_start.value() - 1 ), 'EVENTS' : str( cp.bat_dark_end.value() - cp.bat_dark_start.value() + 1 ), 'IMG_REC_MODULE' : str( cp.bat_img_rec_mod.value() ), 'DETINFO' : str( cp.bat_det_info.value() ), 'FNAME_PEDS_AVE' : fnm.path_pedestals_ave(), 'FNAME_PEDS_RMS' : fnm.path_pedestals_rms() } self.d_subs['FNAME_HOTPIX_MASK' ] = fnm.path_hotpix_mask() self.d_subs['HOTPIX_THRESHOLD_ADU'] = str( cp.mask_hot_thr.value() ) #if cp.mask_hot_is_used.value() : # self.d_subs['FNAME_HOTPIX_MASK' ] = fnm.path_hotpix_mask() # self.d_subs['HOTPIX_THRESHOLD_ADU'] = str( cp.mask_hot_thr.value() ) #else : # self.d_subs['FNAME_HOTPIX_MASK' ] = '' # self.d_subs['HOTPIX_THRESHOLD_ADU'] = '10000' #self.print_substitution_dict() #self.make_cfg_file() txt_cfg = self.text_for_section() self.save_cfg_file(txt_cfg, self.path_out)
def make_psana_cfg_file_for_peds_aver(self): self.path_in = apputils.AppDataPath( 'CorAna/scripts/psana-peds-aver.cfg').path() self.path_out = fnm.path_peds_aver_psana_cfg() self.d_subs = { 'FNAME_XTC': fnm.path_dark_xtc_cond(), 'SKIP': str(cp.bat_dark_start.value() - 1), 'EVENTS': str(cp.bat_dark_end.value() - cp.bat_dark_start.value() + 1), 'IMG_REC_MODULE': str(cp.bat_img_rec_mod.value()), 'DETINFO': str(cp.bat_det_info.value()), 'FNAME_PEDS_AVE': fnm.path_pedestals_ave(), 'FNAME_PEDS_RMS': fnm.path_pedestals_rms() } self.d_subs['FNAME_HOTPIX_MASK'] = fnm.path_hotpix_mask() self.d_subs['HOTPIX_THRESHOLD_ADU'] = str(cp.mask_hot_thr.value()) #if cp.mask_hot_is_used.value() : # self.d_subs['FNAME_HOTPIX_MASK' ] = fnm.path_hotpix_mask() # self.d_subs['HOTPIX_THRESHOLD_ADU'] = str( cp.mask_hot_thr.value() ) #else : # self.d_subs['FNAME_HOTPIX_MASK' ] = '' # self.d_subs['HOTPIX_THRESHOLD_ADU'] = '10000' self.print_substitution_dict() self.make_cfg_file()
def cfg_file_body_for_peds_aver(self) : txt_cfg_body = '#Module parameters' self.ind = 0 for det_name in cp.list_of_dets_selected() : lst_tepes, lst_srcs = cp.blsp.list_of_types_and_sources_for_detector(det_name) list_path_peds_ave = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_ave(), lst_srcs) list_path_peds_rms = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_rms(), lst_srcs) list_path_hotpix_mask = gu.get_list_of_files_for_list_of_insets(fnm.path_hotpix_mask(), lst_srcs) if self.do_test_print : print 'Detector selected: %10s' % (det_name), ' sources:', lst_srcs for (self.source, self.fname_ave, self.fname_rms, self.fname_mask) in zip(lst_srcs, list_path_peds_ave, list_path_peds_rms, list_path_hotpix_mask) : self.ind += 1 #print self.ind, self.source, self.fname_ave, self.fname_rms # list_of_dets = ['CSPAD', 'CSPAD2x2', 'Princeton', 'pnCCD', 'Tm6740', 'Opal2000', 'Opal4000', 'Acqiris'] #if det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPadPedestals') #elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPad2x2Pedestals') if det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPadNDArrProducer') elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPad2x2NDArrProducer') elif det_name == cp.list_of_dets[2] : self.add_cfg_module_peds_aver_princeton() elif det_name == cp.list_of_dets[3] : self.add_cfg_module_peds_aver_pnccd_ndarr() #elif det_name == cp.list_of_dets[3] : self.add_cfg_module_peds_aver_pnccd_img() elif det_name == cp.list_of_dets[4] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[5] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[6] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[7] : self.add_cfg_module_peds_aver_acqiris() elif det_name == cp.list_of_dets[8] : self.print_warning() else : logger.warning('UNKNOWN DETECTOR: %s' % det_name, __name__)
def cfg_file_body_for_peds_aver(self) : txt_cfg_body = '#Module parameters' self.ind = 0 for det_name in cp.list_of_dets_selected() : lst_tepes, lst_srcs = cp.blsp.list_of_types_and_sources_for_detector(det_name) list_path_peds_ave = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_ave(), lst_srcs) list_path_peds_rms = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_rms(), lst_srcs) list_path_hotpix_mask = gu.get_list_of_files_for_list_of_insets(fnm.path_hotpix_mask(), lst_srcs) if self.do_test_print : print 'Detector selected: %10s' % (det_name), ' sources:', lst_srcs for (self.source, self.fname_ave, self.fname_rms, self.fname_mask) in zip(lst_srcs, list_path_peds_ave, list_path_peds_rms, list_path_hotpix_mask) : self.ind += 1 #print self.ind, self.source, self.fname_ave, self.fname_rms # list_of_dets = ['CSPAD', 'CSPAD2x2', 'Princeton', 'pnCCD', 'Tm6740', 'Opal2000', 'Opal4000', 'Acqiris'] #if det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPadPedestals') #elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPad2x2Pedestals') if det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPadNDArrProducer') elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPad2x2NDArrProducer') elif det_name == cp.list_of_dets[2] : self.add_cfg_module_peds_aver_princeton() elif det_name == cp.list_of_dets[3] : self.add_cfg_module_peds_aver_pnccd() elif det_name == cp.list_of_dets[4] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[5] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[6] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[7] : self.add_cfg_module_peds_aver_acqiris() elif det_name == cp.list_of_dets[8] : self.print_warning() else : logger.warning('UNKNOWN DETECTOR: %s' % det_name, __name__)
def add_cfg_module_ndarraverage_for_peds_aver (self) : self.path_in = apputils.AppDataPath('CorAna/scripts/psana-module-ndarraverage.cfg').path() mod = 'ImgAlgos.NDArrAverage' self.d_subs = { 'MODULE' : mod, 'DETINFO' : str( cp.bat_det_info.value() ), 'IMAGE' : 'img', 'FNAME_AVE' : fnm.path_pedestals_ave(), 'FNAME_RMS' : fnm.path_pedestals_rms(), 'FNAME_MASK' : fnm.path_hotpix_mask(), 'THR_RMS_ADU' : str( cp.mask_hot_thr.value() ), 'PRINT_BITS' : '57' } self.add_module_in_cfg (mod)
def add_cfg_module_ndarraverage_for_peds_aver(self): self.path_in = apputils.AppDataPath( 'CorAna/scripts/psana-module-ndarraverage.cfg').path() mod = 'ImgAlgos.NDArrAverage' self.d_subs = { 'MODULE': mod, 'DETINFO': str(cp.bat_det_info.value()), 'IMAGE': 'img', 'FNAME_AVE': fnm.path_pedestals_ave(), 'FNAME_RMS': fnm.path_pedestals_rms(), 'FNAME_MASK': fnm.path_hotpix_mask(), 'THR_RMS_ADU': str(cp.mask_hot_thr.value()), 'PRINT_BITS': '57' } self.add_module_in_cfg(mod)
def cfg_file_body_for_peds_aver(self) : txt_cfg_body = '#Module parameters' self.ind = 0 for det_name in cp.list_of_dets_selected() : lst_types, lst_srcs, lst_ctypes = cp.blsp.list_of_types_and_sources_for_detector(det_name) list_path_peds_ave = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_ave(), lst_srcs) list_path_peds_rms = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_rms(), lst_srcs) list_path_hotpix_mask = gu.get_list_of_files_for_list_of_insets(fnm.path_hotpix_mask(), lst_srcs) if self.do_test_print : print 'Detector selected: %10s' % (det_name), ' sources:', lst_srcs for (self.source, self.fname_ave, self.fname_rms, self.fname_mask) in zip(lst_srcs, list_path_peds_ave, list_path_peds_rms, list_path_hotpix_mask) : self.ind += 1 #print self.ind, self.source, self.fname_ave, self.fname_rms #list_of_dets = ['CSPAD', 'CSPAD2x2', 'Princeton', 'pnCCD', 'Tm6740', 'Opal1000', 'Opal2000', 'Opal4000', 'Opal8000', \ # 'OrcaFl40', 'Epix', 'Epix10k', 'Epix100a', 'Fccd960', 'Andor', 'Acqiris'] #if det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPadPedestals') #elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPad2x2Pedestals') if det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPadNDArrProducer') elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPad2x2NDArrProducer') elif det_name == cp.list_of_dets[2] : self.add_cfg_module_peds_aver_princeton() elif det_name == cp.list_of_dets[3] : self.add_cfg_module_peds_aver_pnccd_ndarr() #elif det_name == cp.list_of_dets[3] : self.add_cfg_module_peds_aver_pnccd_img() elif det_name == cp.list_of_dets[4] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[5] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[6] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[7] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[8] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[9] : self.add_cfg_module_peds_aver_camera() elif det_name == cp.list_of_dets[10]: self.add_cfg_module_peds_aver_epix() elif det_name == cp.list_of_dets[11]: self.add_cfg_module_peds_aver_epix() elif det_name == cp.list_of_dets[12]: self.add_cfg_module_peds_aver_epix() elif det_name == cp.list_of_dets[13]: self.add_cfg_module_peds_aver_camera(out_dtype='int') elif det_name == cp.list_of_dets[14]: self.add_cfg_module_peds_aver_andor() elif det_name == cp.list_of_dets[15]: self.add_cfg_module_peds_aver_acqiris() elif det_name == cp.list_of_dets[16]: self.print_warning() else : logger.warning('UNKNOWN DETECTOR: %s' % det_name, __name__) if self.ind > 0 : return True msg = 'Selected detectors NOT FOUND in the list of keys in xtc scan log file !!!' logger.warning(msg, __name__) return False
def get_list_of_deploy_commands_and_sources(self): """Get list of deploy commands for all detectors of the same type""" self.exportLocalPars() #cp.blsp.print_list_of_types_and_sources() list_of_types, list_of_sources = cp.blsp.list_of_types_and_sources_for_selected_detectors( ) # list_of_types : ['CsPad::DataV1', 'CsPad::DataV1'] # list_of_sources: ['CxiDs1.0:Cspad.0', 'CxiDsd.0:Cspad.0'] list_of_deploy_commands = self.get_list_of_deploy_commands_for_calibtype( list_of_types, list_of_sources, fnm.path_peds_ave(), 'pedestals') if cp.dark_deploy_hotpix.value(): list_of_deploy_commands += self.get_list_of_deploy_commands_for_calibtype( list_of_types, list_of_sources, fnm.path_hotpix_mask(), 'pixel_status') return list_of_deploy_commands, list_of_sources
def make_psana_cfg_file_for_data_aver (self) : self.path_in = apputils.AppDataPath('CorAna/scripts/psana-data-aver.cfg').path() self.path_out = fnm.path_data_aver_psana_cfg() self.d_subs = {'FNAME_XTC' : fnm.path_data_xtc_cond(), 'SKIP' : str( cp.bat_data_start.value() - 1 ), 'EVENTS' : str( cp.bat_data_end.value() - cp.bat_data_start.value() + 1 ), 'IMG_REC_MODULE' : str( cp.bat_img_rec_mod.value() ), 'DETINFO' : str( cp.bat_det_info.value() ), 'FNAME_DATA_AVE' : fnm.path_data_ave(), 'FNAME_DATA_RMS' : fnm.path_data_rms(), 'SAT_THR_ADU' : str( cp.ccdset_adcsatu.value() ), 'SATPIX_MASK' : fnm.path_satpix_mask(), 'HOTPIX_MASK' : fnm.path_hotpix_mask(), 'SATPIX_FRAC' : fnm.path_satpix_frac(), 'HOTPIX_FRAC' : fnm.path_hotpix_frac() } # cp.ccdset_ccdgain.value() # cp.ccdset_ccdeff .value() self.print_substitution_dict() self.make_cfg_file()
def make_psana_cfg_file_for_peds_aver_princeton (self) : self.path_in = apputils.AppDataPath('CalibManager/scripts/psana-peds-aver-princeton.cfg').path() self.path_out = fnm.path_peds_aver_psana_cfg() self.d_subs = {'FNAME_XTC' : str(fnm.path_to_xtc_files_for_run()), 'SKIP' : str( cp.bat_dark_start.value() - 1 ), 'EVENTS' : str( cp.bat_dark_end.value() - cp.bat_dark_start.value() + 1 ), 'IMG_REC_MODULE' : str( cp.bat_img_rec_mod.value() ), 'DETINFO' : str( cp.bat_det_info.value() ), 'FNAME_PEDS_AVE' : fnm.path_peds_ave(), 'FNAME_PEDS_RMS' : fnm.path_peds_rms() } self.d_subs['FNAME_HOTPIX_MASK' ] = fnm.path_hotpix_mask() self.d_subs['HOTPIX_THRESHOLD_ADU'] = str( cp.mask_hot_thr.value() ) #if cp.mask_hot_is_used.value() : # self.d_subs['FNAME_HOTPIX_MASK' ] = fnm.path_hotpix_mask() # self.d_subs['HOTPIX_THRESHOLD_ADU'] = str( cp.mask_hot_thr.value() ) #else : # self.d_subs['FNAME_HOTPIX_MASK' ] = '' # self.d_subs['HOTPIX_THRESHOLD_ADU'] = '10000' self.print_substitution_dict() self.make_cfg_file()
def get_list_of_files_dark_expected(self): lst_of_srcs = cp.blsp.list_of_sources_for_selected_detectors() return fnm.get_list_of_files_peds() \ + gu.get_list_of_files_for_list_of_insets(fnm.path_peds_ave(), lst_of_srcs) \ + gu.get_list_of_files_for_list_of_insets(fnm.path_peds_rms(), lst_of_srcs) \ + gu.get_list_of_files_for_list_of_insets(fnm.path_hotpix_mask(), lst_of_srcs)
def get_list_of_files_dark_expected(self) : lst_of_srcs = cp.blsp.list_of_sources_for_selected_detectors() return fnm.get_list_of_files_peds() \ + gu.get_list_of_files_for_list_of_insets(fnm.path_peds_ave(), lst_of_srcs) \ + gu.get_list_of_files_for_list_of_insets(fnm.path_peds_rms(), lst_of_srcs) \ + gu.get_list_of_files_for_list_of_insets(fnm.path_hotpix_mask(), lst_of_srcs)
def get_list_of_deploy_commands_and_sources(self): """Get list of deploy commands for all detectors of the same type""" self.exportLocalPars() #cp.blsp.print_list_of_types_and_sources() list_of_types, list_of_sources = cp.blsp.list_of_types_and_sources_for_selected_detectors() # list_of_types : ['CsPad::DataV1', 'CsPad::DataV1'] # list_of_sources: ['CxiDs1.0:Cspad.0', 'CxiDsd.0:Cspad.0'] list_of_deploy_commands = self.get_list_of_deploy_commands_for_calibtype(list_of_types, list_of_sources, fnm.path_peds_ave(), 'pedestals') list_of_deploy_commands += self.get_list_of_deploy_commands_for_calibtype(list_of_types, list_of_sources, fnm.path_peds_rms(), 'pixel_rms') if cp.dark_deploy_hotpix.value() : list_of_deploy_commands += self.get_list_of_deploy_commands_for_calibtype(list_of_types, list_of_sources, fnm.path_hotpix_mask(), 'pixel_status') return list_of_deploy_commands, list_of_sources
def get_list_of_deploy_commands_and_sources_dark(str_run_number, str_run_range): """Get list of deploy commands for all detectors of the same type""" cp.str_run_number.setValue(str_run_number) #cp.blsp.print_list_of_types_and_sources() list_of_types, list_of_sources = cp.blsp.list_of_types_and_sources_for_selected_detectors() # list_of_types : ['CsPad::DataV1', 'CsPad::DataV1'] # list_of_sources: ['CxiDs1.0:Cspad.0', 'CxiDsd.0:Cspad.0'] list_of_deploy_commands = get_list_of_deploy_commands_for_calibtype(list_of_types, list_of_sources, fnm.path_peds_ave(), 'pedestals', str_run_range) list_of_deploy_commands += get_list_of_deploy_commands_for_calibtype(list_of_types, list_of_sources, fnm.path_peds_rms(), 'pixel_rms', str_run_range) if cp.dark_deploy_hotpix.value() : list_of_deploy_commands += get_list_of_deploy_commands_for_calibtype(list_of_types, list_of_sources, fnm.path_hotpix_mask(), 'pixel_status', str_run_range) return list_of_deploy_commands, list_of_sources
def get_list_of_files_peds(self) : list_of_fnames = fnm.get_list_of_files_peds() \ + cp.blsp.get_list_of_files_for_all_sources(fnm.path_peds_ave()) \ + cp.blsp.get_list_of_files_for_all_sources(fnm.path_peds_rms()) list_of_fnames.append(fnm.path_hotpix_mask()) return list_of_fnames
def get_list_of_files_peds(self): list_of_fnames = fnm.get_list_of_files_peds() \ + cp.blsp.get_list_of_files_for_all_sources(fnm.path_peds_ave()) \ + cp.blsp.get_list_of_files_for_all_sources(fnm.path_peds_rms()) list_of_fnames.append(fnm.path_hotpix_mask()) return list_of_fnames