spec2nexus.utils
#
Common methods used throughout the package.
source code documentation#
(internal library) common methods used in spec2nexus modules
|
create a name that is allowed by both HDF5 and NeXus rules |
|
convert SPEC time (example: Wed Nov 03 13:39:34 2010) into ISO8601 string |
|
Shape scan data from raw to different dimensionality |
|
Make name that is allowed by HDF5 and NeXus rules. |
|
SPEC labels may contain one space |
Split a string scan number into its parts. |
|
|
return everything after the first space on the line from the spec data file |
- spec2nexus.utils.clean_name(key)[source]#
create a name that is allowed by both HDF5 and NeXus rules
- Parameters:
key (str) – identifying string from SPEC data file
- See:
The “sanitized” name fits this regexp:
[A-Za-z_][\w_]*
An easier expression might be:
[\w_]*
but this will not pass the rule that valid NeXus group or field names cannot start with a digit.
- spec2nexus.utils.iso8601(date)[source]#
convert SPEC time (example: Wed Nov 03 13:39:34 2010) into ISO8601 string
- Parameters:
date (str) – time string from SPEC data file
Example
- SPEC:
Wed Nov 03 13:39:34 2010
- ISO8601:
2010-11-03T13:39:34
- SPOCK:
09/15/17 04:39:10
- ISO8601:
2017-09-15T04:39:10
- spec2nexus.utils.reshape_data(scan_data, scan_shape)[source]#
Shape scan data from raw to different dimensionality
Some SPEC macros collect data in a mesh or grid yet report the data as a 1-D sequence of observations. For further processing (such as plotting), the scan data needs to be reshaped according to its intended dimensionality.
modified from nexpy.readers.readspec.reshape_data
- spec2nexus.utils.sanitize_name(group, key)[source]#
Make name that is allowed by HDF5 and NeXus rules.
- Note:
deprecated use
clean_name()
instead (group
is never used)- Parameters:
group (str) – unused
key (str) – identifying string from SPEC data file
- See:
sanitized name fits this regexp:
[A-Za-z_][\w_]*
An easier expression might be:
[\w_]*
but this will not pass the rule that valid names cannot start with a digit.
- spec2nexus.utils.split_scan_number_string(key)[source]#
Split a string scan number into its parts.
- key str:
A value from the list returned by
getScanNumbers()
.- returns:
tuple of (#S number, repeat occurrence number)
EXAMPLES:
>>> split_scan_number_string("0") (0, 0) >>> split_scan_number_string("0.5") (0, 5)