Skip to content

Commit

Permalink
Refs #9584 Add example for SaveNexusProcessed
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Jun 9, 2014
1 parent 248e9fe commit 83e430f
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions Code/Mantid/docs/source/algorithms/SaveNexusProcessed-v1.rst
Expand Up @@ -45,4 +45,76 @@ data. **Warning!** This can be *very* slow, and only gives approx. 40%
compression because event data is typically denser than histogram data.
*CompressNexus* is off by default.

Usage
-----
**Example - a basic example using SaveNexusProcessed.**

.. testcode:: ExSaveNexusProcessedSimple

import os

ws = CreateSampleWorkspace()
file_name = "myworkspace.nxs"
SaveNexusProcessed(ws, file_name)

path = os.path.join(config['defaultsave.directory'], file_name)
print os.path.isfile(path)

Output:

.. testoutput:: ExSaveNexusProcessedSimple

True

.. testcleanup:: ExSaveNexusProcessedSimple

import os
def removeFiles(files):
for ws in files:
try:
path = os.path.join(config['defaultsave.directory'], ws)
os.remove(path)
except:
pass

removeFiles(file_name)


**Example - an example using SaveNexusProcessed with additonal options.**

.. testcode:: ExSaveNexusProcessedOptions

import os

ws = CreateSampleWorkspace()
file_name = "myworkspace.nxs"
SaveNexusProcessed(ws, file_name, Title="MyWorkspace", WorkspaceIndexMin=0, WorkspaceIndexMax=9)

path = os.path.join(config['defaultsave.directory'], file_name)
print os.path.isfile(path)

ws = Load(file_name)
print "Saved workspace has %d spectra" % ws.getNumberHistograms()

Output:

.. testoutput:: ExSaveNexusProcessedOptions

True
Saved workspace has 10 spectra

.. testcleanup:: ExSaveNexusProcessedOptions

import os
def removeFiles(files):
for ws in files:
try:
path = os.path.join(config['defaultsave.directory'], ws)
os.remove(path)
except:
pass

removeFiles(file_name)


.. categories::

0 comments on commit 83e430f

Please sign in to comment.