You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please do not read
I still need to figure out if this is actually a problem or not. Nevertheless, let me write it down
Symptons
# from straxen/tests/importtempfileimportstraximportstraxenimportnumpyasnpfromimmutabledictimportimmutabledictfromstrax.testutilsimportrun_id, recs_per_chunkimportos# Number of chunks for the dummy raw records we are writing hereN_CHUNKS=2### Tools### Some configs are better obtained from the strax_auxiliary_files repo.# Let's use small files, we don't want to spend a lot of time downloading# some file.testing_config_nT=dict(
nn_architecture=straxen.aux_repo+'f0df03e1f45b5bdd9be364c5caefdaf3c74e044e/fax_files/mlp_model.json',
nn_weights=straxen.aux_repo+'f0df03e1f45b5bdd9be364c5caefdaf3c74e044e/fax_files/mlp_model.h5',
nn_file=None,
gain_model=
('to_pe_per_run',
straxen.aux_repo+'58e615f99a4a6b15e97b12951c510de91ce06045/fax_files/to_pe_nt.npy')
)
testing_config_1T=dict(
hev_gain_model=('to_pe_constant', 0.0085),
gain_model=('to_pe_constant', 0.0085)
)
@strax.takes_config(strax.Option('secret_time_offset', default=0, track=False))classDummyRawRecords(strax.Plugin):
""" Provide dummy raw records for the mayor raw_record types """provides= ('raw_records',
'raw_records_he',
'raw_records_nv',
'raw_records_aqmon',
'raw_records_aux_mv',
'raw_records_mv'
)
parallel='process'depends_on=tuple()
data_kind=immutabledict(zip(provides, provides))
rechunk_on_save=Falsedtype= {p: strax.raw_record_dtype() forpinprovides}
defsource_finished(self):
returnTruedefis_ready(self, chunk_i):
returnchunk_i<N_CHUNKSdefcompute(self, chunk_i):
t0= (chunk_i)*2+self.config['secret_time_offset']
ifchunk_i<N_CHUNKS-1:
r=np.zeros(recs_per_chunk, self.dtype['raw_records'])
r['time'] =t0r['length'] =r['dt'] =1r['channel'] =np.arange(len(r))
else:
r=np.zeros(0, self.dtype['raw_records'])
res= {p:
self.chunk(start=t0, end=t0+1, data=r, data_type=p)
forpinself.provides}
returnres# Don't concern ourselves with rr_aqmon et ceteraforbidden_plugins=tuple([pforpinstraxen.daqreader.DAQReader.providesifpnotinDummyRawRecords.provides])
def_run_plugins(st,
make_all=False,
run_id=run_id,
**proces_kwargs):
""" Try all plugins (except the DAQReader) for a given context (st) to see if we can really push some (empty) data from it and don't have any nasty problems like that we are referring to some non existant dali folder. """withtempfile.TemporaryDirectory() astemp_dir:
st.storage= [strax.DataDirectory(temp_dir)]
# As we use a temporary directory we should have a clean startassertnotst.is_stored(run_id, 'raw_records'), 'have RR???'# Create event infotarget='event_info'st.make(run_id=run_id,
targets=target,
**proces_kwargs)
# The stuff should be thereassertst.is_stored(run_id, target), f'Could not make {target}'# I'm only going to do this for nT because:# A) Doing this many more times does not give us much more# info (everything above already worked fine)# B) Most development will be on nT, 1T may get less changes# in the near futureifmake_all:
# Now make sure we can get some data for all pluginsforpinlist(st._plugin_class_registry.keys()):
ifpnotinforbidden_plugins:
st.get_array(run_id=run_id,
targets=p,
**proces_kwargs)
# Check for types that we want to save that they are stored.if (int(st._plugin_class_registry['peaks'].save_when) >int(strax.SaveWhen.TARGET)):
is_stored=st.is_stored(run_id, p)
assertis_stored, f"{p} did not save correctly!"print("Wonderful all plugins work (= at least they don't fail), bye bye")
def_update_context(st, max_workers, fallback_gains=None, nt=True):
# Change config to allow for testing both multiprocessing and lazy modest.set_context_config({'forbid_creation_of': forbidden_plugins})
st.register(DummyRawRecords)
ifnt:
st.set_config(testing_config_nT)
ifstraxen.uconfigisNone:
st.register(straxen.PeakPositions1T)
else:
st.set_config(testing_config_1T)
try:
ifstraxen.uconfigisNone:
raiseValueError('uconfig did not import')
# If you want to have quicker checks: always raise an ValueError# as the CMT does take quite long to load the right corrections.ifmax_workers>1andfallback_gainsisnotNone:
raiseValueError(
'Use fallback gains for multicore to save time on tests')
exceptValueError:
# Okay so we cannot initize the runs-database. Let's just use some# fallback values if they are specified.if ('gain_model'inst.configandst.config['gain_model'][0] =='CMT_model'):
iffallback_gainsisNone:
# If you run into this error, go to the test_nT() - test and# see for example how it is done there.raiseValueError('Context uses CMT_model but no fallback_gains ''are specified in test_plugins.py for this ''context being tested')
else:
st.set_config({'gain_model': fallback_gains})
ifmax_workers-1:
st.set_context_config({
'allow_multiprocess': True,
'allow_lazy': False,
'timeout': 60, # we don't want to build travis for ever
})
st=straxen.contexts.xenonnt_online(_database_init=False)
offline_gain_model= ('to_pe_constant', 'gain_placeholder')
_update_context(st, 1, fallback_gains=offline_gain_model, nt=True)
p=st.get_array('008900', 'peak_basics')
Then we can open the metadata:
while peaklets had a very different structure:
The text was updated successfully, but these errors were encountered:
Please do not read
I still need to figure out if this is actually a problem or not. Nevertheless, let me write it down
Symptons
Then we can open the metadata:
while peaklets had a very different structure:
The text was updated successfully, but these errors were encountered: