Ticket #1190 (closed)
Respond to Cameron's emails
Reported by: | Steve Williams | Owned by: | Steve Williams |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Keywords: | ||
Cc: | Blocked By: | ||
Blocking: | Tester: | Michael Whitty |
Description
Respond to the following email and later follow ons to it From: Neylon, Cameron (STFC,RAL,ISIS) Sent: 31 March 2010 14:37 To: Draper, Nick (-,RAL,ISIS) Subject: Re: [Mantid-help] Available python libraries in Mantid
Hi Nick
Thanks for this and sorry for being slow to reply - I did successfully put in a lab notebook entry from within Mantid so I've got that end working. I was wondering whether you could point me in the direction of documentation (or just the relevant code) that would enable me to programmatically do some SANS raw data addition and 1d reduction.
Essentially my plan is:
Feed program a list of sample and background runs and transmissions in some form - working towards a GUI at some point but some sort of batch file will probably be my starting point. I could use the existing Batch processing input format for this.
Have it do the additions/reductions requested and generate SASxml objects.
Post each resulting reduced data object as an xml file into the online lab notebook.
I've looked at the SANS scripts but its not immediately clear to me how much setup needs to be done and exactly which ones I want to call if not using the GUI. I'm guessing that the SANSBatchMode.py is probably the most informative script for figuring this out?
Cheers
Cameron
Change History
comment:2 Changed 10 years ago by Steve Williams
- Status changed from new to accepted
The only email, so far, to Cameron Neylon
Sorry for missing the attachments from the first email.
Cheers, Steve
From: Williams, Steve (STFC,RAL,ISIS) Sent: 09 April 2010 09:47 To: Neylon, Cameron (STFC,RAL,ISIS) Subject: FW: [Mantid-help] Available python libraries in Mantid
Hi Cameron,
Sorry about the delay in giving you an answer there was a problem that I couldn't fix before I went away for Easter. We have a script which uses the functionality in SANSBatchMode.py to do much of what you want. I've attached the script and an example comma separated values file where the sample files (not background files yet) to be converted are listed. You will need to change the directory names at the top of the file to correspond to where the files are stored on your computer. You also need to get today's development build from download.mantidproject.org as there have been some recent updates.
The script creates Mantid workspaces and creates text files as output. It doesn't have functionality to that adds raw files together, although I've been told that Richard Heenan has a way to do that.
It may be helpful for your application if BatchReduce(), called at the end of the script, returned an array of the filenames that it created. Let us know if you want to us to change it to do that.
Regards, Steve
From: Draper, Nick (-,RAL,ISIS) Sent: 01 April 2010 09:14 To: Neylon, Cameron (STFC,RAL,ISIS) Cc: Williams, Steve (STFC,RAL,ISIS); Gigg, Martyn (Tessella,RAL,ISIS) Subject: RE: [Mantid-help] Available python libraries in Mantid
Cameron,
I'll pass you on to my Colleague Steve for that, as he know more about the SANS scripts than I do.
Regards, Nick Draper
From: Neylon, Cameron (STFC,RAL,ISIS) Sent: 31 March 2010 14:37 To: Draper, Nick (-,RAL,ISIS) Subject: Re: [Mantid-help] Available python libraries in Mantid
Hi Nick
Thanks for this and sorry for being slow to reply - I did successfully put in a lab notebook entry from within Mantid so I've got that end working. I was wondering whether you could point me in the direction of documentation (or just the relevant code) that would enable me to programmatically do some SANS raw data addition and 1d reduction.
Essentially my plan is:
Feed program a list of sample and background runs and transmissions in some form - working towards a GUI at some point but some sort of batch file will probably be my starting point. I could use the existing Batch processing input format for this.
Have it do the additions/reductions requested and generate SASxml objects.
Post each resulting reduced data object as an xml file into the online lab notebook.
I've looked at the SANS scripts but its not immediately clear to me how much setup needs to be done and exactly which ones I want to call if not using the GUI. I'm guessing that the SANSBatchMode.py is probably the most informative script for figuring this out?
Cheers
Cameron
comment:4 Changed 10 years ago by Steve Williams
- Milestone changed from Iteration 23 to Ongoing
Hi Cameron, PyQt is a good way to get applications to working quickly. Although we haven't yet used in the Mantid project or documented how to use it. Here is a (slightly trivial) example of using PyQt with Mantid. In MantidPlot press F3 to get the Python interpreter and copy in the following code
#
import sys
from PyQt4 import QtGui
reply = QtGui.QMessageBox.question(widget, 'Message',
"Load raw?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
data = LoadRawDialog()[0]
else:
data = LoadNexus()[0]
#
plotSpectrum(data, 0)
press ctrl-return to execute it. Martyn pointed me to a PyQt tutorial here http://zetcode.com/tutorials/pyqt4/ , which I like.
Much of our code is written in C++ so that we can interact with the MantidAPI's and QtiPlot's C++ code in a deeper way. You're unlikely to need this as you can ask us to expose the functionality that you need to Python. But you can find the code to the main SANS GUI from here http://trac.mantidproject.org/mantid/browser/trunk/Code/qtiplot/MantidQt/CustomInterfaces/ and particularly here SANSRunWindow.cpp. If you want more explanation of the that code please ask, it's not easy to understand at first or compile but we have more documentation and things to help.
Hope that helps, let us know how you get on,
Steve
From: Neylon, Cameron (STFC,RAL,ISIS) Sent: 13 May 2010 07:22 To: Williams, Steve (STFC,RAL,ISIS) Subject: Code for Mantid SANS GUI
Hi Guys
Could you point me to where the code for the SANS GUI is in Mantid. I'm starting to work with PyQt and build up a few things and want to make sure that I'm doing things in the same way. Will probably also re-use some of the code.
Cheers
Cameron
comment:6 Changed 10 years ago by Michael Whitty
- Status changed from verify to verifying
- Tester set to Michael Whitty
(In [4247]) For the SANS Python scripts fill some in some instrument defaults that will allow batch processing of input files re #1190