Fitting Curve Code

cd Y:
cd FourthYear_MajorProject/
import astropy.io.fits
f = astropy.io.fits.open("./60s_DarkFrame.FIT")
f0 = f[0]
d = f0.data
hist(d.flatten(),100,0,1000)
hist(d.flatten(),100,(0,1000))
hist(d.flatten(),100,(0,1000))
hist(d.flatten())
hist?
hist(d.flatten(),100,(0,1000))
hist(d.flatten(),100,(0,10000))
hist(d[0,;].flatten(),100,(0,10000))
hist(d[0,:].flatten(),100,(0,10000))
h = hist(d[0,:].flatten(),100,(0,10000))
h
h[0]
h[1]
clf()
plot(h[0])
plot(h[1])
shape(h[0])
shape(h[1])
y = h[0]
xedge = h[1]
roll(xedge,-1)
roll(xedge,-1)
xcentre = (xedge + roll(xedge,-1))/2.0
shape(xcentre)
x = xcentre[0:100]
x
clf()
plot(x,y)
import numpy as np
def guass(x,a, mu, sigma) :
    return a*np.exp(-(x-mu)**2/(2*sigma**2))
x = linspace(-10,10,0.01)
x
x = linspace(-10,10,100)
x
x = xcentre[0:100]
a = linspace(-10,10,100)
gauss
def gauss(x,a, mu, sigma) :
    return a*np.exp(-(x-mu)**2/(2*sigma**2))
gauss(a,10,0,5)
plot(a,gauss(a,10,0,5))
plot(a,gauss(a,10,0,5))
xx
x
history
import scipy.optimize
scipy.optimize.curve_fit?
import scipy.optimize(gauss,x,y)
import scipy.optimize.curve_fit(gauss,x,y)
scipy.optimize.curve_fit(gauss,x,y)
scipy.optimize.curve_fit(gauss,x,y,(1000,10000,1000))
[p0,pcov] = scipy.optimize.curve_fit(gauss,x,y,(1000,10000,1000))
p0
plot(x,y)
yfit = gauss(x,p[0],p[1],p[2])
yfit = gauss(x,p0[0],p0[1],p0[2])
plot(x,yfit)
history

hist(d.flatten(),100,(0,10000))
Out[64]: 
(array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          2.71090000e+04,   1.84788000e+05,   4.29200000e+04,
          1.61890000e+04,   9.47900000e+03,   6.93700000e+03,
          5.62000000e+03,   4.36500000e+03,   3.86600000e+03,
          3.42800000e+03,   3.37100000e+03,   3.34200000e+03,
          3.50800000e+03,   3.62800000e+03,   3.73300000e+03,
          3.66900000e+03,   3.83600000e+03,   3.74400000e+03,
          3.86800000e+03,   3.90500000e+03,   4.07800000e+03,
          3.93000000e+03,   4.07100000e+03,   4.24200000e+03,
          4.32300000e+03,   8.10100000e+03,   1.37150000e+04,
          1.84290000e+04,   3.25800000e+04,   4.36370000e+04,
          5.17390000e+04,   4.71470000e+04,   4.51360000e+04,
          4.42660000e+04,   4.36230000e+04,   4.28680000e+04,
          4.27450000e+04,   4.16300000e+04,   4.12820000e+04,
          4.06740000e+04,   4.09460000e+04,   4.01030000e+04,
          4.09280000e+04,   4.15130000e+04,   4.28810000e+04,
          4.47720000e+04,   4.55400000e+04,   4.41330000e+04,
          4.23810000e+04,   4.08130000e+04,   4.09200000e+04,
          4.25520000e+04,   4.64760000e+04,   5.23540000e+04,
          3.08160000e+04,   3.32900000e+03,   1.38000000e+02,
          9.80000000e+01,   9.10000000e+01,   3.70000000e+01,
          2.60000000e+01,   1.60000000e+01,   1.10000000e+01,
          1.10000000e+01,   9.00000000e+00,   1.30000000e+01,
          2.00000000e+00,   6.00000000e+00,   7.00000000e+00,
          9.00000000e+00,   3.00000000e+00,   7.00000000e+00,
          3.00000000e+00,   1.00000000e+01,   5.00000000e+00,
          3.00000000e+00,   6.00000000e+00,   5.00000000e+00,
          3.00000000e+00,   5.00000000e+00,   8.00000000e+00,
          5.00000000e+00,   4.00000000e+00,   1.00000000e+00,
          3.00000000e+00,   2.00000000e+00,   1.00000000e+00,
          2.00000000e+00]),
 array([     0.,    100.,    200.,    300.,    400.,    500.,    600.,
           700.,    800.,    900.,   1000.,   1100.,   1200.,   1300.,
          1400.,   1500.,   1600.,   1700.,   1800.,   1900.,   2000.,
          2100.,   2200.,   2300.,   2400.,   2500.,   2600.,   2700.,
          2800.,   2900.,   3000.,   3100.,   3200.,   3300.,   3400.,
          3500.,   3600.,   3700.,   3800.,   3900.,   4000.,   4100.,
          4200.,   4300.,   4400.,   4500.,   4600.,   4700.,   4800.,
          4900.,   5000.,   5100.,   5200.,   5300.,   5400.,   5500.,
          5600.,   5700.,   5800.,   5900.,   6000.,   6100.,   6200.,
          6300.,   6400.,   6500.,   6600.,   6700.,   6800.,   6900.,
          7000.,   7100.,   7200.,   7300.,   7400.,   7500.,   7600.,
          7700.,   7800.,   7900.,   8000.,   8100.,   8200.,   8300.,
          8400.,   8500.,   8600.,   8700.,   8800.,   8900.,   9000.,
          9100.,   9200.,   9300.,   9400.,   9500.,   9600.,   9700.,
          9800.,   9900.,  10000.]),
 <a list of 100 Patch objects>)

history
cd Y:
cd FourthYear_MajorProject/
import astropy.io.fits
f = astropy.io.fits.open("./60s_DarkFrame.FIT")
f0 = f[0]
d = f0.data
hist(d.flatten(),100,0,1000)
hist(d.flatten(),100,(0,1000))
hist(d.flatten(),100,(0,1000))
hist(d.flatten())
hist?
hist(d.flatten(),100,(0,1000))
hist(d.flatten(),100,(0,10000))
hist(d[0,;].flatten(),100,(0,10000))
hist(d[0,:].flatten(),100,(0,10000))
h = hist(d[0,:].flatten(),100,(0,10000))
h
h[0]
h[1]
clf()
plot(h[0])
plot(h[1])
shape(h[0])
shape(h[1])
y = h[0]
xedge = h[1]
roll(xedge,-1)
roll(xedge,-1)
xcentre = (xedge + roll(xedge,-1))/2.0
shape(xcentre)
x = xcentre[0:100]
x
clf()
plot(x,y)
import numpy as np
def guass(x,a, mu, sigma) :
    return a*np.exp(-(x-mu)**2/(2*sigma**2))
x = linspace(-10,10,0.01)
x
x = linspace(-10,10,100)
x
x = xcentre[0:100]
a = linspace(-10,10,100)
gauss
def gauss(x,a, mu, sigma) :
    return a*np.exp(-(x-mu)**2/(2*sigma**2))
gauss(a,10,0,5)
plot(a,gauss(a,10,0,5))
plot(a,gauss(a,10,0,5))
xx
x
history
import scipy.optimize
scipy.optimize.curve_fit?
import scipy.optimize(gauss,x,y)
import scipy.optimize.curve_fit(gauss,x,y)
scipy.optimize.curve_fit(gauss,x,y)
scipy.optimize.curve_fit(gauss,x,y,(1000,10000,1000))
[p0,pcov] = scipy.optimize.curve_fit(gauss,x,y,(1000,10000,1000))
p0
plot(x,y)
yfit = gauss(x,p[0],p[1],p[2])
yfit = gauss(x,p0[0],p0[1],p0[2])
plot(x,yfit)
history
hist(d.flatten(),100,(0,10000))
history





-- BekiChafer - 12 Oct 2017
Topic attachments
I Attachment Action Size Date Who Comment
Compressed Zip archivezip 15_DarkFrame.zip manage 23590.9 K 12 Oct 2017 - 23:54 BekiChafer  
Compressed Zip archivezip 25Degrees.zip manage 31292.3 K 12 Oct 2017 - 23:44 BekiChafer Dark frames taken at ccd temp. 25 degrees at various exposure times

Physics WebpagesRHUL WebpagesCampus Connect • Royal Holloway, University of London, Egham, Surrey TW20 0EX; Tel/Fax +44 (0)1784 434455/437520

Topic revision: r3 - 12 Oct 2017 - BekiChafer

 
This site is powered by the TWiki collaboration platformCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding RHUL Physics Department TWiki? Send feedback