\(\renewcommand\AA{\unicode{x212B}}\)

CopySample v1

../_images/CopySample-v1_dlg.png

CopySample dialog.

Summary

Copy some/all the sample information from one workspace to another.

See Also

CompareSampleLogs, CopyLogs, CheckForSampleLogs

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

Workspace

Mandatory

An input workspace from wich to copy sample information.

OutputWorkspace

InOut

Workspace

Mandatory

An output workspace to wich to copy sample information..

CopyName

Input

boolean

True

Copy the name of the sample

CopyMaterial

Input

boolean

True

Copy the material of the sample

CopyEnvironment

Input

boolean

True

Copy the sample environment

CopyShape

Input

boolean

True

Copy the sample shape

CopyLattice

Input

boolean

True

Copy the sample oriented lattice

CopyOrientationOnly

Input

boolean

False

Copy the U matrix only, if both origin and destination have oriented lattices

MDInputSampleNumber

Input

number

0

The number of the sample to be copied from, for an MD workspace (starting from 0)

MDOutputSampleNumber

Input

number

Optional

The number of the sample to be copied to for an MD workspace (starting from 0). No number, or negative number, means that it will copy to all samples

Description

The algorithm copies some/all the sample information from one workspace to another. For MD input workspaces, if no input sample number is specified, or not found, it will copy the first sample. For MD output workspaces, if no output sample number is specified (or negative), it will copy to all samples. The following information can be copied:

  • Name

  • Material

  • Sample environment

  • Shape

  • Oriented lattice

One can copy the orientation matrix only. To do this, select both CopyLattice and CopyOrientationOnly. If only CopyOrientationOnly is true, the algorithm will throw an error.

A common use for this algorithm is for single crystal measurements. Finding the UB matrix occurs on a PeaksWorkspace. In order to convertthe data to HKL space, one needs to copy the oriented lattice to the individual data workspaces.

Usage

#create some workspaces
peaks=CreateWorkspace(DataX='1,2',DataY='1',WorkspaceTitle='Workspace a')
SetUB(peaks,a=2,b=3,c=4,alpha=90,beta=90,gamma=90,u="1,0,0",v="0,0,1")
data=CreateWorkspace(DataX='1,2',DataY='1',WorkspaceTitle='Workspace b')
SetUB(data,a=1,b=1,c=1,alpha=90,beta=90,gamma=90,u="1,0,0",v="0,1,1")

#apply algorithm
CopySample(InputWorkspace=peaks,OutputWorkspace=data,CopyName=0,CopyMaterial=0,CopyEnvironment=0,CopyShape=0,CopyLattice=1)

#do a quick check
ol=data.sample().getOrientedLattice()
print("Data lattice parameters are: {} {} {} {} {} {}".format(
       ol.a(), ol.b(), ol.c(), ol.alpha(), ol.beta(), ol.gamma()))

Output:

Data lattice parameters are: 2.0 3.0 4.0 90.0 90.0 90.0

CopySample can be used to copy a sample shape, but apply a new automatic goniometer rotation. SetGoniometer should be called before CopySample. After running this example code, the sample shapes can be plotted (see 3D Mesh Plots for Sample Shapes):

cuboid = " \
<cuboid id='some-cuboid'> \
<height val='2.0'  /> \
<width val='2.0' />  \
<depth  val='0.2' />  \
<centre x='10.0' y='10.0' z='10.0'  />  \
</cuboid>  \
<algebra val='some-cuboid' /> \
"

ws = CreateSampleWorkspace()
SetGoniometer(ws, Axis0="0,0,1,0,1")
SetSample(ws, Geometry={'Shape': 'CSG', 'Value': cuboid})

ws1 = CreateSampleWorkspace()
SetGoniometer(ws1, Axis0="30,0,1,0,-1")
CopySample(ws,ws1,CopyEnvironment=False, CopyMaterial=False,CopyShape=True)

(Source code)

../_images/CopySample-v1-1_00.png

(png, hires.png, pdf)

../_images/CopySample-v1-1_01.png

(png, hires.png, pdf)

Categories: AlgorithmIndex | Sample | Utility\Workspaces

Source

C++ header: CopySample.h

C++ source: CopySample.cpp