How can fit the data on temperature/thermal profile?

前端 未结 2 932
终归单人心
终归单人心 2020-12-12 01:24

I have a dataset consisting of a certain temperature profile and I wanna fit or map the measurement points on temperature profile which is following:

Dwell-t

2条回答
  •  忘掉有多难
    2020-12-12 02:01

    If you are only interested in the two temperature levels, this might be useful:

    import matplotlib.pyplot as plt
    import numpy as np
    from scipy.optimize import curve_fit
    
    inData = np.loadtxt('SOF.csv', skiprows=1, delimiter=',' )
    
    def gauss( x, s ):
        return 1. / np.sqrt( 2. * np.pi * s**2 ) * np.exp( -x**2 / ( 2. * s**2 ) )
    
    def two_peak( x , a1, mu1, s1, a2, mu2, s2 ):
        return a1 * gauss( x - mu1, s1 ) + a2 * gauss( x - mu2, s2 )
    
    fList = inData[ :, 2 ]
    
    nBins = 2 * int( max( fList ) - min( fList ) )
    fig = plt.figure()
    
    ax = fig.add_subplot( 2, 1 , 1 )
    ax.plot( fList , marker='x' )
    bx = fig.add_subplot( 2, 1 , 2 )
    histogram, binEdges, _ = bx.hist( fList, bins=nBins )
    
    binCentre = np.fromiter( (  ( a + b ) / 2. for a,b in zip( binEdges[ 1: ], binEdges[ :-1 ] ) ) , np.float )
    sol, err = curve_fit( two_peak, binCentre, histogram, [ 120, min( fList ), 1 ] + [ 500, max( fList ), 1 ] )
    print sol[1], sol[4]
    print sol[2], sol[5]
    bx.plot( binCentre, two_peak( binCentre, *sol ) )
    bx.set_yscale( 'log' )
    bx.set_ylim( [ 1e-0, 5e3] )
    plt.show()
    

    providing:

    >> -46.01513424923528 150.06381412858244
    >> 1.8737971845243133 0.6964990809008554
    

    and

    Interestingly your non-plateau data is all around zero, so that's probably not due to the ramp, but a different effect.

提交回复
热议问题