17
17
ITERATIONS = 10000
18
18
TUNING = 25000
19
19
WALKERS = 25
20
+ CORES = 1
20
21
PARAMNAMES = ['Amplitude' , 'Plateau Slope (d$^{-1}$)' , 'Plateau Duration (d)' ,
21
22
'Reference Epoch (d)' , 'Rise Time (d)' , 'Fall Time (d)' ]
22
23
@@ -303,7 +304,7 @@ def setup_model2(obs, parameters, x_priors, y_priors):
303
304
304
305
305
306
def sample_or_load_trace (model , trace_file , force = False , iterations = ITERATIONS , walkers = WALKERS , tuning = TUNING ,
306
- cores = 1 ):
307
+ cores = CORES ):
307
308
"""
308
309
Run a Metropolis Hastings MCMC for the given model with a certain number iterations, burn in (tuning), and walkers.
309
310
@@ -324,7 +325,7 @@ def sample_or_load_trace(model, trace_file, force=False, iterations=ITERATIONS,
324
325
tuning : int, optional
325
326
The number of iterations used for tuning.
326
327
cores : int, optional
327
- The number of walkers to run in parallel. Default: 1.
328
+ The number of walkers to run in parallel.
328
329
329
330
Returns
330
331
-------
@@ -585,7 +586,7 @@ def select_event_data(t, phase_min=PHASE_MIN, phase_max=PHASE_MAX, nsigma=None):
585
586
586
587
587
588
def two_iteration_mcmc (light_curve , outfile , filters = None , force = False , force_second = False , do_diagnostics = True ,
588
- iterations = ITERATIONS , walkers = WALKERS , tuning = TUNING ):
589
+ iterations = ITERATIONS , walkers = WALKERS , tuning = TUNING , cores = CORES ):
589
590
"""
590
591
Fit the model to the observed light curve. Then combine the posteriors for each filter and use that as the new prior
591
592
for a second iteration of fitting.
@@ -611,6 +612,8 @@ def two_iteration_mcmc(light_curve, outfile, filters=None, force=False, force_se
611
612
The number of cores and walkers used.
612
613
tuning : int, optional
613
614
The number of iterations used for tuning.
615
+ cores : int, optional
616
+ The number of walkers to run in parallel.
614
617
615
618
Returns
616
619
-------
@@ -633,7 +636,7 @@ def two_iteration_mcmc(light_curve, outfile, filters=None, force=False, force_se
633
636
obs = t [t ['FLT' ] == fltr ]
634
637
model1 , parameters1 = setup_model1 (obs , t ['FLUXCAL' ].max ())
635
638
outfile1 = outfile .format ('_1' + fltr )
636
- trace1 = sample_or_load_trace (model1 , outfile1 , force , iterations , walkers , tuning )
639
+ trace1 = sample_or_load_trace (model1 , outfile1 , force , iterations , walkers , tuning , cores )
637
640
traces1 [fltr ] = trace1
638
641
if do_diagnostics :
639
642
diagnostics (obs , trace1 , parameters1 , outfile1 )
@@ -648,7 +651,7 @@ def two_iteration_mcmc(light_curve, outfile, filters=None, force=False, force_se
648
651
obs = t [t ['FLT' ] == fltr ]
649
652
model2 , parameters2 = setup_model2 (obs , parameters1 , x_priors , y_priors )
650
653
outfile2 = outfile .format ('_2' + fltr )
651
- trace2 = sample_or_load_trace (model2 , outfile2 , force or force_second , iterations , walkers , tuning )
654
+ trace2 = sample_or_load_trace (model2 , outfile2 , force or force_second , iterations , walkers , tuning , cores )
652
655
traces2 [fltr ] = trace2
653
656
if do_diagnostics :
654
657
diagnostics (obs , trace2 , parameters2 , outfile2 )
@@ -663,7 +666,7 @@ def _main():
663
666
parser .add_argument ('--iterations' , type = int , default = ITERATIONS , help = 'Number of steps after burn-in' )
664
667
parser .add_argument ('--tuning' , type = int , default = TUNING , help = 'Number of burn-in steps' )
665
668
parser .add_argument ('--walkers' , type = int , default = WALKERS , help = 'Number of walkers' )
666
- parser .add_argument ('--cores' , type = int , default = 1 , help = 'Number of walkers to run in parallel' )
669
+ parser .add_argument ('--cores' , type = int , default = CORES , help = 'Number of walkers to run in parallel' )
667
670
parser .add_argument ('--output-dir' , type = str , default = '.' , help = 'Path in which to save the PyMC3 trace data' )
668
671
parser .add_argument ('--zmin' , type = float , help = 'Do not fit the transient if redshift <= zmin in the header' )
669
672
parser .add_argument ('-f' , '--force' , action = 'store_true' , help = 'redo the fit even if the trace is already saved' )
0 commit comments