Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose fitting parameters to python #38968

Open
RichardWaiteSTFC opened this issue Feb 25, 2025 · 0 comments
Open

Expose fitting parameters to python #38968

RichardWaiteSTFC opened this issue Feb 25, 2025 · 0 comments
Assignees
Labels
Diffraction Issues and pull requests related to diffraction ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS Powder Issues and pull requests related to powder diffraction
Milestone

Comments

@RichardWaiteSTFC
Copy link
Contributor

RichardWaiteSTFC commented Feb 25, 2025

Is your feature request related to a problem? Please describe.
POLDI has the wavelength dependence of the flux as a fitting parameter in the IDF - we need to access this from python

<parameter name="PoldiSpectrum:WavelengthDistribution" type="fitting">
<!--
This is the POLDI neutron wavelength distribution. The intensities
are given such that Mean(I) = 1.0.
-->
<lookuptable x-unit="Wavelength">

from mantid.simpleapi import *
ws = LoadEmptyInstrument(InstrumentName='POLDI', OutputWorkspace='ws')
source = ws.getInstrument().getComponentByName("source")
print(source.hasParameter("WavelengthDistribution"))  # True

but try to access it e.g.

source.getNumberParameter("WavelengthDistribution")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[11], line 1
----> 1 source.getNumberParameter("WavelengthDistribution")

RuntimeError: Wrong type of parameter.

I can't see a getFittingParameter or similar function - this is how it's accessed in C++

Parameter_sptr spectrumParameter =
instrumentParameterMap->getRecursive(&(*source), "WavelengthDistribution", "fitting");

It seems like this is not exposed to python

ParameterMap_sptr Instrument::getParameterMap() const {

You can also look at setMatrixWorkspace which parses the Parameters .xml file to initialise parameters of fitting functions.

Describe the solution you'd like
Expose fitting parameters (such as the flux in POLDI, but also peak profile parameters etc.) to python

@RichardWaiteSTFC RichardWaiteSTFC added Diffraction Issues and pull requests related to diffraction Powder Issues and pull requests related to powder diffraction ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS labels Feb 25, 2025
@RichardWaiteSTFC RichardWaiteSTFC added this to the Release 6.13 milestone Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Diffraction Issues and pull requests related to diffraction ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS Powder Issues and pull requests related to powder diffraction
Projects
Status: Todo
Development

No branches or pull requests

2 participants