Ticket #10531 (assigned)

Opened 6 years ago

Last modified 5 years ago

Plot MD should respect correspondent MD axis

Reported by: Alex Buts Owned by: Owen Arnold
Priority: major Milestone: Backlog
Component: Framework Keywords:
Cc: Blocked By:
Blocking: Tester:

Description (last modified by Alex Buts) (diff)

Run two scripts below using data from ftp://ftp.nd.rl.ac.uk/scratch/VATES_Validation/Fe_data.zip to produce 1D MD cut.

Right click on the cut to look a the result.

The X-axis of the result presented on the right side make no sense and should look like the one plotted on the left side of the image provided (at least showing the axis numbers, caption is the separate issue)

Script 1 Generate data:

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 2 make 1D cut.

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')

Attachments

plotMD_bug.png (69.8 KB) - added by Alex Buts 6 years ago.
Error in plot MD and how it should look like

Change History

Changed 6 years ago by Alex Buts

Error in plot MD and how it should look like

comment:1 Changed 6 years ago by Alex Buts

  • Description modified (diff)

comment:2 Changed 6 years ago by Alex Buts

  • Description modified (diff)

comment:3 Changed 6 years ago by Nick Draper

  • Owner set to Owen Arnold
  • Status changed from new to assigned

Owen, please take a look at this and let me know what the problem is.

comment:4 Changed 6 years ago by Nick Draper

Moved to the backlog at the code freeze of R3.3

comment:5 Changed 6 years ago by Nick Draper

  • Milestone changed from Release 3.3 to Backlog

comment:6 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 11373

Note: See TracTickets for help on using tickets.