Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110920906
script.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Apr 28, 19:50
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Apr 30, 19:50 (2 d)
Engine
blob
Format
Raw Data
Handle
25864417
Attached To
rSTICAZZI yearII_reports
script.py
View Options
#!/usr/bin/python3
import
mesure
from
mesure
import
Mesure
import
math
hystfile
=
"hysteresis.dat"
VBs
=
[
(
"Si1mum_VB.dat"
,
0.001
,
1e-6
,
1
,
1
),
\
(
"Si2mum_VB.dat"
,
0.001
,
2e-6
,
1
,
1
),
\
(
"Ag_VB.dat"
,
2.0
,
1.9e-6
,
1
,
1e3
),
\
(
"Cu_VB.dat"
,
2.0
,
1.6e-6
,
1
,
1e3
),
\
(
"InSn_VB.dat"
,
0.1
,
1.5e-7
,
1
,
1e3
)
]
VIs
=
[
(
"Si1mum_VI.dat"
,
0.41
,
1e-6
,
1e3
,
1
),
\
(
"Si2mum_VI.dat"
,
0.421
,
2e-6
,
1e3
,
1
),
\
(
"Ag_VI.dat"
,
0.437
,
1.9e-6
,
1
,
1e3
),
\
(
"Cu_VI.dat"
,
0.376
,
1.6e-6
,
1
,
1e3
),
\
(
"InSn_VI.dat"
,
0.399
,
1.5e-7
,
1e3
,
1e3
)
]
def
hystFit
(
r
):
I
=
mesure
.
loadMesures
(
"rawdata/"
+
hystfile
,
"I"
,
"errI"
)
#A
B
=
mesure
.
loadMesures
(
"rawdata/"
+
hystfile
,
"B"
,
"errB"
)
#mT
index
=
0
change
=
False
while
(
not
change
):
if
I
[
index
]
.
v
>=
0
:
break
index
+=
1
X
=
[]
Y
=
[]
for
i
in
range
(
len
(
I
)):
if
math
.
fabs
(
I
[
i
])
<
r
:
X
.
append
(
I
[
i
])
Y
.
append
(
B
[
i
])
(
m
,
q
)
=
mesure
.
linearRegression
(
X
,
Y
)
print
(
"B in function of I: B = (
%s
) * I + (
%s
)"
%
(
str
(
m
),
str
(
q
)))
return
(
m
,
q
)
def
computeRH
(
infile
,
what
,
fixed
,
a
,
gain
=
(
1
,
1
),
discard
=
0
,
Bfit
=
None
):
print
(
"Processing:"
,
infile
)
X
=
mesure
.
loadMesures
(
"rawdata/"
+
infile
,
'I'
,
'errI'
,
gain
[
0
])
V
=
mesure
.
loadMesures
(
"rawdata/"
+
infile
,
'V'
,
'errV'
,
gain
[
1
])
if
what
==
'B'
:
if
Bfit
is
None
:
Bfit
=
hystFit
(
3
)
out
=
open
(
"outs/"
+
infile
,
'w'
)
out
.
write
(
"B V errB errV
\n
"
)
for
i
in
range
(
len
(
X
)):
X
[
i
]
=
Bfit
[
0
]
*
X
[
i
]
+
Bfit
[
1
]
out
.
write
(
"
%f
%f
%f
%f
\n
"
%
(
X
[
i
]
.
v
*
1e3
,
V
[
i
]
.
v
*
gain
[
1
],
X
[
i
]
.
e
*
1e3
,
V
[
i
]
.
e
*
gain
[
1
]))
out
.
close
()
if
discard
>
0
:
V
=
V
[
discard
:
-
discard
]
X
=
X
[
discard
:
-
discard
]
(
m
,
q
)
=
mesure
.
linearRegression
(
X
,
V
)
print
(
"V in function of
%s
: V = (
%s
) *
%s
+ (
%s
)"
%
(
what
,
str
(
m
),
what
,
str
(
q
)))
Rh
=
m
*
a
/
fixed
print
(
"Rh:
%g
+-
%g
"
%
(
Rh
.
v
,
Rh
.
e
))
Bfit
=
hystFit
(
3.0
)
for
vb
in
VBs
:
computeRH
(
vb
[
0
],
'B'
,
vb
[
1
],
vb
[
2
],
(
vb
[
3
],
vb
[
4
]),
0
,
Bfit
)
for
vi
in
VIs
:
computeRH
(
vi
[
0
],
'I'
,
vi
[
1
],
vi
[
2
],
(
vi
[
3
],
vi
[
4
]),
0
,
Bfit
)
Event Timeline
Log In to Comment