From bd6b5f8b669867655be2dfd6097998b8a3ddffe0 Mon Sep 17 00:00:00 2001 From: bfrosik Date: Fri, 9 Apr 2021 13:54:48 -0500 Subject: [PATCH] added beamline conf parameter --- scripts/create_experiment.py | 21 ++++++++++++--------- scripts/setup_34idc.py | 7 +++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/create_experiment.py b/scripts/create_experiment.py index 261216d..675e8de 100755 --- a/scripts/create_experiment.py +++ b/scripts/create_experiment.py @@ -174,7 +174,7 @@ def create_conf_disp(conf_dir): f.close() -def create_exp(prefix, scan, working_dir, specfile=None): +def create_exp(prefix, scan, working_dir, **args): """ Concludes experiment name, creates directory, and "conf" subdirectory with initial configuration files. @@ -219,8 +219,10 @@ def create_exp(prefix, scan, working_dir, specfile=None): conf_map['working_dir'] = '"' + working_dir + '"' conf_map['experiment_id'] = '"' + prefix + '"' conf_map['scan'] = '"' + scan + '"' - if specfile is not None: - conf_map['specfile'] = '"' + specfile + '"' + if 'specfile' in args: + conf_map['specfile'] = '"' + args['specfile'] + '"' + if 'beamline' in args: + conf_map['beamline'] = '"' + args['beamline'] + '"' temp_file = os.path.join(experiment_conf_dir, 'temp') with open(temp_file, 'a') as f: @@ -228,8 +230,6 @@ def create_exp(prefix, scan, working_dir, specfile=None): value = conf_map[key] if len(value) > 0: f.write(key + ' = ' + conf_map[key] + '\n') - if specfile is None: - f.write('// specfile = "/path/to/specfile/specfile"\n') f.close() if not ver.ver_config(temp_file): print('please check the entered parameters. Cannot save this format') @@ -251,6 +251,7 @@ def main(arg): parser.add_argument("id", help="prefix to name of the experiment/data reconstruction") parser.add_argument("scan", help="a range of scans to prepare data from") parser.add_argument("working_dir", help="directory where the created experiment will be located") + parser.add_argument('--beamline', action='store') parser.add_argument('--specfile', action='store') args = parser.parse_args() @@ -258,12 +259,14 @@ def main(arg): id = args.id working_dir = args.working_dir + varpar = {} if args.specfile and os.path.isfile(args.specfile): - specfile = args.specfile - else: - specfile = None + varpar['specfile'] = args.specfile + + if args.beamline: + varpar['beamline'] = args.beamline - return create_exp(id, scan, working_dir, specfile=specfile) + return create_exp(id, scan, working_dir, **varpar) if __name__ == "__main__": diff --git a/scripts/setup_34idc.py b/scripts/setup_34idc.py index d0b3b20..0a45bf1 100755 --- a/scripts/setup_34idc.py +++ b/scripts/setup_34idc.py @@ -103,6 +103,7 @@ def setup_rundirs(prefix, scan, conf_dir, **kwargs): try: with open(main_conf, 'r') as f: config_map = cfg.Config(f.read()) + print(config_map) except Exception as e: print('Please check the configuration file ' + main_conf + '. Cannot parse ' + str(e)) return @@ -137,6 +138,12 @@ def setup_rundirs(prefix, scan, conf_dir, **kwargs): conf_map['scan'] = '"' + scan + '"' if specfile is not None: conf_map['specfile'] = '"' + specfile + '"' + print (conf_map) + try: + conf_map['beamline'] = '"' + config_map.beamline + '"' + except: + pass + temp_file = os.path.join(experiment_conf_dir, 'temp') with open(temp_file, 'a') as f: for key in conf_map: