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

show installed version

Verify the version of the installed spec2nexus:

$ spec2nexus  -v
2014.03.02

command-line options

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  user@host ~$ spec2nexus.py -h
  usage: spec2nexus [-h] [-e HDF5_EXTENSION] [-f] [-v] [-s SCAN_LIST] [-t]
                    [--quiet | --verbose]
                    infile [infile ...]

  spec2nexus: Convert SPEC data file into a NeXus HDF5 file.

  positional arguments:
    infile                SPEC data file name(s)

  optional arguments:
    -h, --help            show this help message and exit
    -e HDF5_EXTENSION, --hdf5-extension HDF5_EXTENSION
                          NeXus HDF5 output file extension, default = .hdf5
    -f, --force-overwrite
                          overwrite output file if it exists
    -v, --version         show program's version number and exit
    -s SCAN_LIST, --scan SCAN_LIST
                          specify which scans to save, such as: -s all or -s 1
                          or -s 1,2,3-5 (no spaces!), default = all
    --quiet                     suppress all program output (except errors), do not
                          use with --verbose option
    --verbose                   print more program output, do not use with --quiet
                          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.