splat/model.py
def _modelFitEMCEE_plotcomparison(samples,spec,file,**kwargs):
    '''
    for now just plotting best model
    would like to do draws from posterior instead
    '''
# extract best fit values
    mplabels = ['teff','logg','z']
    draws = kwargs.get('draws',1)
    pargs = (spec,)
    legend = [spec.name]
    colors = ['k']
    alpha = [0]
    tbl = Table()
    tbl['parameter_weights'] = kwargs.get('parameter_weights',numpy.ones(samples.shape[0]))
    tbl['parameter_weights'] = numpy.max(tbl['parameter_weights'])-tbl['parameter_weights']
    for i in range(samples.shape[-1]):
        tbl[mplabels[i]] = samples[:,i]
    tbl.sort('parameter_weights')
    tblu = tunique(tbl,keys=mplabels[i][:samples.shape[-1]])
    draws = numpy.min([draws,len(tblu)])
    for k in range(draws):
        mkwargs = copy.deepcopy(kwargs)
        mlegend = r''
        for i in range(samples.shape[-1]):
            mkwargs[mplabels[i]] = tblu[mplabels[i]][k]
            mlegend+='{:s}={:.2f} '.format(SPECTRAL_MODEL_PARAMETER[mplabels[i]]['title'],mkwargs[mplabels[i]])
        mdl = loadModel(**mkwargs)
#    print(mdl.teff,mdl.logg)
        stat,scl = compareSpectra(spec,mdl,**kwargs)
        mdl.scale(scl)
        pargs = pargs + (mdl,)
        legend.append(mlegend)
        colors.append('grey')
        alpha.append(tblu['parameter_weights'][k])
#    print(*pargs)
    return splot.plotSpectrum(*pargs,colors=colors,alpha=alpha,\
        uncertainty=True,telluric=True,file=file,legend=legend)

    for now just plotting best model
    would like to do draws from posterior instead
    
for now just plotting best model
would like to do draws from posterior instead
for now just plotting best model would like to do draws from posterior instead
def _modelFitEMCEE_plotcomparison(samples,spec,file,**kwargs):
    mplabels = ['teff','logg','z']
    draws = kwargs.get('draws',1)
    pargs = (spec,)
    legend = [spec.name]
    colors = ['k']
    alpha = [0]
    tbl = Table()
    tbl['parameter_weights'] = kwargs.get('parameter_weights',numpy.ones(samples.shape[0]))
    tbl['parameter_weights'] = numpy.max(tbl['parameter_weights'])-tbl['parameter_weights']
    for i in range(samples.shape[-1]):
        tbl[mplabels[i]] = samples[:,i]
    tbl.sort('parameter_weights')
    tblu = tunique(tbl,keys=mplabels[i][:samples.shape[-1]])
    draws = numpy.min([draws,len(tblu)])
    for k in range(draws):
        mkwargs = copy.deepcopy(kwargs)
        mlegend = r''
        for i in range(samples.shape[-1]):
            mkwargs[mplabels[i]] = tblu[mplabels[i]][k]
            mlegend+='{:s}={:.2f} '.format(SPECTRAL_MODEL_PARAMETER[mplabels[i]]['title'],mkwargs[mplabels[i]])
        mdl = loadModel(**mkwargs)
        stat,scl = compareSpectra(spec,mdl,**kwargs)
        mdl.scale(scl)
        pargs = pargs + (mdl,)
        legend.append(mlegend)
        colors.append('grey')
        alpha.append(tblu['parameter_weights'][k])
    return splot.plotSpectrum(*pargs,colors=colors,alpha=alpha,\
        uncertainty=True,telluric=True,file=file,legend=legend)
def _modelFitEMCEE_plotcomparison ( samples , spec , file , ** kwargs ) : mplabels = [ 'teff' , 'logg' , 'z' ] draws = kwargs . get ( 'draws' , 1 ) pargs = ( spec , ) legend = [ spec . name ] colors = [ 'k' ] alpha = [ 0 ] tbl = Table ( ) tbl [ 'parameter_weights' ] = kwargs . get ( 'parameter_weights' , numpy . ones ( samples . shape [ 0 ] ) ) tbl [ 'parameter_weights' ] = numpy . max ( tbl [ 'parameter_weights' ] ) - tbl [ 'parameter_weights' ] for i in range ( samples . shape [ - 1 ] ) : tbl [ mplabels [ i ] ] = samples [ : , i ] tbl . sort ( 'parameter_weights' ) tblu = tunique ( tbl , keys = mplabels [ i ] [ : samples . shape [ - 1 ] ] ) draws = numpy . min ( [ draws , len ( tblu ) ] ) for k in range ( draws ) : mkwargs = copy . deepcopy ( kwargs ) mlegend = r'' for i in range ( samples . shape [ - 1 ] ) : mkwargs [ mplabels [ i ] ] = tblu [ mplabels [ i ] ] [ k ] mlegend += '{:s}={:.2f} ' . format ( SPECTRAL_MODEL_PARAMETER [ mplabels [ i ] ] [ 'title' ] , mkwargs [ mplabels [ i ] ] ) mdl = loadModel ( ** mkwargs ) stat , scl = compareSpectra ( spec , mdl , ** kwargs ) mdl . scale ( scl ) pargs = pargs + ( mdl , ) legend . append ( mlegend ) colors . append ( 'grey' ) alpha . append ( tblu [ 'parameter_weights' ] [ k ] ) return splot . plotSpectrum ( * pargs , colors = colors , alpha = alpha , uncertainty = True , telluric = True , file = file , legend = legend )
for now just plotting best model
would like to do draws from posterior instead
for now just plotting best model would like to do draws from posterior instead
'''
    for now just plotting best model
    would like to do draws from posterior instead
    ''' # extract best fit values #    print(mdl.teff,mdl.logg) #    print(*pargs)
samples
spec
file