Пример #1
0
def fit_pk_obj_1d(p,x,f0,pktype):  
    if pktype == 'gaussian':
        f=pkfuncs.gaussian1d(p,x)
    elif pktype == 'lorentzian':
        f=pkfuncs.lorentzian1d(p,x)
    elif pktype == 'pvoigt':
        f=pkfuncs.pvoigt1d(p,x)
    elif pktype == 'split_pvoigt':
        f=pkfuncs.split_pvoigt1d(p,x)
    elif pktype == 'tanh_stepdown':
        f=pkfuncs.tanh_stepdown_nobg(p,x)
    
    resd = f-f0
    return resd
Пример #2
0
def fit_pk_obj_1d_bnded(p,x,f0,pktype,weight,lb,ub):  
    if pktype == 'gaussian':
        f=pkfuncs.gaussian1d(p,x)
    elif pktype == 'lorentzian':
        f=pkfuncs.lorentzian1d(p,x)
    elif pktype == 'pvoigt':
        f=pkfuncs.pvoigt1d(p,x)
    elif pktype == 'split_pvoigt':
        f=pkfuncs.split_pvoigt1d(p,x)
    
    num_data=len(f)
    num_parm=len(p)
    resd=np.zeros(num_data+num_parm)
    #tub bnds implementation    
    
    resd[:num_data] = f-f0
    for ii in range(num_parm):
        if lb[ii] is not None:        
            resd[num_data+ii]=weight*np.max([-(p[ii]-lb[ii]),0.,(p[ii]-ub[ii])])
    
    
    return resd