Skip to content

Commit

Permalink
Merge pull request #132 from mantidproject/analysis-reduction-to-mant…
Browse files Browse the repository at this point in the history
…id-algo

Analysis reduction routine to Mantid Algorithm
  • Loading branch information
GuiMacielPereira authored Nov 7, 2024
2 parents 2ed3eb4 + 72f5d84 commit f7b610e
Show file tree
Hide file tree
Showing 17 changed files with 689 additions and 424 deletions.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ dependencies:
- pytest
- jacobi==0.4.2 #pinned until newer versions functionality confirmed
- coverage
- dill # Used to convert constraints to strings
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies = [
"iminuit",
"h5py",
"jacobi==0.4.2",
"dill",
]

[project.optional-dependencies]
Expand Down
27 changes: 19 additions & 8 deletions src/mvesuvio/analysis_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@


def fitInYSpaceProcedure(yFitIC, IC, wsTOF):

try:
wsTOF = mtd[wsTOF]
except KeyError:
print(f"Workspace to fit {wsTOF} not found.")
return

ncpForEachMass = extractNCPFromWorkspaces(wsTOF, IC)
wsResSum, wsRes = calculateMantidResolutionFirstMass(IC, yFitIC, wsTOF)

Expand Down Expand Up @@ -42,14 +49,18 @@ def fitInYSpaceProcedure(yFitIC, IC, wsTOF):
def extractNCPFromWorkspaces(wsFinal, ic):
"""Extra function to extract ncps from loaded ws in mantid."""

ncpForEachMass = mtd[wsFinal.name() + "_TOF_Fitted_Profile_0"].extractY()[
np.newaxis, :, :
]
for i in range(1, ic.noOfMasses):
ncpToAppend = mtd[wsFinal.name() + "_TOF_Fitted_Profile_" + str(i)].extractY()[
np.newaxis, :, :
]
ncpForEachMass = np.append(ncpForEachMass, ncpToAppend, axis=0)
for ws_name in mtd.getObjectNames():
if ws_name.startswith(ic.name+'_'+str(ic.noOfMSIterations)) and ws_name.endswith('ncp'):

if 'total' in ws_name:
continue

ws = mtd[ws_name]
dataY = ws.extractY()[np.newaxis, :, :]
try:
ncpForEachMass = np.append(ncpForEachMass, dataY, axis=0)
except UnboundLocalError:
ncpForEachMass = dataY

# Ensure shape of ncp matches data
shape = ncpForEachMass.shape
Expand Down
Loading

0 comments on commit f7b610e

Please sign in to comment.