def submit_batch_for_peds_scan(self): self.exportLocalPars() if not self.job_can_be_submitted(self.job_id_scan_str, self.time_scan_job_submitted, 'scan'): return self.time_scan_job_submitted = gu.get_time_sec() cfg.make_psana_cfg_file_for_peds_scan() command = 'psana -c ' + fnm.path_peds_scan_psana_cfg( ) + ' ' + fnm.path_to_xtc_files_for_run() # fnm.path_dark_xtc_cond() queue = self.queue.value() bat_log_file = fnm.path_peds_scan_batch_log() #print 'command :', command #print 'queue :', queue #print 'bat_log_file:', bat_log_file self.job_id_scan_str, out, err = gu.batch_job_submit( command, queue, bat_log_file) self.procDarkStatus ^= 1 # set bit to 1 if err != '': self.stop_auto_processing(is_stop_on_button_click=False) logger.warning( 'Autoprocessing for run %s is stopped due to batch submission error!!!' % self.str_run_number, __name__)
def make_set_of_lines_from_file_for_pattern(self, pattern='EventKey(type=Psana'): """Makse self.list_of_found_lines - a set of lines from file specified containing pattern """ self.path = fnm.path_peds_scan_batch_log() if not os.path.lexists(self.path): logger.info( '\nThe requested file: ' + self.path + '\nIS NOT AVAILABLE!', __name__) return False self.list_of_found_lines = [] fin = open(self.path, 'r') for line in fin: if pattern in line: line_st = line.rstrip('\n').strip(' ') if line_st in self.list_of_found_lines: continue # if the line is already in the list self.list_of_found_lines.append(line_st) #print 'found line:', line_st fin.close() return True
def command_for_peds_aver(self): if not cfg.make_psana_cfg_file_for_peds_aver(): logger.warning('INTERACTIVE JOB IS NOT STARTED !!!', __name__) return False command = 'psana -c ' + fnm.path_peds_aver_psana_cfg( ) # + ' ' + fnm.path_to_xtc_files_for_run() # fnm.path_dark_xtc_cond() command_seq = command.split() msg = 'Avereging xtc file(s) using command:\n%s' % command \ + '\nand save results in the log-file: %s' % fnm.path_peds_scan_batch_log() logger.info(msg, __name__) err = gu.subproc_in_log( command_seq, fnm.path_peds_aver_batch_log()) # , shell=True) if err != '': logger.error('\nerr: %s' % (err), __name__) logger.warning( 'Processing for run %s is stopped due to error at execution of the averaging command' % self.str_run_number, __name__) return False else: logger.info( 'Avereging for run %s is completed' % self.str_run_number, __name__) return True
def parse_batch_log_peds_scan(self): if self.is_parsed and self.path == fnm.path_peds_scan_batch_log(): return if self.det_name.value() == 'Select': return self.path = fnm.path_peds_scan_batch_log() self.pattern = self.dict_of_det_types[self.det_name.value()] #print 'Parse file: %s for pattern: %s' % (self.path, self.pattern) #self.print_dict_of_det_types() self.parse_scan_log() #self.print_list_of_types_and_sources() self.is_parsed = True
def command_for_peds_scan(self) : cfg.make_psana_cfg_file_for_peds_scan() #command = 'env' command = 'psana -c ' + fnm.path_peds_scan_psana_cfg() + self.opt command_seq = command.split() msg = 'Scan xtc file(s) using command:\n%s' % command \ + '\nand save results in the log-file: %s' % fnm.path_peds_scan_batch_log() logger.info(msg, __name__) err = gu.subproc_in_log(command_seq, fnm.path_peds_scan_batch_log()) # , shell=True) if err != '' : logger.error('\nerr: %s' % (err), __name__) self.stop_auto_processing(is_stop_on_button_click=False) logger.warning('Autoprocessing for run %s is stopped due to error at execution of the scan command' % self.str_run_number, __name__) else : logger.info('Scan for run %s is completed' % self.str_run_number, __name__)
def parse_batch_log_peds_scan(self): """Psrses log file for dark run scan and makes lists: self.list_of_types and self.list_of_sources for all psana data types in file. """ if self.path == fnm.path_peds_scan_batch_log(): return #and self.det_names_parsed == self.det_name.value(): return #self.det_names_parsed = self.det_name.value() #if self.det_name.value == self.det_name.value_def() : return self.list_of_detinfo_sources = [] self.list_of_sources = [] self.list_of_types = [] if not self.make_set_of_lines_from_file_for_pattern(): return self.make_list_of_types_and_sources()
def parse_batch_log_peds_scan (self) : self.path = fnm.path_peds_scan_batch_log() self.dict = {'BATCH_FRAME_TIME_INTERVAL_AVE' : cp.bat_dark_dt_ave, 'BATCH_FRAME_TIME_INTERVAL_RMS' : cp.bat_dark_dt_rms, #'BATCH_FRAME_TIME_INDEX_MAX' : time_ind_max, #'BATCH_RUN_NUMBER' : run_num, #'BATCH_SEC_PER_EVENT' : rate_sec_per_evt, #'BATCH_EVENTS_PER_SEC' : rate_evt_per_sec, 'BATCH_NUMBER_OF_EVENTS' : cp.bat_dark_total, 'BATCH_PROCESSING_TIME' : cp.bat_dark_time } self.print_dict() self.parse_log_file() if cp.bat_dark_end.value() == cp.bat_dark_end.value_def() and cp.bat_dark_total.value() != cp.bat_dark_total.value_def(): cp.bat_dark_end.setValue(cp.bat_dark_total.value())
def parse_batch_log_peds_scan (self) : """Psrses log file for dark run scan and makes lists: self.list_of_types and self.list_of_sources for all psana data types in file. """ if self.path == fnm.path_peds_scan_batch_log() : return #and self.det_names_parsed == self.det_name.value(): return #self.det_names_parsed = self.det_name.value() #if self.det_name.value == self.det_name.value_def() : return self.list_of_detinfo_sources = [] self.list_of_sources = [] self.list_of_types = [] if not self.make_set_of_lines_from_file_for_pattern() : return self.make_list_of_types_and_sources()
def command_for_peds_aver(self) : if not cfg.make_psana_cfg_file_for_peds_aver() : logger.warning('INTERACTIVE JOB IS NOT STARTED !!!', __name__) return False command = 'psana -c ' + fnm.path_peds_aver_psana_cfg() # + ' ' + fnm.path_to_xtc_files_for_run() # fnm.path_dark_xtc_cond() command_seq = command.split() msg = 'Avereging xtc file(s) using command:\n%s' % command \ + '\nand save results in the log-file: %s' % fnm.path_peds_scan_batch_log() logger.info(msg, __name__) err = gu.subproc_in_log(command_seq, fnm.path_peds_aver_batch_log()) # , shell=True) if err != '' : logger.error('\nerr: %s' % (err), __name__) logger.warning('Processing for run %s is stopped due to error at execution of the averaging command' % self.str_run_number, __name__) return False else : logger.info('Avereging for run %s is completed' % self.str_run_number, __name__) return True
def submit_batch_for_peds_scan(self) : self.exportLocalPars() if not self.job_can_be_submitted(self.job_id_scan_str, self.time_scan_job_submitted, 'scan') : return self.time_scan_job_submitted = gu.get_time_sec() cfg.make_psana_cfg_file_for_peds_scan() command = 'psana -c ' + fnm.path_peds_scan_psana_cfg() + ' ' + fnm.path_to_xtc_files_for_run() # fnm.path_dark_xtc_cond() queue = self.queue.value() bat_log_file = fnm.path_peds_scan_batch_log() #print 'command :', command #print 'queue :', queue #print 'bat_log_file:', bat_log_file self.job_id_scan_str, out, err = gu.batch_job_submit(command, queue, bat_log_file) self.procDarkStatus ^= 1 # set bit to 1 if err != '' : self.stop_auto_processing(is_stop_on_button_click=False) logger.warning('Autoprocessing for run %s is stopped due to batch submission error!!!' % self.str_run_number, __name__)
def make_set_of_lines_from_file_for_pattern(self, pattern = 'EventKey(type=Psana' ) : """Makse self.list_of_found_lines - a set of lines from file specified containing pattern """ self.path = fnm.path_peds_scan_batch_log() if not os.path.lexists(self.path) : logger.info('\nThe requested file: ' + self.path + '\nIS NOT AVAILABLE!', __name__) return False self.list_of_found_lines = [] fin = open(self.path, 'r') for line in fin : if pattern in line : line_st = line.rstrip('\n').strip(' ') if line_st in self.list_of_found_lines : continue # if the line is already in the list self.list_of_found_lines.append(line_st) #print 'found line:', line_st fin.close() return True
def scan_log_exists(self): return os.path.exists(fnm.path_peds_scan_batch_log())
def scan_log_exists (self) : return os.path.exists(fnm.path_peds_scan_batch_log())