def generateObsInfoDat (self, finished_subdir, completed_subdir): obs_results_file = self.finished_dir + "/" + finished_subdir + "/obs.results" obs_header_file = self.completed_dir + "/" + completed_subdir + "/obs.header" obs_info_dat_file = self.completed_dir + "/" + completed_subdir + "/obs_info.dat" proposal_id = "" if not os.path.exists (obs_info_dat_file): self.log (2, "MeerKATArchiverDaemon::generateObsInfoDat creating obs_info.dat") if os.path.exists(obs_results_file): self.log (2, "MeerKATArchiverDaemon::generateObsInfoDat: reading " + obs_results_file) obs_results = Config.readCFGFileIntoDict(obs_results_file) else: self.log (2, "MeerKATArchiverDaemon::generateObsInfoDat: generating results") obs_results = self.computeResults (self.finished_dir + "/" + finished_subdir) if not os.path.exists(obs_header_file): self.log (-1, "MeerKATArchiverDaemon::generateObsInfoDat: " + obs_header_file + " did not exist") return ("fail", "obs.header file did not exist") obs_header = Config.readCFGFileIntoDict(obs_header_file) obs_info_dat = {} obs_info_dat["observer"] = self.extractKey(obs_header ,"OBSERVER") obs_info_dat["program_block_id"] = self.extractKey(obs_header, "PROGRAM_BLOCK_ID") obs_info_dat["targets"] = "['" + self.extractKey(obs_header,"SOURCE") + "']" obs_info_dat["mode"] = self.extractKey(obs_header,"MODE") obs_info_dat["sb_id_code"] = self.extractKey(obs_header,"SCHEDULE_BLOCK_ID") obs_info_dat["target_duration"] = self.extractKey(obs_results, "length") obs_info_dat["target_snr"] = self.extractKey(obs_results, "snr") obs_info_dat["proposal_id"] = self.extractKey(obs_header, "PROPOSAL_ID") obs_info_dat["description"] = self.extractKey(obs_header, "DESCRIPTION") obs_info_dat["backend_args"] = "TBD" obs_info_dat["experiment_id"] = self.extractKey(obs_header, "EXPERIMENT_ID") obs_info_dat["adc_sync_time"] = self.extractKey(obs_header, "ADC_SYNC_TIME") obs_info_dat["precisetime_fraction"] = self.extractKey(obs_header, "PRECISETIME_FRACTION_AVG") obs_info_dat["utc_start_offset_picoseconds"] = self.extractKey(obs_header, "PICOSECONDS") fold_mode = self.extractKey(obs_header, "PERFORM_FOLD") search_mode = self.extractKey(obs_header, "PERFORM_SEARCH") Config.writeDictToColonSVFile(obs_info_dat, obs_info_dat_file) proposal_id = obs_info_dat["proposal_id"] else: self.log (2, "MeerKATArchiverDaemon::generateObsInfoDat obs_info.dat existed") return ("ok", proposal_id)
def generateObsInfoDat (self, finished_subdir, completed_subdir): obs_results_file = self.finished_dir + "/" + finished_subdir + "/obs.results" obs_header_file = self.completed_dir + "/" + completed_subdir + "/obs.header" obs_info_dat_file = self.completed_dir + "/" + completed_subdir + "/obs_info.dat" if not os.path.exists (obs_info_dat_file): self.log (2, "MeerKATArchiverDaemon::generateObsInfoDat creating obs_info.dat") if os.path.exists(obs_results_file): self.log (2, "MeerKATArchiverDaemon::generateObsInfoDat: reading " + obs_results_file) obs_results = Config.readCFGFileIntoDict(obs_results_file) else: self.log (2, "MeerKATArchiverDaemon::generateObsInfoDat: generating results") obs_results = self.computeResults (self.finished_dir + "/" + finished_subdir) if not os.path.exists(obs_header_file): self.log (-1, "MeerKATArchiverDaemon::generateObsInfoDat: " + obs_header_file + " did not exist") return ("fail", "obs.header file did not exist") obs_header = Config.readCFGFileIntoDict(obs_header_file) obs_info_dat = {} obs_info_dat["observer"] = self.extractKey(obs_header ,"OBSERVER") obs_info_dat["program_block_id"] = self.extractKey(obs_header, "PROGRAM_BLOCK_ID") obs_info_dat["targets"] = "['" + self.extractKey(obs_header,"SOURCE") + "']" obs_info_dat["mode"] = self.extractKey(obs_header,"MODE") obs_info_dat["sb_id_code"] = self.extractKey(obs_header,"SCHEDULE_BLOCK_ID") obs_info_dat["target_duration"] = self.extractKey(obs_results, "length") obs_info_dat["target_snr"] = self.extractKey(obs_results, "snr") obs_info_dat["proposal_id"] = self.extractKey(obs_header, "PROPOSAL_ID") obs_info_dat["description"] = self.extractKey(obs_header, "DESCRIPTION") obs_info_dat["backend_args"] = "TBD" obs_info_dat["experiment_id"] = self.extractKey(obs_header, "EXPERIMENT_ID") obs_info_dat["adc_sync_time"] = self.extractKey(obs_header, "ADC_SYNC_TIME") obs_info_dat["precisetime_fraction"] = self.extractKey(obs_header, "PRECISETIME_FRACTION_AVG") obs_info_dat["utc_start_offset_picoseconds"] = self.extractKey(obs_header, "PICOSECONDS") fold_mode = self.extractKey(obs_header, "PERFORM_FOLD") search_mode = self.extractKey(obs_header, "PERFORM_SEARCH") Config.writeDictToColonSVFile(obs_info_dat, obs_info_dat_file) else: self.log (2, "MeerKATArchiverDaemon::generateObsInfoDat obs_info.dat existed") return ("ok", "")
def generateObsInfoDat(self, finished_subdir, completed_subdir): obs_results_file = self.finished_dir + "/" + finished_subdir + "/obs.results" obs_header_file = self.completed_dir + "/" + completed_subdir + "/obs.header" obs_info_dat_file = self.completed_dir + "/" + completed_subdir + "/obs_info.dat" if not os.path.exists(obs_info_dat_file): self.log( 2, "MeerKATArchiverDaemon::generateObsInfoDat creating obs_info.dat" ) obs_results = Config.readCFGFileIntoDict(obs_results_file) obs_header = Config.readCFGFileIntoDict(obs_header_file) obs_info_dat = {} obs_info_dat["observer"] = self.extractKey(obs_header, "OBSERVER") obs_info_dat["program_block_id"] = self.extractKey( obs_header, "PROGRAM_BLOCK_ID") obs_info_dat["targets"] = "['" + self.extractKey( obs_header, "SOURCE") + "']" obs_info_dat["mode"] = self.extractKey(obs_header, "MODE") obs_info_dat["sb_id_code"] = self.extractKey( obs_header, "SCHEDULE_BLOCK_ID") obs_info_dat["target_duration"] = self.extractKey( obs_results, "length") obs_info_dat["target_snr"] = self.extractKey(obs_results, "snr") obs_info_dat["proposal_id"] = self.extractKey( obs_header, "PROPOSAL_ID") obs_info_dat["description"] = self.extractKey( obs_header, "DESCRIPTION") obs_info_dat["backend_args"] = "TBD" obs_info_dat["experiment_id"] = self.extractKey( obs_header, "EXPERIMENT_ID") Config.writeDictToColonSVFile(obs_info_dat, obs_info_dat_file) else: self.log( 2, "MeerKATArchiverDaemon::generateObsInfoDat obs_info.dat existed" ) return ("ok", "")