From 30988801ecf82beb1e0ed6d442d470a6755b875d Mon Sep 17 00:00:00 2001 From: Andrii Terliuk Date: Mon, 26 Jul 2021 12:29:08 -0500 Subject: [PATCH 1/8] Modificatons of nT simulation context --- straxen/contexts.py | 169 +++++++++++++++++++++++++++++--------------- 1 file changed, 112 insertions(+), 57 deletions(-) diff --git a/straxen/contexts.py b/straxen/contexts.py index 0679e11ec..fbb1a03a1 100644 --- a/straxen/contexts.py +++ b/straxen/contexts.py @@ -220,37 +220,61 @@ def xenonnt_led(**kwargs): return st -def xenonnt_simulation(output_folder='./strax_data', - cmt_run_id='020280', - cmt_version='v3', - fax_config='fax_config_nt_design.json', - cmt_option_overwrite=immutabledict(), - overwrite_from_fax_file=False, - _cmt_run_id_proc_only=None, - _forbid_creation_of=None, - _config_overlap=immutabledict(drift_time_gate='electron_drift_time_gate', - drift_velocity_liquid='electron_drift_velocity', - electron_lifetime_liquid='elife_conf'), - **kwargs): + +def xenonnt_simulation( + output_folder = './strax_data', + cmt_run_id_sim = None, + cmt_run_id_proc = None, + cmt_version = 'v3', + fax_config = 'fax_config_nt_design.json', + overwrite_from_fax_file_sim = False, + overwrite_from_fax_file_proc = False, + cmt_option_overwrite_sim = immutabledict(), + cmt_option_overwrite_proc = immutabledict(), + _forbid_creation_of = None, + _config_overlap = immutabledict( + drift_time_gate='electron_drift_time_gate', + drift_velocity_liquid='electron_drift_velocity', + electron_lifetime_liquid='elife_conf'), + **kwargs): """ - Context with CMT options updated with cmt_run_id. + + The most generic context that allows for setting full divergent + settings for simulation purposes + + It makes full divergent setup, allowing to set detector simulation + part (i.e. for wfsim up to truth and raw_records). Parameters _sim + refer to detector simulation parameters. + + Arguments having _proc in their name refer to detector parameters that + are used for processing of simulations as done to the real datector + data. This means starting from already existing raw_records and finishing + with higher level data, such as peaks, events etc. + CMT options can also be overwritten via fax config file. :param output_folder: Output folder for strax data. - :param cmt_run_id: Run id which should be used to load corrections. + :param cmt_run_id_sim: Run id for detector parameters from CMT to be used in + for creation of raw_records. + :param cmt_run_id_proc: Run id for detector parameters from CMT to be used in + for processing from raw_records to higher level data. :param cmt_version: Global version for corrections to be loaded. :param fax_config: Fax config file to use. - :param cmt_option_overwrite: Dictionary to overwrite CMT settings. Keys - must be valid CMT option keys. - :param overwrite_from_fax_file: If true overwrites CMT options with - constants from fax file. - :param _cmt_run_id_proc_only: Run id just for > raw_records processing if diverge from - cmt_run_id. + :param overwrite_from_fax_file_sim: If true sets detector simulation + parameters for truth/raw_records from from fax_config file istead of CMT + :param overwrite_from_fax_file_proc: If true sets detector processing + parameters after raw_records(peaklets/events/etc) from from fax_config + file istead of CMT + :param cmt_option_overwrite_sim: Dictionary to overwrite CMT settings for + the detector simulation part. + :param cmt_option_overwrite_proc: Dictionary to overwrite CMT settings for + the data processing part. :param _forbid_creation_of: str/tuple, of datatypes to prevent form being written (e.g. 'raw_records' for read only simulation context). :param _config_overlap: Dictionary of options to overwrite. Keys must be simulation config keys, values must be valid CMT option keys. :param kwargs: Additional kwargs taken by strax.Context. :return: strax.Context instance + """ import wfsim st = strax.Context( @@ -261,56 +285,87 @@ def xenonnt_simulation(output_folder='./strax_data', **straxen.contexts.xnt_common_config,), **straxen.contexts.xnt_common_opts, **kwargs) st.register(wfsim.RawRecordsFromFaxNT) - + st.apply_cmt_version(f'global_{cmt_version}') + if _forbid_creation_of is not None: st.context_config['forbid_creation_of'] += strax.to_str_tuple(_forbid_creation_of) - - st.apply_cmt_version(f'global_{cmt_version}') - if not cmt_run_id: - raise ValueError('You have to specify a run_id which should be used to initialize ' - 'the corrections.') - if _cmt_run_id_proc_only is None: - _cmt_run_id_proc_only = cmt_run_id - - # Setup processing + + # doing sanity checks for cmt run ids for simulation and processing + if not (cmt_run_id_sim is None) and not (cmt_run_id_proc is None): + if not (cmt_run_id_sim==cmt_run_id_proc): + print("INFO : divergent CMT runs for simulation and processing") + print(" cmt_run_id_sim".ljust(25), cmt_run_id_sim) + print(" cmt_run_id_proc".ljust(25), cmt_run_id_proc) + elif (cmt_run_id_sim is None) and not (cmt_run_id_proc is None): + cmt_run_id_sim=cmt_run_id_proc + elif not (cmt_run_id_sim is None) and (cmt_run_id_proc is None): + cmt_run_id_proc=cmt_run_id_sim + else: + raise RuntimeError("Trying to set both cmt_run_id_sim and cmt_run_id_proc to None") + # Replace default cmt options with cmt_run_id tag + cmt run id - cmt_options = straxen.get_corrections.get_cmt_options(st) + cmt_options = straxen.get_corrections.get_cmt_options(st) + + # First, fix gain model for simulation + st.set_config({'gain_model_mc': tuple(['cmt_run_id', + cmt_run_id_sim, + *cmt_options['gain_model']])}) + fax_config_override_from_cmt = dict() + for fax_field, cmt_field in _config_overlap.items(): + fax_config_override_from_cmt[fax_field] = tuple( + ['cmt_run_id', + cmt_run_id_sim, + *cmt_options[cmt_field]] + ) + st.set_config({'fax_config_override_from_cmt': fax_config_override_from_cmt}) + + # and all other parameters for processing for option in cmt_options: - st.config[option] = tuple(['cmt_run_id', _cmt_run_id_proc_only, *cmt_options[option]]) - + st.config[option] = tuple(['cmt_run_id', cmt_run_id_proc, *cmt_options[option]]) + + # Done with "default" usage, now to overwrites from file + # # Take fax config and put into context option - if overwrite_from_fax_file: + if (overwrite_from_fax_file_proc or + overwrite_from_fax_file_sim): fax_config = straxen.get_resource(fax_config, fmt='json') - - for fax_field, cmt_field in _config_overlap.items(): - st.config[cmt_field] = tuple([cmt_options[cmt_field][0] + '_constant', - fax_config[fax_field]]) - - # Setup simulation - # Pass the CMT options to simulation (override all other config input methods) - else: - fax_config_override_from_cmt = dict() - for fax_field, cmt_field in _config_overlap.items(): - fax_config_override_from_cmt[fax_field] = tuple(['cmt_run_id', cmt_run_id, *cmt_options[cmt_field]]) - st.set_config({'fax_config_override_from_cmt': fax_config_override_from_cmt}) - - # Fix gain model - st.set_config({'gain_model_mc': tuple(['cmt_run_id', cmt_run_id, *cmt_options['gain_model']])}) - - # User customized overwrite - cmt_options = straxen.get_corrections.get_cmt_options(st) # This includes gain_model_mc - for option in cmt_option_overwrite: + if overwrite_from_fax_file_proc: + st.config[cmt_field] = tuple([ + cmt_options[cmt_field][0] + '_constant',fax_config[fax_field]]) + if overwrite_from_fax_file_sim: + st.config['fax_config_override_from_cmt'][fax_field] = tuple( + [cmt_options[cmt_field][0] + '_constant',fax_config[fax_field]]) + + # And as the last step - manual overrrides, since they have the highest priority + # User customized for simulation + for option in cmt_option_overwrite_sim: if option not in cmt_options: raise ValueError(f'Overwrite option {option} is not using CMT by default ' 'you should just use set config') + if not option in _config_overlap.values(): + raise ValueError(f'Overwrite option {option} does not have mapping from ' + 'CMT to fax config! ') + for fax_key,cmt_key in _config_overlap.items(): + if cmt_key==option: continue _name_index = 2 if 'cmt_run_id' in cmt_options[option] else 0 - st.config[option] = (cmt_options[option][_name_index] + '_constant', cmt_option_overwrite[option]) - + st.config['fax_config_override_from_cmt'][fax_key] = ( + cmt_options[option][_name_index] + '_constant', + cmt_option_overwrite_sim[option] + ) + del(fax_key,cmt_key,_name_index) + # User customized for simulation + for option in cmt_option_overwrite_proc: + if option not in cmt_options: + raise ValueError(f'Overwrite option {option} is not using CMT by default ' + 'you should just use set config') + _name_index = 2 if 'cmt_run_id' in cmt_options[option] else 0 + st.config[option] = (cmt_options[option][_name_index] + '_constant', cmt_option_overwrite_proc[option]) + del(_name_index) # Only for simulations st.set_config({"event_info_function": "disabled"}) - - return st + + return(st) ## From d6b7f3381e595c0dff2b5ef563065bde6a21ee01 Mon Sep 17 00:00:00 2001 From: Andrii Terliuk Date: Mon, 26 Jul 2021 14:15:09 -0500 Subject: [PATCH 2/8] Throwing some whitespae bones to the doggy --- straxen/contexts.py | 87 ++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/straxen/contexts.py b/straxen/contexts.py index fbb1a03a1..8d97f88a4 100644 --- a/straxen/contexts.py +++ b/straxen/contexts.py @@ -219,8 +219,6 @@ def xenonnt_led(**kwargs): st.register([straxen.DAQReader, straxen.LEDCalibration]) return st - - def xenonnt_simulation( output_folder = './strax_data', cmt_run_id_sim = None, @@ -233,48 +231,46 @@ def xenonnt_simulation( cmt_option_overwrite_proc = immutabledict(), _forbid_creation_of = None, _config_overlap = immutabledict( - drift_time_gate='electron_drift_time_gate', - drift_velocity_liquid='electron_drift_velocity', - electron_lifetime_liquid='elife_conf'), + drift_time_gate='electron_drift_time_gate', + drift_velocity_liquid='electron_drift_velocity', + electron_lifetime_liquid='elife_conf'), **kwargs): """ - - The most generic context that allows for setting full divergent + The most generic context that allows for setting full divergent settings for simulation purposes - - It makes full divergent setup, allowing to set detector simulation - part (i.e. for wfsim up to truth and raw_records). Parameters _sim - refer to detector simulation parameters. - - Arguments having _proc in their name refer to detector parameters that - are used for processing of simulations as done to the real datector - data. This means starting from already existing raw_records and finishing + + It makes full divergent setup, allowing to set detector simulation + part (i.e. for wfsim up to truth and raw_records). Parameters _sim + refer to detector simulation parameters. + + Arguments having _proc in their name refer to detector parameters that + are used for processing of simulations as done to the real datector + data. This means starting from already existing raw_records and finishing with higher level data, such as peaks, events etc. - + CMT options can also be overwritten via fax config file. :param output_folder: Output folder for strax data. - :param cmt_run_id_sim: Run id for detector parameters from CMT to be used in - for creation of raw_records. - :param cmt_run_id_proc: Run id for detector parameters from CMT to be used in + :param cmt_run_id_sim: Run id for detector parameters from CMT to be used in + for creation of raw_records. + :param cmt_run_id_proc: Run id for detector parameters from CMT to be used in for processing from raw_records to higher level data. :param cmt_version: Global version for corrections to be loaded. :param fax_config: Fax config file to use. - :param overwrite_from_fax_file_sim: If true sets detector simulation + :param overwrite_from_fax_file_sim: If true sets detector simulation parameters for truth/raw_records from from fax_config file istead of CMT - :param overwrite_from_fax_file_proc: If true sets detector processing - parameters after raw_records(peaklets/events/etc) from from fax_config + :param overwrite_from_fax_file_proc: If true sets detector processing + parameters after raw_records(peaklets/events/etc) from from fax_config file istead of CMT - :param cmt_option_overwrite_sim: Dictionary to overwrite CMT settings for - the detector simulation part. - :param cmt_option_overwrite_proc: Dictionary to overwrite CMT settings for - the data processing part. + :param cmt_option_overwrite_sim: Dictionary to overwrite CMT settings for + the detector simulation part. + :param cmt_option_overwrite_proc: Dictionary to overwrite CMT settings for + the data processing part. :param _forbid_creation_of: str/tuple, of datatypes to prevent form being written (e.g. 'raw_records' for read only simulation context). :param _config_overlap: Dictionary of options to overwrite. Keys must be simulation config keys, values must be valid CMT option keys. :param kwargs: Additional kwargs taken by strax.Context. :return: strax.Context instance - """ import wfsim st = strax.Context( @@ -286,10 +282,10 @@ def xenonnt_simulation( **straxen.contexts.xnt_common_opts, **kwargs) st.register(wfsim.RawRecordsFromFaxNT) st.apply_cmt_version(f'global_{cmt_version}') - + if _forbid_creation_of is not None: st.context_config['forbid_creation_of'] += strax.to_str_tuple(_forbid_creation_of) - + # doing sanity checks for cmt run ids for simulation and processing if not (cmt_run_id_sim is None) and not (cmt_run_id_proc is None): if not (cmt_run_id_sim==cmt_run_id_proc): @@ -302,31 +298,31 @@ def xenonnt_simulation( cmt_run_id_proc=cmt_run_id_sim else: raise RuntimeError("Trying to set both cmt_run_id_sim and cmt_run_id_proc to None") - + # Replace default cmt options with cmt_run_id tag + cmt run id - cmt_options = straxen.get_corrections.get_cmt_options(st) - + cmt_options = straxen.get_corrections.get_cmt_options(st) + # First, fix gain model for simulation - st.set_config({'gain_model_mc': tuple(['cmt_run_id', - cmt_run_id_sim, + st.set_config({'gain_model_mc': tuple(['cmt_run_id', + cmt_run_id_sim, *cmt_options['gain_model']])}) fax_config_override_from_cmt = dict() for fax_field, cmt_field in _config_overlap.items(): fax_config_override_from_cmt[fax_field] = tuple( - ['cmt_run_id', - cmt_run_id_sim, + ['cmt_run_id', + cmt_run_id_sim, *cmt_options[cmt_field]] ) st.set_config({'fax_config_override_from_cmt': fax_config_override_from_cmt}) - + # and all other parameters for processing for option in cmt_options: st.config[option] = tuple(['cmt_run_id', cmt_run_id_proc, *cmt_options[option]]) - + # Done with "default" usage, now to overwrites from file # # Take fax config and put into context option - if (overwrite_from_fax_file_proc or + if (overwrite_from_fax_file_proc or overwrite_from_fax_file_sim): fax_config = straxen.get_resource(fax_config, fmt='json') for fax_field, cmt_field in _config_overlap.items(): @@ -335,9 +331,9 @@ def xenonnt_simulation( cmt_options[cmt_field][0] + '_constant',fax_config[fax_field]]) if overwrite_from_fax_file_sim: st.config['fax_config_override_from_cmt'][fax_field] = tuple( - [cmt_options[cmt_field][0] + '_constant',fax_config[fax_field]]) - - # And as the last step - manual overrrides, since they have the highest priority + [cmt_options[cmt_field][0] + '_constant',fax_config[fax_field]]) + + # And as the last step - manual overrrides, since they have the highest priority # User customized for simulation for option in cmt_option_overwrite_sim: if option not in cmt_options: @@ -345,9 +341,10 @@ def xenonnt_simulation( 'you should just use set config') if not option in _config_overlap.values(): raise ValueError(f'Overwrite option {option} does not have mapping from ' - 'CMT to fax config! ') + 'CMT to fax config! ') for fax_key,cmt_key in _config_overlap.items(): - if cmt_key==option: continue + if cmt_key==option: + continue _name_index = 2 if 'cmt_run_id' in cmt_options[option] else 0 st.config['fax_config_override_from_cmt'][fax_key] = ( cmt_options[option][_name_index] + '_constant', @@ -364,7 +361,7 @@ def xenonnt_simulation( del(_name_index) # Only for simulations st.set_config({"event_info_function": "disabled"}) - + return(st) From f96a1dc9709aaa178263e674268e8c87d1e6995e Mon Sep 17 00:00:00 2001 From: Andrii Terliuk Date: Tue, 27 Jul 2021 12:49:31 -0500 Subject: [PATCH 3/8] some changes to make Daniel a bit happier, but still leeping shorter lines --- straxen/contexts.py | 76 +++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/straxen/contexts.py b/straxen/contexts.py index 8d97f88a4..eaec178de 100644 --- a/straxen/contexts.py +++ b/straxen/contexts.py @@ -220,17 +220,17 @@ def xenonnt_led(**kwargs): return st def xenonnt_simulation( - output_folder = './strax_data', - cmt_run_id_sim = None, - cmt_run_id_proc = None, - cmt_version = 'v3', - fax_config = 'fax_config_nt_design.json', - overwrite_from_fax_file_sim = False, - overwrite_from_fax_file_proc = False, - cmt_option_overwrite_sim = immutabledict(), - cmt_option_overwrite_proc = immutabledict(), - _forbid_creation_of = None, - _config_overlap = immutabledict( + output_folder='./strax_data', + cmt_run_id_sim=None, + cmt_run_id_proc=None, + cmt_version='v3', + fax_config='fax_config_nt_design.json', + overwrite_from_fax_file_sim=False, + overwrite_from_fax_file_proc=False, + cmt_option_overwrite_sim=immutabledict(), + cmt_option_overwrite_proc=immutabledict(), + _forbid_creation_of=None, + _config_overlap=immutabledict( drift_time_gate='electron_drift_time_gate', drift_velocity_liquid='electron_drift_velocity', electron_lifetime_liquid='elife_conf'), @@ -287,51 +287,45 @@ def xenonnt_simulation( st.context_config['forbid_creation_of'] += strax.to_str_tuple(_forbid_creation_of) # doing sanity checks for cmt run ids for simulation and processing - if not (cmt_run_id_sim is None) and not (cmt_run_id_proc is None): - if not (cmt_run_id_sim==cmt_run_id_proc): - print("INFO : divergent CMT runs for simulation and processing") - print(" cmt_run_id_sim".ljust(25), cmt_run_id_sim) - print(" cmt_run_id_proc".ljust(25), cmt_run_id_proc) - elif (cmt_run_id_sim is None) and not (cmt_run_id_proc is None): - cmt_run_id_sim=cmt_run_id_proc - elif not (cmt_run_id_sim is None) and (cmt_run_id_proc is None): - cmt_run_id_proc=cmt_run_id_sim + if (not cmt_run_id_sim ) and (not cmt_run_id_proc ): + raise RuntimeError("Setting both cmt_run_id_sim and cmt_run_id_proc to None") + if (cmt_run_id_sim and cmt_run_id_proc ) and (cmt_run_id_sim!=cmt_run_id_proc): + print("INFO : divergent CMT runs for simulation and processing") + print(" cmt_run_id_sim".ljust(25), cmt_run_id_sim) + print(" cmt_run_id_proc".ljust(25), cmt_run_id_proc) else: - raise RuntimeError("Trying to set both cmt_run_id_sim and cmt_run_id_proc to None") + cmt_id = cmt_run_id_sim or cmt_run_id_proc + cmt_run_id_sim = cmt_id + cmt_run_id_proc = cmt_id # Replace default cmt options with cmt_run_id tag + cmt run id cmt_options = straxen.get_corrections.get_cmt_options(st) # First, fix gain model for simulation - st.set_config({'gain_model_mc': tuple(['cmt_run_id', - cmt_run_id_sim, - *cmt_options['gain_model']])}) + st.set_config({'gain_model_mc': + ('cmt_run_id', cmt_run_id_sim, *cmt_options['gain_model'])}) fax_config_override_from_cmt = dict() for fax_field, cmt_field in _config_overlap.items(): - fax_config_override_from_cmt[fax_field] = tuple( - ['cmt_run_id', - cmt_run_id_sim, - *cmt_options[cmt_field]] - ) + fax_config_override_from_cmt[fax_field] = ('cmt_run_id', cmt_run_id_sim, + *cmt_options[cmt_field]) st.set_config({'fax_config_override_from_cmt': fax_config_override_from_cmt}) # and all other parameters for processing for option in cmt_options: - st.config[option] = tuple(['cmt_run_id', cmt_run_id_proc, *cmt_options[option]]) + st.config[option] = ('cmt_run_id', cmt_run_id_proc, *cmt_options[option]) # Done with "default" usage, now to overwrites from file # # Take fax config and put into context option - if (overwrite_from_fax_file_proc or - overwrite_from_fax_file_sim): + if overwrite_from_fax_file_proc or overwrite_from_fax_file_sim: fax_config = straxen.get_resource(fax_config, fmt='json') for fax_field, cmt_field in _config_overlap.items(): if overwrite_from_fax_file_proc: - st.config[cmt_field] = tuple([ - cmt_options[cmt_field][0] + '_constant',fax_config[fax_field]]) + st.config[cmt_field] = ( cmt_options[cmt_field][0] + '_constant', + fax_config[fax_field]) if overwrite_from_fax_file_sim: - st.config['fax_config_override_from_cmt'][fax_field] = tuple( - [cmt_options[cmt_field][0] + '_constant',fax_config[fax_field]]) + st.config['fax_config_override_from_cmt'][fax_field] = ( + cmt_options[cmt_field][0] + '_constant',fax_config[fax_field]) # And as the last step - manual overrrides, since they have the highest priority # User customized for simulation @@ -347,9 +341,8 @@ def xenonnt_simulation( continue _name_index = 2 if 'cmt_run_id' in cmt_options[option] else 0 st.config['fax_config_override_from_cmt'][fax_key] = ( - cmt_options[option][_name_index] + '_constant', - cmt_option_overwrite_sim[option] - ) + cmt_options[option][_name_index] + '_constant', + cmt_option_overwrite_sim[option]) del(fax_key,cmt_key,_name_index) # User customized for simulation for option in cmt_option_overwrite_proc: @@ -357,12 +350,13 @@ def xenonnt_simulation( raise ValueError(f'Overwrite option {option} is not using CMT by default ' 'you should just use set config') _name_index = 2 if 'cmt_run_id' in cmt_options[option] else 0 - st.config[option] = (cmt_options[option][_name_index] + '_constant', cmt_option_overwrite_proc[option]) + st.config[option] = (cmt_options[option][_name_index] + '_constant', + cmt_option_overwrite_proc[option]) del(_name_index) # Only for simulations st.set_config({"event_info_function": "disabled"}) - return(st) + return st ## From 18ae54f597378aba369d6bb1311f18101d95f3f5 Mon Sep 17 00:00:00 2001 From: Andrii Terliuk Date: Wed, 28 Jul 2021 03:14:00 -0500 Subject: [PATCH 4/8] Changes to error and docstring --- straxen/contexts.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/straxen/contexts.py b/straxen/contexts.py index eaec178de..2e38b2ca8 100644 --- a/straxen/contexts.py +++ b/straxen/contexts.py @@ -248,11 +248,16 @@ def xenonnt_simulation( data. This means starting from already existing raw_records and finishing with higher level data, such as peaks, events etc. + If only one cmt_run_id is given, the second one will be set automatically, + resulting in CMT match between simulation and processing. However, detector + parameters can be still overwritten from fax file or manually using cmt + config overwrite options. + CMT options can also be overwritten via fax config file. :param output_folder: Output folder for strax data. - :param cmt_run_id_sim: Run id for detector parameters from CMT to be used in + :param cmt_run_id_sim: Run id for detector parameters from CMT to be used for creation of raw_records. - :param cmt_run_id_proc: Run id for detector parameters from CMT to be used in + :param cmt_run_id_proc: Run id for detector parameters from CMT to be used for processing from raw_records to higher level data. :param cmt_version: Global version for corrections to be loaded. :param fax_config: Fax config file to use. @@ -288,7 +293,8 @@ def xenonnt_simulation( # doing sanity checks for cmt run ids for simulation and processing if (not cmt_run_id_sim ) and (not cmt_run_id_proc ): - raise RuntimeError("Setting both cmt_run_id_sim and cmt_run_id_proc to None") + raise RuntimeError("cmt_run_id_sim and cmt_run_id_proc are None. " + "You have to specify at least one CMT run id. ") if (cmt_run_id_sim and cmt_run_id_proc ) and (cmt_run_id_sim!=cmt_run_id_proc): print("INFO : divergent CMT runs for simulation and processing") print(" cmt_run_id_sim".ljust(25), cmt_run_id_sim) From 270a059e45707ba005791c982fe1d1d9788af425 Mon Sep 17 00:00:00 2001 From: Andrii Terliuk Date: Wed, 28 Jul 2021 04:00:03 -0500 Subject: [PATCH 5/8] actually, there should be break here --- straxen/contexts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/straxen/contexts.py b/straxen/contexts.py index 2e38b2ca8..84cea3210 100644 --- a/straxen/contexts.py +++ b/straxen/contexts.py @@ -344,7 +344,7 @@ def xenonnt_simulation( 'CMT to fax config! ') for fax_key,cmt_key in _config_overlap.items(): if cmt_key==option: - continue + break _name_index = 2 if 'cmt_run_id' in cmt_options[option] else 0 st.config['fax_config_override_from_cmt'][fax_key] = ( cmt_options[option][_name_index] + '_constant', From ad506204cd12393dae1b54c35e4cddf179ea1179 Mon Sep 17 00:00:00 2001 From: Andrii Terliuk Date: Wed, 28 Jul 2021 04:34:26 -0500 Subject: [PATCH 6/8] Small modification in the loop --- straxen/contexts.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/straxen/contexts.py b/straxen/contexts.py index 84cea3210..d446cf653 100644 --- a/straxen/contexts.py +++ b/straxen/contexts.py @@ -344,11 +344,10 @@ def xenonnt_simulation( 'CMT to fax config! ') for fax_key,cmt_key in _config_overlap.items(): if cmt_key==option: - break - _name_index = 2 if 'cmt_run_id' in cmt_options[option] else 0 - st.config['fax_config_override_from_cmt'][fax_key] = ( - cmt_options[option][_name_index] + '_constant', - cmt_option_overwrite_sim[option]) + _name_index = 2 if 'cmt_run_id' in cmt_options[option] else 0 + st.config['fax_config_override_from_cmt'][fax_key] = ( + cmt_options[option][_name_index] + '_constant', + cmt_option_overwrite_sim[option]) del(fax_key,cmt_key,_name_index) # User customized for simulation for option in cmt_option_overwrite_proc: From 27863a16025b29f2cd8891d1870ba2e86000c1b2 Mon Sep 17 00:00:00 2001 From: Andrii Terliuk Date: Wed, 28 Jul 2021 09:15:19 -0500 Subject: [PATCH 7/8] Empty line to redo codefactor --- straxen/contexts.py | 1 - 1 file changed, 1 deletion(-) diff --git a/straxen/contexts.py b/straxen/contexts.py index d446cf653..00fcc0f61 100644 --- a/straxen/contexts.py +++ b/straxen/contexts.py @@ -363,7 +363,6 @@ def xenonnt_simulation( return st - ## # XENON1T ## From c79b2fe2ab29bd1385ef481e28bbcb3588acb2df Mon Sep 17 00:00:00 2001 From: Andrii Terliuk Date: Wed, 28 Jul 2021 09:23:46 -0500 Subject: [PATCH 8/8] Hopefully, this is the correct way to fix codefactor complain --- straxen/contexts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/straxen/contexts.py b/straxen/contexts.py index 00fcc0f61..2b0ef2e6c 100644 --- a/straxen/contexts.py +++ b/straxen/contexts.py @@ -348,7 +348,8 @@ def xenonnt_simulation( st.config['fax_config_override_from_cmt'][fax_key] = ( cmt_options[option][_name_index] + '_constant', cmt_option_overwrite_sim[option]) - del(fax_key,cmt_key,_name_index) + del(_name_index) + del(fax_key, cmt_key) # User customized for simulation for option in cmt_option_overwrite_proc: if option not in cmt_options: