diff --git a/tools/Python/mcrun/mcrun.py b/tools/Python/mcrun/mcrun.py index e266c6512..28e2f4936 100644 --- a/tools/Python/mcrun/mcrun.py +++ b/tools/Python/mcrun/mcrun.py @@ -95,6 +95,10 @@ def add_mcrun_options(parser): type=int, metavar='NP', help='Set number of scan points') + add('--seeds', + metavar='SEEDS', + help='Set range of seeds to scan (each must be: SEED != 0)') + add('-L', '--list', action='store_true', help='Use a fixed list of points for linear scanning') @@ -541,6 +545,9 @@ def main(): mcstas.prepare(options) (fixed_params, intervals) = get_parameters(options) + # Add --seeds as an 'interval', to allow scanning simulation seed + if options.seeds: + intervals['--seed']=options.seeds.split(',') # Indicate end of setup / start of computations LOG.info('===') @@ -561,6 +568,10 @@ def main(): if options.list and options.numpoints: raise OptionValueError('--numpoints cannot be used with --list') + # Can't both do list and --seeds scanning + if options.list and options.seeds: + raise OptionValueError('--seeds cannot be used with --list') + if options.list: if len(intervals) == 0: raise OptionValueError( @@ -569,7 +580,7 @@ def main(): points = len(pointlist[0]) if not (all(map(lambda i: len(i) == points, intervals.values()))): raise OptionValueError( - 'All variables much have an equal amount of points.') + 'All variables must have an equal amount of points.') interval_points = LinearInterval.from_list( points, intervals) diff --git a/tools/Python/mcrun/optimisation.py b/tools/Python/mcrun/optimisation.py index 1c0f2c463..7d7ef346e 100644 --- a/tools/Python/mcrun/optimisation.py +++ b/tools/Python/mcrun/optimisation.py @@ -37,7 +37,9 @@ def build_header(options, params, intervals, detectors): # Date format: Fri Aug 26 12:21:39 2011 date = datetime.strftime(datetime.now(), '%a %b %d %H %M %Y') - xvars = ', '.join(params) + # Strip header keys of -- (to make --seed -> seed + hdrparams = {key.lstrip('-') for key in params} + xvars = ', '.join(hdrparams) lst = intervals[list(params)[0]] xmin = min(lst) xmax = max(lst) @@ -56,7 +58,7 @@ def build_header(options, params, intervals, detectors): scantype = 'multiarray_1d(%d)' % N - variables = list(params) + variables = list(hdrparams) for detector in detectors: variables += [detector + '_I', detector + '_ERR']