Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
raser
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RASER-TEAM
raser
Commits
550818da
Commit
550818da
authored
5 months ago
by
Chenxi Fu
Browse files
Options
Downloads
Patches
Plain Diff
ngspice画图代码整理
parent
05865e4e
No related branches found
No related tags found
1 merge request
!27
ngspice画图代码整理
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
elec/ABCStar_fe_get_fig.py
+0
-59
0 additions, 59 deletions
elec/ABCStar_fe_get_fig.py
elec/__init__.py
+8
-12
8 additions, 12 deletions
elec/__init__.py
elec/drs4_get_fig.py
+0
-57
0 additions, 57 deletions
elec/drs4_get_fig.py
elec/ngspice_get_fig.py
+12
-10
12 additions, 10 deletions
elec/ngspice_get_fig.py
with
20 additions
and
138 deletions
elec/ABCStar_fe_get_fig.py
deleted
100755 → 0
+
0
−
59
View file @
05865e4e
#!/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
()
This diff is collapsed.
Click to expand it.
elec/__init__.py
+
8
−
12
View file @
550818da
import
os
def
main
(
kwargs
):
def
main
(
kwargs
):
label
=
kwargs
[
'
label
'
]
label
=
kwargs
[
'
label
'
]
os
.
makedirs
(
'
output/elec
'
,
exist_ok
=
True
)
if
label
==
'
ngspice_t1
'
:
if
label
==
'
ngspice_t1
'
:
import
subprocess
import
subprocess
subprocess
.
run
([
'
ngspice -b output/elec/T1_tmp.cir
'
],
shell
=
True
)
subprocess
.
run
([
'
ngspice -b output/elec/T1_tmp.cir
'
],
shell
=
True
)
elif
label
==
'
ngspice_ABCStar_fe
'
:
elif
label
.
startswith
(
'
ngspice_
'
):
import
subprocess
subprocess
.
run
([
'
ngspice -b param_file/circuit/ABCStar_fe.cir
'
],
shell
=
True
)
elif
label
==
'
drs4_get_analog
'
:
import
subprocess
import
subprocess
subprocess
.
run
([
'
ngspice -b param_file/circuit/drs4_analog.cir
'
],
shell
=
True
)
elec_name
=
label
.
replace
(
'
ngspice_
'
,
''
)
elif
label
==
'
drs4_get_fig
'
:
subprocess
.
run
([
'
ngspice -b param_file/circuit/{}.cir
'
.
format
(
elec_name
)],
shell
=
True
)
from
.
import
drs4_get_fig
elif
label
.
endswith
(
'
_get_fig
'
):
drs4_get_fig
.
main
()
from
.
import
ngspice_get_fig
elif
label
==
'
ABCStar_fe_get_fig
'
:
ngspice_get_fig
.
main
(
label
.
replace
(
'
_get_fig
'
,
''
))
from
.
import
ABCStar_fe_get_fig
ABCStar_fe_get_fig
.
main
()
else
:
else
:
from
.
import
readout
from
.
import
readout
readout
.
main
(
label
)
readout
.
main
(
label
)
This diff is collapsed.
Click to expand it.
elec/drs4_get_fig.py
deleted
100755 → 0
+
0
−
57
View file @
05865e4e
#!/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
()
This diff is collapsed.
Click to expand it.
elec/ngspice_get_fig.py
+
12
−
10
View file @
550818da
#!/usr/bin/env python3
#!/usr/bin/env python3
import
ROOT
import
sys
import
sys
import
os
import
numpy
import
numpy
import
ROOT
from
util.output
import
output
# TODO: Need to be TOTALLY rewritten
# TODO: Need to be TOTALLY rewritten
def
read_file
(
file_path
,
file_name
):
def
read_file
(
file_path
,
file_name
):
with
open
(
file_path
+
'
/
'
+
file_name
)
as
f
:
with
open
(
file_path
+
'
/
'
+
file_name
)
as
f
:
...
@@ -18,15 +23,14 @@ def read_file(file_path,file_name):
...
@@ -18,15 +23,14 @@ def read_file(file_path,file_name):
return
time
,
volt
return
time
,
volt
def
main
():
def
main
(
elec_name
):
file_path
=
'
output/elec/ngspice_fig
'
file_path
=
output
(
__file__
)
file_name
=
sys
.
argv
[
1
]
fig_name
=
os
.
path
.
join
(
file_path
,
elec_name
+
'
.pdf
'
)
com_name
=
file_name
.
split
(
'
.
'
)[
0
]
fig_name
=
file_path
+
com_name
+
'
.pdf
'
time
,
volt
=
[],[]
time
,
volt
=
[],[]
time
,
volt
=
read_file
(
file_path
,
fi
le_name
)
time
,
volt
=
read_file
(
file_path
,
e
le
c
_name
+
'
.raw
'
)
length
=
len
(
time
)
length
=
len
(
time
)
t_min
,
t_max
=
time
[
0
],
time
[
-
1
]
ROOT
.
gROOT
.
SetBatch
()
ROOT
.
gROOT
.
SetBatch
()
c
=
ROOT
.
TCanvas
(
'
c
'
,
'
c
'
,
700
,
600
)
c
=
ROOT
.
TCanvas
(
'
c
'
,
'
c
'
,
700
,
600
)
...
@@ -37,13 +41,12 @@ def main():
...
@@ -37,13 +41,12 @@ def main():
f1
.
SetLineWidth
(
2
)
f1
.
SetLineWidth
(
2
)
f1
.
GetXaxis
().
SetTitle
(
'
Time [ns]
'
)
f1
.
GetXaxis
().
SetTitle
(
'
Time [ns]
'
)
f1
.
GetXaxis
().
SetLimits
(
0
,
20
)
f1
.
GetXaxis
().
SetLimits
(
t_min
,
t_max
)
f1
.
GetXaxis
().
CenterTitle
()
f1
.
GetXaxis
().
CenterTitle
()
f1
.
GetXaxis
().
SetTitleSize
(
0.05
)
f1
.
GetXaxis
().
SetTitleSize
(
0.05
)
f1
.
GetXaxis
().
SetTitleOffset
(
0.8
)
f1
.
GetXaxis
().
SetTitleOffset
(
0.8
)
f1
.
GetYaxis
().
SetTitle
(
'
Voltage [mV]
'
)
f1
.
GetYaxis
().
SetTitle
(
'
Voltage [mV]
'
)
f1
.
GetYaxis
().
SetLimits
(
0
,
-
5
)
f1
.
GetYaxis
().
CenterTitle
()
f1
.
GetYaxis
().
CenterTitle
()
f1
.
GetYaxis
().
SetTitleSize
(
0.05
)
f1
.
GetYaxis
().
SetTitleSize
(
0.05
)
f1
.
GetYaxis
().
SetTitleOffset
(
0.7
)
f1
.
GetYaxis
().
SetTitleOffset
(
0.7
)
...
@@ -51,7 +54,6 @@ def main():
...
@@ -51,7 +54,6 @@ def main():
c
.
cd
()
c
.
cd
()
f1
.
Draw
(
'
AL
'
)
f1
.
Draw
(
'
AL
'
)
c
.
SaveAs
(
fig_name
)
c
.
SaveAs
(
fig_name
)
print
(
"
figure has been saved in
"
,
fig_name
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
main
()
main
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment