Example #1
0
File: detect.py Project: LucMiaz/KG
 def from_measurement(cls, ID, mic, Paths):
     found=False
     if Paths:
         for p in Paths:
             presults=p.joinpath('raw_signals')
             listfiles= os.listdir(presults.as_posix())
             if listfiles.count(str(ID)+"_"+str(mic)+".mat")>0:
                 measuredSignal.setup(p)
                 pathmes=p
                 found=True
                 print(str(p))
                 break
             
     if not found:
         return None
     mS = measuredSignal(ID,mic)
     if mS.initialized:
         y,t,sR = mS.get_signal(mic)
         ch_info = mS.channel_info(mic)
         var = ['Tb','Te','Tp_b','Tp_e','LAEQ']
         mesValues= measuredValues.from_json(pathmes)
         micValues = mesValues.get_variables_values(ID, mic, var)
         micValues.update(ch_info)
         return(cls(ID,mic,y,t,sR, micValues), mesValues)
     else:#if the signal could not be found return None
         return None
Example #2
0
 splitvalidID=split_list(validID2,validlength//blocks_size)
 print('Case cases in :')
 print(str(validID2[0])+', --- , '+str(validID2[-1])+' : '+str(len(validID2))+' items.')
 print('----------------------')
 for validIDs in tqdm(splitvalidID):
     for file in tqdm(validIDs):
         ID=file.split('_')[0:-1]
         id=ID[0]
         for i in range(1,len(ID)):
             id+='_'+ID[i]
         ID=id
         mic=file.split('_')[-1]
         #print('('+ID+', '+str(mic)+')', end = '; ')
         # read the signal
         try:
             mS = measuredSignal(ID,mic)
         except:
             print('element avoided')
         else:
             if mS.is_initialized():
                 y, t, sR = mS.get_signal(mic)
                 ch_info = mS.channel_info(mic)
                 # get the values from measuredValues to initiate MicSignal and Case
                 var = ['Tb','Te','Tp_b','Tp_e','LAEQ']
                 micValues = mesVal.get_variables_values(ID, mic, var)
                 if micValues:
                     micValues.update(ch_info)
                     # initiate  MicSignal
                     micSn = MicSignal(ID,mic,y,t,sR, micValues)
                     # test if signal is clipped, skip it if True
                     if micSn.clippedtest():