Skip to content

Commit

Permalink
First-pass testing works
Browse files Browse the repository at this point in the history
  • Loading branch information
ktactac-ornl committed May 9, 2024
1 parent 23b651e commit 662050a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/shiver/models/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)
from mantid.simpleapi import (
mtd,
AddSampleLog,
CloneMDWorkspace,
DeleteWorkspace,
RenameWorkspace,
Expand Down Expand Up @@ -175,16 +176,24 @@ def generate_mde(self, config_dict: dict) -> str:

def clone(self, ws_name, ws_clone_name):
"""Clone the workspace"""

CloneMDWorkspace(InputWorkspace=ws_name, OutputWorkspace=ws_clone_name)

def scale(self, ws_name_in, ws_name_out, scale_factor):
"""Scale the workspace"""

ws_scalefactor = CreateSingleValuedWorkspace(OutputWorkspace="scalefactor", DataValue=scale_factor)
MultiplyMD(LHSWorkspace=ws_name_in, RHSWorkspace=ws_scalefactor, OutputWorkspace=ws_name_out)
DeleteWorkspace(ws_scalefactor)

# update the sample log
# if previous scale factor applied: multiply by this scale factor
# else add a new entry with this scale factor
run = mtd[ws_name_out].getExperimentInfo(0).run()
if 'MDScale' in run.keys():
AddSampleLog(Workspace=ws_name_out, LogName="MDScale", LogText=str(run['MDScale'].value * float(scale_factor)), LogType='Number', NumberType='Double')
else:
AddSampleLog(Workspace=ws_name_out, LogName="MDScale", LogText=scale_factor, LogType='Number', NumberType='Double')


def delete(self, ws_name):
"""Delete the workspace"""
DeleteWorkspace(ws_name, EnableLogging=False)
Expand Down

0 comments on commit 662050a

Please sign in to comment.