MCMC Fitting¶
Warning
These functions are under construction.
Setup¶
- Copy the
config.yaml
andrun.py
from the main directory to an external folder. - Edit your configuration script
config.yaml
, which should look something like below. - In your new directory run
python run.py
in terminal.
Configuration¶
# Instrument specifications
data:
instrument: "APOGEE"
data_path: "default" # defaults to $APOGEE_DATA path (see setup documentation), unless otherwise specified
ID: "2M01195227+8409327"
orders: [[15200,15800],[15860,16425],[16475,16935]] # wave ranges, and orders
dtype: "ap1d"
visit: 1
sigma_clip: [.3,.05]
pixel_buffer: [0,2]
# Make sure this config.yaml and run.py files are placed in your input directory
# I recommend copying config.yaml and run.py to a path external to apogee_tools
workdir:
input: "/home/jess/Desktop/Research/FAST/fit_models"
output: "/home/jess/Desktop/Research/FAST/fit_models/output"
out:
mcmc_sampler: False
corner: False
walkers: False
print_report: True
# Specify which parameters will be sampled by MCMC
# otherwise parameters will be fixed at 'init' values
model:
grid_name: "PHOENIX" #directory: phoenix/apogee/order
theta: ['teff', 'logg', 'fe_h', 'rv', 'vsini', 'alpha']
fix_param: # specify fixed parameters (not sampled by MCMC)
airmass: 1.0 # airmass of telluric model, either 1.0 or 1.5
cont_deg: 5 # continuum polynomial degree
interp_method: "splat" # or "cannon"
resample_method: "fast" # or "splat"
# MCMC tuning
mcmc:
nwalkers: 12
nsteps: 3
# Initial parameters for MCMC
init:
teff: 3500
logg: 4.50
fe_h: 0.0
rv: -4.77
vsini: 5.79
alpha: 1.0
# Step parameters for MCMC
step:
teff: 1
logg: .01
fe_h: .01
rv: .1
vsini: .1
alpha: .01
# Prior ranges for MCMC (for flat prior)
prior:
teff: [2500, 5500]
logg: [0.0, 5.5]
fe_h: [-1.0, 1.0]
rv: [-200, 200]
vsini: [0, 200]
alpha: [0, 5]
Pre-MCMC Testing¶
To test to make sure all of the modeling modules are working, run the following command in terminal:
python run.py make_model
which should return something like:
[25.732014894485474s] MCMC initialization step complete.
##################################################
Making model: teff=3500 logg=4.5 fe_h=0.0 rv=-4.77 vsini=5.79 alpha=1.0
[0.07615256309509277s] Interpolated model
[0.0025053024291992188s] Shifted radial velocity
[0.0032796859741210938s] Applied vsini broadening
[0.05470013618469238s] Convolved telluric model
[0.08379793167114258s] Applied LSF broadening

To test by eye, that your initial MCMC parameters are some close to the data:
python run.py test_fit
Running the MCMC¶
Run the MCMC:
python run.py mcmc
Plot the outputs:
python run.py walkers
python run.py corner