diff --git a/tools/Python/mcrun/mcrun.py b/tools/Python/mcrun/mcrun.py index 2e74c84ce3..25efd7b043 100644 --- a/tools/Python/mcrun/mcrun.py +++ b/tools/Python/mcrun/mcrun.py @@ -600,6 +600,9 @@ def main(): # Parameters for linear scanning present if interval_points and (options.scan_split is None): + # In case of list, update with number of list points + if options.list: + options.numpoints=len(pointlist[0]) scanner = Scanner(mcstas, intervals) scanner.set_points(interval_points) if (not options.dir == ''): diff --git a/tools/Python/mcrun/optimisation.py b/tools/Python/mcrun/optimisation.py index 7d7ef346e4..490cc8bd47 100644 --- a/tools/Python/mcrun/optimisation.py +++ b/tools/Python/mcrun/optimisation.py @@ -29,6 +29,7 @@ def build_header(options, params, intervals, detectors): # ylabel: 'Intensity' # xvars: %(xvars)s # yvars: %(yvars)s +# list: %(xvals)s # xlimits: %(xmin)s %(xmax)s # filename: %(filename)s # variables: %(variables)s @@ -41,8 +42,12 @@ def build_header(options, params, intervals, detectors): hdrparams = {key.lstrip('-') for key in params} xvars = ', '.join(hdrparams) lst = intervals[list(params)[0]] - xmin = min(lst) - xmax = max(lst) + if options.list: + xmin=1 + xmax=len(lst) + else: + xmin = min(lst) + xmax = max(lst) # Get Numpoints from length of -L list N = len(lst) # ... or using options.numponts if in fact a normal scan @@ -77,6 +82,8 @@ def build_header(options, params, intervals, detectors): 'xvars': xvars, 'yvars': ' '.join('(%s_I,%s_ERR)' % (d, d) for d in detectors), + 'xvals': str(lst), + 'xmin': xmin, 'xmax': xmax, @@ -308,7 +315,18 @@ def run(self): LOG.info("Wrote headers") LOG.info(f"Write step detectors line into {self.outfile}") values = ['%s %s' % (d.intensity, d.error) for d in detectors] - line = '%s %s\n' % (' '.join(map(str, par_values)), ' '.join(values)) + + # Normal equidistant scan + if not self.mcstas.options.list: + line = '%s %s\n' % (' '.join(map(str, par_values)), ' '.join(values)) + else: + try: + # Check if parameters are numeric/float + par_floats = [float(x) for x in par_values] + line = '%s %s\n' % (' '.join(map(str, par_floats)), ' '.join(values)) + except: + # otherwise use simple 'index' (may be scanning e.g. a filename) + line = '%s %s\n' % (str(i), ' '.join(values)) outfile.write(line) outfile.flush()