Exemple #1
0
def run_tests():
    testEmdee = emdee.Emdee(mode='new')
    print()

    testEmdee.AddParam('core_mass')
    testEmdee.AddParam('Qimp', [1.0, 4.0])
    testEmdee.PrintParams()
    testEmdee.AddParam('core_mass', [1.5, 1.6])
    print()

    testEmdee.ChangeBounds('core_mass', [1.6, 2.1])
    testEmdee.PrintParams()
    testEmdee.ChangeBounds('core_radius', [9.0, 9.2])
    print()

    print(testEmdee.nwalkers)
    testEmdee.ChangeWalkers(30)
    print(testEmdee.nwalkers)
    testEmdee.ChangeWalkers(17)
    testEmdee.ChangeWalkers(2)
    print(testEmdee.nwalkers)
    print()

    print(testEmdee.dstar_dir)
    testEmdee.ChangeDStarDir('some/dstar/somewhere')
    print(testEmdee.dstar_dir)
    print()

    testEmdee._lastlogged = 100
    testEmdee.AddParam('Mdot')
    print()

    print("\n...testPrep complete...\n")
Exemple #2
0
import time
import datetime
import os
import sys
sys.path.insert(
    0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))

import emdee

print(
    datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))

emdeeClass = emdee.Emdee()

emdeeClass.AddParam("core_mass")
emdeeClass.AddParam("core_radius")
emdeeClass.PrintParams()

emdeeClass.ChangeWalkers(100)

emdeeClass.GoMCMC(50)

emdeeClass.PlotChains(save=True,
                      hlines={
                          "core_mass": 1.6,
                          "core_radius": 10.4
                      })
emdeeClass.PlotCorner(lastpt=True, save=True)
emdeeClass.PrintPercentiles(lastpt=True)

print(
Exemple #3
0
import sys
sys.path.insert(
    0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))

import emdee

print(
    datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))

if os.path.exists('load_data'):
    shutil.rmtree('load_data')
shutil.copytree('test_data', 'load_data')
if os.path.exists('load_data/README'):
    os.remove('load_data/README')

emdeeClass = emdee.Emdee(mode='load', loc='load_data')
emdeeClass.PrintParams()
#print(emdeeClass.nwalkers)
#print(emdeeClass._lastlogged)
#print(emdeeClass._current_pos)
#print(emdeeClass._current_lnprob)

emdeeClass.PlotChains(name='chain_before.png',
                      save=True,
                      hlines={
                          "core_mass": 1.6,
                          "core_radius": 10.4
                      })
emdeeClass.PlotCorner(name='corner_before.png', lastpt=True, save=True)
emdeeClass.PrintPercentiles(lastpt=True)
Exemple #4
0
import os
import sys
sys.path.insert(
    0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))


import emdee


print(datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))


# Invoke a fresh Emdee class. 
# mode argument is 'new' by default, but shown explicitly here just for example purposes.
# loc is the subdirectory where results will be saved.
emdeeClass = emdee.Emdee(mode='new',loc='example_output')

# We'll use the core mass and radius as free parameters to "scan" over.
# Here we manually set bounds on mass (lower bound of 1.45 Msun, upper bound of 1.9 Msun).
# If no bounds are provided manually, a set of defaults appropriate to that parameter
#    is chosen (see emdee/emdeeDefaults.py for reference).
emdeeClass.AddParam("core_mass",[1.45,1.9])
emdeeClass.AddParam("core_radius")
emdeeClass.PrintParams()  # Optional, just to check, for example purposes

# Change the number of walkers, each with some initial position
emdeeClass.ChangeWalkers(100)

# "Run" the MCMC for this many steps. On each step, a new position is chosen for each
# walker based on the goodness of fit from the previous step. 
emdeeClass.GoMCMC(50)
Exemple #5
0
import time
import datetime
import shutil
import os
import sys
sys.path.insert(
    0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))


import emdee


print(datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))

# In this case we want to LOAD the results of a previous emdee run to pick up where
# we left off. With mode set to 'load' and loc pointing to the subdirectory containing
# a previous set of results (LOG.txt, last_lnprob.txt, etc...), an Emdee class is 
# populated with the loaded data and is ready to continue iterating. Changes to the 
# number of walkers or the parameters (and bounds) should not be made at this point.
# This is primarily for continuing runs that may have crashed, or completed successfully
# but haven't reached burn in (if running in small chunks locally, for example).
emdeeClass = emdee.Emdee(mode='load',loc='example_output')
emdeeClass.PrintParams()  # Just to check, for example

# As before, we just run another batch of iterations picking up from where the previous
# run that we loaded had left off.
emdeeClass.GoMCMC(100)


print(datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))
Exemple #6
0
import os
import sys
sys.path.insert(0,
                os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

import emdee

testEmdee = emdee.Emdee(mode='new')
print()

testEmdee.AddParam('core_mass')
testEmdee.AddParam('core_radius', gaussian_init=[10.4, 0.1])
testEmdee.AddParam('Qimp', gaussian_init=[20.0, 100.0])
testEmdee.ChangeWalkers(10)
print()

pos0 = testEmdee._InitWalkers()
print(pos0)
print('The first column should be uniform masses between 1.4 and 2.0')
print('The second coulmn should be radii in a narrow Gaussian around 10.4')
print(
    'The third column should be Qimp in a VERY wide Gaussian around 20, with some exact 20s mixed in (testing bounds)'
)