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

ConvertToMatrix workspace does not work on some MD workspaces #11365

Closed
abuts opened this issue Nov 10, 2014 · 3 comments
Closed

ConvertToMatrix workspace does not work on some MD workspaces #11365

abuts opened this issue Nov 10, 2014 · 3 comments
Labels
Framework Issues and pull requests related to components in the Framework Stale This label is automatically applied to issues that are automatically closed by the stale bot

Comments

@abuts
Copy link
Member

abuts commented Nov 10, 2014

This issue was originally TRAC 10523

This ticket is blocks : TRAC10526

The script below fails with mysterious message:

Error in execution of algorithm ConvertMDHistoToMatrixWorkspace:
All arguments to init must be positive and non-zero

If one uncomments penultimate statement and comment the one before it, then it passes.

The data used in the script are in ftp://ftp.nd.rl.ac.uk/scratch/VATES_Validation/ folder.


if 'MDws' in mtd:
    MDws = mtd['MDws'];
else:
    LoadNXSPE(Filename=r'MER23357_75meV_on2one.nxspe', OutputWorkspace='cur_ws')
    AddSampleLog(Workspace='cur_ws', LogName='Psi', LogText='0.', LogType='Number')
    SetUB(Workspace='cur_ws', a='5.947', b='10.3',c='6.722', beta='107.16', u='0,0,1')
    SetGoniometer(Workspace='cur_ws', Axis0='Psi,0,1,0,1')
    MDws=ConvertToMD(InputWorkspace='cur_ws', QDimensions='Q3D', Q3DFrames='HKL', QConversionScales='HKL', PreprocDetectorsWS='preprDetMER', SplitInto='50,50,50,60', MaxRecursionDepth='1')


cut2D=SliceMD(InputWorkspace='MDws', AlignedDim0='[H,0,0],-3,3,120', AlignedDim1='DeltaE,0,50,80', AlignedDim2='[0,K,0],0.4,0.6,1')
cut1D=BinMD(InputWorkspace=cut2D, AlignedDim0='[H,0,0],-3,3,120', AlignedDim1='DeltaE,25,27,1')
#cut1D= BinMD(InputWorkspace='cut2D', AxisAligned=False, BasisVector0='X,units,0.935604,0.35305,0', BasisVector1='Y,units,-0.35305,0.935604,0', BasisVector2='2,units,-0,0,1', Translation='-2.65562,25,0.4', OutputExtents='0,5.66492,-1.40997,1.40997,-0.2,0.2', OutputBins='113,1,1')
cut1D_mw=ConvertMDHistoToMatrixWorkspace(InputWorkspace=cut1D,  Normalization='NumEventsNormalization')


In addition to that, script below can be used to generate test md workspace (The data to test are on also on VATES validation in ftp://ftp.nd.rl.ac.uk/scratch/VATES_Validation/Fe_data.zip archive)

Then, running the script 3, generates error message

ValueError: Invalid value for property InputWorkspace (MatrixWorkspace) "cut1_1D": Workspace cut1_1D is not of the correct type
  at line 18 in 'D:/users/abuts/SVN/Mantid/VATES_Validation/Russell/cut2D_1D.py'
  caused by line 568 in 'C:/mprogs/MantidNightlyInstall/bin\mantid\simpleapi.py'
  caused by line 530 in 'C:/mprogs/MantidNightlyInstall/bin\mantid\simpleapi.py'

And attempt to run ConvertToMatrixWorkspace from GUI crashes Mantid

Script 2: Build test mD workspace

import os
#
data_path=os.path.dirname(os.path.realpath(__file__))

config.appendDataSearchDir(data_path)
config['defaultsave.directory']=data_path
# set up target ws name and remove target workspace with the same name which can occasionally exist.
# list of MD files (workspaces) to combine into target MD workspace
MD_FilesList='';

# define convetr to MD parameters
pars = dict();
pars['InputWorkspace']=''
pars['QDimensions']='Q3D'
pars['dEAnalysisMode']='Direct'
pars['Q3DFrames']='HKL'
pars['QConversionScales']='HKL'
pars['PreprocDetectorsWS']='preprDetMantid'
pars['MinValues']='-3,-3,-3,-40.0'
pars['MaxValues']='7,7,3,380.0'
pars['SplitInto']=50
pars['MaxRecursionDepth']=1
pars['MinRecursionDepth']=1
pars['OverwriteExisting']=1  # Change this to false, if the files should/can be added in memory
# test script combines all contributed files in memory
pars['OverwriteExisting']=0  # Change this to false, if the files should/can be added in memory
#
#---> Start loop over contributing files
psi=range(0,90,2)
#psi=range(0,4,2)
for n in range(len(psi)):
     source_file = 'map'+str(15052+n)+'_ei400.nxspe'; # redefine source files list as function of loop number
     target  = 'MDMAP_psi'+str(n*2)+'.nxs';
     # check if the file already been converted to MD and is there
     if not(os.path.exists(target )):
         print 'Converting ',source_file
         current_ws=LoadNXSPE(Filename=source_file)
         #### For the sample script, simulate load operation above
         #current_ws = CreateSimulationWorkspace(Instrument='MAP',BinParams=[-3,1,3],UnitX='DeltaE',OutputWorkspace=source_file)
         AddSampleLog(Workspace=current_ws,LogName='Ei',LogText='400.0',LogType='Number')

         #### Add iformation which is not stored in the nxspe file
         # Add UB matrix (lattice and the beam direction)
         SetUB(Workspace=current_ws,a='2.87',b='2.87',c='2.87',u='1,0,0',v='0,1,0')
         # Add crystal rotation (assume rotation abgle Psi=5*n where n is file number. Define list of angles if this is not correct
         AddSampleLog(Workspace=current_ws,LogName='Psi',LogText=str(psi[n])+'.',LogType='Number')  # --correct Psi value may be already in nxspe file. This operation is then unnecessary
         # set crystal rotation
         SetGoniometer(Workspace=current_ws,Axis0='Psi,0,1,0,1')

         # Convert to MD
         pars['InputWorkspace']=current_ws;
         md_ws=ConvertToMD(**pars)

         # save MD for further usage -- disabled in test script
         SaveMD(md_ws,Filename=target);
         DeleteWorkspace(md_ws);  # delete intermediate workspace to save memory
         DeleteWorkspace(current_ws);

     # add the file name of the file to combine
     if (len(MD_FilesList) == 0):
         MD_FilesList = target;
     else:
         MD_FilesList=MD_FilesList+','+target;
#---> End loop

print(MD_FilesList)

# merge md files into file-based MD workspace
md_ws = MergeMDFiles(MD_FilesList,OutputFilename='TestSQW_1.nxs',Parallel='0');
# plot results using sliceviewer
#plotSlice(md_ws)
# produce some test output
#print "Resulting MD workspace contains {0} events and {1} dimensions".format(md_ws.getNEvents(),md_ws.getNumDims())
#print "MD workspace ID is:\n",md_ws.id
print "--------------------------------------------"

Script 3: Make cut and convert:

import os
#
data_path=os.path.dirname(os.path.realpath(__file__))

config.appendDataSearchDir(data_path)
config['defaultsave.directory']=data_path


if 'md_ws' in mtd:
    md_ws=mtd['md_ws'];
else:
    md_ws=LoadMD(Filename='TestSQW_1.nxs');

cut2_MD=SliceMD(InputWorkspace='md_ws', AxisAligned=False, NormalizeBasisVectors=False,\
                         BasisVector0='[h:k:0],rlu,1,1,0,0', BasisVector1='dE,mEv,0,0,0,1', BasisVector2='[mh:k:0],rlu,-1,1,0,0', BasisVector3='l,rlu,0,0,1,0', OutputExtents='-3,3,0,280,-1.1,-0.9,-0.1,0.1', OutputBins='120,70,1,1')

cut1_1D=BinMD(cut2_MD,AxisAligned=True,AlignedDim0='[h:k:0],-3,3,120',AlignedDim1='dE,100,110,1')
cut1D_1d_mws=ConvertToMatrixWorkspace(cut1_1D)

@abuts
Copy link
Member Author

abuts commented Dec 8, 2014

@NickDraper (2014-12-08T10:25:38):
Moved to the backlog at the code freeze of R3.3

@abuts abuts added the Framework Issues and pull requests related to components in the Framework label Jun 3, 2015
@stale
Copy link

stale bot commented Feb 23, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you feel this is incorrect please comment to keep it alive, with a reason why.

To prevent closure, e.g. for long-term planning issues, add the "Never Stale" label.

@stale stale bot added the Stale This label is automatically applied to issues that are automatically closed by the stale bot label Feb 23, 2021
@stale
Copy link

stale bot commented Mar 2, 2021

This issue has been closed automatically. If this still affects you please re-open this issue with a comment so we can look into resolving it.

@stale stale bot closed this as completed Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues and pull requests related to components in the Framework Stale This label is automatically applied to issues that are automatically closed by the stale bot
Projects
None yet
Development

No branches or pull requests

2 participants