예제 #1
0
def n():  ########### remove interference noise from 4_light

    width = 100
    r = RamanSpectrum('/home/chris/Documents/DataWeiss/150304/4_light.SPE')

    lambdaa = 10**7 / (10**7 / 514.5 - array(r.index))
    r.index = pandas.Float64Index(lambdaa)
    r = r.iloc[90:900]

    for i in range(5):
        r = smooth(r)

    fit = polyfit(array(r.index), r.values, 4)
    r /= polyeval(fit, array(r.index))

    xs = array(r.index) / 1000

    def funct(x, A, m, b, phase):
        return (1 + (A) * cos((x + m * x**2) * pi / b + phase))**2

    guess = [0.005, 1, 0.005, 0.1]

    plot(xs, funct(xs, *guess), 'k')
    plot(xs, r.values)
    x = scipy.optimize.curve_fit(funct, xs, r.values, guess)
    print x[0]
    plot(xs, funct(xs, *x[0]))

    return 0
예제 #2
0
def n2(name):  ########### remove interference noise from 3_light

    r = RamanSpectrum(name)

    lambdaa = 10**7 / (10**7 / 514.5 - array(r.index))
    r.index = pandas.Float64Index(lambdaa)
    r = r.iloc[300:800]

    weights = zeros(r.size)

    for i in range(5):
        r = smooth(r)

    fit = polyfit(array(r.index), r.values, 5)
    r /= polyeval(fit, array(r.index))

    xs = array(r.index) / 1000

    plot(xs, r.values)

    def funct(p):
        return sum((r.values - 0.0017 * cos(700 / (xs + 4 * xs**2) + p) - 1)
                   **2)

    bnds = ((0, 2 * pi), )
    pguess = float(scipy.optimize.minimize(funct, pi, bounds=bnds)['x'])

    pguess = 0

    #plot(xs,0.0017*cos(600/(xs+1*xs**2) +pguess)+1 ,'r')

    #def funct(x,A,m,b):return (A/1000.0)*cos(d*100/(a*x**2+b*x**2+c)+pguess)+1   #def funct(x,A,b,phase):return (1+(A)*cos(x*pi/b+phase))**2
    #guess = [1.7,4,6.0]#

    def funct(x, A, a, b, c):
        return (A / 1000.0) * cos(
            1000 / (a * x**2 + b * x + c)
        ) + 1  #def funct(x,A,b,phase):return (1+(A)*cos(x*pi/b+phase))**2

    guess = [1.7, 3, 1, 0]  #

    # plot(xs,funct(xs, *guess),'k')

    x = scipy.optimize.curve_fit(funct, xs, r.values, guess)
    print x[0]
    plot(
        xs,
        funct(xs, *x[0]),
        label=os.path.basename(name),
        color=gca().lines[-1].get_color())
    print sum((r.values - funct(xs, *x[0]))**2)

    legend()

    return 0
예제 #3
0
파일: Feb24.py 프로젝트: cmthompson/data
def RhodBonRaman():
    
    
    os.chdir('/home/chris/Documents/DataWeiss/150228')
    RB1=RamanSpectrum('RhB 500sec 0_01_filter.SPE')
    RB2= RamanSpectrum('RhB 500sec 0_1_filter.SPE')
    RB3=RamanSpectrum('RhB 500sec full power_filter.SPE')
    RBref = RamanSpectrum(pandas.Series.from_csv('/home/chris/Documents/DataWeiss/RhodamineB.csv'))
    RBref.index=pandas.Float64Index(10**7/514.5-10**7/array(RBref.index))
    dark = mean(RamanSpectrum('dark 50 s.SPE'))*10
    
    
    

    RB1/=max(RB1)
    RB1.plot()
    RBref.plot()
    return RBref