nexus_reader¶
find_matching_scans(filename, match_field='scan_command', search_scans_before=10, search_scans_after=None)
¶
Find scans with scan numbers close to the current file with matching scan command
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
nexus file to start at (must include scan number in filename) |
required |
match_field
|
str
|
nexus field to compare between scan files |
'scan_command'
|
search_scans_before
|
int
|
number of scans before current scan to look for |
10
|
search_scans_after
|
int | None
|
number of scans after current scan to look for (None==before) |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
list of scan files that exist and have matching field values |
Source code in mmg_toolbox/nexus/nexus_reader.py
find_scans(filename, *files, hdf_map=None, first_only=False, **matches)
¶
Find scans files with matching parameters
matches = {
'name1': 'scan', # matches if 'scan' in file['name1']
'name2': value, # matches if file['name2'] ~= value
'name3': (value, tol), # matches if abs(file['name3'] - value) < tol
}
match_files = find_scans(*filenames, **matches)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
nexus filename (used to create hdfmap) |
required |
files
|
str
|
list of additional nexus files |
()
|
hdf_map
|
NexusMap | None
|
if given, uses this hdfmap rather than generating one. |
None
|
first_only
|
bool
|
if true, returns on the first result |
False
|
matches
|
str | float | tuple[float, float]
|
keyword arguments for matching parameters |
{}
|
Returns:
| Type | Description |
|---|---|
list[str]
|
list of scan files that match all requirements |
Source code in mmg_toolbox/nexus/nexus_reader.py
find_similar_scans(filename, *files, metadata)
¶
Find scan files with similar metadata
metadata = [
'name', # match scans with file2['name'] == file1['name']
('name', tol) # match scans with abs(file2['name'] - file1['name']) < tol
]
match_files = find_similar_scans(*filenames, metadata=metadata)
:praam files: list of additional nexus files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
nexus scan file to compare others with |
required |
metadata
|
list[str | tuple[str, float]]
|
list of nexus metadata fields to compare |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list of scan files that match all requirements |
Source code in mmg_toolbox/nexus/nexus_reader.py
read_nexus_file(filename, flatten_scannables=True, beamline=None)
¶
Read Nexus file as DataHolder
Source code in mmg_toolbox/nexus/nexus_reader.py
read_nexus_files(*filenames, beamline=None)
¶
Read Nexus files as NexusScan