Beispiel #1
0
def residuals(params):
    f = profile(params)                         #f = k(param)
    f = np.reshape(f,(N**2))                    #reshape f into 1D array
    f -= mean                                   #changed 'change' (which was an experiment) to 'mean'#f = f-change
    for m in range(1,6):
        f -= np.inner(f,vecs[:,-m])*vecs[:,-m]  #removing projections along principle axes
    return f
Beispiel #2
0
def residuals(params):
    f = profile(params)                         #f = k(param)
    f = np.reshape(f,(N**2))                    #reshape f into 1D array
    clip = 2.5
                                  #set clip value to keep inside the region of the ensemble models (between 2 and 3 because Gaussian fit)
    f -= mean                                   #take away the mean
    for m in range(1,11):
        i = np.inner(f,vecs[:,-m])              #clip the principal components
        if i>clip:
            i = clip
        elif i<-clip:
            i = -clip
        f -= i*vecs[:,-m]                       #removing projections along principle axes
    return mask*f                               
Beispiel #3
0
lev = np.linspace(0,5,11)
# lev = 10**(np.linspace(-1,1,21))
pl.contour(X,Y,J, levels=lev)               #plot graph of parameterised model with real parameters
meanplot = np.reshape(mean,(N,N))
#pl.contour(X,Y,meanplot, levels=lev)       #plot graph of mean
L = residuals(trueparam)
M = J - np.reshape(L, (N,N))                #best fit from principal component subspace to J
#print 'residuals', np.sum(L*L)
lev = np.linspace(0,5,11)
pl.contour(X,Y,M, levels=lev)               #plot k(trueparam) - residuals(trueparam)
pl.axes().set_aspect('equal')
pl.title('The best fit from principal component subspace to the true parameterised model')
pl.show()
"""

F = profile(lsq)                            #F = k(param) with optimised parameters
lev = np.linspace(0,5,11)
# lev = 10**(np.linspace(-1,1,21))
pl.contour(X,Y,F, levels=lev)
L = residuals(lsq)
M = F - np.reshape(L, (N,N))
#print 'residuals', np.sum(L*L)              #compare to trueparam value above
lev = np.linspace(0,5,11)
pl.contour(X,Y,M, levels=lev)               #plot k(param) - residuals(param) for optimised params
pl.axes().set_aspect('equal')
pl.title('Parameterised model with best fit to parameterised model')
pl.show()


"""Plot parameterised model"""
F = profile(lsq)                            #F = k(param) with optimised parameters