algorithms.append(ZischenDetetkt2(3500,1.99828945412812,0.1,Rexport=True)) algorithms.append(ZischenDetetkt2(3000,2.22468607016445,0.05,Rexport=True)) algorithms.append(ZischenDetetkt2(3000,2.57727672753696,0.1,Rexport=True)) algorithms.append(ZischenDetetkt2(2000,2.89499961394424,0.02,Rexport=True)) algorithms.append(ZischenDetetkt2(2000,3.23479771056204,0.05,Rexport=True)) algorithms.append(ZischenDetetkt2(2000,3.52850682557497,0.1,Rexport=True)) #load cases # todo: if necessary serialize on mesVal mesValues = measuredValues.from_json(mesPath) casePath = mesValues.path.joinpath('test_cases') #collect cases cases = [] for authP in casePath.iterdir(): if authP.is_dir(): print(authP) cases.extend([Case.from_JSON(cp) for cp in authP.iterdir()\ if cp.match('case_**.json') ]) notfound=[] print('Case cases:') print('----------------------') for case in cases: print(str(case)) mID = case.case['mID'] mic = case.case['mic'] # initaite mic signal micSn, mesVal = MicSignal.from_measurement(mID, mic, Paths=Paths) if micSn: for alg in algorithms: print(str(alg),end = ', ') alg.test_on_case(case, mesVal, micSn) print('.')
# 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)
# 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]) ## if 2<1: f,axes = plt.subplots(2,sharex = True) ax = axes[0] micSn.plot_triggers(ax,color = '#272822',lw=1) micSn.plot_BPR(algorithm, ax, color = '#272822', linewidth=1) case.plot(ax) ax.set_xlim(-0.5,8) ymin,ymax = ax.get_ylim()