Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tools/Python/mcrun/mcrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == ''):
Expand Down
24 changes: 21 additions & 3 deletions tools/Python/mcrun/optimisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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()

Expand Down
Loading