Ticket #2215 (closed: fixed)

Opened 10 years ago

Last modified 5 years ago

Matrix Algebra error

Reported by: Nick Draper Owned by: Martyn Gigg
Priority: critical Milestone: Iteration 27
Component: Mantid Keywords:
Cc: Blocked By:
Blocking: Tester: Owen Arnold

Description

This script now fails to run on the latest stable 64 bit Mantid (also 32 bit windows). It breaks on the

Io= m2*(Ipp*Iaa - Ipa*Iap)/(Ipp + Iaa - Ipa - Iap)

Line with following error. The sizes of the two workspaces are not compatible for algorithm Multiply Logic Error in execution of algorithm Multiply The sizes of the two workspaces are not compatible for algorithm Multiply Unfortunately the multiplication works if you subsequently use the qti interface so presumably there is a bug in the link between python and Mantid Rob

LoadRaw(Filename="OFFSPEC00005730.raw",OutputWorkspace="ws",Cache="Always",LoadLogFiles="0")
for i in range(5732,5746,2):
        LoadRaw(Filename="OFFSPEC0000"+str(i)+".raw",OutputWorkspace="wtemp",Cache="Always",LoadLogFiles="0")
        Plus("ws","wtemp","ws")
for i in range(5713,5729,2):
        LoadRaw(Filename="OFFSPEC0000"+str(i)+".raw",OutputWorkspace="wtemp",Cache="Always",LoadLogFiles="0")
        Plus("ws","wtemp","ws")
        
ConvertUnits("ws","ws","Wavelength",AlignBins="1")
Rebin("ws","ws","0.5,0.2,14.5")
CloneWorkspace("ws","wsdet")
CloneWorkspace("ws","wsmon2")
CropWorkspace("wsmon2","wsmon2t",StartWorkspaceIndex="1",EndWorkspaceIndex="1")
mantid.deleteWorkspace("wsmon2")
RenameWorkspace("wsmon2t","wsmon2")
CropWorkspace("wsdet","wsdett",StartWorkspaceIndex="3",EndWorkspaceIndex="3")
mantid.deleteWorkspace("wsdet")
RenameWorkspace("wsdett","wsdet")
        
Divide("wsdet","wsmon2","rs")
Ispp=mtd["rs_1"]
Ispa=mtd["rs_2"]
Isap=mtd["rs_3"]
Isaa=mtd["rs_4"]
LoadRaw(Filename="OFFSPEC00005731.raw",OutputWorkspace="w",Cache="Always",LoadLogFiles="0")
for i in range(5733,5746,2):
        LoadRaw(Filename="OFFSPEC0000"+str(i)+".raw",OutputWorkspace="wtemp",Cache="Always",LoadLogFiles="0")
        Plus("w","wtemp","w")
for i in range(5714,5729,2):
        LoadRaw(Filename="OFFSPEC0000"+str(i)+".raw",OutputWorkspace="wtemp",Cache="Always",LoadLogFiles="0")
        Plus("w","wtemp","w")
        
ConvertUnits("w","w","Wavelength",AlignBins="1")
Rebin("w","w","0.5,0.2,14.5")
CloneWorkspace("w","wdet")
CloneWorkspace("w","wmon2")
CropWorkspace("wmon2","wmon2t",StartWorkspaceIndex="1",EndWorkspaceIndex="1")
mantid.deleteWorkspace("wmon2")
RenameWorkspace("wmon2t","wmon2")
CropWorkspace("wdet","wdett",StartWorkspaceIndex="3",EndWorkspaceIndex="3")
mantid.deleteWorkspace("wdet")
RenameWorkspace("wdett","wdet")
        
Divide("wdet","wmon2","r")
Ipp=mtd["r_1"]
Ipa=mtd["r_2"]
Iap=mtd["r_3"]
Iaa=mtd["r_4"]
rho = (Iaa - Iap)/(Ipp - Ipa)
alpha = (Iaa - Ipa)/(Ipp - Iap)
ppap = (Ipp - Ipa)*(Ipp - Iap)/(Ipp*Iaa - Ipa*Iap)
paaa = rho*alpha*ppap
CreateSingleValuedWorkspace("m2","2.0","0.0")
m2=mtd["m2"]
Io= m2*(Ipp*Iaa - Ipa*Iap)/(Ipp + Iaa - Ipa - Iap)
Pp=(Ispp+Isaa - Ispa-Isap)*(alpha*(Ispp - Isap) - Isaa+Ispa)/((rho*alpha*Ispp+Isaa + rho*Ispa + alpha*Isap)*(rho*  (Ispp - Ispa) - Isaa+Isap))
Ap=(Ispp+Isaa - Ispa-Isap)*(rho*(Ispp - Ispa) - Isaa+Isap)/((rho*alpha*Ispp+Isaa + rho*Ispa + alpha*Isap)*(alpha*  (Ispp - Isap) - Isaa+Ispa)) 
Rs=(alpha*(Ispp - Isap) - Isaa+Ispa)*(rho*(Ispp - Ispa) - Isaa+Isap)/((rho*alpha*Ispp+Isaa + rho*Ispa + alpha*Isap) *(Ispp+Isaa - Ispa - Isap) )
ReplaceSpecialValues(rho,"rho","0.0","0.0","0.0","0.0")
ReplaceSpecialValues(alpha,"alpha","0.0","0.0","0.0","0.0")
ReplaceSpecialValues(Io,"Io","0.0","0.0","0.0","0.0")
ReplaceSpecialValues(Pp,"Pp","0.0","0.0","0.0","0.0")
ReplaceSpecialValues(Ap,"Ap","0.0","0.0","0.0","0.0")
ReplaceSpecialValues(Rs,"Rs","0.0","0.0","0.0","0.0")
Sqrt("Pp")
Sqrt("Ap")
Sqrt("Rs")
ReplaceSpecialValues(Pp,"Pp","0.0","0.0","0.0","0.0")
ReplaceSpecialValues(Ap,"Ap","0.0","0.0","0.0","0.0")
ReplaceSpecialValues(Rs,"Rs","0.0","0.0","0.0","0.0")
p1=plotSpectrum(["rho","alpha","Pp","Ap"],0,0)
l=p1.activeLayer()
l.setAxisScale(Layer.Left,0.5,1.2)
p1=plotSpectrum(["Pp","Ap"],0,1)
l=p1.activeLayer()
l.setAxisScale(Layer.Left,0.5,1.2)
p1=plotSpectrum(["rho","alpha"],0,1)
l=p1.activeLayer()
l.setAxisScale(Layer.Left,0.5,1.2)

Change History

comment:1 Changed 10 years ago by Martyn Gigg

  • Status changed from new to accepted

comment:2 Changed 10 years ago by Martyn Gigg

The commit message below didn't make it for some reason:

(In [8672]) Ensure that single valued workspaces can be used in binary operations regardless of whether they are lhs or rhs. There was a small bug with multiply that meant they would fail on the lhs. Also ensured that the Python binary overloads provide better information if they fail. Re #2215

comment:3 Changed 10 years ago by Martyn Gigg

  • Status changed from accepted to verify
  • Resolution set to fixed

comment:4 Changed 10 years ago by Owen Arnold

  • Status changed from verify to verifying
  • Tester set to Owen Arnold

comment:5 Changed 10 years ago by Owen Arnold

  • Status changed from verifying to closed

Verify that binary operations work on singlevalued workspaces (lhs and rhs).

comment:6 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 3062

Note: See TracTickets for help on using tickets.