示例#1
0
def fitpars_from_abslines(abslinelist):
    '''Builds veeper parameter array from list of linetools AbsLines

    Parameters
    ----------
    abslinelist: list
        List of AbsLine objects

    Returns
    -------
    fitpars : list of lists
        The joebvp parameter array that includes line measurements
    '''
    from joebvp import joebvpfit
    restwaves = [al.wrest.value for al in abslinelist]
    linecol = [al.attrib['logN'] for al in abslinelist]
    lineb = [al.attrib['b'].value for al in abslinelist]
    linevel = [al.attrib['vel'].value for al in abslinelist]
    linevlim1 = [al.limits.vlim[0].value for al in abslinelist]
    linevlim2 = [al.limits.vlim[1].value for al in abslinelist]
    zs = [al.z for al in abslinelist]
    initpars = [restwaves, linecol, lineb, zs, linevel, linevlim1, linevlim2]
    initinfo = [[1]*len(abslinelist)]*len(initpars)
    fitpars, parinfo = joebvpfit.initlinepars(zs, restwaves, initpars,
                                              initinfo=initinfo)

    return fitpars
示例#2
0
def cosvoigt_cont(vwave,cont,vpars):
    from joebvp import joebvpfit
    pars,info=joebvpfit.initlinepars(vpars[3],vpars[0],vpars,initinfo=[0,0,0])
    cfg.fitidx=joebvpfit.fitpix(vwave, pars,find_bad_pixels=False)
    cfg.wave=vwave
    vflux=np.zeros(len(vwave))+1.
    factor=voigt(vwave,vpars[0],vpars[1],vpars[2],vpars[3],vpars[4])
    convfactor=convolvecos(vwave,factor*cont,vpars[0],vpars[3])
    vflux*=convfactor
    return vflux
示例#3
0
 def addLine(self,wave,newrestwave,newz,newcol,newb,newvel,newvel1,newvel2,newrely=None,newcmt=None):
     ### Setup new parameters and append them to main arrays of the data model
     newpars=[[newrestwave],[newcol],[newb],[newz],[newvel],[newvel1],[newvel2]]
     fitpars=np.hstack((self.fitpars,newpars))
     newerrors=[[-99],[-99],[-99],[-99],[-99]]
     fiterrors=np.hstack((self.fiterrors,newerrors))
     newindex=np.max(self.parinfo[1])+1
     newinfo=[[1],[newindex],[newindex],[1],[newindex]]
     parinfo=np.hstack((self.parinfo,newinfo))
     newcmts=[newrely,newcmt]
     linecmts=np.hstack((self.linecmts,newcmts))
     ### Call initlinepars to set atomic data in cfg.fosc, etc.
     junk,junk=joebvpfit.initlinepars(fitpars[3],fitpars[0],initvals=fitpars,initinfo=parinfo)
     ### Do the update
     midx=QModelIndex()  # Needed for 'beginInsertRows'
     self.beginInsertRows(midx,len(self.fitpars[0]),len(self.fitpars[0]))
     self.updatedata(fitpars,fiterrors,parinfo,linecmts)
     self.endInsertRows()
     ### Reset pixels for fit and wavegroups for convolution
     cfg.fitidx=joebvpfit.fitpix(wave, fitpars) #Reset pixels for fit
     cfg.wavegroups=[]
示例#4
0
 def addLine(self,wave,newrestwave,newz,newcol,newb,newvel,newvel1,newvel2,newrely=None,newcmt=None):
     ### Setup new parameters and append them to main arrays of the data model
     newpars=[[newrestwave],[newcol],[newb],[newz],[newvel],[newvel1],[newvel2]]
     fitpars=np.hstack((self.fitpars,newpars))
     newerrors=[[-99],[-99],[-99],[-99],[-99]]
     fiterrors=np.hstack((self.fiterrors,newerrors))
     newindex=np.max(self.parinfo[1])+1
     newinfo=[[1],[newindex],[newindex],[1],[newindex]]
     parinfo=np.hstack((self.parinfo,newinfo))
     newcmts=[newrely,newcmt]
     linecmts=np.hstack((self.linecmts,newcmts))
     ### Call initlinepars to set atomic data in cfg.fosc, etc.
     junk,junk=joebvpfit.initlinepars(fitpars[3],fitpars[0],initvals=fitpars,initinfo=parinfo)
     ### Do the update
     midx=QModelIndex()  # Needed for 'beginInsertRows'
     self.beginInsertRows(midx,len(self.fitpars[0]),len(self.fitpars[0]))
     self.updatedata(fitpars,fiterrors,parinfo,linecmts)
     self.endInsertRows()
     ### Reset pixels for fit and wavegroups for convolution
     cfg.fitidx=joebvpfit.fitpix(wave, fitpars) #Reset pixels for fit
     cfg.wavegroups=[]