import yaml
import numpy as np

config = "ham_conf.yml"
config_args = {}

if type(config) == str:
    with open(config) as cfile:
        config_args.update(yaml.load(cfile))
elif type(config) == dict:
    config_args.update(config)
else:
    print "config is wrong type"


""" Prepare Bloch Sphere settings """
db=Bloch()
colors = ["b","g","r","k"]#,"r","g","#CC6600"]
db.point_color = colors
db.point_marker = ['o']


result_states = qload("anim/notodd")

for i in range(4):
	db.add_points(np.transpose(np.array([Plotter.bloch_vector(result_states[t].ptrace(0)) for t in range(int(i*config_args['steps']/4.),int((i+1)*config_args['steps']/4.),10)])))

db.add_states(result_states[-1].ptrace(0))

db.show()
def log_result(result):
    # This is called whenever simulation(i) returns a result.
    # result_list is modified only by the main process, not the pool workers.
    final_states.insert(result[0], result[1].ptrace(0))
    philist.insert(result[0], Plotter.extract_phi(Plotter.bloch_vector(result[1].ptrace(0))))