Getting EFixed from ExperimentInfo

I’m trying to read the EFixed value from a workspace without success. This seems to need an ExperimentInfo, but I can’t work out how to get a handle on it.

For spectrum info I can use:

ws = mtd['iris88490_graphite002_red']
spec_info = ws.spectrumInfo()
twoth = [i.twoTheta for i in spec_info]
print (twoth)

Although it is possible to use ws.getExperimentInfo() on an event workspace, this is not possible on a workspace 2D.

I would imagine I should be able to use something like:

ws = mtd['iris88490_graphite002_red']
exp_info = ws.experimentInfo()
ef =
print (ef)

How can I read EFixed relating to a 2D Workspace?

You should simply be able to run ws.getEFixed(detid) where detid is the DetectorID.

Thanks Daniel,

that will work for me in a hacky way for my script. I’m trying to get it to work with different detector groupings and I can’t guarantee that a given detector is present or know which spectrum number it is associated with. Is there a way to get a DetectorID from a spectrum number or EFixed for a spectrum?

You could also use ws.getInstrument().getNumberParameter(‘EFixed’)[0]
Efixed for indirect geometry is the d-spacing of the analyser. Why would this depend on detectorID?

Thanks Spencer, that makes sense.

The EFixed would not depend on DetectorID. I would normally go for spectrum[0], as that is present independent of how reduction is done. If I went for ws.getEFixed(det3), but the detector was not involved in the reduction, then it would fail.

Thank you for your input Spencer!

On the workspace I’ve tested on, your command doesn’t work for me. The following worked: energy = ws.getInstrument().getDetector(3).getNumberParameter('Efixed')[0]
where the DetectorID was 3.

Ian, since you know what spectrum number you want to use, then you could try this:

ws = mtd['IRIS']
detID = ws.getSpectrum(0).getDetectorIDs()
ei_val = ws.getInstrument().getDetector(detID[0]).getNumberParameter('Efixed')[0]

so the detectorIDs relevant to your spectrum are extracted and one of them is then used for the EFixed value. I get that it’s annoying that you have to reference the DetectorID when it’s the same value for all, at least in this case.

Reading around a bit more (I’m very much still learning python & Mantid), it seems that there should be a better way of what I’m trying to do.

What I really want to do is to set an instrument (IRIS or OSIRIS), then the instrument configuration (analyser & reflection), then read some of the parameter values from the IDF and parameters file.

In pseudocode:

my_inst_setup = loadInstrument(instrument = 'IRIS', analyser = 'graphite', reflection = '002' )
ef = my_inst_setup.getEfixed()

Is there a way to do this without parsing the xml of the IDF and components files?

All this is done in the indirect scripts. There are lots of routines in the scripts & which you can find in the ManidInstall scripts/inelastic directory

The analyser/reflection is in the Instrument Parameter File so you can just LoadInstrumentParameter

You should be able to run:

from IndirectCommon import getEfixed
ws= mtd['irs26173_graphite002_red']
print( getEfixed(ws) )

The file: mantid/ at master · mantidproject/mantid · GitHub (9.2 KB)
Here’s a worked example of creating a workspace using instrument parameters etc which I use for dealing with ascii files.

Thanks both, that’s great.