Skip to content
Snippets Groups Projects
SaveOpenGenieAscii-v1.rst 1.75 KiB
Newer Older
.. algorithm::

.. summary::

.. alias::

.. properties::

Description
-----------

This algorithm outputs the data in OpenGenie ASCII file, which
can also be generated by `put /New/Ascii... ` on OpenGenie. The
algorithm takes a focused workspaces which would generate an
OpenGenie ASCII file with data saved inside. The algorithm will
assume focused data (which contains single spectrum) has been
provided, but if a workspace with multiple spectra is passed, the
algorithm will save the first spectrum, while ignoring the rest.
Shahroz Ahmed's avatar
Shahroz Ahmed committed
The algorithms will write out the x, y and e axis for each spectra
along with all the sample logs which are available in the nexus
file which is provided. The x, y, e axis and the sample logs are
sorted by ascending alphabetical order within the file, which
matches the format of OpenGenie ASCII file. The`ntc` field is
also included, which is required in order to run the generated
file on OpenGenie, the value for `ntc` is the number of bins of
the provided workspace.

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

.. testcode:: ExSaveOpenGenie

    import os

    ws = CreateSampleWorkspace()
    ws = ExtractSingleSpectrum(ws, WorkspaceIndex=0)
    file_name = "myworkspace.ascii"
    path = os.path.join(os.path.expanduser("~"), file_name)

    SaveOpenGenieAscii(ws, path)

    path = os.path.join(os.path.expanduser("~"), "myworkspace.ascii")
    print(os.path.isfile(path))


Output:

.. testoutput:: ExSaveOpenGenie

    True

.. testcleanup:: ExSaveOpenGenie

    import os
    def removeFiles(files):
      for ws in files:
        try:
          path = os.path.join(os.path.expanduser("~"), ws)
          os.remove(path)
        except:
          pass

    removeFiles(["myworkspace.ascii"])

.. categories::

.. sourcelink::