workspaceHandles
#
This is a feature for more advanced users who may want to do additional processing on workspaces output by snapwrap
. According to a specified request, it returns a list of data objects called “handles”. A handle is a python class that contains all workspaces for a given run number and, provides a way to access the corresponding workspaces from the most recent reduction without having to deal directly with the workspace names, which can be complicated due to the use of a timestamp.
Different workspace types generated by SNAPRed are identified via their prefix, which is a single string followed by an underscore “”. Common examples are: “reduced”, “resampled_” and “diagnostic_”. e.g.:
reduced_dsp_all_064413_2025-02-18T170940
resampled_dsp_all_064413_2025-02-18T171501
diagnostic_dsp_all_064413_2025-02-18T171632
By default, workspaceHandles
will return workspaces with the reduced_dsp
, but this can be specified with a parameter prefix
.
So, for example if we wanted handles on all runs with resampled workspaces we could use the following:
import snapwrap as wrap
handles = wrap.workspacehandles(prefix="resampled_dsp"):
print(f"found {len(handles)} matching workspaces handles with prefix _resampled")
print("the corresponding run numbers are:")
for handle in handles:
print(handle.runNumber)
print(handle.timestamp)
print(handle.wsName)
Note here we print three handle attributes: runNumber
, timestamp
, wsName
, but handles include many more attributes and these can be extended readily.
Ongoing work is to associate additional metadata to particular workspaces, for example, appending a list of different crystal structures giving rise to the diffraction data in the workspace.
Optional arguments#
prefix
#
Used to define a prefix to select which workspace types to return handles for. Default value is “reduced_dsp”
pgs
#
Can be used to specify a pixel grouping scheme in the event you only want handles for one of these. Default value is None
corresponding to behaviour that all present pixel groups will be allocated handles
runNumber
#
In the event handles for workspaces corresponding to only a single run number are needed, this can be specified here. THe default is None
and, in the case, workspaces for all run numbers will be returned.