Skip to content

Commit

Permalink
The spectroscopic binary code now works! See Issue Starfish-develop#68.
Browse files Browse the repository at this point in the history
  • Loading branch information
gully committed Jun 11, 2016
1 parent 9592af8 commit 69884ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Starfish/model_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ThetaParam:
:param grid: parameters corresponding to the dimensions of the grid.
:type grid: 1D np.array
'''
def __init__(self, grid, vz=0.0, vsini=0.0, logOmega=0.0, Av=0.0, teff2=6000.0, logOmega2=-0.5, grid2=[3100, 3.8, 0.0], vz2=0.0, vsini2=0.0, logOmega2=0.0):
def __init__(self, grid, vz=0.0, vsini=0.0, logOmega=0.0, Av=0.0, grid2=[3100, 3.8, 0.0], vz2=0.0, vsini2=0.0, logOmega2=0.0):
self.grid = grid
self.vz = vz
self.vsini = vsini
Expand Down Expand Up @@ -76,7 +76,7 @@ def default(self, o):
"vz":o.vz,
"vsini":o.vsini,
"logOmega":o.logOmega,
"Av":o.Av
"Av":o.Av,
"grid2":o.grid2.tolist(),
"vz2":o.vz2,
"vsini2":o.vsini2,
Expand Down
15 changes: 8 additions & 7 deletions scripts/star_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# All of the argument parsing is done in the `parallel.py` module.

import multiprocessing
#import multiprocessing
import time
import numpy as np
import Starfish
Expand Down Expand Up @@ -449,25 +449,26 @@ def lnprob_all(p):
fname = Starfish.specfmt.format(model.spectrum_id, model.order) + "phi.json"
phi0 = PhiParam.load(fname)

ndim, nwalkers = 12, 40
ndim, nwalkers = 18, 40

p0 = np.array(start["grid"] + [start["vz"], start["vsini"], start["logOmega"]]
p0 = np.array(start["grid"] + [start["vz"], start["vsini"], start["logOmega"]] +
start["grid2"] + [start["vz2"], start["vsini2"],
start["logOmega2"]] +
phi0.cheb.tolist() + [phi0.sigAmp, phi0.logAmp, phi0.l])

p0_std = [5, 0.02, 0.02, 0.5, 0.5, -0.01,
5, 0.02, 0.02, 0.5, 0.5, -0.01,
-0.005, -0.005, -0.005, 0.01, 0.001, 0.5]
p0_std = [5, 0.02, 0.02, 0.5, 0.5, 0.01,
5, 0.02, 0.02, 0.5, 0.5, 0.01,
0.005, 0.005, 0.005, 0.01, 0.001, 0.5]

if args.resume:
p0_ball = np.load("emcee_chain.npy")[:,-1,:]
else:
p0_ball = emcee.utils.sample_ball(p0, p0_std, size=nwalkers)

n_threads = multiprocessing.cpu_count()
n_threads = 1#multiprocessing.cpu_count()
sampler = emcee.EnsembleSampler(nwalkers, ndim, lnprob_all, threads=n_threads)

test = lnprob_all(p0)

nsteps = args.samples
ninc = args.incremental_save
Expand Down

0 comments on commit 69884ca

Please sign in to comment.