from pylab import *
from irfpy.swim.flux import *
import logging
logging.basicConfig(level=logging.DEBUG)
from irfpy.util import maxwell
def main():
funcv=maxwell.mkslice(3000000.,400000.,40000.)
v=arange(100000,1000000,10000)
err=1e-11
fv = funcv(v) + err*(random(len(v))-0.5)
fv = where(fv>0, fv, 0)
plot(v, fv)
yscale('log')
v_km_s = v*1e-3
n,vs,vt= simple_moment(v_km_s, fv)
print(n, vs,vt)
fitv=maxwell.mkslice(n,vs*1e3,vt*1e3)
fvfit=fitv(v)
plot(v,fvfit,'o')
ylim([1e-13,1e-8])
plt.show()
if __name__=='__main__':
main()