diff --git a/elec/ABCStar_fe_get_fig.py b/elec/ABCStar_fe_get_fig.py deleted file mode 100755 index dc634321bbdc4b3991e23cdf5f7872fffbad0a88..0000000000000000000000000000000000000000 --- a/elec/ABCStar_fe_get_fig.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python3 -# TODO: Need to be TOTALLY rewritten -import ROOT -import numpy - -def read_file(file_path,file_name): - with open(file_path + file_name) as f: - lines = f.readlines() - time,volt = [],[] - - for line in lines: - time.append(float(line.split()[0])*1e9) - volt.append(float(line.split()[1])) - - time = numpy.array(time,dtype='float64') - volt = numpy.array(volt,dtype='float64') - - return time,volt - -def main(): - file_path = 'output/elec/' - #file_name = 'drs4_analog.raw' - file_name = 'ABCStar_fe.raw' - com_name=file_name.split('.')[0] - fig_name=file_path + com_name + '.pdf' - time,volt = [],[] - - time,volt = read_file(file_path,file_name) - length = len(time) - - ROOT.gROOT.SetBatch() - c = ROOT.TCanvas('c','c',700,600) - f1 = ROOT.TGraph(length,time,volt) - f1.SetTitle(' ') - - f1.SetLineColor(2) - f1.SetLineWidth(2) - - f1.GetXaxis().SetTitle('Time [ns]') - # f1.GetXaxis().SetLimits(0,5) - f1.GetXaxis().SetLimits(0,30) - f1.GetXaxis().CenterTitle() - f1.GetXaxis().SetTitleSize(0.05) - f1.GetXaxis().SetTitleOffset(0.8) - - f1.GetYaxis().SetTitle('Voltage [V]') - f1.GetYaxis().SetLimits(0,-1) - f1.GetYaxis().CenterTitle() - f1.GetYaxis().SetTitleSize(0.05) - f1.GetYaxis().SetTitleOffset(0.93) - - c.cd() - f1.Draw('AL') - c.SaveAs(fig_name) - print("figure has been saved in " , fig_name) - -if __name__ == '__main__': - main() - diff --git a/elec/__init__.py b/elec/__init__.py index 3d9a1d6550ec630d49e63fd2fffe7f561c9af2f1..9292bbef4c9f6b1a956298c628823cae1b8732fa 100644 --- a/elec/__init__.py +++ b/elec/__init__.py @@ -1,22 +1,18 @@ - +import os def main(kwargs): label = kwargs['label'] + os.makedirs('output/elec', exist_ok=True) if label == 'ngspice_t1': import subprocess subprocess.run(['ngspice -b output/elec/T1_tmp.cir'], shell=True) - elif label == 'ngspice_ABCStar_fe': - import subprocess - subprocess.run(['ngspice -b param_file/circuit/ABCStar_fe.cir'], shell=True) - elif label == 'drs4_get_analog': + elif label.startswith('ngspice_'): import subprocess - subprocess.run(['ngspice -b param_file/circuit/drs4_analog.cir'], shell=True) - elif label == 'drs4_get_fig': - from . import drs4_get_fig - drs4_get_fig.main() - elif label == 'ABCStar_fe_get_fig': - from . import ABCStar_fe_get_fig - ABCStar_fe_get_fig.main() + elec_name = label.replace('ngspice_', '') + subprocess.run(['ngspice -b param_file/circuit/{}.cir'.format(elec_name)], shell=True) + elif label.endswith('_get_fig'): + from . import ngspice_get_fig + ngspice_get_fig.main(label.replace('_get_fig', '')) else: from . import readout readout.main(label) diff --git a/elec/drs4_get_fig.py b/elec/drs4_get_fig.py deleted file mode 100755 index a27c8917101fd1de35daaeaf8308a2a1d08b5765..0000000000000000000000000000000000000000 --- a/elec/drs4_get_fig.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 -# TODO: Need to be TOTALLY rewritten -import ROOT -import numpy - -def read_file(file_path,file_name): - with open(file_path + file_name) as f: - lines = f.readlines() - time,volt = [],[] - - for line in lines: - time.append(float(line.split()[0])*1e9) - volt.append(float(line.split()[1])) - - time = numpy.array(time,dtype='float64') - volt = numpy.array(volt,dtype='float64') - - return time,volt - -def main(): - file_path = 'output/elec/' - file_name = 'drs4_analog.raw' - com_name=file_name.split('.')[0] - fig_name=file_path + com_name + '.pdf' - time,volt = [],[] - - time,volt = read_file(file_path,file_name) - length = len(time) - - ROOT.gROOT.SetBatch() - c = ROOT.TCanvas('c','c',700,600) - f1 = ROOT.TGraph(length,time,volt) - f1.SetTitle(' ') - - f1.SetLineColor(2) - f1.SetLineWidth(2) - - f1.GetXaxis().SetTitle('Time [ns]') - f1.GetXaxis().SetLimits(0,5) - f1.GetXaxis().CenterTitle() - f1.GetXaxis().SetTitleSize(0.05) - f1.GetXaxis().SetTitleOffset(0.8) - - f1.GetYaxis().SetTitle('Voltage [V]') - f1.GetYaxis().SetLimits(0,-1) - f1.GetYaxis().CenterTitle() - f1.GetYaxis().SetTitleSize(0.05) - f1.GetYaxis().SetTitleOffset(0.93) - - c.cd() - f1.Draw('AL') - c.SaveAs(fig_name) - print("figure has been saved in " , fig_name) - -if __name__ == '__main__': - main() - diff --git a/elec/ngspice_get_fig.py b/elec/ngspice_get_fig.py index 9026dbc327b6e7c9337ffa88931d90c224dde08c..130765e59121c6da721d167e8967f2588b8ede00 100644 --- a/elec/ngspice_get_fig.py +++ b/elec/ngspice_get_fig.py @@ -1,8 +1,13 @@ #!/usr/bin/env python3 -import ROOT import sys +import os + import numpy +import ROOT + +from util.output import output + # TODO: Need to be TOTALLY rewritten def read_file(file_path,file_name): with open(file_path + '/' + file_name) as f: @@ -18,15 +23,14 @@ def read_file(file_path,file_name): return time,volt -def main(): - file_path = 'output/elec/ngspice_fig' - file_name = sys.argv[1] - com_name=file_name.split('.')[0] - fig_name=file_path + com_name + '.pdf' +def main(elec_name): + file_path = output(__file__) + fig_name = os.path.join(file_path, elec_name+'.pdf') time,volt = [],[] - time,volt = read_file(file_path,file_name) + time,volt = read_file(file_path, elec_name+'.raw') length = len(time) + t_min, t_max = time[0], time[-1] ROOT.gROOT.SetBatch() c = ROOT.TCanvas('c','c',700,600) @@ -37,13 +41,12 @@ def main(): f1.SetLineWidth(2) f1.GetXaxis().SetTitle('Time [ns]') - f1.GetXaxis().SetLimits(0,20) + f1.GetXaxis().SetLimits(t_min, t_max) f1.GetXaxis().CenterTitle() f1.GetXaxis().SetTitleSize(0.05) f1.GetXaxis().SetTitleOffset(0.8) f1.GetYaxis().SetTitle('Voltage [mV]') - f1.GetYaxis().SetLimits(0,-5) f1.GetYaxis().CenterTitle() f1.GetYaxis().SetTitleSize(0.05) f1.GetYaxis().SetTitleOffset(0.7) @@ -51,7 +54,6 @@ def main(): c.cd() f1.Draw('AL') c.SaveAs(fig_name) - print("figure has been saved in " , fig_name) if __name__ == '__main__': main() diff --git a/tct/tct_signal.py b/tct/tct_signal.py index 2af29b6ec5feeba376aed023a0e8568a49ebe881..d17b213acc01f7f8649e32f0a8f1cfc28b136443 100644 --- a/tct/tct_signal.py +++ b/tct/tct_signal.py @@ -78,7 +78,7 @@ def main(kwargs): my_current = ccrt.CalCurrentLaser(my_d, my_f, my_l) if 'ngspice' in amplifier: - save_current(my_d, my_current,my_f = devfield.DevsimField(my_d.device, my_d.dimension, voltage, 1, my_d.l_z), key=None) + save_current(my_d, my_current, key=None) input_p=ngsip.set_input(my_current, my_d, key=None) input_c=','.join(input_p) ng.ngspice_t0(input_c, input_p) @@ -102,7 +102,7 @@ def main(kwargs): print("total time used:%s"%(time.time()-start)) #TODO: move this to calcurrent -def save_current(my_d,my_current,my_f,key): +def save_current(my_d,my_current,key): if "planar3D" in my_d.det_model or "planarRing" in my_d.det_model: path = os.path.join('output', 'pintct', my_d.det_name, ) elif "lgad3D" in my_d.det_model: diff --git a/tct/tct_t1.py b/tct/tct_t1.py index 7cc4d52d43cdd3b591794cd592f79e600663f996..67710988cfae003c009aaaaa3e15a7e5ca729725 100644 --- a/tct/tct_t1.py +++ b/tct/tct_t1.py @@ -28,7 +28,7 @@ my_l = raser.TCTTracks(my_d, dset.laser) my_current = raser.CalCurrentLaser(my_d, my_f, my_l) ele_current = raser.Amplifier(my_current.sum_cu, dset.amplifier) save_TTree.save_signal_TTree(dset,my_d,my_l.fx_rel,ele_current,my_f) -my_current.save_current(dset,my_d,my_l,my_f,"fx_rel") +my_current.save_current(dset,my_d,my_l,"fx_rel") current_SiC = array("d") T_SiC = array("d")