-
Notifications
You must be signed in to change notification settings - Fork 9
refactor #363 #376
refactor #363 #376
Conversation
|
||
st = strax.Context( | ||
storage=tempdir, | ||
config=dict( | ||
nchunk=2, event_rate=1, chunk_size=1, | ||
detector='XENON1T', | ||
fax_config=('https://raw.githubusercontent.com/XENONnT/strax_auxiliary_files' | ||
'/36d352580b328ff057b1588b8af8c9a6ed8ae704/sim_files/fax_config_1t.json'), # noqa | ||
'/a5b92102505d6d0bfcdb563b6117bd4040a93435/sim_files/fax_config_1t.json'), # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
important to get the latest version
fax_config_override=dict( | ||
url_base=("https://raw.githubusercontent.com/XENONnT/strax_auxiliary_files" | ||
"/36d352580b328ff057b1588b8af8c9a6ed8ae704/sim_files/"), ), | ||
"/a5b92102505d6d0bfcdb563b6117bd4040a93435/sim_files/"), | ||
**conf_1t, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and update with the test in the load-resource test
|
||
@skipIf(not straxen.utilix_is_configured(), 'utilix is not configured') | ||
def test_sim_nt_advanced( | ||
config = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should always test the default config - this wasn't done before
st.set_config({'fax_config_override': dict(s2_luminescence_model='simple', | ||
s2_time_model="s2_time_spread around zero", | ||
s1_lce_correction_map='XENONnT_s1_xyz_LCE_corrected_qes_MCva43fa9b_wires.json.gz', | ||
s1_time_spline='XENONnT_s1_proponly_va43fa9b_wires_20200625.json.gz', | ||
s1_model_type='optical_propagation+simple',)}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add this in a separate test
@skipIf(not straxen.utilix_is_configured(), 'utilix is not configured') | ||
def test_nt_advanced_alt_s2_model(): | ||
config = dict( | ||
fax_config_override=dict( | ||
s2_luminescence_model='simple', | ||
s2_time_model="s2_time_spread around zero", | ||
s1_lce_correction_map='XENONnT_s1_xyz_LCE_corrected_qes_MCva43fa9b_wires.json.gz', | ||
s1_time_spline='XENONnT_s1_proponly_va43fa9b_wires_20200625.json.gz', | ||
s1_model_type='optical_propagation+simple', | ||
) | ||
) | ||
test_sim_nt_advanced(config) | ||
|
||
|
||
@skipIf(not straxen.utilix_is_configured(), 'utilix is not configured') | ||
def test_nt_advanced_garfield(): | ||
config = dict( | ||
fax_config_override=dict( | ||
s2_luminescence_model='garfield', | ||
s2_correction_map=False, | ||
s2_time_model="s2_time_spread around zero", | ||
s1_lce_correction_map='XENONnT_s1_xyz_LCE_corrected_qes_MCva43fa9b_wires.json.gz', | ||
s1_time_spline='XENONnT_s1_proponly_va43fa9b_wires_20200625.json.gz', | ||
s1_model_type='optical_propagation+simple', | ||
) | ||
) | ||
test_sim_nt_advanced(config) | ||
|
||
@skipIf(not straxen.utilix_is_configured(), 'utilix is not configured') | ||
def test_nt_advanced_gas_gap_garfield(): | ||
config = dict( | ||
fax_config_override=dict( | ||
s2_luminescence_model='garfield_gas_gap', | ||
s2_correction_map="XENONnT_s2_xy_map_v4_210503_mlp_3_in_1_iterated.json", | ||
s2_luminescence_gg= "garfield_timing_map_gas_gap_sr0.npy", | ||
garfield_gas_gap_map= "garfield_gas_gap_map_sr0.json", | ||
se_gain_map="XENONnT_se_xy_map_v1_mlp.json", | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bunch of older test configurations that we should keep supporting
@@ -455,7 +457,7 @@ def digitizer_saturation(data, channel_mask): | |||
@export | |||
class RawDataOptical(RawData): | |||
|
|||
def __init__(self, config, channels=[], timings=[]): | |||
def __init__(self, config, channels=tuple(), timings=tuple()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having mutable default is an absolutely disastrous idea
if ('ext_eff_from_map' not in config): | ||
cy = electron_lifetime_correction*config['electron_extraction_yield'] | ||
else: | ||
if config['ext_eff_from_map'] == False: | ||
cy = electron_lifetime_correction*config['electron_extraction_yield'] | ||
else: | ||
# Extraction efficiency is g2(x,y)/SE_gain(x,y) | ||
cy = config['g2_mean']*resource.s2_correction_map(xy_int)*\ | ||
electron_lifetime_correction/resource.se_gain_map(xy_int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looked a bit convoluted
s2_luminescence_map = straxen.get_resource(files['s2_luminescence'], fmt='npy') | ||
self.s2_luminescence = s2_luminescence_map | ||
|
||
gf_file_name = files['s2_luminescence'] | ||
if gf_file_name.endswith('npy'): | ||
s2_luminescence_map = straxen.get_resource(gf_file_name, fmt='npy') | ||
self.s2_luminescence = s2_luminescence_map | ||
elif gf_file_name.endswith('npz'): | ||
# Backwards compatibility from before #363 / #370 | ||
s2_luminescence_map = straxen.get_resource(gf_file_name, fmt='npy_pickle')['arr_0'] | ||
# Get directly the map for the simulated level | ||
liquid_level_available = np.unique(s2_luminescence_map['ll']) # available levels (cm) | ||
liquid_level = config['gate_to_anode_distance'] - config['elr_gas_gap_length'] # cm | ||
liquid_level = min(liquid_level_available, key=lambda x: abs(x - liquid_level)) | ||
self.s2_luminescence = s2_luminescence_map[s2_luminescence_map['ll'] == liquid_level] | ||
else: | ||
raise ValueError(f'{gf_file_name} is of unknown format') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why the tests kept failing
def __init__(self, config=None): | ||
if config is None: | ||
config = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mutable defaults strike again
Hi Joran, Thank you for checking these tests, I really appreciate it! |
Fix a few problems and testing for #363