Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
phy-exp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
recolic-hust
phy-exp
Commits
6d36a331
There was an error fetching the commit references. Please try again later.
Unverified
Commit
6d36a331
authored
6 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
fix va.
parent
9c820810
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
quickmap.py
+1
-1
1 addition, 1 deletion
quickmap.py
va/__pycache__/quickmap.cpython-36.pyc
+0
-0
0 additions, 0 deletions
va/__pycache__/quickmap.cpython-36.pyc
va/quickmap.py
+0
-57
0 additions, 57 deletions
va/quickmap.py
va/va.py
+5
-3
5 additions, 3 deletions
va/va.py
with
6 additions
and
61 deletions
quickmap.py
+
1
−
1
View file @
6d36a331
...
...
@@ -173,4 +173,4 @@ def DataFileToXYArray(fname, lineDelimiter = '\n', wordDelimiter = ' ', commentS
yArray
.
append
(
_DataType
(
ar
[
1
]))
except
:
print
(
'
At data line
"
{}
"
:
'
.
format
(
ori_line
))
return
xArray
,
yArray
\ No newline at end of file
return
xArray
,
yArray
This diff is collapsed.
Click to expand it.
va/__pycache__/quickmap.cpython-36.pyc
+
0
−
0
View file @
6d36a331
No preview for this file type
This diff is collapsed.
Click to expand it.
va/quickmap.py
deleted
100644 → 0
+
0
−
57
View file @
9c820810
#!/bin/env python3
# -*- coding: UTF-8 -*-
# Gereric: Draw line.
# Recolic Keghart, Apr 29, 2017.
import
numpy
from
scipy.optimize
import
leastsq
import
matplotlib.pyplot
as
plt
from
matplotlib
import
rcParams
def
GetMap
(
parrX
,
parrY
,
windowX
=
12
,
windowY
=
8
,
line
=
False
,
passO
=
False
):
print
(
'
This quickmap.py is deleted becaused of out of date!!!
'
)
arrX
,
arrY
=
parrX
,
parrY
maxX
,
maxY
=
max
(
arrX
)
*
1.2
,
max
(
arrY
)
*
1.25
# Do calculate
# y = k x + b (I = k V + b)
print
(
'
Your input:
'
,
arrX
,
'
|
'
,
arrY
)
print
(
'
Data collection done. Generating result...
'
)
V
,
I
=
numpy
.
array
(
arrX
),
numpy
.
array
(
arrY
)
def
lineFunc
(
kb
,
v
):
k
,
b
=
kb
if
passO
:
return
k
*
v
else
:
return
k
*
v
+
b
lossFunc
=
lambda
kb
,
v
,
i
:
lineFunc
(
kb
,
v
)
-
i
# Fire!
if
line
:
kb0
=
[
10
,
0
]
kbFinal
=
leastsq
(
lossFunc
,
kb0
,
args
=
(
V
,
I
))
k
,
b
=
kbFinal
[
0
]
print
(
'
Fit line done. Y=
'
,
k
,
'
X +
'
,
b
)
else
:
print
(
'
Drawing map without fitting a line...
'
)
# Draw function map.
rcParams
[
'
grid.linestyle
'
]
=
'
-
'
rcParams
[
'
grid.color
'
]
=
'
blue
'
rcParams
[
'
grid.linewidth
'
]
=
0.2
plt
.
figure
(
figsize
=
(
windowX
,
windowY
))
plt
.
scatter
(
V
,
I
,
color
=
"
red
"
,
label
=
"
Sample Point
"
,
linewidth
=
3
)
if
line
:
px
=
numpy
.
linspace
(
0
,
maxX
,
1000
)
py
=
k
*
px
+
b
plt
.
plot
(
px
,
py
,
color
=
"
orange
"
,
label
=
"
Fitting Line
"
,
linewidth
=
2
)
plt
.
legend
()
plt
.
grid
()
plt
.
show
()
def
toFloat
(
sstr
):
if
sstr
==
''
:
return
0.0
else
:
return
float
(
sstr
)
This diff is collapsed.
Click to expand it.
va/va.py
+
5
−
3
View file @
6d36a331
#!/bin/env python3
import
numpy
import
sys
from
quickmap
import
GetMap
as
draw
sys
.
path
.
append
(
'
..
'
)
from
quickmap
import
*
print
(
'
Usage: python va.py path/va-dat.in <Voltmeter range(V)> <Ammeter range(mA)> <fit line>
'
)
print
(
'
Example: python3 va.py va-dat.in 1 15 true
'
)
...
...
@@ -10,6 +12,6 @@ Uraw,Iraw=dat[:,0],dat[:,1]
U
=
[
utrue
/
100
*
float
(
sys
.
argv
[
2
])
for
utrue
in
Uraw
]
I
=
[
itrue
/
150
*
float
(
sys
.
argv
[
3
])
for
itrue
in
Iraw
]
if
sys
.
argv
[
4
]
==
'
true
'
:
draw
(
U
,
I
,
6
,
4
,
l
ine
=
True
,
passO
=
True
)
GetMap
(
U
,
I
,
polyL
ine
=
True
,
poly_
passO
=
True
)
else
:
draw
(
U
,
I
,
6
,
4
)
GetMap
(
U
,
I
)
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