def train_prep_trainopt_list(self): CONFIG = self.config_yaml['CONFIG'] key = TRAINOPT_STRING if key in CONFIG: trainopt_rows = CONFIG[key] else: trainopt_rows = [] # - - - - - trainopt_dict = util.prep_jobopt_list(trainopt_rows, TRAINOPT_STRING, KEY_SHIFTLIST_FILE) n_trainopt = trainopt_dict['n_jobopt'] trainopt_arg_list = trainopt_dict['jobopt_arg_list'] trainopt_ARG_list = trainopt_dict['jobopt_ARG_list'] trainopt_num_list = trainopt_dict['jobopt_num_list'] trainopt_label_list = trainopt_dict['jobopt_label_list'] trainopt_shift_file = trainopt_dict['jobopt_file_list'] use_shift_file = trainopt_dict['use_arg_file'] logging.info(f" Store {n_trainopt-1} TRAIN-SALT2 options " \ f"from {TRAINOPT_STRING} keys") self.config_prep['n_trainopt'] = n_trainopt self.config_prep['trainopt_arg_list'] = trainopt_arg_list self.config_prep['trainopt_ARG_list'] = trainopt_ARG_list self.config_prep['trainopt_num_list'] = trainopt_num_list self.config_prep['trainopt_label_list'] = trainopt_label_list self.config_prep['trainopt_shift_file'] = trainopt_shift_file self.config_prep['use_shift_file'] = use_shift_file
def train_prep_trainopt_list(self): CONFIG = self.config_yaml['CONFIG'] trainopt_global = "" # apply to each TRAINOPT trainopt_rows = [] # TRAINOT-specified commands # start with global settings key = TRAINOPT_GLOBAL_STRING if key in CONFIG: trainopt_global = CONFIG[key] # next, TRAINOPT per job key = TRAINOPT_STRING if key in CONFIG: trainopt_rows = CONFIG[key] # - - - - - trainopt_dict = util.prep_jobopt_list(trainopt_rows, TRAINOPT_STRING, KEY_SHIFTLIST_FILE) n_trainopt = trainopt_dict['n_jobopt'] trainopt_arg_list = trainopt_dict['jobopt_arg_list'] trainopt_ARG_list = trainopt_dict['jobopt_ARG_list'] trainopt_num_list = trainopt_dict['jobopt_num_list'] trainopt_label_list = trainopt_dict['jobopt_label_list'] trainopt_shift_file = trainopt_dict['jobopt_file_list'] use_arg_file = trainopt_dict['use_arg_file'] logging.info(f" Store {n_trainopt-1} TRAIN-SALT3 options " \ f"from {TRAINOPT_STRING} keys") # for MAGSHIFT and./or WAVESHIFT, create calibration file # in script_dir. The returned calib_shift_file has each # calib arg unpacked so that each row has only 1 shift. # arg_replace = arg, but calibration shifts are replaced # with command to read calib-shift file. arg_replace_list = [] calib_shift_list = [] for num, arg in zip(trainopt_num_list, trainopt_arg_list): arg_replace, calib_shift = self.make_calib_shift_file(num, arg) arg_replace_list.append(arg_replace) calib_shift_list.append(calib_shift) # list of lists self.config_prep['n_trainopt'] = n_trainopt self.config_prep['trainopt_arg_list'] = arg_replace_list self.config_prep['trainopt_ARG_list'] = trainopt_ARG_list self.config_prep['trainopt_num_list'] = trainopt_num_list self.config_prep['trainopt_label_list'] = trainopt_label_list self.config_prep['trainopt_shift_file'] = trainopt_shift_file self.config_prep['trainopt_global'] = trainopt_global self.config_prep['use_arg_file'] = use_arg_file self.config_prep['calib_shift_list'] = calib_shift_list print('')
def wfit_prep_wfitopt_list(self): msgerr = [] input_file = self.config_yaml['args'].input_file CONFIG = self.config_yaml['CONFIG'] key = KEYNAME_WFITOPT if key not in CONFIG: msgerr.append(f"Missing required {key} key in CONFIG block") msgerr.append(f"Check {input_file}") self.log_assert(False, msgerr) else: wfitopt_rows = CONFIG[key] if wfitopt_rows is None: msgerr.append(f"{key} is empty.") msgerr.append(f"Check {input_file}") self.log_assert(False, msgerr) wfitopt_dict = util.prep_jobopt_list(wfitopt_rows, key, None) n_wfitopt = wfitopt_dict['n_jobopt'] wfitopt_arg_list = wfitopt_dict['jobopt_arg_list'] wfitopt_num_list = wfitopt_dict['jobopt_num_list'] wfitopt_label_list = wfitopt_dict['jobopt_label_list'] logging.info(f"\n Store {n_wfitopt} wfit options from " \ f"{key} keys" ) self.config_prep['n_wfitopt'] = n_wfitopt self.config_prep['wfitopt_arg_list'] = wfitopt_arg_list self.config_prep['wfitopt_num_list'] = wfitopt_num_list self.config_prep['wfitopt_label_list'] = wfitopt_label_list # check for global wfitopt key = f"{KEYNAME_WFITOPT}_GLOBAL" wfitopt_global = "" if key in CONFIG: wfitopt_global = CONFIG[key] self.config_prep['wfitopt_global'] = wfitopt_global # check for wa in fit use_wa = False tmp_list = wfitopt_arg_list + [wfitopt_global] for tmp in tmp_list: if '-wa' in tmp: use_wa = True self.config_prep['use_wa'] = use_wa