From 0871d9aa1437abef697d8aa109cb7c9bac47c830 Mon Sep 17 00:00:00 2001 From: fuchenxi <1256257282@qq.com> Date: Wed, 16 Oct 2024 13:34:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86tct=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=B8=8Engspice=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __main__.py | 2 +- current/cal_current.py | 4 +--- elec/__init__.py | 8 +++++--- elec/ngspice_get_fig.py | 4 ++-- elec/ngspice_set_input.py | 5 +---- elec/readout.py | 4 ++-- tct/tct_signal.py | 2 +- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/__main__.py b/__main__.py index f220c4f0..c428ce79 100755 --- a/__main__.py +++ b/__main__.py @@ -34,7 +34,7 @@ parser_draw.add_argument('label', help='LABEL to identify root files') parser_elec = subparsers.add_parser('elec', help='electronic readout') parser_elec.add_argument('label', help='LABEL to identify electronics operations') parser_elec.add_argument('name', help='LABEL to identify electronics files') -parser_elec.add_argument('-tct', help='signal from TCT', action="store_true") +parser_elec.add_argument('-tct', help='signal from TCT') parser_field = subparsers.add_parser('field', help='calculate field/weight field and iv/cv') parser_field.add_argument('label', help='LABEL to identify operation') diff --git a/current/cal_current.py b/current/cal_current.py index ee5236d2..a9577061 100644 --- a/current/cal_current.py +++ b/current/cal_current.py @@ -294,11 +294,9 @@ class CalCurrent: def save_current(self, my_d, key=None): + path = output(__file__, my_d.det_name) if key==None: - path = output(__file__, my_d.det_name) key = "" - else: - path = output(__file__, my_d.det_name, key) time = array('d', [999.]) current = array('d', [999.]) diff --git a/elec/__init__.py b/elec/__init__.py index 85f43c8e..15a61ca4 100644 --- a/elec/__init__.py +++ b/elec/__init__.py @@ -5,7 +5,7 @@ from util.output import output def main(kwargs): label = kwargs['label'] # Operation label or detector name name = kwargs['name'] - is_tct = kwargs['tct'] + tct = kwargs['tct'] os.makedirs('output/elec/{}'.format(name), exist_ok=True) if label == 'trans': @@ -20,10 +20,12 @@ def main(kwargs): else: from . import ngspice_set_input from . import ngspice_set_tmp_cir - input_p = ngspice_set_input.set_input(label, is_tct) + if tct == None: + tct = '' + input_p = ngspice_set_input.set_input(label, tct) input_c=','.join(input_p) ngspice_set_tmp_cir.ngspice_set_tmp_cir(input_c, label, name) subprocess.run(['ngspice -b output/elec/{}/{}_tmp.cir'.format(label, name)], shell=True) file_path = output(__file__, label) from . import ngspice_get_fig - ngspice_get_fig.main(name, file_path) + ngspice_get_fig.main(name, file_path, tct) diff --git a/elec/ngspice_get_fig.py b/elec/ngspice_get_fig.py index 32abce1e..0b8c8f28 100644 --- a/elec/ngspice_get_fig.py +++ b/elec/ngspice_get_fig.py @@ -24,8 +24,8 @@ def read_file(file_path,file_name): return time,volt -def main(elec_name, file_path): - fig_name = os.path.join(file_path, elec_name+'.pdf') +def main(elec_name, file_path, key=None): + fig_name = os.path.join(file_path, elec_name+key+'.pdf') time,volt = [],[] time,volt = read_file(file_path, elec_name+'.raw') diff --git a/elec/ngspice_set_input.py b/elec/ngspice_set_input.py index 493357c8..4be753e2 100644 --- a/elec/ngspice_set_input.py +++ b/elec/ngspice_set_input.py @@ -13,10 +13,7 @@ def set_input(det_name, is_tct=False, key=None): if key == None: key = "" path = "output/current/{}".format(det_name) - if is_tct: - myFile = ROOT.TFile(os.path.join(path, "sim-current-TCT"+str(key))+".root") - else: - myFile = ROOT.TFile(os.path.join(path, "sim-current"+str(key))+".root") + myFile = ROOT.TFile(os.path.join(path, "sim-current"+str(key))+".root") myt = myFile.tree for entry in myt: diff --git a/elec/readout.py b/elec/readout.py index edd218cf..1b19191f 100644 --- a/elec/readout.py +++ b/elec/readout.py @@ -212,9 +212,9 @@ class Amplifier: volt = array('d', [999.]) time = array('d', [999.]) if self.read_ele_num==1: - fout = ROOT.TFile(os.path.join(path, "sim-current") + str(key) + ".root", "RECREATE") + fout = ROOT.TFile(os.path.join(path, "amplified-current") + str(key) + ".root", "RECREATE") else: - fout = ROOT.TFile(os.path.join(path, "sim-current") + str(key)+"No_"+str(j)+".root", "RECREATE") + fout = ROOT.TFile(os.path.join(path, "amplified-current") + str(key)+"No_"+str(j)+".root", "RECREATE") t_out = ROOT.TTree("tree", "signal") t_out.Branch("volt", volt, "volt/D") t_out.Branch("time", time, "time/D") diff --git a/tct/tct_signal.py b/tct/tct_signal.py index bf9569d7..6ecf8e6c 100644 --- a/tct/tct_signal.py +++ b/tct/tct_signal.py @@ -68,7 +68,7 @@ def main(kwargs): my_current = ccrt.CalCurrentLaser(my_d, my_f, my_l) if 'ngspice' in amplifier: - my_current.save_current(my_d) + my_current.save_current(my_d, my_l.model) else: path = output(__file__, my_d.det_name, my_l.model) ele_current = rdo.Amplifier(my_current.sum_cu, amplifier) -- GitLab