Skip to content
Snippets Groups Projects
Commit 2e088227 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

init

parents
No related branches found
No related tags found
No related merge requests found
import numpy
import matplotlib.pyplot as plt
from matplotlib import rcParams
# Points here!
yrc=[-6.77, -6.78, -6.78, -6.76, -6.73, -6.73, -6.72, -6.70, -6.69, -6.67, -6.60, -6.45, -6.37, -6.20, -5.99, -5.77, -5.45, -5.07, -3.52, -2.87, -2.36, -2.08, -1.77, -1.55, -1.40, -1.26, -0.97, -0.84, -0.64]
xrc=[0.0, 2.0, 4.0, 10.0, 20.0, 22.0, 25.0, 30.0, 33.0, 35.0, 37.0, 38.0, 38.5, 39.0, 39.6, 40.0, 40.5, 41.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 53.0, 55.0, 60.0]
x=xrc
y=[abs(yi) for yi in yrc]
# Draw function map.
rcParams['grid.linestyle']='-'
rcParams['grid.color'] = 'blue'
rcParams['grid.linewidth'] = 0.2
plt.figure(figsize=(8,6)) # Change 8 to yMax here.
plt.scatter(x,y,color="red",label="Sample Point",linewidth=3)
px=numpy.linspace(0,65,1000)
plt.legend()
plt.grid()
plt.show()
\ No newline at end of file
File added
cookie 0 → 100644
ASPSESSIONIDSSTBDAQD=NDNJDAGANPGKIFAEDOBPEGON
#!/bin/env python3
# -*- coding: UTF-8 -*-
# Hall effect: data processing. (This py will calc VH-Is and VH-Im)
# Recolic Keghart, Apr 29, 2017.
import numpy, sys
from scipy.optimize import leastsq
import matplotlib.pyplot as plt
from matplotlib import rcParams
Imax = 5 # Maybe you need to change it to 0.5 for Im
arrI, arrV = [], []
# Read data from file? File can include 'done' line or not.
if len(sys.argv) == 2:
fd = open(sys.argv[1])
fcont = fd.read()
fd.close()
farr = fcont.split('\n')
for s in farr:
if s == 'done':
break
if s == '':
print('Warning: empty data line ignored.')
continue
sarr = s.split(' ')
if len(sarr) != 5:
print('Warning: invalid data line ignored.')
continue
farr = [abs(float(v)) for v in sarr]
arrI.append(farr[0])
arrV.append(sum(farr[1:5]) / 4)
else: # Do data collect
print('Give me your data please.')
print('Format: Is(mA)/Im(A) V1(mV) V2 V3 V4')
print('Example(It\'s ok to write 1.00 as 1):')
print('>1.00 -1.50 1.43 -1.40 1.53')
print('Input "done" to stop, and launch calculator.')
print('Now, let\'s start! Be careful to your space.')
while True:
s = input('>')
if s == 'done':
break
if s == '':
print('Warning: empty data line ignored.')
continue
sarr = s.split(' ')
if len(sarr) != 5:
print('Warning: invalid data line ignored.')
continue
farr = [abs(float(v)) for v in sarr]
arrI.append(farr[0])
arrV.append(sum(farr[1:5]) / 4)
# Do calculate
# y = k x + b (V = k I + b)
print('Your input: ', arrI, '|', arrV)
print('Data collection done. Generating result...')
I, V = numpy.array(arrI), numpy.array(arrV)
def lineFunc(kb, i):
k,b=kb
return k*i+b
lossFunc = lambda kb, i, v : lineFunc(kb, i) - v
# Fire!
kb0 = [1,0]
kbFinal = leastsq(lossFunc, kb0, args=(I, V))
k,b=kbFinal[0]
print('Done. VH=', k, 'I* +', b)
# Draw function map.
rcParams['grid.linestyle']='-'
rcParams['grid.color'] = 'blue'
rcParams['grid.linewidth'] = 0.2
plt.figure(figsize=(8,6))
plt.scatter(I,V,color="red",label="Sample Point",linewidth=3)
px=numpy.linspace(0,Imax,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)
# Calc more
print('Continue to get Hall constant.[If you\'re using VH-Im, press Ctrl-C to exit now]')
print('I need to know about your Hall element:')
d=toFloat(input('d(mm) 0.500 ?>'))
gsa=toFloat(input('B/Im(KGS/A) >'))
im=toFloat(input('Im(A) 0.450 ?>'))
if d == 0:
d = 0.5
if gsa == 0:
print('You MUST give gsa!')
exit(1)
if im == 0:
im = 0.45
hallC = k * d * 1e4 / (im * gsa) # KGs and mm
n = 1 / (hallC * 1.6021766208e-19)
print('RH(cm^3/C)(multiply 3pi/8 manually if you prefer)=', hallC, ', n(cm^-3)(divided 3pi/8 manually if you prefer)=', n)
print('Deal with statistical dispersion by yourself.')
#!/bin/env python3
# -*- coding: UTF-8 -*-
# Hall effect: data processing. (This py will calc Is-V6)
# Recolic Keghart, Apr 29, 2017.
import numpy, sys
from scipy.optimize import leastsq
import matplotlib.pyplot as plt
from matplotlib import rcParams
arrV, arrI = [], []
# Read data from file? File can include 'done' line or not.
if len(sys.argv) == 2:
fd = open(sys.argv[1])
fcont = fd.read()
fd.close()
farr = fcont.split('\n')
for s in farr:
if s == 'done':
break
if s == '':
print('Warning: empty data line ignored.')
continue
sarr = s.split(' ')
if len(sarr) != 2:
print('Warning: invalid data line ignored.')
continue
farr = [abs(float(v)) for v in sarr]
arrV.append(farr[1])
arrI.append(farr[0])
else: # Do data collect
print('Give me your data please.')
print('Format: Is(mA) V6(mV)')
print('Example(It\'s ok to write 1.00 as 1):')
print('>0.10 -8.5')
print('Input "done" to stop, and launch calculator.')
print('Now, let\'s start! Be careful to your space.')
while True:
s = input('>')
if s == 'done':
break
if s == '':
print('Warning: empty data line ignored.')
continue
sarr = s.split(' ')
if len(sarr) != 2:
print('Warning: invalid data line ignored.')
continue
farr = [abs(float(v)) for v in sarr]
arrV.append(farr[1])
arrI.append(farr[0])
# Do calculate
# y = k x + b (I = k V + b)
print('Your input: ', arrV, '|', arrI)
print('Data collection done. Generating result...')
V, I = numpy.array(arrV), numpy.array(arrI)
def lineFunc(kb, v):
k,b=kb
return k*v+b
lossFunc = lambda kb, v, i : lineFunc(kb, v) - i
# Fire!
kb0 = [10,0]
kbFinal = leastsq(lossFunc, kb0, args=(V, I))
k,b=kbFinal[0]
print('Done. Is=', k, 'V6 +', b)
# Draw function map.
rcParams['grid.linestyle']='-'
rcParams['grid.color'] = 'blue'
rcParams['grid.linewidth'] = 0.2
plt.figure(figsize=(1,10))
plt.scatter(V,I,color="red",label="Sample Point",linewidth=3)
px=numpy.linspace(0,100,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)
# Calc more
print('Continue to get electric conductivity.')
print('I need to know about your Hall element:')
d=toFloat(input('d(mm) 0.500 ?>'))
b=toFloat(input('b(mm) 4.00 ?>'))
l=toFloat(input('l(mm) 3.00 ?>'))
rh=toFloat(input('RH(Calculated by HallEffect.py) ?>'))
if d == 0:
d = 0.5
if b == 0:
b = 4
if l == 0:
l = 3
if rh == 0:
print('You MUST give RH')
exit(1)
c6 = k * l * 10 / (b * d)
u = c6 * rh
print('6(o^-1 * cm^-1)=', c6, ', u(cm^2 * o^-1 * C^-1)=', u)
print('Deal with statistical dispersion by yourself.')
1.00 -1.50 1.43 -1.40 1.53
1.50 -2.25 2.14 -2.11 2.28
2.00 -3.00 2.85 -2.81 3.02
2.50 -3.75 3.56 -3.51 3.78
3.00 -4.50 4.26 -4.23 4.53
3.50 -5.25 4.97 -4.93 5.29
4.00 -5.99 5.67 -5.65 6.04
4.50 -6.74 6.39 -6.35 6.80
0.10 -1.65 1.29 -1.26 1.68
0.15 -2.38 2.02 -1.99 2.41
0.20 -3.10 2.75 -2.70 3.14
0.25 -3.83 3.48 -3.44 3.88
0.30 -4.55 4.21 -4.15 4.60
0.35 -5.28 4.94 -4.89 5.32
0.40 -6.02 5.67 -5.60 6.04
0.45 -6.74 6.39 -6.35 6.79
0.10 -8.5
0.20 -16.4
0.30 -25.0
0.40 -33.1
0.50 -41.6
0.60 -49.9
0.70 -57.7
0.80 -66.0
0.90 -74.4
1.00 -83.0
1.00 -1.50 1.43 -1.40 1.53
1.50 -2.25 2.14 -2.11 2.28
2.00 -3.00 2.85 -2.81 3.02
2.50 -3.75 3.56 -3.51 3.78
3.00 -4.50 4.26 -4.23 4.53
3.50 -5.25 4.97 -4.93 5.29
4.00 -5.99 5.67 -5.65 6.04
4.50 -6.74 6.39 -6.35 6.80
0.10 -1.65 1.29 -1.26 1.68
0.15 -2.38 2.02 -1.99 2.41
0.20 -3.10 2.75 -2.70 3.14
0.25 -3.83 3.48 -3.44 3.88
0.30 -4.55 4.21 -4.15 4.60
0.35 -5.28 4.94 -4.89 5.32
0.40 -6.02 5.67 -5.60 6.04
0.45 -6.74 6.39 -6.35 6.79
0.10 -8.5
0.20 -16.4
0.30 -25.0
0.40 -33.1
0.50 -41.6
0.60 -49.9
0.70 -57.7
0.80 -66.0
0.90 -74.4
1.00 -83.0
#!/bin/env python3
# -*- coding: UTF-8 -*-
# Gereric: Draw line.
# Recolic Keghart, Apr 29, 2017.
import numpy, sys
from scipy.optimize import leastsq
import matplotlib.pyplot as plt
from matplotlib import rcParams
arrX, arrY = [0, 4, 3, 2, 18, 5, 3, 5, 7, 3, 7], [0, 0.64, 0.55, 0.33, 2.92, 0.79, 0.50, 0.79, 1.14, 0.49, 1.15]
maxX, maxY = 20, 2
windowX, windowY = 12, 8
# 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
return k*v + b
lossFunc = lambda kb, v, i : lineFunc(kb, v) - i
# Fire!
kb0 = [10,0]
kbFinal = leastsq(lossFunc, kb0, args=(V, I))
k,b=kbFinal[0]
print('Done. Y=', k, 'X +', b)
# 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)
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)
#!/bin/env python3
# -*- coding: UTF-8 -*-
# Scan password and personal information.
import urllib.parse, urllib.request
import sys
def doTest(sid):
return (True, 'cookie')
def grepPriv(sid, cookie):
print('Name:... Sid:...')
for sid in range(201610001, 201617174):
bSuccess, cookie = doTest(sid)[0]
if bSuccess:
grepPriv()
\ No newline at end of file
#!/bin/env python3
# -*- coding: UTF-8 -*-
# Scan if there's any empty seat to play physics exp..
# License: Unauthorized copy is strictly FORBIDDEN.
# By Recolic Keghart, Apr 26, 2017
import urllib.parse, urllib.request
import sys
weekNumberList = [14,15,16,17,18]
experimentNumberList = [37,38,39,40,41,42,43,44]
errorPageDump = '/home/recolic/tmp/phySpiderDump.html'
# Needn't edit below.
experimentNumberDict = {
37:'分光计',
38:'多功能摆',
41:'直流电桥',
42:'伏安特性',
40:'密里根油滴',
43:'声速测量',
44:'示波器',
39:'霍尔效应'
}
def doLogin():
cookieStr = ''
print('Please use --cookie')
exit(1)
return cookieStr
def dumpWebpage(content, filePath):
fd = open(filePath, 'w')
fd.write(content)
fd.close()
def doTest(expNum, weekNum, cookieStr):
url='http://115.156.233.249/yuyue.asp'
formData = urllib.parse.urlencode({
'ExperimentSelectCtrl':expNum,
'hidden_sybh':expNum,
'zc':weekNum,
'hidden_zc':weekNum,
'hidden_ActionType':0,
'hidden_DiscardYuYue_sbbh':0,
'hidden_DiscardYuYue_zc':0,
'hidden_DiscardYuYue_rq':0,
'hidden_Msg':None
}).encode('utf-8')
request = urllib.request.Request(url, headers={
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4',
'Cache-Control':'max-age=0',
'Connection':'keep-alive',
'Content-Length':'166',
'Content-Type':'application/x-www-form-urlencoded',
'Cookie':cookieStr,
'Host':'115.156.233.249',
'Origin':'http://115.156.233.249',
'Referer':'http://115.156.233.249/yuyue.asp',
'Upgrade-Insecure-Requests':'1',
'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36'
})
responce = urllib.request.urlopen(request, formData)
responce = responce.read().decode('utf-8', errors = 'backslashreplace')
if len(responce) < 3000:
if responce.find('<head><title>Object moved<') != -1:
print('Error: Cookie is invalid. Responce dumped at ', errorPageDump)
if responce.find('<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">') != -1:
print('Error: Cookie is invalid. Responce dumped at ', errorPageDump)
else:
print('Error: Unknown error. Responce dumped at ', errorPageDump)
dumpWebpage(responce, errorPageDump)
exit(1)
location = 10000
while True:
location = responce.find('<input type=\'radio\' name=\'RadioButton_yuyue\'', location + 1)
if location != -1:
location += 52
seatStr = responce[location:location+9]
print('Available seat detected:', experimentNumberDict[expNum], 'week=', weekNum, 'seat=', seatStr)
else:
#print('Full:', experimentNumberDict[expNum], ',week=', weekNum)
break
return
# login:
if len(sys.argv) > 1 and sys.argv[1] == '--cookie':
try:
with open('cookie.in', 'r') as cookieFile:
m_cookie = cookieFile.readline()
if m_cookie[len(m_cookie) - 1] == '\n':
m_cookie=m_cookie[0:len(m_cookie)-2]
except FileNotFoundError:
print('Please input a valid cookie(You can put it as cookie.in):')
m_cookie = input()
print('Using cookie:', m_cookie)
else:
m_cookie = doLogin()
print('\nStart working now...\n')
for expNum in experimentNumberList:
for weekNum in weekNumberList:
doTest(expNum, weekNum, m_cookie)
#!/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('Generic-GetMap by Recolic.')
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)
\ No newline at end of file
File added
#!/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('Generic-GetMap by Recolic.')
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)
\ No newline at end of file
91.2 115.1
84.9 106.8
66.0 82.9
59.0 73.0
49.3 61.8
39.9 50.6
31.5 39.3
18.4 23.2
90.5 119.3
85.8 113.1
75.3 99.1
59.0 77.9
45.5 60.0
35.0 46.3
18.7 24.8
14.5 3.0
38.7 7.8
59.7 12.2
77.9 20.7
84.5 28.8
88.3 37.0
93.4 61.3
97.0 110.8
97.9 143.1
39.0 4.0
51.0 5.0
65.8 7.2
68.0 8.2
72.4 12.2
73.1 13.6
76.2 24.6
79.0 51.9
82.0 144.4
import numpy
import sys
from quickmap import GetMap as draw
dat=numpy.loadtxt(sys.argv[1], delimiter=' ')
Uraw,Iraw=dat[:,0],dat[:,1]
U=[utrue/100*2.5 for utrue in Uraw]
I=[itrue/150*30 for itrue in Iraw]
draw(I,U,line=True,passO=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment