diff --git a/etabackend/static/help.html b/etabackend/static/help.html index 0345132..6e3fce8 100644 --- a/etabackend/static/help.html +++ b/etabackend/static/help.html @@ -50,7 +50,7 @@ ONLINE DOCUMENTATION - ETA GUI Version: 0.9.6 + ETA GUI Version: 0.9.7 Exit diff --git a/etabackend/static/recipes/Correlation-hydraharp.eta b/etabackend/static/recipes/Correlation-hydraharp.eta index 8902fed..52b1ef8 100644 --- a/etabackend/static/recipes/Correlation-hydraharp.eta +++ b/etabackend/static/recipes/Correlation-hydraharp.eta @@ -1 +1 @@ -{"vi_templatejg59migx":"{\"nodes\":[{\"x\":101,\"y\":101,\"fixed\":true,\"text\":\"a\",\"px\":101,\"py\":101,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"1\"}],\"usercode\":\"a:\\n emit(4,`bw_delay`)# here, ch1 is duplicated to ch3 with a delay of 0ps\"}","vi_templatejfc9koma":"{\"nodes\":[{\"x\":82,\"y\":88,\"fixed\":true,\"text\":\"a\",\"px\":82,\"py\":88,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"0\"}],\"usercode\":\"a:\\n emit(3,`fw_delay`)# here, ch0 is duplicated to ch2 with a delay of 0ps\"}","vi_templatejg52ksbp":"{\"nodes\":[{\"x\":346,\"y\":111,\"fixed\":true,\"text\":\"start\",\"px\":346,\"py\":111},{\"x\":95,\"y\":102,\"fixed\":true,\"text\":\"stop\",\"px\":95,\"py\":102,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":1,\"text\":\"4\"},{\"source\":1,\"target\":0,\"text\":\"3\"},{\"source\":0,\"target\":0,\"text\":\"3\"},{\"source\":1,\"target\":1,\"text\":\"4\"}],\"usercode\":\"HISTOGRAM(h4,(`bins`,`binsize`,\\\"time-1\\\"))\\nHISTOGRAM(h4_zero,(1,1))\\nCLOCK(c4,100,1)\\nstart:\\n c4.start()\\nstop:\\n c4.stop()\\n h4.record_all(c4)\\n h4_zero.record_all(c4)\"}","vi_templatejfb2qshf":"{\"nodes\":[{\"x\":346,\"y\":111,\"fixed\":true,\"text\":\"start\",\"px\":346,\"py\":111},{\"x\":102,\"y\":102,\"fixed\":true,\"text\":\"stop\",\"px\":102,\"py\":102,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":1,\"text\":\"3\"},{\"source\":1,\"target\":0,\"text\":\"4\"},{\"source\":0,\"target\":0,\"text\":\"4\"},{\"source\":1,\"target\":1,\"text\":\"3\"}],\"usercode\":\"HISTOGRAM(h3,(`bins`,`binsize`))\\nCLOCK(c3,100,1)\\nstart:\\n c3.start()\\nstop:\\n c3.stop()\\n h3.record_all(c3)\"}","eta_index_table":"[{\"id\":\"var_templatejgmgopco\",\"name\":\"file\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.timeres\"},{\"id\":\"var_templatejkim8l39\",\"name\":\"binsize\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"16\"},{\"id\":\"var_templatejkim8rzm\",\"name\":\"expname\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"Correlation\"},{\"id\":\"var_templatejkim8w21\",\"name\":\"bins\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"10000\"},{\"id\":\"var_templatek71lu4ak\",\"name\":\"records_per_cut\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"2e5\"},{\"id\":\"var_templatek7uj6ou8\",\"name\":\"HH400_mode\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"T3\"},{\"id\":\"var_templatek8g3kag4\",\"name\":\"delay\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"var_templatek8g498fo\",\"name\":\"bw_delay\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"var_templatek8g49hcs\",\"name\":\"fw_delay\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"dpp_templatek7r3sgz1\",\"name\":\"display\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatek0e4ffk5\",\"name\":\"save txt\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatek6z7rk2w\",\"name\":\"HH400\",\"group\":\"T2,T3\",\"info\":\"📜[0, 1, 2] \",\"config\":\"\"},{\"id\":\"vi_templatek0e44hsk\",\"name\":\"DL1-3 (T2)\",\"group\":\"T2\",\"info\":\"📥[1] 📤[3] \",\"config\":\"\"},{\"id\":\"vi_templatek0e44v54\",\"name\":\"DL2-4 (T2)\",\"group\":\"T2\",\"info\":\"📥[2] 📤[4] \",\"config\":\"\"},{\"id\":\"vi_templatejfc9koma\",\"name\":\"DL0-3 (T3)\",\"group\":\"T3\",\"info\":\"📥[0] 📤[3] \",\"config\":\"\"},{\"id\":\"vi_templatejg59migx\",\"name\":\"DL1-4 (T3)\",\"group\":\"T3\",\"info\":\"📥[1] 📤[4] \",\"config\":\"\"},{\"id\":\"vi_templatejg52ksbp\",\"name\":\"backward correlation\",\"group\":\"T2,T3\",\"info\":\"📥[4, 3] \",\"config\":\"\"},{\"id\":\"vi_templatejfb2qshf\",\"name\":\"forward correlation\",\"group\":\"T2,T3\",\"info\":\"📥[3, 4] \",\"config\":\"\"}]","var_templatejgmgopco":null,"var_templatejkim8l39":null,"var_templatejkim8rzm":null,"var_templatejkim8w21":null,"vi_templatek0e44hsk":"{\"nodes\":[{\"x\":82,\"y\":88,\"fixed\":true,\"text\":\"a\",\"px\":82,\"py\":88,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"1\"}],\"usercode\":\"a:\\n emit(3,`fw_delay`)# here, ch0 is duplicated to ch2 with a delay of 0ps\"}","vi_templatek0e44v54":"{\"nodes\":[{\"x\":101,\"y\":101,\"fixed\":true,\"text\":\"a\",\"px\":101,\"py\":101,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"2\"}],\"usercode\":\"a:\\n emit(4,`bw_delay`)# here, ch1 is duplicated to ch3 with a delay of 0ps\"}","dpp_templatek0e4ffk5":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return (f'Created with ETA - https://timetag.github.io\\n'\r\n f'filename: {filename.name}\\n'\r\n f'binsize: {binsize}\\n'\r\n f'bins: {bins}\\n'\r\n f'mode: {lambda HH400_mode: HH400_mode if HH400_mode in globals() else \"qutag\"}\\n'\r\n )\r\n\r\n#------ADJUST DELAY-----\r\ndelay = int(float(delay))\r\neta.recipe.set_parameter(\"bw_delay\",str(max(0,-1*delay)))\r\neta.recipe.set_parameter(\"fw_delay\",str(max(0,delay)))\r\neta.load_recipe()\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n cutfile = eta.clips(f)\r\n result=eta.run({\"timetagger1\":cutfile}, group=HH400_mode)\r\n hist1=result[\"h3\"]\r\n hist2=result[\"h4\"] \r\n hist0=result[\"h4_zero\"]\r\n hist1[0]+= hist0[0]\r\n fullhist=np.concatenate((hist2[::-1],hist1))\r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_correlation' + '.txt'), np.transpose([np.arange(-hist2.size,hist1.size)*binsize,fullhist]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')\r\n\r\n","vi_templatek6z7rk2w":"{\"nodes\":[{\"x\":129,\"y\":62,\"fixed\":true,\"initial\":true}],\"edges\":[],\"usercode\":\"\\n########## click Help on the menu to get started! ##########\\nRFILE(timetagger1,[0,1,2])\"}","var_templatek71lu4ak":null,"dpp_templatek7r3sgz1":"import pathlib\nimport logging\n\nimport numpy as np\n\nfrom bokeh.application import Application\nfrom bokeh.application.handlers.function import FunctionHandler\nimport etabackend.tk as etatk\n\nlogger = logging.getLogger('etabackend.frontend')\n\nlogger.info(\"ETA realtime is started.\")\n\nrecords_per_cut = int(float(records_per_cut)\n ) if records_per_cut != \"\" else None\n\nSIMULATE_GROWTH = False\nDATAFOLDER = 'analyzed data'\nTITLE = expname\n\nbinsize = int(float(binsize))\nbins = int(float(bins))\nbin_factor = int(float(binsize))\nfile = pathlib.Path(file)\n\n#------ADJUST DELAY-----\ndelay = int(float(delay))\neta.recipe.set_parameter(\"bw_delay\",str(max(0,-1*delay)))\neta.recipe.set_parameter(\"fw_delay\",str(max(0,delay)))\neta.load_recipe()\n\n#------Evaluate Data-----\nclass HistogramResult(etatk.data.ETAResult):\n def calculate_result(self, result):\n hist1 = result['h3']\n hist2 = result['h4']\n hist0 = result[\"h4_zero\"]\n hist1[0] += hist0[0]\n xdata = np.arange(-hist2.size, hist1.size) * bin_factor\n ydata = np.concatenate((hist2[::-1], hist1))\n return xdata, ydata\n\nresult = HistogramResult(file, group=HH400_mode, records_per_cut=records_per_cut, \n kernel=eta, timeout=0.2, run_immediately=False, \n simulate_growth=SIMULATE_GROWTH)\nresult.update()\nbp = etatk.plot.ETABokehPlot(result, result_folder=DATAFOLDER, title=TITLE)\n\nnot_displaying = eta.display(Application(FunctionHandler(bp.bokeh_plot_document)), 'bokeh')\nbp.run(not_displaying)\n\nlogger.info(\"ETA realtime is stopped.\")","var_templatek7uj6ou8":null,"var_templatek8g3kag4":null,"var_templatek8g498fo":null,"var_templatek8g49hcs":null} \ No newline at end of file +{"vi_templatejg59migx":"{\"nodes\":[{\"x\":101,\"y\":101,\"fixed\":true,\"text\":\"a\",\"px\":101,\"py\":101,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"1\"}],\"usercode\":\"a:\\n emit(4,`bw_delay`)# here, ch1 is duplicated to ch3 with a delay of 0ps\"}","vi_templatejfc9koma":"{\"nodes\":[{\"x\":82,\"y\":88,\"fixed\":true,\"text\":\"a\",\"px\":82,\"py\":88,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"0\"}],\"usercode\":\"a:\\n emit(3,`fw_delay`)# here, ch0 is duplicated to ch2 with a delay of 0ps\"}","vi_templatejg52ksbp":"{\"nodes\":[{\"x\":346,\"y\":111,\"fixed\":true,\"text\":\"start\",\"px\":346,\"py\":111},{\"x\":95,\"y\":102,\"fixed\":true,\"text\":\"stop\",\"px\":95,\"py\":102,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":1,\"text\":\"4\"},{\"source\":1,\"target\":0,\"text\":\"3\"},{\"source\":0,\"target\":0,\"text\":\"3\"},{\"source\":1,\"target\":1,\"text\":\"4\"}],\"usercode\":\"HISTOGRAM(h4,(`bins`,`binsize`,\\\"time-1\\\"))\\nHISTOGRAM(h4_zero,(1,1))\\nCLOCK(c4,100,1)\\nstart:\\n c4.start()\\nstop:\\n c4.stop()\\n h4.record_all(c4)\\n h4_zero.record_all(c4)\"}","vi_templatejfb2qshf":"{\"nodes\":[{\"x\":346,\"y\":111,\"fixed\":true,\"text\":\"start\",\"px\":346,\"py\":111},{\"x\":102,\"y\":102,\"fixed\":true,\"text\":\"stop\",\"px\":102,\"py\":102,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":1,\"text\":\"3\"},{\"source\":1,\"target\":0,\"text\":\"4\"},{\"source\":0,\"target\":0,\"text\":\"4\"},{\"source\":1,\"target\":1,\"text\":\"3\"}],\"usercode\":\"HISTOGRAM(h3,(`bins`,`binsize`))\\nCLOCK(c3,100,1)\\nstart:\\n c3.start()\\nstop:\\n c3.stop()\\n h3.record_all(c3)\"}","eta_index_table":"[{\"id\":\"var_templatejgmgopco\",\"name\":\"file\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.timeres\"},{\"id\":\"var_templatejkim8l39\",\"name\":\"binsize\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"16\"},{\"id\":\"var_templatejkim8rzm\",\"name\":\"expname\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"Correlation\"},{\"id\":\"var_templatejkim8w21\",\"name\":\"bins\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"10000\"},{\"id\":\"var_templatek71lu4ak\",\"name\":\"records_per_cut\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"2e5\"},{\"id\":\"var_templatek7uj6ou8\",\"name\":\"HH400_mode\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"T3\"},{\"id\":\"var_templatek8g3kag4\",\"name\":\"delay\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"var_templatek8g498fo\",\"name\":\"bw_delay\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"var_templatek8g49hcs\",\"name\":\"fw_delay\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"dpp_templatek7r3sgz1\",\"name\":\"display\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatek0e4ffk5\",\"name\":\"save txt\",\"group\":\"T2,T3\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatek6z7rk2w\",\"name\":\"HH400\",\"group\":\"T2,T3\",\"info\":\"📜[0, 1, 2] \",\"config\":\"\"},{\"id\":\"vi_templatek0e44hsk\",\"name\":\"DL1-3 (T2)\",\"group\":\"T2\",\"info\":\"📥[1] 📤[3] \",\"config\":\"\"},{\"id\":\"vi_templatek0e44v54\",\"name\":\"DL2-4 (T2)\",\"group\":\"T2\",\"info\":\"📥[2] 📤[4] \",\"config\":\"\"},{\"id\":\"vi_templatejfc9koma\",\"name\":\"DL0-3 (T3)\",\"group\":\"T3\",\"info\":\"📥[0] 📤[3] \",\"config\":\"\"},{\"id\":\"vi_templatejg59migx\",\"name\":\"DL1-4 (T3)\",\"group\":\"T3\",\"info\":\"📥[1] 📤[4] \",\"config\":\"\"},{\"id\":\"vi_templatejg52ksbp\",\"name\":\"backward correlation\",\"group\":\"T2,T3\",\"info\":\"📥[4, 3] \",\"config\":\"\"},{\"id\":\"vi_templatejfb2qshf\",\"name\":\"forward correlation\",\"group\":\"T2,T3\",\"info\":\"📥[3, 4] \",\"config\":\"\"}]","var_templatejgmgopco":null,"var_templatejkim8l39":null,"var_templatejkim8rzm":null,"var_templatejkim8w21":null,"vi_templatek0e44hsk":"{\"nodes\":[{\"x\":82,\"y\":88,\"fixed\":true,\"text\":\"a\",\"px\":82,\"py\":88,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"1\"}],\"usercode\":\"a:\\n emit(3,`fw_delay`)# here, ch0 is duplicated to ch2 with a delay of 0ps\"}","vi_templatek0e44v54":"{\"nodes\":[{\"x\":101,\"y\":101,\"fixed\":true,\"text\":\"a\",\"px\":101,\"py\":101,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"2\"}],\"usercode\":\"a:\\n emit(4,`bw_delay`)# here, ch1 is duplicated to ch3 with a delay of 0ps\"}","dpp_templatek0e4ffk5":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return ('Created with ETA - https://timetag.github.io\\n'+'filename: {}\\n'.format(filename.name) +'binsize: {}\\n'.format(binsize) +'bins: {}\\n'.format(bins) +'mode: {}\\n'.format(HH400_mode if \"HH400_mode\" in globals() else \"qutag\") )\r\n\r\n\r\n#------ADJUST DELAY-----\r\ndelay = int(float(delay))\r\neta.recipe.set_parameter(\"bw_delay\",str(max(0,-1*delay)))\r\neta.recipe.set_parameter(\"fw_delay\",str(max(0,delay)))\r\neta.load_recipe()\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n cutfile = eta.clips(f)\r\n result=eta.run({\"timetagger1\":cutfile}, group=HH400_mode)\r\n hist1=result[\"h3\"]\r\n hist2=result[\"h4\"] \r\n hist0=result[\"h4_zero\"]\r\n hist1[0]+=hist0[0]\r\n hist0[0]=0\r\n fullhist=np.concatenate((hist2[::-1],hist1))\r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_correlation' + '.txt'), np.transpose([np.arange(-hist2.size,hist1.size)*binsize,fullhist]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')\r\n\r\n","vi_templatek6z7rk2w":"{\"nodes\":[{\"x\":129,\"y\":62,\"fixed\":true,\"initial\":true}],\"edges\":[],\"usercode\":\"\\n########## click Help on the menu to get started! ##########\\nRFILE(timetagger1,[0,1,2])\"}","var_templatek71lu4ak":null,"dpp_templatek7r3sgz1":"import pathlib\nimport logging\n\nimport numpy as np\n\nfrom bokeh.application import Application\nfrom bokeh.application.handlers.function import FunctionHandler\nimport etabackend.tk as etatk\n\nlogger = logging.getLogger('etabackend.frontend')\n\nlogger.info(\"ETA realtime is started.\")\n\nrecords_per_cut = int(float(records_per_cut)\n ) if records_per_cut != \"\" else None\n\nSIMULATE_GROWTH = False\nDATAFOLDER = 'analyzed data'\nTITLE = expname\n\nbinsize = int(float(binsize))\nbins = int(float(bins))\nbin_factor = int(float(binsize))\nfile = pathlib.Path(file)\n\n#------ADJUST DELAY-----\ndelay = int(float(delay))\neta.recipe.set_parameter(\"bw_delay\",str(max(0,-1*delay)))\neta.recipe.set_parameter(\"fw_delay\",str(max(0,delay)))\neta.load_recipe()\n\n#------Evaluate Data-----\nclass HistogramResult(etatk.data.ETAResult):\n def calculate_result(self, result):\n hist1 = result['h3']\n hist2 = result['h4']\n hist0 = result[\"h4_zero\"]\n hist1[0] += hist0[0]\n hist0[0] = 0\n xdata = np.arange(-hist2.size, hist1.size) * bin_factor\n ydata = np.concatenate((hist2[::-1], hist1))\n return xdata, ydata\n\nresult = HistogramResult(file, group=HH400_mode, records_per_cut=records_per_cut, \n kernel=eta, timeout=0.2, run_immediately=False, \n simulate_growth=SIMULATE_GROWTH)\nresult.update()\nbp = etatk.plot.ETABokehPlot(result, result_folder=DATAFOLDER, title=TITLE)\n\nnot_displaying = eta.display(Application(FunctionHandler(bp.bokeh_plot_document)), 'bokeh')\nbp.run(not_displaying)\n\nlogger.info(\"ETA realtime is stopped.\")","var_templatek7uj6ou8":null,"var_templatek8g3kag4":null,"var_templatek8g498fo":null,"var_templatek8g49hcs":null} \ No newline at end of file diff --git a/etabackend/static/recipes/Correlation-qutag.eta b/etabackend/static/recipes/Correlation-qutag.eta index e791149..e4e10c3 100644 --- a/etabackend/static/recipes/Correlation-qutag.eta +++ b/etabackend/static/recipes/Correlation-qutag.eta @@ -1 +1 @@ -{"eta_index_table":"[{\"id\":\"var_templatejgmgopco\",\"name\":\"file\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.timeres\"},{\"id\":\"var_templatejkim8l39\",\"name\":\"binsize\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"16\"},{\"id\":\"var_templatejkim8rzm\",\"name\":\"expname\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"Correlation\"},{\"id\":\"var_templatejkim8w21\",\"name\":\"bins\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"10000\"},{\"id\":\"var_templatek8g3kag4\",\"name\":\"delay\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"var_templatek8g498fo\",\"name\":\"bw_delay\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"var_templatek8g49hcs\",\"name\":\"fw_delay\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"dpp_templatek7r3sgz1\",\"name\":\"display\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatek0e4ffxo\",\"name\":\"save txt\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatek6z7s4mo\",\"name\":\"quTAG\",\"group\":\"quTAG\",\"info\":\"📜[0, 1, 2, 3, 4, 5] \",\"config\":\"\"},{\"id\":\"vi_templatek0e3lgeo\",\"name\":\"DL1-6 (quTAG)\",\"group\":\"quTAG\",\"info\":\"📥[1] 📤[6] \",\"config\":\"\"},{\"id\":\"vi_templatek0e3lz43\",\"name\":\"DL2-7 (quTAG)\",\"group\":\"quTAG\",\"info\":\"📥[2] 📤[7] \",\"config\":\"\"},{\"id\":\"vi_templatek0e3qybt\",\"name\":\"backward correlation (quTAG)\",\"group\":\"quTAG\",\"info\":\"📥[7, 6] \",\"config\":\"\"},{\"id\":\"vi_templatek0e3sowi\",\"name\":\"forward correlation (quTAG)\",\"group\":\"quTAG\",\"info\":\"📥[6, 7] \",\"config\":\"\"}]","var_templatejgmgopco":null,"var_templatejkim8l39":null,"var_templatejkim8rzm":null,"var_templatejkim8w21":null,"vi_templatek0e3lgeo":"{\"nodes\":[{\"x\":121,\"y\":114,\"fixed\":true,\"text\":\"a\",\"initial\":true,\"px\":121,\"py\":114}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"1\"}],\"usercode\":\"a:\\n emit(6,`fw_delay`)\"}","vi_templatek0e3lz43":"{\"nodes\":[{\"x\":89,\"y\":107,\"fixed\":true,\"initial\":true,\"text\":\"a\"}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"2\"}],\"usercode\":\"a:\\n emit(7,`bw_delay`)\"}","vi_templatek0e3qybt":"{\"nodes\":[{\"x\":346,\"y\":111,\"fixed\":true,\"text\":\"start\",\"px\":346,\"py\":111},{\"x\":75,\"y\":86,\"fixed\":true,\"text\":\"stop\",\"px\":75,\"py\":86,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":1,\"text\":\"7\"},{\"source\":1,\"target\":0,\"text\":\"6\"},{\"source\":0,\"target\":0,\"text\":\"6\"},{\"source\":1,\"target\":1,\"text\":\"7\"}],\"usercode\":\"HISTOGRAM(h4,(`bins`,`binsize`))\\nHISTOGRAM(h4_zero,(1,1))\\nCLOCK(c4,100,1)\\nstart:\\n c4.start()\\nstop:\\n c4.stop()\\n h4.record_all(c4)\\n h4_zero.record_all(c4)\"}","vi_templatek0e3sowi":"{\"nodes\":[{\"x\":346,\"y\":111,\"fixed\":true,\"text\":\"start\",\"px\":346,\"py\":111},{\"x\":76,\"y\":88,\"fixed\":true,\"text\":\"stop\",\"px\":76,\"py\":88,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":1,\"text\":\"6\"},{\"source\":1,\"target\":0,\"text\":\"7\"},{\"source\":0,\"target\":0,\"text\":\"7\"},{\"source\":1,\"target\":1,\"text\":\"6\"}],\"usercode\":\"HISTOGRAM(h3,(`bins`,`binsize`))\\nCLOCK(c3,100,1)\\nstart:\\n c3.start()\\nstop:\\n c3.stop()\\n h3.record_all(c3)\"}","dpp_templatek0e4ffxo":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return (f'Created with ETA - https://timetag.github.io\\n'\r\n f'filename: {filename.name}\\n'\r\n f'binsize: {binsize}\\n'\r\n f'bins: {bins}\\n'\r\n )\r\n\r\n#------ADJUST DELAY-----\r\ndelay = int(float(delay))\r\neta.recipe.set_parameter(\"bw_delay\",str(max(0,-1*delay)))\r\neta.recipe.set_parameter(\"fw_delay\",str(max(0,delay)))\r\neta.load_recipe()\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n cutfile = eta.clips(f)\r\n result=eta.run({\"timetagger1\":cutfile}, group='quTAG')\r\n hist1=result[\"h3\"]\r\n hist2=result[\"h4\"]\r\n hist0=result[\"h4_zero\"]\r\n hist1[0]+= hist0[0]\r\n fullhist=np.concatenate((hist2[::-1],hist1))\r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_correlation' + '.txt'), np.transpose([np.arange(-hist2.size,hist1.size)*binsize,fullhist]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')\r\n\r\n","vi_templatek6z7s4mo":"{\"nodes\":[{\"x\":192,\"y\":157,\"fixed\":true,\"initial\":true}],\"edges\":[],\"usercode\":\"\\n########## click Help on the menu to get started! ##########\\nRFILE(timetagger1,[0,1,2,3,4,5])\"}","dpp_templatek7r3sgz1":"# Unfortunately no realtime recipe for quTAG, as the file is not written by\n# the control software until the experiment is stopped.\n#------IMPORTS-----\n\nimport numpy as np\nimport pandas as pd\nfrom pathlib import Path\n\nimport etabackend.tk.plot as etaplt\nimport etabackend.tk.utils as etautils\n\n#------ADJUST DELAY-----\ndelay = int(float(delay))\neta.recipe.set_parameter(\"bw_delay\",str(max(0,-1*delay)))\neta.recipe.set_parameter(\"fw_delay\",str(max(0,delay)))\neta.load_recipe()\n\n#------ETA PROCESSING-----\ncut=eta.clips(Path(file))\nresult= eta.run({\"timetagger1\":cut}, group='quTAG')\nhist1=result[\"h3\"]\nhist2=result[\"h4\"]\nhist0=result[\"h4_zero\"]\nhist1[0]+= hist0[0]\n\nfullhist=np.concatenate((hist2[::-1],hist1))\nxdata = np.arange(-hist2.size,hist1.size)*int(float(binsize))\n\nf=Path(file)\nDATAFOLDER = 'analyzed data'\nLABEL = expname\n#------PLOTTING-----\n\ndf = pd.DataFrame(np.vstack((xdata, fullhist)).T, \n columns=['time bins', 'histogram events'])\ndf['log events'] = np.clip(df['histogram events'].values, 0.5, None)\n\ndef generate_doc(doc):\n root = etaplt.plot_histogram(df, f, f.parent.joinpath(DATAFOLDER), \n data_name=LABEL.capitalize(), file_label=LABEL.lower(), \n info=etautils.info(globals_dict=eta.compilecache_vars['quTAG'], recipe_type=LABEL))\n doc.add_root(root)\n return doc\n\neta.display(generate_doc, 'bokeh')\n","var_templatek8g3kag4":null,"var_templatek8g498fo":null,"var_templatek8g49hcs":null} \ No newline at end of file +{"eta_index_table":"[{\"id\":\"var_templatejgmgopco\",\"name\":\"file\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.timeres\"},{\"id\":\"var_templatejkim8l39\",\"name\":\"binsize\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"16\"},{\"id\":\"var_templatejkim8rzm\",\"name\":\"expname\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"Correlation\"},{\"id\":\"var_templatejkim8w21\",\"name\":\"bins\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"10000\"},{\"id\":\"var_templatek8g3kag4\",\"name\":\"delay\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"var_templatek8g498fo\",\"name\":\"bw_delay\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"var_templatek8g49hcs\",\"name\":\"fw_delay\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"0\"},{\"id\":\"dpp_templatek7r3sgz1\",\"name\":\"display\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatek0e4ffxo\",\"name\":\"save txt\",\"group\":\"quTAG\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatek6z7s4mo\",\"name\":\"quTAG\",\"group\":\"quTAG\",\"info\":\"📜[0, 1, 2, 3, 4, 5] \",\"config\":\"\"},{\"id\":\"vi_templatek0e3lgeo\",\"name\":\"DL1-6 (quTAG)\",\"group\":\"quTAG\",\"info\":\"📥[1] 📤[6] \",\"config\":\"\"},{\"id\":\"vi_templatek0e3lz43\",\"name\":\"DL2-7 (quTAG)\",\"group\":\"quTAG\",\"info\":\"📥[2] 📤[7] \",\"config\":\"\"},{\"id\":\"vi_templatek0e3qybt\",\"name\":\"backward correlation (quTAG)\",\"group\":\"quTAG\",\"info\":\"📥[7, 6] \",\"config\":\"\"},{\"id\":\"vi_templatek0e3sowi\",\"name\":\"forward correlation (quTAG)\",\"group\":\"quTAG\",\"info\":\"📥[6, 7] \",\"config\":\"\"}]","var_templatejgmgopco":null,"var_templatejkim8l39":null,"var_templatejkim8rzm":null,"var_templatejkim8w21":null,"vi_templatek0e3lgeo":"{\"nodes\":[{\"x\":121,\"y\":114,\"fixed\":true,\"text\":\"a\",\"initial\":true,\"px\":121,\"py\":114}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"1\"}],\"usercode\":\"a:\\n emit(6,`fw_delay`)\"}","vi_templatek0e3lz43":"{\"nodes\":[{\"x\":89,\"y\":107,\"fixed\":true,\"initial\":true,\"text\":\"a\"}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"2\"}],\"usercode\":\"a:\\n emit(7,`bw_delay`)\"}","vi_templatek0e3qybt":"{\"nodes\":[{\"x\":346,\"y\":111,\"fixed\":true,\"text\":\"start\",\"px\":346,\"py\":111},{\"x\":75,\"y\":86,\"fixed\":true,\"text\":\"stop\",\"px\":75,\"py\":86,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":1,\"text\":\"7\"},{\"source\":1,\"target\":0,\"text\":\"6\"},{\"source\":0,\"target\":0,\"text\":\"6\"},{\"source\":1,\"target\":1,\"text\":\"7\"}],\"usercode\":\"HISTOGRAM(h4,(`bins`,`binsize`))\\nHISTOGRAM(h4_zero,(1,1))\\nCLOCK(c4,100,1)\\nstart:\\n c4.start()\\nstop:\\n c4.stop()\\n h4.record_all(c4)\\n h4_zero.record_all(c4)\"}","vi_templatek0e3sowi":"{\"nodes\":[{\"x\":346,\"y\":111,\"fixed\":true,\"text\":\"start\",\"px\":346,\"py\":111},{\"x\":76,\"y\":88,\"fixed\":true,\"text\":\"stop\",\"px\":76,\"py\":88,\"initial\":true}],\"edges\":[{\"source\":0,\"target\":1,\"text\":\"6\"},{\"source\":1,\"target\":0,\"text\":\"7\"},{\"source\":0,\"target\":0,\"text\":\"7\"},{\"source\":1,\"target\":1,\"text\":\"6\"}],\"usercode\":\"HISTOGRAM(h3,(`bins`,`binsize`))\\nCLOCK(c3,100,1)\\nstart:\\n c3.start()\\nstop:\\n c3.stop()\\n h3.record_all(c3)\"}","dpp_templatek0e4ffxo":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return ('Created with ETA - https://timetag.github.io\\n'+'filename: {}\\n'.format(filename.name) +'binsize: {}\\n'.format(binsize) +'bins: {}\\n'.format(bins) +'mode: {}\\n'.format(HH400_mode if \"HH400_mode\" in globals() else \"qutag\") )\r\n\r\n\r\n\r\n#------ADJUST DELAY-----\r\ndelay = int(float(delay))\r\neta.recipe.set_parameter(\"bw_delay\",str(max(0,-1*delay)))\r\neta.recipe.set_parameter(\"fw_delay\",str(max(0,delay)))\r\neta.load_recipe()\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n cutfile = eta.clips(f)\r\n result=eta.run({\"timetagger1\":cutfile}, group='quTAG')\r\n hist1=result[\"h3\"]\r\n hist2=result[\"h4\"]\r\n hist0=result[\"h4_zero\"]\r\n hist1[0]+=hist0[0]\r\n hist0[0]=0\r\n fullhist=np.concatenate((hist2[::-1],hist1))\r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_correlation' + '.txt'), np.transpose([np.arange(-hist2.size,hist1.size)*binsize,fullhist]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')\r\n\r\n","vi_templatek6z7s4mo":"{\"nodes\":[{\"x\":192,\"y\":157,\"fixed\":true,\"initial\":true}],\"edges\":[],\"usercode\":\"\\n########## click Help on the menu to get started! ##########\\nRFILE(timetagger1,[0,1,2,3,4,5])\"}","dpp_templatek7r3sgz1":"# Unfortunately no realtime recipe for quTAG, as the file is not written by\n# the control software until the experiment is stopped.\n#------IMPORTS-----\n\nimport numpy as np\nimport pandas as pd\nfrom pathlib import Path\n\nimport etabackend.tk.plot as etaplt\nimport etabackend.tk.utils as etautils\n\n#------ADJUST DELAY-----\ndelay = int(float(delay))\neta.recipe.set_parameter(\"bw_delay\",str(max(0,-1*delay)))\neta.recipe.set_parameter(\"fw_delay\",str(max(0,delay)))\neta.load_recipe()\n\n#------ETA PROCESSING-----\ncut=eta.clips(Path(file))\nresult= eta.run({\"timetagger1\":cut}, group='quTAG')\nhist1=result[\"h3\"]\nhist2=result[\"h4\"]\nhist0=result[\"h4_zero\"]\nhist1[0]+= hist0[0]\n\nfullhist=np.concatenate((hist2[::-1],hist1))\nxdata = np.arange(-hist2.size,hist1.size)*int(float(binsize))\n\nf=Path(file)\nDATAFOLDER = 'analyzed data'\nLABEL = expname\n#------PLOTTING-----\n\ndf = pd.DataFrame(np.vstack((xdata, fullhist)).T, \n columns=['time bins', 'histogram events'])\ndf['log events'] = np.clip(df['histogram events'].values, 0.5, None)\n\ndef generate_doc(doc):\n root = etaplt.plot_histogram(df, f, f.parent.joinpath(DATAFOLDER), \n data_name=LABEL.capitalize(), file_label=LABEL.lower(), \n info=etautils.info(globals_dict=eta.compilecache_vars['quTAG'], recipe_type=LABEL))\n doc.add_root(root)\n return doc\n\neta.display(generate_doc, 'bokeh')\n","var_templatek8g3kag4":null,"var_templatek8g498fo":null,"var_templatek8g49hcs":null} \ No newline at end of file diff --git a/etabackend/static/recipes/Countrate-hydraharp.eta b/etabackend/static/recipes/Countrate-hydraharp.eta index 5af431d..7852c64 100644 --- a/etabackend/static/recipes/Countrate-hydraharp.eta +++ b/etabackend/static/recipes/Countrate-hydraharp.eta @@ -1 +1 @@ -{"vi_templatejg7rpkiv":"{\"nodes\":[{\"x\":114,\"y\":140,\"fixed\":true,\"text\":\"a\",\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"0,1,2,3,4,5,6,7\"}],\"usercode\":\"HISTOGRAM(h0,(`bins`, `binsize`))\\nHISTOGRAM(h1,(`bins`, `binsize`))\\nHISTOGRAM(h2,(`bins`, `binsize`))\\nHISTOGRAM(h3,(`bins`, `binsize`))\\nHISTOGRAM(h4,(`bins`, `binsize`))\\nHISTOGRAM(h5,(`bins`, `binsize`))\\nHISTOGRAM(h6,(`bins`, `binsize`))\\nHISTOGRAM(h7,(`bins`, `binsize`))\\nCLOCK(c0)\\nCLOCK(c1)\\nCLOCK(c2)\\nCLOCK(c3)\\nCLOCK(c4)\\nCLOCK(c5)\\nCLOCK(c6)\\nCLOCK(c7)\\na--0-->a:\\n c0.stop()\\n h0.record(c0)\\na--1-->a:\\n c1.stop()\\n h1.record(c1)\\na--2-->a:\\n c2.stop()\\n h2.record(c2)\\na--3-->a:\\n c3.stop()\\n h3.record(c3)\\na--4-->a:\\n c4.stop()\\n h4.record(c4)\\na--5-->a:\\n c5.stop()\\n h5.record(c5)\\na--6-->a:\\n c6.stop()\\n h6.record(c6)\\na--7-->a:\\n c7.stop()\\n h7.record(c7)\"}","dpp_template_code":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return (f'Created with ETA - https://timetag.github.io\\n'\r\n f'filename: {filename.name}\\n'\r\n f'binsize: {binsize}\\n'\r\n f'bins: {bins}\\n'\r\n )\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='hydraharp')\r\n t0=result[\"h0\"]\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n t5=result[\"h5\"]\r\n t6=result[\"h6\"]\r\n t7=result[\"h7\"]\r\n #hist1=np.sum(t1.reshape(-1, int(float(rebinsize))), axis=1) # apply extra binning (2343)\r\n #hist2=np.sum(t2.reshape(-1, int(float(rebinsize))), axis=1)\r\n \r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_countrate' + '.txt'), np.transpose([np.arange(t1.size)/3600,t0,t1,t2,t3,t4,t5,t6,t7]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","eta_index_table":"[{\"id\":\"var_templatejkimp1dz\",\"name\":\"file\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.timeres\"},{\"id\":\"var_templatejkimp6ts\",\"name\":\"binsize\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"1e12\"},{\"id\":\"var_templatejkimp49t\",\"name\":\"bins\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"3600\"},{\"id\":\"var_templatejkimq3l9\",\"name\":\"rebinsize\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"1\"},{\"id\":\"var_templatekckqkvhi\",\"name\":\"records_per_cut\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"2e5\"},{\"id\":\"dpp_templatejgmfdvub\",\"name\":\"display\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_template_code\",\"name\":\"save txt\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatejgxmbufn\",\"name\":\"save graph\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatek70723ys\",\"name\":\"timetagger\",\"group\":\"hydraharp\",\"info\":\"📜[0, 1, 2, 3] \",\"config\":\"\"},{\"id\":\"vi_templatejg7rpkiv\",\"name\":\"countrate\",\"group\":\"hydraharp\",\"info\":\"📥[0, 1, 2, 3] \",\"config\":\"\"}]","dpp_templatejgmfdvub":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport logging\r\n\r\nimport numpy as np\r\n\r\nfrom bokeh.application import Application\r\nfrom bokeh.application.handlers.function import FunctionHandler\r\nimport etabackend.tk as etatk\r\n\r\nlogger = logging.getLogger('etabackend.frontend')\r\n\r\nlogger.info(\"ETA realtime is started.\")\r\n\r\n#------ETA PROCESSING-----\r\nrecords_per_cut = int(float(records_per_cut)\r\n ) if records_per_cut != \"\" else None\r\n\r\nSIMULATE_GROWTH = False\r\nDATAFOLDER = 'analyzed data'\r\nLABEL = 'Countrate'\r\nline_label = \"Ch\"\r\nfile = Path(file)\r\nbinsize = int(float(binsize))\r\n\r\n#------Evaluate Data-----\r\nclass HistogramResult(etatk.data.ETAResult):\r\n def calculate_result(self, result):\r\n import etabackend\r\n keys = []\r\n ydata = []\r\n for key,y_array in result.items():\r\n keys.append(key)\r\n if not isinstance(y_array, etabackend.clip.Clip):\r\n ydata.append(y_array)\r\n xdata = np.arange(0,result[keys[1]].size)/(60E12/binsize)\r\n return [xdata]+ydata # attach xdata to beginning of list of ydata\r\n\r\nresult = HistogramResult(file, group=\"hydraharp\", records_per_cut=records_per_cut, \r\n kernel=eta, timeout=0.2, run_immediately=False, \r\n simulate_growth=SIMULATE_GROWTH)\r\nresult.update()\r\nbp = etatk.plot.ETABokehPlot(result, result_folder=DATAFOLDER, title=LABEL, line_label=line_label)\r\n\r\nnot_displaying = eta.display(Application(FunctionHandler(bp.bokeh_plot_document)), 'bokeh')\r\nbp.run(not_displaying)\r\n\r\nlogger.info(\"ETA realtime is stopped.\")","dpp_templatejgxmbufn":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ngraphsfolder='graphs'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='hydraharp')\r\n t0=result[\"h0\"]\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n t5=result[\"h5\"]\r\n t6=result[\"h6\"]\r\n t7=result[\"h7\"]\r\n \r\n x = np.arange(t1.size)/60 #display in h\r\n p0 = plt.bar(x,t0, width=1/60, color='red')\r\n p1 = plt.bar(x,t1, width=1/60, bottom= t0, color='crimson')\r\n p2 = plt.bar(x,t2, width=1/60, bottom= t0+t1, color='navy')\r\n p3 = plt.bar(x,t3, width=1/60, bottom= t0+t1+t2, color='#bc5090')\r\n p4 = plt.bar(x,t4, width=1/60, bottom= t0+t1+t2+t3, color='#ffa600')\r\n p5 = plt.bar(x,t5, width=1/60, bottom= t0+t1+t2+t3+t4, color='#ffa600')\r\n p6 = plt.bar(x,t6, width=1/60, bottom= t0+t1+t2+t3+t4+t5, color='#ffa600')\r\n p7 = plt.bar(x,t7, width=1/60, bottom= t0+t1+t2+t3+t4+t5+t6, color='#ffa600')\r\n \r\n plt.ylabel('photon events')\r\n plt.xlabel('time (min)')\r\n \r\n \r\n list_of_title=str(f.stem).split('_')[:-1]\r\n title=' '.join(list_of_title)\r\n plt.title(title)\r\n \r\n f.parent.joinpath(graphsfolder).mkdir(parents=True, exist_ok=True)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.eps'), format='eps', dpi=1200)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.png'), format='png', dpi=1200)\r\n \r\n plt.clf()\r\n \r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","var_templatejkimp1dz":null,"var_templatejkimp49t":null,"var_templatejkimp6ts":null,"var_templatejkimq3l9":null,"ri_templatejkimu3sj":null,"vi_templatek70723ys":"{\"nodes\":[{\"x\":107,\"y\":38,\"fixed\":true,\"initial\":true,\"px\":107,\"py\":38}],\"edges\":[],\"usercode\":\"RFILE(timetagger1,[0,1,2,3,4,5,6,7])\"}","var_templatekckqkvhi":null} \ No newline at end of file +{"vi_templatejg7rpkiv":"{\"nodes\":[{\"x\":114,\"y\":140,\"fixed\":true,\"text\":\"a\",\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"0,1,2,3,4,5,6,7\"}],\"usercode\":\"HISTOGRAM(h0,(`bins`, `binsize`))\\nHISTOGRAM(h1,(`bins`, `binsize`))\\nHISTOGRAM(h2,(`bins`, `binsize`))\\nHISTOGRAM(h3,(`bins`, `binsize`))\\nHISTOGRAM(h4,(`bins`, `binsize`))\\nHISTOGRAM(h5,(`bins`, `binsize`))\\nHISTOGRAM(h6,(`bins`, `binsize`))\\nHISTOGRAM(h7,(`bins`, `binsize`))\\nCLOCK(c0)\\nCLOCK(c1)\\nCLOCK(c2)\\nCLOCK(c3)\\nCLOCK(c4)\\nCLOCK(c5)\\nCLOCK(c6)\\nCLOCK(c7)\\na--0-->a:\\n c0.stop()\\n h0.record(c0)\\na--1-->a:\\n c1.stop()\\n h1.record(c1)\\na--2-->a:\\n c2.stop()\\n h2.record(c2)\\na--3-->a:\\n c3.stop()\\n h3.record(c3)\\na--4-->a:\\n c4.stop()\\n h4.record(c4)\\na--5-->a:\\n c5.stop()\\n h5.record(c5)\\na--6-->a:\\n c6.stop()\\n h6.record(c6)\\na--7-->a:\\n c7.stop()\\n h7.record(c7)\"}","dpp_template_code":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return ('Created with ETA - https://timetag.github.io\\n'+'filename: {}\\n'.format(filename.name) +'binsize: {}\\n'.format(binsize) +'bins: {}\\n'.format(bins) +'mode: {}\\n'.format(HH400_mode if \"HH400_mode\" in globals() else \"qutag\") )\r\n\r\n\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='hydraharp')\r\n t0=result[\"h0\"]\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n t5=result[\"h5\"]\r\n t6=result[\"h6\"]\r\n t7=result[\"h7\"]\r\n #hist1=np.sum(t1.reshape(-1, int(float(rebinsize))), axis=1) # apply extra binning (2343)\r\n #hist2=np.sum(t2.reshape(-1, int(float(rebinsize))), axis=1)\r\n \r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_countrate' + '.txt'), np.transpose([np.arange(t1.size)/3600,t0,t1,t2,t3,t4,t5,t6,t7]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","eta_index_table":"[{\"id\":\"var_templatejkimp1dz\",\"name\":\"file\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.timeres\"},{\"id\":\"var_templatejkimp6ts\",\"name\":\"binsize\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"1e12\"},{\"id\":\"var_templatejkimp49t\",\"name\":\"bins\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"3600\"},{\"id\":\"var_templatejkimq3l9\",\"name\":\"rebinsize\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"1\"},{\"id\":\"var_templatekckqkvhi\",\"name\":\"records_per_cut\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"2e5\"},{\"id\":\"dpp_templatejgmfdvub\",\"name\":\"display\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_template_code\",\"name\":\"save txt\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatejgxmbufn\",\"name\":\"save graph\",\"group\":\"hydraharp\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatek70723ys\",\"name\":\"timetagger\",\"group\":\"hydraharp\",\"info\":\"📜[0, 1, 2, 3] \",\"config\":\"\"},{\"id\":\"vi_templatejg7rpkiv\",\"name\":\"countrate\",\"group\":\"hydraharp\",\"info\":\"📥[0, 1, 2, 3] \",\"config\":\"\"}]","dpp_templatejgmfdvub":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport logging\r\n\r\nimport numpy as np\r\n\r\nfrom bokeh.application import Application\r\nfrom bokeh.application.handlers.function import FunctionHandler\r\nimport etabackend.tk as etatk\r\n\r\nlogger = logging.getLogger('etabackend.frontend')\r\n\r\nlogger.info(\"ETA realtime is started.\")\r\n\r\n#------ETA PROCESSING-----\r\nrecords_per_cut = int(float(records_per_cut)\r\n ) if records_per_cut != \"\" else None\r\n\r\nSIMULATE_GROWTH = False\r\nDATAFOLDER = 'analyzed data'\r\nLABEL = 'Countrate'\r\nline_label = \"Ch\"\r\nfile = Path(file)\r\nbinsize = int(float(binsize))\r\n\r\n#------Evaluate Data-----\r\nclass HistogramResult(etatk.data.ETAResult):\r\n def calculate_result(self, result):\r\n import etabackend\r\n keys = []\r\n ydata = []\r\n for key,y_array in result.items():\r\n keys.append(key)\r\n if not isinstance(y_array, etabackend.clip.Clip):\r\n ydata.append(y_array)\r\n xdata = np.arange(0,result[keys[1]].size)/(60E12/binsize)\r\n return [xdata]+ydata # attach xdata to beginning of list of ydata\r\n\r\nresult = HistogramResult(file, group=\"hydraharp\", records_per_cut=records_per_cut, \r\n kernel=eta, timeout=0.2, run_immediately=False, \r\n simulate_growth=SIMULATE_GROWTH)\r\nresult.update()\r\nbp = etatk.plot.ETABokehPlot(result, result_folder=DATAFOLDER, title=LABEL, line_label=line_label)\r\n\r\nnot_displaying = eta.display(Application(FunctionHandler(bp.bokeh_plot_document)), 'bokeh')\r\nbp.run(not_displaying)\r\n\r\nlogger.info(\"ETA realtime is stopped.\")","dpp_templatejgxmbufn":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ngraphsfolder='graphs'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='hydraharp')\r\n t0=result[\"h0\"]\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n t5=result[\"h5\"]\r\n t6=result[\"h6\"]\r\n t7=result[\"h7\"]\r\n \r\n x = np.arange(t1.size)/60 #display in h\r\n p0 = plt.bar(x,t0, width=1/60, color='red')\r\n p1 = plt.bar(x,t1, width=1/60, bottom= t0, color='crimson')\r\n p2 = plt.bar(x,t2, width=1/60, bottom= t0+t1, color='navy')\r\n p3 = plt.bar(x,t3, width=1/60, bottom= t0+t1+t2, color='#bc5090')\r\n p4 = plt.bar(x,t4, width=1/60, bottom= t0+t1+t2+t3, color='#ffa600')\r\n p5 = plt.bar(x,t5, width=1/60, bottom= t0+t1+t2+t3+t4, color='#ffa600')\r\n p6 = plt.bar(x,t6, width=1/60, bottom= t0+t1+t2+t3+t4+t5, color='#ffa600')\r\n p7 = plt.bar(x,t7, width=1/60, bottom= t0+t1+t2+t3+t4+t5+t6, color='#ffa600')\r\n \r\n plt.ylabel('photon events')\r\n plt.xlabel('time (min)')\r\n \r\n \r\n list_of_title=str(f.stem).split('_')[:-1]\r\n title=' '.join(list_of_title)\r\n plt.title(title)\r\n \r\n f.parent.joinpath(graphsfolder).mkdir(parents=True, exist_ok=True)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.eps'), format='eps', dpi=1200)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.png'), format='png', dpi=1200)\r\n \r\n plt.clf()\r\n \r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","var_templatejkimp1dz":null,"var_templatejkimp49t":null,"var_templatejkimp6ts":null,"var_templatejkimq3l9":null,"ri_templatejkimu3sj":null,"vi_templatek70723ys":"{\"nodes\":[{\"x\":107,\"y\":38,\"fixed\":true,\"initial\":true,\"px\":107,\"py\":38}],\"edges\":[],\"usercode\":\"RFILE(timetagger1,[0,1,2,3,4,5,6,7])\"}","var_templatekckqkvhi":null} \ No newline at end of file diff --git a/etabackend/static/recipes/Countrate-qutag.eta b/etabackend/static/recipes/Countrate-qutag.eta index 953caf8..7c0910b 100644 --- a/etabackend/static/recipes/Countrate-qutag.eta +++ b/etabackend/static/recipes/Countrate-qutag.eta @@ -1 +1 @@ -{"vi_templatejg7rpkiv":"{\"nodes\":[{\"x\":181,\"y\":216,\"fixed\":true,\"text\":\"a\",\"px\":181,\"py\":216},{\"x\":110,\"y\":56,\"fixed\":true,\"initial\":true,\"text\":\"beginning\",\"px\":110,\"py\":56}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"1,2,3,4\"},{\"source\":1,\"target\":0,\"text\":\"0,1,2,3,4,5\"}],\"usercode\":\"HISTOGRAM(h1,(`bins`, `binsize`))\\nHISTOGRAM(h2,(`bins`, `binsize`))\\nHISTOGRAM(h3,(`bins`, `binsize`))\\nHISTOGRAM(h4,(`bins`, `binsize`))\\nCLOCK(c1, 100, 1)\\nCLOCK(c2, 100, 1)\\nCLOCK(c3, 100, 1)\\nCLOCK(c4, 100, 1)\\n\\nbeginning--0,1,2,3,4,5-->a:\\n c1.start()\\n c2.start()\\n c3.start()\\n c4.start()\\na--1-->a:\\n c1.stop()\\n h1.record_all(c1)\\na--2-->a:\\n c2.stop()\\n h2.record_all(c2)\\na--3-->a:\\n c3.stop()\\n h3.record_all(c3)\\na--4-->a:\\n c4.stop()\\n h4.record_all(c4)\"}","dpp_template_code":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return (f'Created with ETA - https://timetag.github.io\\n'\r\n f'filename: {filename.name}\\n'\r\n f'binsize: {binsize}\\n'\r\n f'bins: {bins}\\n'\r\n )\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='qutag')\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n #hist1=np.sum(t1.reshape(-1, int(float(rebinsize))), axis=1) # apply extra binning (2343)\r\n #hist2=np.sum(t2.reshape(-1, int(float(rebinsize))), axis=1)\r\n \r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_countrate' + '.txt'), np.transpose([np.arange(t1.size)/3600,t1,t2,t3,t4]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","eta_index_table":"[{\"id\":\"var_templatejkimp1dz\",\"name\":\"file\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.bin\"},{\"id\":\"var_templatejkimp6ts\",\"name\":\"binsize\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"1e12\"},{\"id\":\"var_templatejkimp49t\",\"name\":\"bins\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"3600\"},{\"id\":\"var_templatekclx602n\",\"name\":\"records_per_cut\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"2e5\"},{\"id\":\"dpp_templatejgmfdvub\",\"name\":\"display\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_template_code\",\"name\":\"save txt\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatejgxmbufn\",\"name\":\"save graph\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatejg7rpkiv\",\"name\":\"countrate\",\"group\":\"qutag\",\"info\":\"📥[1, 2, 3, 4, 0, 5] \",\"config\":\"\"},{\"id\":\"vi_templatek70723ys\",\"name\":\"timetagger\",\"group\":\"qutag\",\"info\":\"📜[0, 1, 2, 3, 4, 5] \",\"config\":\"\"}]","dpp_templatejgmfdvub":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport logging\r\n\r\nimport numpy as np\r\n\r\nfrom bokeh.application import Application\r\nfrom bokeh.application.handlers.function import FunctionHandler\r\nimport etabackend.tk as etatk\r\n\r\nlogger = logging.getLogger('etabackend.frontend')\r\n\r\nlogger.info(\"ETA realtime is started.\")\r\n\r\n#------ETA PROCESSING-----\r\nrecords_per_cut = int(float(records_per_cut)\r\n ) if records_per_cut != \"\" else None\r\n\r\nSIMULATE_GROWTH = False\r\nDATAFOLDER = 'analyzed data'\r\nLABEL = 'Countrate'\r\nline_label = \"Ch\"\r\nfile = Path(file)\r\nbinsize = int(float(binsize))\r\n\r\n#------Evaluate Data-----\r\nclass HistogramResult(etatk.data.ETAResult):\r\n def calculate_result(self, result):\r\n import etabackend\r\n keys = []\r\n ydata = []\r\n for key,y_array in result.items():\r\n keys.append(key)\r\n if not isinstance(y_array, etabackend.clip.Clip):\r\n ydata.append(y_array)\r\n xdata = np.arange(0,result[keys[1]].size)/(60E12/binsize)\r\n return [xdata]+ydata # attach xdata to beginning of list of ydata\r\n\r\nresult = HistogramResult(file, group=\"qutag\", records_per_cut=records_per_cut, \r\n kernel=eta, timeout=0.2, \r\n simulate_growth=SIMULATE_GROWTH)\r\nbp = etatk.plot.ETABokehPlot(result, result_folder=DATAFOLDER, title=LABEL, line_label=line_label)\r\n\r\nnot_displaying = eta.display(Application(FunctionHandler(bp.bokeh_plot_document)), 'bokeh')\r\nbp.run(not_displaying)\r\n\r\nlogger.info(\"ETA realtime is stopped.\")\r\n","dpp_templatejgxmbufn":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ngraphsfolder='graphs'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='qutag')\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n \r\n x = np.arange(t1.size)/60 #display in h\r\n \r\n p1 = plt.bar(x,t1, width=1/60, color='crimson')\r\n p2 = plt.bar(x,t2, width=1/60, bottom= t1, color='navy')\r\n p3 = plt.bar(x,t3, width=1/60, bottom= t1+t2, color='#bc5090')\r\n p4 = plt.bar(x,t4, width=1/60, bottom= t1+t2+t3, color='#ffa600')\r\n \r\n plt.ylabel('photon events')\r\n plt.xlabel('time (min)')\r\n \r\n \r\n list_of_title=str(f.stem).split('_')[:-1]\r\n title=' '.join(list_of_title)\r\n plt.title(title)\r\n \r\n f.parent.joinpath(graphsfolder).mkdir(parents=True, exist_ok=True)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.eps'), format='eps', dpi=1200)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.png'), format='png', dpi=1200)\r\n \r\n plt.clf()\r\n \r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","var_templatejkimp1dz":null,"var_templatejkimp49t":null,"var_templatejkimp6ts":null,"ri_templatejkimu3sj":null,"vi_templatek70723ys":"{\"nodes\":[{\"x\":107,\"y\":38,\"fixed\":true,\"initial\":true,\"px\":107,\"py\":38}],\"edges\":[],\"usercode\":\"RFILE(timetagger1, [0, 1, 2, 3, 4, 5])\"}","var_templatekclx602n":null} \ No newline at end of file +{"vi_templatejg7rpkiv":"{\"nodes\":[{\"x\":181,\"y\":216,\"fixed\":true,\"text\":\"a\",\"px\":181,\"py\":216},{\"x\":110,\"y\":56,\"fixed\":true,\"initial\":true,\"text\":\"beginning\",\"px\":110,\"py\":56}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"1,2,3,4\"},{\"source\":1,\"target\":0,\"text\":\"0,1,2,3,4,5\"}],\"usercode\":\"HISTOGRAM(h1,(`bins`, `binsize`))\\nHISTOGRAM(h2,(`bins`, `binsize`))\\nHISTOGRAM(h3,(`bins`, `binsize`))\\nHISTOGRAM(h4,(`bins`, `binsize`))\\nCLOCK(c1, 100, 1)\\nCLOCK(c2, 100, 1)\\nCLOCK(c3, 100, 1)\\nCLOCK(c4, 100, 1)\\n\\nbeginning--0,1,2,3,4,5-->a:\\n c1.start()\\n c2.start()\\n c3.start()\\n c4.start()\\na--1-->a:\\n c1.stop()\\n h1.record_all(c1)\\na--2-->a:\\n c2.stop()\\n h2.record_all(c2)\\na--3-->a:\\n c3.stop()\\n h3.record_all(c3)\\na--4-->a:\\n c4.stop()\\n h4.record_all(c4)\"}","dpp_template_code":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return ('Created with ETA - https://timetag.github.io\\n'+'filename: {}\\n'.format(filename.name) +'binsize: {}\\n'.format(binsize) +'bins: {}\\n'.format(bins) +'mode: {}\\n'.format(HH400_mode if \"HH400_mode\" in globals() else \"qutag\") )\r\n\r\n\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='qutag')\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n #hist1=np.sum(t1.reshape(-1, int(float(rebinsize))), axis=1) # apply extra binning (2343)\r\n #hist2=np.sum(t2.reshape(-1, int(float(rebinsize))), axis=1)\r\n \r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_countrate' + '.txt'), np.transpose([np.arange(t1.size)/3600,t1,t2,t3,t4]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","eta_index_table":"[{\"id\":\"var_templatejkimp1dz\",\"name\":\"file\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.bin\"},{\"id\":\"var_templatejkimp6ts\",\"name\":\"binsize\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"1e12\"},{\"id\":\"var_templatejkimp49t\",\"name\":\"bins\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"3600\"},{\"id\":\"var_templatekclx602n\",\"name\":\"records_per_cut\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"2e5\"},{\"id\":\"dpp_templatejgmfdvub\",\"name\":\"display\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_template_code\",\"name\":\"save txt\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatejgxmbufn\",\"name\":\"save graph\",\"group\":\"qutag\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatejg7rpkiv\",\"name\":\"countrate\",\"group\":\"qutag\",\"info\":\"📥[1, 2, 3, 4, 0, 5] \",\"config\":\"\"},{\"id\":\"vi_templatek70723ys\",\"name\":\"timetagger\",\"group\":\"qutag\",\"info\":\"📜[0, 1, 2, 3, 4, 5] \",\"config\":\"\"}]","dpp_templatejgmfdvub":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport logging\r\n\r\nimport numpy as np\r\n\r\nfrom bokeh.application import Application\r\nfrom bokeh.application.handlers.function import FunctionHandler\r\nimport etabackend.tk as etatk\r\n\r\nlogger = logging.getLogger('etabackend.frontend')\r\n\r\nlogger.info(\"ETA realtime is started.\")\r\n\r\n#------ETA PROCESSING-----\r\nrecords_per_cut = int(float(records_per_cut)\r\n ) if records_per_cut != \"\" else None\r\n\r\nSIMULATE_GROWTH = False\r\nDATAFOLDER = 'analyzed data'\r\nLABEL = 'Countrate'\r\nline_label = \"Ch\"\r\nfile = Path(file)\r\nbinsize = int(float(binsize))\r\n\r\n#------Evaluate Data-----\r\nclass HistogramResult(etatk.data.ETAResult):\r\n def calculate_result(self, result):\r\n import etabackend\r\n keys = []\r\n ydata = []\r\n for key,y_array in result.items():\r\n keys.append(key)\r\n if not isinstance(y_array, etabackend.clip.Clip):\r\n ydata.append(y_array)\r\n xdata = np.arange(0,result[keys[1]].size)/(60E12/binsize)\r\n return [xdata]+ydata # attach xdata to beginning of list of ydata\r\n\r\nresult = HistogramResult(file, group=\"qutag\", records_per_cut=records_per_cut, \r\n kernel=eta, timeout=0.2, \r\n simulate_growth=SIMULATE_GROWTH)\r\nbp = etatk.plot.ETABokehPlot(result, result_folder=DATAFOLDER, title=LABEL, line_label=line_label)\r\n\r\nnot_displaying = eta.display(Application(FunctionHandler(bp.bokeh_plot_document)), 'bokeh')\r\nbp.run(not_displaying)\r\n\r\nlogger.info(\"ETA realtime is stopped.\")\r\n","dpp_templatejgxmbufn":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ngraphsfolder='graphs'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='qutag')\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n \r\n x = np.arange(t1.size)/60 #display in h\r\n \r\n p1 = plt.bar(x,t1, width=1/60, color='crimson')\r\n p2 = plt.bar(x,t2, width=1/60, bottom= t1, color='navy')\r\n p3 = plt.bar(x,t3, width=1/60, bottom= t1+t2, color='#bc5090')\r\n p4 = plt.bar(x,t4, width=1/60, bottom= t1+t2+t3, color='#ffa600')\r\n \r\n plt.ylabel('photon events')\r\n plt.xlabel('time (min)')\r\n \r\n \r\n list_of_title=str(f.stem).split('_')[:-1]\r\n title=' '.join(list_of_title)\r\n plt.title(title)\r\n \r\n f.parent.joinpath(graphsfolder).mkdir(parents=True, exist_ok=True)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.eps'), format='eps', dpi=1200)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.png'), format='png', dpi=1200)\r\n \r\n plt.clf()\r\n \r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","var_templatejkimp1dz":null,"var_templatejkimp49t":null,"var_templatejkimp6ts":null,"ri_templatejkimu3sj":null,"vi_templatek70723ys":"{\"nodes\":[{\"x\":107,\"y\":38,\"fixed\":true,\"initial\":true,\"px\":107,\"py\":38}],\"edges\":[],\"usercode\":\"RFILE(timetagger1, [0, 1, 2, 3, 4, 5])\"}","var_templatekclx602n":null} \ No newline at end of file diff --git a/etabackend/static/recipes/Countrate.eta b/etabackend/static/recipes/Countrate.eta index bd3c7d2..53e97e3 100644 --- a/etabackend/static/recipes/Countrate.eta +++ b/etabackend/static/recipes/Countrate.eta @@ -1 +1 @@ -{"vi_templatejg7rpkiv":"{\"nodes\":[{\"x\":114,\"y\":140,\"fixed\":true,\"text\":\"a\",\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"0,1,2,3\"}],\"usercode\":\"HISTOGRAM(h1,(`bins`, `binsize`))\\nHISTOGRAM(h2,(`bins`, `binsize`))\\nHISTOGRAM(h3,(`bins`, `binsize`))\\nHISTOGRAM(h4,(`bins`, `binsize`))\\nCLOCK(c1)\\nCLOCK(c2)\\nCLOCK(c3)\\nCLOCK(c4)\\na--0-->a:\\n c1.stop()\\n h1.record(c1)\\na--1-->a:\\n c2.stop()\\n h2.record(c2)\\na--2-->a:\\n c3.stop()\\n h3.record(c3)\\na--3-->a:\\n c4.stop()\\n h4.record(c4)\"}","dpp_template_code":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return (f'Created with ETA - https://timetag.github.io\\n'\r\n f'filename: {filename.name}\\n'\r\n f'binsize: {binsize}\\n'\r\n f'bins: {bins}\\n'\r\n )\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='compile')\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n #hist1=np.sum(t1.reshape(-1, int(float(rebinsize))), axis=1) # apply extra binning (2343)\r\n #hist2=np.sum(t2.reshape(-1, int(float(rebinsize))), axis=1)\r\n \r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_countrate' + '.txt'), np.transpose([np.arange(t1.size)/3600,t1,t2,t3,t4]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","eta_index_table":"[{\"id\":\"var_templatejkimp1dz\",\"name\":\"file\",\"group\":\"compile\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.timeres\"},{\"id\":\"var_templatejkimp6ts\",\"name\":\"binsize\",\"group\":\"compile\",\"info\":\"\",\"config\":\"1e12\"},{\"id\":\"var_templatejkimp49t\",\"name\":\"bins\",\"group\":\"compile\",\"info\":\"\",\"config\":\"3600\"},{\"id\":\"var_templatejkimq3l9\",\"name\":\"rebinsize\",\"group\":\"compile\",\"info\":\"\",\"config\":\"1\"},{\"id\":\"dpp_templatejgmfdvub\",\"name\":\"display\",\"group\":\"compile\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_template_code\",\"name\":\"txt_saver\",\"group\":\"compile\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatejgxmbufn\",\"name\":\"graph_saver\",\"group\":\"compile\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatek70723ys\",\"name\":\"Timetagger\",\"group\":\"compile\",\"info\":\"📜[0, 1, 2, 3] \",\"config\":\"\"},{\"id\":\"vi_templatejg7rpkiv\",\"name\":\"countrate\",\"group\":\"compile\",\"info\":\"📥[0, 1, 2, 3] \",\"config\":\"\"}]","dpp_templatejgmfdvub":"#------IMPORTS-----\r\nimport numpy as np\r\nimport pandas as pd\r\nfrom pathlib import Path\r\nfrom bokeh.layouts import column, row\r\nfrom bokeh.models import ColumnDataSource, Slider, Range1d\r\nfrom bokeh.models.tools import HoverTool\r\nfrom bokeh.plotting import figure\r\nfrom bokeh.server.server import Server\r\nfrom bokeh.themes import Theme\r\nfrom bokeh.models.widgets import Tabs, Panel, Button\r\n\r\n#------ETA PROCESSING-----\r\nf = Path(file)\r\nclips = eta.clips(f)\r\nresult = eta.run(clips, group='compile')\r\n\r\nt1 = result[\"h1\"]\r\nt2 = result[\"h2\"]\r\nt3 = result[\"h3\"]\r\nt4 = result[\"h4\"]\r\n\r\nDATAFOLDER = 'analyzed data'\r\nLABEL = 'countrate'\r\n#------PLOTTING-----\r\nbinsize = int(float(1e12)) # accept bin size variable from left panel\r\nhist1 = np.sum(t1.reshape(-1, int(float(rebinsize))), axis=1) # apply extra binning (2343)\r\nhist2 = np.sum(t2.reshape(-1, int(float(rebinsize))), axis=1)\r\nhist3 = np.sum(t3.reshape(-1, int(float(rebinsize))), axis=1)\r\nhist4 = np.sum(t4.reshape(-1, int(float(rebinsize))), axis=1)\r\n\r\nxdata = np.arange(0,hist1.size)/60\r\ndf = pd.DataFrame(np.vstack((xdata, hist1, hist2, hist3, hist4)).T, \r\n columns=['time bins', 'ch1', 'ch2', 'ch3', 'ch4'])\r\n\r\ndef generate_doc(doc):\r\n source = ColumnDataSource(df)\r\n \r\n def info():\r\n return (f'Created with ETA - https://timetag.github.io\\n'\r\n f'filename: {f.name}\\n'\r\n f'binsize: {binsize}\\n'\r\n f'bins: {bins}\\n'\r\n )\r\n \r\n def style(p):\r\n from bokeh.models import Range1d\r\n # Title \r\n p.title.text = 'Countrate'\r\n p.title.align = 'center'\r\n p.title.text_font_size = '20pt'\r\n p.title.text_font = 'serif'\r\n\r\n # Axis titles\r\n p.xaxis.axis_label = 'Time delay (min)'\r\n p.xaxis.axis_label_text_font_size = '14pt'\r\n p.xaxis.axis_label_text_font_style = 'bold'\r\n p.yaxis.axis_label = 'Histogram events'\r\n p.yaxis.axis_label_text_font_size = '14pt'\r\n p.yaxis.axis_label_text_font_style = 'bold'\r\n\r\n # Tick labels\r\n p.xaxis.major_label_text_font_size = '12pt'\r\n p.yaxis.major_label_text_font_size = '12pt'\r\n \r\n # limit data range\r\n p.x_range = Range1d(0, int(len(df['time bins'].values))/60, bounds=(0,None))\r\n p.y_range = Range1d(0, max(df[['ch1','ch2', 'ch3', 'ch4']].max(axis=0).values)*1.2, bounds=(0,None))\r\n \r\n # remove padding\r\n p.min_border_bottom = 0\r\n p.min_border_left = 0\r\n \r\n # legend\r\n p.legend.location = \"top_right\"\r\n p.legend.click_policy=\"hide\"\r\n \r\n return p\r\n\r\n def bokeh_button_save_callback():\r\n global DATAFOLDER, LABEL\r\n f.parent.joinpath(DATAFOLDER).mkdir(parents=True, exist_ok=True) # Create analyzed folder\r\n # create unique index for file\r\n file_index = 0\r\n while f.parent.joinpath(DATAFOLDER, f\"{f.stem}_{LABEL}_{file_index:0=3d}.txt\").exists():\r\n file_index += 1\r\n np.savetxt(f.parent.joinpath(DATAFOLDER, f\"{f.stem}_{LABEL}_{file_index:0=3d}.txt\"),\r\n np.transpose([xdata, hist1, hist2, hist3, hist4]), delimiter='\\t', header=info())\r\n\r\n def make_plot(src):\r\n button_save = Button(label=\"Save\")\r\n button_save.on_click(bokeh_button_save_callback)\r\n save_button = row(button_save, sizing_mode='stretch_width')\r\n # setup plot tools\r\n hover=HoverTool(tooltips = [\r\n (\"Delay: \", \"@{time bins}\"),\r\n (\"Ch1\", \"@ch1\"),\r\n (\"Ch2\", \"@ch2\"),\r\n (\"Ch3\", \"@ch3\"),\r\n (\"Ch4\", \"@ch4\"),\r\n ],\r\n mode='vline', point_policy = \"snap_to_data\",\r\n line_policy = \"nearest\"\r\n )\r\n toolbox = \"pan,wheel_zoom,box_zoom,reset\"\r\n # Blank plot\r\n p = figure(plot_width = 700, plot_height = 700, tools=toolbox)\r\n p.add_tools(hover)\r\n # Add data\r\n p.line(x='time bins', y='ch1', \r\n source=src, color='firebrick', legend_label='ch1', line_width=2\r\n )\r\n p.line(x='time bins', y='ch2', \r\n source=src, color='navy', legend_label='ch2', line_width=2\r\n )\r\n \r\n p.line(x='time bins', y='ch3', \r\n source=src, color='#bc5090', legend_label='ch3', line_width=2\r\n )\r\n p.line(x='time bins', y='ch4', \r\n source=src, color='#ffa600', legend_label='ch4', line_width=2\r\n )\r\n\r\n # Styling\r\n p = style(p)\r\n return [p, save_button]\r\n\r\n column_content = make_plot(source)\r\n doc.add_root(column(column_content, sizing_mode='stretch_both'))\r\n \r\n return doc\r\n\r\neta.display(generate_doc, 'bokeh')\r\n","dpp_templatejgxmbufn":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ngraphsfolder='graphs'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='compile')\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n \r\n x = np.arange(t1.size)/60 #display in h\r\n \r\n p1 = plt.bar(x,t1, width=1/60, color='crimson')\r\n p2 = plt.bar(x,t2, width=1/60, bottom= t1, color='navy')\r\n p3 = plt.bar(x,t3, width=1/60, bottom= t1+t2, color='#bc5090')\r\n p4 = plt.bar(x,t4, width=1/60, bottom= t1+t2+t3, color='#ffa600')\r\n \r\n plt.ylabel('photon events')\r\n plt.xlabel('time (min)')\r\n \r\n \r\n list_of_title=str(f.stem).split('_')[:-1]\r\n title=' '.join(list_of_title)\r\n plt.title(title)\r\n \r\n f.parent.joinpath(graphsfolder).mkdir(parents=True, exist_ok=True)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.eps'), format='eps', dpi=1200)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.png'), format='png', dpi=1200)\r\n \r\n plt.clf()\r\n \r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","var_templatejkimp1dz":null,"var_templatejkimp49t":null,"var_templatejkimp6ts":null,"var_templatejkimq3l9":null,"ri_templatejkimu3sj":null,"vi_templatek70723ys":"{\"nodes\":[{\"x\":107,\"y\":38,\"fixed\":true,\"initial\":true,\"px\":107,\"py\":38}],\"edges\":[],\"usercode\":\"RFILE(timetagger1)\"}"} \ No newline at end of file +{"vi_templatejg7rpkiv":"{\"nodes\":[{\"x\":114,\"y\":140,\"fixed\":true,\"text\":\"a\",\"initial\":true}],\"edges\":[{\"source\":0,\"target\":0,\"text\":\"0,1,2,3\"}],\"usercode\":\"HISTOGRAM(h1,(`bins`, `binsize`))\\nHISTOGRAM(h2,(`bins`, `binsize`))\\nHISTOGRAM(h3,(`bins`, `binsize`))\\nHISTOGRAM(h4,(`bins`, `binsize`))\\nCLOCK(c1)\\nCLOCK(c2)\\nCLOCK(c3)\\nCLOCK(c4)\\na--0-->a:\\n c1.stop()\\n h1.record(c1)\\na--1-->a:\\n c2.stop()\\n h2.record(c2)\\na--2-->a:\\n c3.stop()\\n h3.record(c3)\\na--3-->a:\\n c4.stop()\\n h4.record(c4)\"}","dpp_template_code":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n \r\ndef info(filename, binsize=binsize, bins=bins):\r\n return (f'Created with ETA - https://timetag.github.io\\n'\r\n f'filename: {filename.name}\\n'\r\n f'binsize: {binsize}\\n'\r\n f'bins: {bins}\\n'\r\n )\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ndatafolder='analyzed data'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='compile')\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n #hist1=np.sum(t1.reshape(-1, int(float(rebinsize))), axis=1) # apply extra binning (2343)\r\n #hist2=np.sum(t2.reshape(-1, int(float(rebinsize))), axis=1)\r\n \r\n f.parent.joinpath(datafolder).mkdir(parents=True, exist_ok=True)\r\n np.savetxt(f.parent.joinpath(datafolder, f.stem + '_countrate' + '.txt'), np.transpose([np.arange(t1.size)/3600,t1,t2,t3,t4]), delimiter='\\t', header=info(f))\r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","eta_index_table":"[{\"id\":\"var_templatejkimp1dz\",\"name\":\"file\",\"group\":\"compile\",\"info\":\"\",\"config\":\"C:/YourFolder/YourFile.timeres\"},{\"id\":\"var_templatejkimp6ts\",\"name\":\"binsize\",\"group\":\"compile\",\"info\":\"\",\"config\":\"1e12\"},{\"id\":\"var_templatejkimp49t\",\"name\":\"bins\",\"group\":\"compile\",\"info\":\"\",\"config\":\"3600\"},{\"id\":\"var_templatejkimq3l9\",\"name\":\"rebinsize\",\"group\":\"compile\",\"info\":\"\",\"config\":\"1\"},{\"id\":\"dpp_templatejgmfdvub\",\"name\":\"display\",\"group\":\"compile\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_template_code\",\"name\":\"txt_saver\",\"group\":\"compile\",\"info\":\"\",\"config\":\"\"},{\"id\":\"dpp_templatejgxmbufn\",\"name\":\"graph_saver\",\"group\":\"compile\",\"info\":\"\",\"config\":\"\"},{\"id\":\"vi_templatek70723ys\",\"name\":\"Timetagger\",\"group\":\"compile\",\"info\":\"📜[0, 1, 2, 3] \",\"config\":\"\"},{\"id\":\"vi_templatejg7rpkiv\",\"name\":\"countrate\",\"group\":\"compile\",\"info\":\"📥[0, 1, 2, 3] \",\"config\":\"\"}]","dpp_templatejgmfdvub":"#------IMPORTS-----\r\nimport numpy as np\r\nimport pandas as pd\r\nfrom pathlib import Path\r\nfrom bokeh.layouts import column, row\r\nfrom bokeh.models import ColumnDataSource, Slider, Range1d\r\nfrom bokeh.models.tools import HoverTool\r\nfrom bokeh.plotting import figure\r\nfrom bokeh.server.server import Server\r\nfrom bokeh.themes import Theme\r\nfrom bokeh.models.widgets import Tabs, Panel, Button\r\n\r\n#------ETA PROCESSING-----\r\nf = Path(file)\r\nclips = eta.clips(f)\r\nresult = eta.run(clips, group='compile')\r\n\r\nt1 = result[\"h1\"]\r\nt2 = result[\"h2\"]\r\nt3 = result[\"h3\"]\r\nt4 = result[\"h4\"]\r\n\r\nDATAFOLDER = 'analyzed data'\r\nLABEL = 'countrate'\r\n#------PLOTTING-----\r\nbinsize = int(float(1e12)) # accept bin size variable from left panel\r\nhist1 = np.sum(t1.reshape(-1, int(float(rebinsize))), axis=1) # apply extra binning (2343)\r\nhist2 = np.sum(t2.reshape(-1, int(float(rebinsize))), axis=1)\r\nhist3 = np.sum(t3.reshape(-1, int(float(rebinsize))), axis=1)\r\nhist4 = np.sum(t4.reshape(-1, int(float(rebinsize))), axis=1)\r\n\r\nxdata = np.arange(0,hist1.size)/60\r\ndf = pd.DataFrame(np.vstack((xdata, hist1, hist2, hist3, hist4)).T, \r\n columns=['time bins', 'ch1', 'ch2', 'ch3', 'ch4'])\r\n\r\ndef generate_doc(doc):\r\n source = ColumnDataSource(df)\r\n \r\n def info():\r\n return ('Created with ETA - https://timetag.github.io\\n'+'filename: {}\\n'.format(f.name)+'binsize: {}\\n'.format(binsize)+'bins: {}\\n'.format(bins))\r\n \r\n def style(p):\r\n from bokeh.models import Range1d\r\n # Title \r\n p.title.text = 'Countrate'\r\n p.title.align = 'center'\r\n p.title.text_font_size = '20pt'\r\n p.title.text_font = 'serif'\r\n\r\n # Axis titles\r\n p.xaxis.axis_label = 'Time delay (min)'\r\n p.xaxis.axis_label_text_font_size = '14pt'\r\n p.xaxis.axis_label_text_font_style = 'bold'\r\n p.yaxis.axis_label = 'Histogram events'\r\n p.yaxis.axis_label_text_font_size = '14pt'\r\n p.yaxis.axis_label_text_font_style = 'bold'\r\n\r\n # Tick labels\r\n p.xaxis.major_label_text_font_size = '12pt'\r\n p.yaxis.major_label_text_font_size = '12pt'\r\n \r\n # limit data range\r\n p.x_range = Range1d(0, int(len(df['time bins'].values))/60, bounds=(0,None))\r\n p.y_range = Range1d(0, max(df[['ch1','ch2', 'ch3', 'ch4']].max(axis=0).values)*1.2, bounds=(0,None))\r\n \r\n # remove padding\r\n p.min_border_bottom = 0\r\n p.min_border_left = 0\r\n \r\n # legend\r\n p.legend.location = \"top_right\"\r\n p.legend.click_policy=\"hide\"\r\n \r\n return p\r\n\r\n def bokeh_button_save_callback():\r\n global DATAFOLDER, LABEL\r\n f.parent.joinpath(DATAFOLDER).mkdir(parents=True, exist_ok=True) # Create analyzed folder\r\n # create unique index for file\r\n file_index = 0\r\n while f.parent.joinpath(DATAFOLDER, f\"{f.stem}_{LABEL}_{file_index:0=3d}.txt\").exists():\r\n file_index += 1\r\n np.savetxt(f.parent.joinpath(DATAFOLDER, f\"{f.stem}_{LABEL}_{file_index:0=3d}.txt\"),\r\n np.transpose([xdata, hist1, hist2, hist3, hist4]), delimiter='\\t', header=info())\r\n\r\n def make_plot(src):\r\n button_save = Button(label=\"Save\")\r\n button_save.on_click(bokeh_button_save_callback)\r\n save_button = row(button_save, sizing_mode='stretch_width')\r\n # setup plot tools\r\n hover=HoverTool(tooltips = [\r\n (\"Delay: \", \"@{time bins}\"),\r\n (\"Ch1\", \"@ch1\"),\r\n (\"Ch2\", \"@ch2\"),\r\n (\"Ch3\", \"@ch3\"),\r\n (\"Ch4\", \"@ch4\"),\r\n ],\r\n mode='vline', point_policy = \"snap_to_data\",\r\n line_policy = \"nearest\"\r\n )\r\n toolbox = \"pan,wheel_zoom,box_zoom,reset\"\r\n # Blank plot\r\n p = figure(plot_width = 700, plot_height = 700, tools=toolbox)\r\n p.add_tools(hover)\r\n # Add data\r\n p.line(x='time bins', y='ch1', \r\n source=src, color='firebrick', legend_label='ch1', line_width=2\r\n )\r\n p.line(x='time bins', y='ch2', \r\n source=src, color='navy', legend_label='ch2', line_width=2\r\n )\r\n \r\n p.line(x='time bins', y='ch3', \r\n source=src, color='#bc5090', legend_label='ch3', line_width=2\r\n )\r\n p.line(x='time bins', y='ch4', \r\n source=src, color='#ffa600', legend_label='ch4', line_width=2\r\n )\r\n\r\n # Styling\r\n p = style(p)\r\n return [p, save_button]\r\n\r\n column_content = make_plot(source)\r\n doc.add_root(column(column_content, sizing_mode='stretch_both'))\r\n \r\n return doc\r\n\r\neta.display(generate_doc, 'bokeh')\r\n","dpp_templatejgxmbufn":"#------IMPORTS-----\r\nfrom pathlib import Path\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\ndef get_files(extensions):\r\n global path\r\n all_files = []\r\n for ext in extensions:\r\n all_files.extend(path.glob(ext))\r\n return all_files\r\n\r\n#------ETA PROCESSING-----\r\nbinsize=int(float(binsize))\r\npath = Path(file)\r\ngraphsfolder='graphs'\r\n\r\nselector = (f for f in get_files(('*.ptu','*.timeres'))) if path.is_dir() else [path]\r\n\r\nfor f in selector:\r\n clips = eta.clips(f)\r\n result=eta.run(clips, group='compile')\r\n t1=result[\"h1\"]\r\n t2=result[\"h2\"]\r\n t3=result[\"h3\"]\r\n t4=result[\"h4\"]\r\n \r\n x = np.arange(t1.size)/60 #display in h\r\n \r\n p1 = plt.bar(x,t1, width=1/60, color='crimson')\r\n p2 = plt.bar(x,t2, width=1/60, bottom= t1, color='navy')\r\n p3 = plt.bar(x,t3, width=1/60, bottom= t1+t2, color='#bc5090')\r\n p4 = plt.bar(x,t4, width=1/60, bottom= t1+t2+t3, color='#ffa600')\r\n \r\n plt.ylabel('photon events')\r\n plt.xlabel('time (min)')\r\n \r\n \r\n list_of_title=str(f.stem).split('_')[:-1]\r\n title=' '.join(list_of_title)\r\n plt.title(title)\r\n \r\n f.parent.joinpath(graphsfolder).mkdir(parents=True, exist_ok=True)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.eps'), format='eps', dpi=1200)\r\n plt.savefig(f.parent.joinpath(graphsfolder, f.stem + '_countrate' + '.png'), format='png', dpi=1200)\r\n \r\n plt.clf()\r\n \r\n eta.send(str(f.name) + ' has been successfully processed')\r\neta.send('FINISHED')","var_templatejkimp1dz":null,"var_templatejkimp49t":null,"var_templatejkimp6ts":null,"var_templatejkimq3l9":null,"ri_templatejkimu3sj":null,"vi_templatek70723ys":"{\"nodes\":[{\"x\":107,\"y\":38,\"fixed\":true,\"initial\":true,\"px\":107,\"py\":38}],\"edges\":[],\"usercode\":\"RFILE(timetagger1)\"}"} \ No newline at end of file diff --git a/gui/package.json b/gui/package.json index 844b1b3..9acf9d9 100644 --- a/gui/package.json +++ b/gui/package.json @@ -4,7 +4,7 @@ "author": "Zuzeng Lin", "repository": "github:timetag/ETA", "homepage": "http://timetag.github.io", - "version": "0.9.6", + "version": "0.9.7", "description": "ETA is a graphical event-driven programming language for time-tag processing.", "scripts": { "dev": "electron .", diff --git a/setup.py b/setup.py index 799a3f8..e25cec4 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setuptools.setup( name="etabackend", - version="0.9.6", + version="0.9.7", author="ETA Team", description="Extensible Timetag Analyzer", include_package_data=True,