Skip to content

Commit

Permalink
Add option to read previous fit for MC fake data template
Browse files Browse the repository at this point in the history
  • Loading branch information
andreicuceu committed Nov 8, 2024
1 parent 4304d6d commit 65842d6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions bin/run_vega_mc_mpi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python
from vega import VegaInterface
from mpi4py import MPI
from astropy.io import fits
import argparse
import sys

from astropy.io import fits
from mpi4py import MPI

from vega import FitResults, VegaInterface
from vega.utils import find_file

if __name__ == '__main__':
pars = argparse.ArgumentParser(
Expand Down Expand Up @@ -39,7 +41,17 @@ def print_func(message):
print_func('Finished initializing Vega')

mc_params = vega.mc_config['params']
if sampling_params:
mc_start_from_fit = vega.main_config['control'].get('mc_start_from_fit', None)
# Read existing fit and use the bestfit values for the MC template
if mc_start_from_fit is not None:
print_func(f'Reading input fit {mc_start_from_fit}')
existing_fit = FitResults(find_file(mc_start_from_fit))
mc_params = existing_fit.params | mc_params

print_func(f'Set template parameters to {mc_params}.')

# Do fit on input data and use the bestfit values for the MC template
elif sampling_params:
print_func('Running initial fit')
# run compute_model once to initialize all the caches
_ = vega.compute_model(run_init=False)
Expand Down

0 comments on commit 65842d6

Please sign in to comment.