예제 #1
0
파일: detect.py 프로젝트: 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
예제 #2
0
파일: case.py 프로젝트: LucMiaz/KG
#     print(casePath.absolute())
#     return(casePath)
# #     
# # @decorator
# # def init2( mesPath, author ):
# #     authP = mesPath.joinpath('test_cases').joinpath(author)
# #     #collect cases
# #     casePaths = [ cp  for cp in authP.iterdir() if cp.match('case_**.json') ]
# #     print(casePaths)
# #     return(casePaths[0])
# # 
# # 

## Test
if __name__ == "__main__":
    from kg.detect import MicSignal
    from kg.algorithm import *
    from kg.algorithm import Case
    from kg.widgets import *
    from kg.measurement_values import measuredValues
    from kg.measurement_signal import measuredSignal
    mesPath = pathlib.Path('Measurements_example\MBBMZugExample')
    mesVal = measuredValues.from_json(mesPath)
    measuredSignal.setup(mesPath)
    W = CaseCreatorWidget.from_measurement(mesVal,'m_0100',[6])
    W.show()
##save
    casePath = mesPath.joinpath('test_cases/esr/case_m_0100_6_esr.json').absolute()
    case = Case.from_JSON(casePath)

    
예제 #3
0
파일: alg_widget.py 프로젝트: LucMiaz/KG
 Paths.append(pathlib.Path('E:/Biel1Vormessung'))
 app=QtGui.QApplication()
 CTW=QtGui.QWidget()
 graphical=False
 if graphical:
     algorithmclass, valid=QtGui.QInputDialog.getItem(CTW,"Algorithm","Please select an algorithm type", [str(cls.__name__) for cls in vars()['Algorithm'].__subclasses__()])
     if valid:
         algorithm=eval(algorithmclass+".askforattributes(CTW)")
 # setup algorithms
 # todo: parametrize alg parameter in the best possible way 
 algorithms = [ZischenDetetkt2(4000,0.79088,0.02)]
 
 ##load cases
 # load measured values
 jsonpath=mesPath.joinpath(pathlib.Path('measurements_example/MBBMZugExample'))
 mesVal = measuredValues.from_json(jsonpath)
 location =  mesVal.location
 measurement = mesVal.measurement
 
 # setup  measured signal 
 measuredSignal.setup(jsonpath)
 # todo: if necessary serialize on mesVal
 mesValues = measuredValues.from_json(jsonpath)
 casePath1 = mesValues.path.joinpath('test_cases/luc/case_m_1656_4_luc.json')
 case1 = Case.from_JSON(casePath1)
 casePath2 = mesValues.path.joinpath('test_cases/luc/case_m_2791_1_luc.json')
 case2 = Case.from_JSON(casePath2)
 ##
 case = case2
 micSn, mesVal = MicSignal.from_measurement(case.case['mID'],case.case['mic'], Paths)
 micSn.calc_kg(algorithms[0])