spec2nexus#

Converts SPEC data files and scans into NeXus HDF5 files.

How to use spec2nexus#

Convert all scans in a SPEC data file:

$ spec2nexus  path/to/file/specfile.dat

Writes path/to/file/specfile.hdf5 (Will not overwrite if the HDF5 exists, use the -f option to force overwrite).

Describe the NeXus File#

The NeXus file could be simple or complex, depending on the data available in the SPEC data file. The content of the NeXus file is described in the following sections. See the Example 1-D scan section for an example.

show installed version#

Verify the version of the installed spec2nexus:

$ spec2nexus  -v
2014.03.02

command-line options#

 1  user@host ~$ spec2nexus.py -h
 2  usage: spec2nexus [-h] [-e HDF5_EXTENSION] [-f] [-v] [-s SCAN_LIST]
 3                    [-o OUTPUT_FILENAME]
 4                    [--quiet | --verbose]
 5                    infile [infile ...]
 6
 7  spec2nexus: Convert SPEC data file into a NeXus HDF5 file.
 8
 9  positional arguments:
10    infile                SPEC data file name(s)
11
12  optional arguments:
13    -h, --help            show this help message and exit
14    -e HDF5_EXTENSION, --hdf5-extension HDF5_EXTENSION
15                          NeXus HDF5 output file extension, default = .hdf5
16    -f, --force-overwrite
17                          overwrite output file if it exists
18    -v, --version         show program's version number and exit
19    -s SCAN_LIST, --scan SCAN_LIST
20                          specify which scans to save, such as: -s all or -s 1
21                          or -s 1,2,3-5 (no spaces!), default = all
22    -o OUTPUT_FILENAME, --output OUTPUT_FILENAME
23                          explicitly set the output file (default is same as input file, but with
24                          the .spec extension changed to .hdf5)
25    --quiet                     suppress all program output (except errors), do not
26                          use with --verbose option
27    --verbose                   print more program output, do not use with --quiet
28                          option

Note

Where’s the source code to spec2nexus?

In the source code, the spec2nexus program is started from file nexus.py (in the spec2nexus.nexus.main() method, for those who look at the source code):

$ python nexus.py specfile.dat

You’re not really going to call that from the source directory, are you? It will work, if you have put that source directory on your PYTHONPATH.


source code documentation#

Converts SPEC data files and scans into NeXus HDF5 files

spec2nexus.nexus.get_user_parameters()[source]#

configure user’s command line parameters from sys.argv

spec2nexus.nexus.main()[source]#

entry point for command-line interface

spec2nexus.nexus.parse_scan_list_spec(scan_list_spec)[source]#

parses the argument of the -s option, returns a scan number list

spec2nexus.nexus.pick_scans(all_scans, opt_scan_list)[source]#

edit opt_scan_list for the scans to be converted

To be converted, a scan number must be first specified in opt_scan_list and then all_scans is checked to make sure that scan exists. The final list is returned.