Ejemplo n.º 1
0
 def initialpars(self,parfilename):
     ### Deal with initial parameters from line input file
     self.fitpars,self.fiterrors,self.parinfo,self.linecmts = joebvpfit.readpars(parfilename)
     cfg.fitidx=joebvpfit.fitpix(self.wave, self.fitpars) #Set pixels for fit
     cfg.wavegroups=[]
     self.datamodel = LineParTableModel(self.fitpars,self.fiterrors,self.parinfo,linecmts=self.linecmts)
     self.tableView.setModel(self.datamodel)
     self.datamodel.updatedata(self.fitpars,self.fitpars,self.parinfo,self.linecmts)
Ejemplo n.º 2
0
 def initialpars(self,parfilename):
     ### Deal with initial parameters from line input file
     self.fitpars,self.fiterrors,self.parinfo,self.linecmts = joebvpfit.readpars(parfilename)
     cfg.fitidx=joebvpfit.fitpix(self.wave, self.fitpars) #Set pixels for fit
     cfg.wavegroups=[]
     self.datamodel = LineParTableModel(self.fitpars,self.fiterrors,self.parinfo,linecmts=self.linecmts)
     self.tableView.setModel(self.datamodel)
     self.datamodel.updatedata(self.fitpars,self.fitpars,self.parinfo,self.linecmts)
Ejemplo n.º 3
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
Ejemplo n.º 4
0
def compose_model(spec,filelist,outfile):
    '''
    Generates full-model spectrum (XSpectrum1D) from a set of joebvp output files and writes out a file with the spectrum.

    Parameters
    ----------
    spec : string or XSpectrum1D
        The spectrum to be fitted with the input lines

    filelist : list of strings or str
        This should be a list containing the names of VP input files or a string referring to a file simply
        listing the input files.
        See joebvpfit.readpars for details of file format

    outfile : str
        Name of model spectrum output file

    '''
    from joebvp import joebvpfit

    ### Deal with alternate input types
    if isinstance(spec,str):
        specobj = readspec(spec)
    else:
        specobj = spec

    ### Load essentials from spectrum
    wave = specobj.wavelength.value
    normsig=specobj.sig.value/specobj.co.value
    cfg.wave = wave

    ### Concatenate all the parameter tables
    concatenate_line_tables(filelist,outtablefile='compiledVPinputs.dat')

    ### Make the model!
    fitpars, fiterrors, parinfo, linecmts = joebvpfit.readpars('compiledVPinputs.dat')  # read this back in to load params
    cfg.fitidx = joebvpfit.fitpix(wave, fitpars)  # set the pixels in the line regions
    model = joebvpfit.voigtfunc(wave,fitpars)  # generate the Voigt profiles of all lines

    ### Instantiate XSpectrum1D object and write it out
    outspec=XSpectrum1D.from_tuple((wave,model,normsig))
    outspec.write_to_fits(outfile)
Ejemplo n.º 5
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=[]
Ejemplo n.º 6
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=[]