示例#1
0
##### modify nebon status
# we want to be able to turn it on and off at will
if sample_results['model'].params['add_neb_emission'] == 2:
	sample_results['model'].params['add_neb_emission'] = np.array(True)

##### initialize sps
sps = model_setup.load_sps(**sample_results['run_params'])


###### MAXPROB_MODEL
# grab maximum probability, plus the thetas that gave it
maxprob = np.max(sample_results['lnprobability'])
probind = sample_results['lnprobability'] == maxprob
thetas = sample_results['chain'][probind,:]
if type(thetas[0]) != np.dtype('float64'):
	thetas = thetas[0]


###### TEST LIKELIHOOD
run_params = model_setup.get_run_params(param_file=param_name)
gp_spec, gp_phot = model_setup.load_gp(**run_params)
likefn = LikelihoodFunction()
mu, phot, x = model.mean_model(model.initial_theta, sample_results['obs'], sps=sps)

mu, phot, x = model.mean_model(thetas, sample_results['obs'], sps = sps)
lnp_phot = likefn.lnlike_phot(phot, obs=sample_results['obs'], gp=gp_phot)
lnp_prior = model.prior_product(thetas)

print lnp_phot + lnp_prior

示例#2
0
# --------------
# Read command line arguments
# --------------
sargv = sys.argv
argdict = {'param_file': ''}
clargs = model_setup.parse_args(sargv, argdict=argdict)
run_params = model_setup.get_run_params(argv=sargv, **clargs)

# --------------
# Globals
# --------------
# SPS Model instance as global
sps = model_setup.load_sps(**run_params)
# GP instances as global
spec_noise, phot_noise = model_setup.load_gp(**run_params)
# Model as global
global_model = model_setup.load_model(**run_params)
# Obs as global
global_obs = model_setup.load_obs(**run_params)

# -----------------
# LnP function as global
# ------------------

def lnprobfn(theta, model=None, obs=None, residuals=False,
             verbose=run_params['verbose']):
    """Given a parameter vector and optionally a dictionary of observational
    ata and a model object, return the ln of the posterior. This requires that
    an sps object (and if using spectra and gaussian processes, a GP object) be
    instantiated.
示例#3
0
# --------------
# Read command line arguments
# --------------
sargv = sys.argv
argdict = {'param_file': ''}
clargs = model_setup.parse_args(sargv, argdict=argdict)
run_params = model_setup.get_run_params(argv=sargv, **clargs)

# --------------
# Globals
# --------------
# SPS Model instance as global
sps = model_setup.load_sps(**run_params)
# GP instances as global
spec_noise, phot_noise = model_setup.load_gp(**run_params)
# Model as global
global_model = model_setup.load_model(**run_params)
# Obs as global
global_obs = model_setup.load_obs(**run_params)

# -----------------
# LnP function as global
# ------------------

def lnprobfn(theta, model=None, obs=None, verbose=run_params['verbose']):
    """Given a parameter vector and optionally a dictionary of observational
    ata and a model object, return the ln of the posterior. This requires that
    an sps object (and if using spectra and gaussian processes, a GP object) be
    instantiated.