Writing Fit Parameters to a File

Hello,
How can I save the parameters of a fit (workspace_parameters) in an ASCII file using a python command line?
Thanks Tatiana

This can be achieved using the Python open command and a for loop, e.g.

params_table = mtd['workspace_parameters']
params_file = open(r"/home/dmn58364/fit_params.txt", 'w')
for row in params_table:
    params_file.write('{0} {1} {2}\n'.format(row['Name'], row['Value'], row['Error']))

params_file.close()

In case the table doesn’t have columns labelled “Name”, “Value”, and “Error”, you can use:

for row in params_table:
    params_file.write(",".join([str(row[keys]) for keys in params_table.keys()])+'\n')

I’ve used this and packaged it into an algorithm here: http://pastebin.com/d2DrCtRH

To use it, open it in the Python window in Mantid and run “Execute All”, then you can access from the Algorithm panel (it’s called SaveTableAscii); to use the commandline put it in the algorithms path (e.g. C:\Program Files\Mantid\plugins\python\algorithms ) and restart Mantid, or from the Script Interpreter do:

from SaveTableAscii import *

with the file either in your script path or opened in the Python window.