unicat plugin#
#H & #V - Metadata in SPEC data files as defined by APS UNICAT
Handles the UNICAT control lines which write additional metadata in the scans using #H/#V pairs of labels/values.
- class spec2nexus.plugins.unicat.UNICAT_MetadataMnemonics[source]#
Bases:
ControlLineBase
#H – UNICAT metadata names (numbered rows: #H0, #H1, …)
Individual metadata names are expected to be single-word strings but may be multi-word strings as long as the words in the string are separated by only one space. The delimiter between metadata names is two consecutive spaces. A tab (
\t
) character is also acceptable but should be avoided.IN-MEMORY REPRESENTATION
(SpecDataFileHeader) : H : labels
(SpecDataFileScan): metadata : {labels: values}
HDF5/NeXus REPRESENTATION
NXnote group named metadata below the NXentry group, such as /entry/metadata
datasets created from dictionary <scan>.metadata
- key = '#H\\d+'#
- known_keys = {'#@CHANN': <spec2nexus.plugins.spec_common.SPEC_MCA_ChannelInformation object>, '#@CTIME': <spec2nexus.plugins.spec_common.SPEC_MCA_CountTime object>, '#@MCA': <spec2nexus.plugins.spec_common.SPEC_MCA object>, '#@ROI': <spec2nexus.plugins.spec_common.SPEC_MCA_RegionOfInterest object>, '#@[cC][aA][lL][iI][bB]': <spec2nexus.plugins.spec_common.SPEC_MCA_Calibration object>, '#C': <spec2nexus.plugins.spec_common.SPEC_Comment object>, '#CCD': <spec2nexus.plugins.XPCS.XPCS_CCD object>, '#D': <spec2nexus.plugins.spec_common.SPEC_Date object>, '#E': <spec2nexus.plugins.spec_common.SPEC_Epoch object>, '#F': <spec2nexus.plugins.spec_common.SPEC_File object>, '#G\\d+': <spec2nexus.plugins.spec_common.SPEC_Geometry object>, '#H\\d+': <unicat.UNICAT_MetadataMnemonics object>, '#I': <spec2nexus.plugins.spec_common.SPEC_NormalizingFactor object>, '#J\\d+': <spec2nexus.plugins.spec_common.SPEC_CounterNames object>, '#L': <spec2nexus.plugins.spec_common.SPEC_Labels object>, '#M': <spec2nexus.plugins.spec_common.SPEC_Monitor object>, '#MD\\w*': <spec2nexus.plugins.apstools_specwriter.MD_apstools object>, '#N': <spec2nexus.plugins.spec_common.SPEC_NumColumns object>, '#O\\d+': <spec2nexus.plugins.spec_common.SPEC_PositionerNames object>, '#P\\d+': <spec2nexus.plugins.spec_common.SPEC_Positioners object>, '#Q': <spec2nexus.plugins.spec_common.SPEC_HKL object>, '#R': <spec2nexus.plugins.spec_common.SPEC_UserResults object>, '#S': <spec2nexus.plugins.spec_common.SPEC_Scan object>, '#T': <spec2nexus.plugins.spec_common.SPEC_CountTime object>, '#U': <spec2nexus.plugins.spec_common.SPEC_UserReserved object>, '#UIM\\w*': <spec2nexus.plugins.uim.UIM_generic object>, '#UXML': <uxml.UXML_metadata object>, '#VA\\d+': <spec2nexus.plugins.XPCS.XPCS_VA object>, '#VD\\d+': <spec2nexus.plugins.XPCS.XPCS_VD object>, '#VE\\d+': <spec2nexus.plugins.XPCS.XPCS_VE object>, '#V\\d+': <unicat.UNICAT_MetadataValues object>, '#X': <spec2nexus.plugins.spec_common.SPEC_TemperatureSetPoint object>, '#XPCS': <spec2nexus.plugins.XPCS.XPCS_XPCS object>, '#j\\d+': <spec2nexus.plugins.spec_common.SPEC_CounterMnemonics object>, '#o\\d+': <spec2nexus.plugins.spec_common.SPEC_PositionerMnemonics object>, '@A\\d*': <spec2nexus.plugins.spec_common.SPEC_MCA_Array object>, 'scan_data': <spec2nexus.plugins.spec_common.SPEC_DataLine object>, 'unrecognized_control_line': <spec2nexus.plugins.fallback.UnrecognizedControlLine object>}#
- lazy_attributes = ['H', 'V', 'metadata', 'UXML', 'UXML_root', 'MD', '_unrecognized', 'UIM', 'comments', 'G', 'diffractometer', 'I', 'J', 'j', 'L', 'column_first', 'column_last', 'M', 'monitor_name', 'N', 'O', 'o', 'P', 'positioner', 'Q', 'R', 'T', 'time_name', 'U', 'TEMP_SP', 'DEGC_SP', 'data', 'data_lines', 'MCA', 'VA', 'VD', 'VE', 'XPCS', 'CCD']#
- match_key(text)#
Test if this handler’s key matches text.
- Parameters:
text (str) – first word on the line, up to but not including the first whitespace
- Returns:
key or None
Applies a regular expression match using each handler’s
key
as the regular expression to match withtext
.
- plugins = [<spec2nexus.plugins.unicat.UNICAT_MetadataMnemonics object>, <spec2nexus.plugins.unicat.UNICAT_MetadataValues object>, <spec2nexus.plugins.uxml.UXML_metadata object>, <apstools_specwriter.MD_apstools object>, <fallback.UnrecognizedControlLine object>, <unicat.UNICAT_MetadataMnemonics object>, <unicat.UNICAT_MetadataValues object>, <uxml.UXML_metadata object>, <uim.UIM_generic object>, <spec_common.SPEC_File object>, <spec_common.SPEC_Epoch object>, <spec_common.SPEC_Date object>, <spec_common.SPEC_Comment object>, <spec_common.SPEC_Scan object>, <spec_common.SPEC_Geometry object>, <spec_common.SPEC_NormalizingFactor object>, <spec_common.SPEC_CounterNames object>, <spec_common.SPEC_CounterMnemonics object>, <spec_common.SPEC_Labels object>, <spec_common.SPEC_Monitor object>, <spec_common.SPEC_NumColumns object>, <spec_common.SPEC_PositionerNames object>, <spec_common.SPEC_PositionerMnemonics object>, <spec_common.SPEC_Positioners object>, <spec_common.SPEC_HKL object>, <spec_common.SPEC_UserResults object>, <spec_common.SPEC_CountTime object>, <spec_common.SPEC_UserReserved object>, <spec_common.SPEC_TemperatureSetPoint object>, <spec_common.SPEC_DataLine object>, <spec_common.SPEC_MCA object>, <spec_common.SPEC_MCA_Array object>, <spec_common.SPEC_MCA_Calibration object>, <spec_common.SPEC_MCA_ChannelInformation object>, <spec_common.SPEC_MCA_CountTime object>, <spec_common.SPEC_MCA_RegionOfInterest object>, <XPCS.XPCS_VA object>, <XPCS.XPCS_VD object>, <XPCS.XPCS_VE object>, <XPCS.XPCS_XPCS object>, <XPCS.XPCS_CCD object>, <spec2nexus.plugins.uim.UIM_generic object>, <spec2nexus.plugins.apstools_specwriter.MD_apstools object>, <spec2nexus.plugins.XPCS.XPCS_VA object>, <spec2nexus.plugins.XPCS.XPCS_VD object>, <spec2nexus.plugins.XPCS.XPCS_VE object>, <spec2nexus.plugins.XPCS.XPCS_XPCS object>, <spec2nexus.plugins.XPCS.XPCS_CCD object>, <spec2nexus.plugins.fallback.UnrecognizedControlLine object>, <spec2nexus.plugins.spec_common.SPEC_File object>, <spec2nexus.plugins.spec_common.SPEC_Epoch object>, <spec2nexus.plugins.spec_common.SPEC_Date object>, <spec2nexus.plugins.spec_common.SPEC_Comment object>, <spec2nexus.plugins.spec_common.SPEC_Scan object>, <spec2nexus.plugins.spec_common.SPEC_Geometry object>, <spec2nexus.plugins.spec_common.SPEC_NormalizingFactor object>, <spec2nexus.plugins.spec_common.SPEC_CounterNames object>, <spec2nexus.plugins.spec_common.SPEC_CounterMnemonics object>, <spec2nexus.plugins.spec_common.SPEC_Labels object>, <spec2nexus.plugins.spec_common.SPEC_Monitor object>, <spec2nexus.plugins.spec_common.SPEC_NumColumns object>, <spec2nexus.plugins.spec_common.SPEC_PositionerNames object>, <spec2nexus.plugins.spec_common.SPEC_PositionerMnemonics object>, <spec2nexus.plugins.spec_common.SPEC_Positioners object>, <spec2nexus.plugins.spec_common.SPEC_HKL object>, <spec2nexus.plugins.spec_common.SPEC_UserResults object>, <spec2nexus.plugins.spec_common.SPEC_CountTime object>, <spec2nexus.plugins.spec_common.SPEC_UserReserved object>, <spec2nexus.plugins.spec_common.SPEC_TemperatureSetPoint object>, <spec2nexus.plugins.spec_common.SPEC_DataLine object>, <spec2nexus.plugins.spec_common.SPEC_MCA object>, <spec2nexus.plugins.spec_common.SPEC_MCA_Array object>, <spec2nexus.plugins.spec_common.SPEC_MCA_Calibration object>, <spec2nexus.plugins.spec_common.SPEC_MCA_ChannelInformation object>, <spec2nexus.plugins.spec_common.SPEC_MCA_CountTime object>, <spec2nexus.plugins.spec_common.SPEC_MCA_RegionOfInterest object>]#
- postprocess(header, *args, **kws)#
optional: More processing deferred until after data file has been read.
- process(text, spec_obj, *args, **kws)[source]#
required: Handle this line from a SPEC data file.
PARAMETERS
- text str:
?raw text?
- spec_obj obj:
Instance of
SpecDataFile
,SpecDataFileHeader
, orSpecDataFileScan
- scan_attributes_defined = ['H']#
- writer(h5parent, writer, scan, nxclass=None, *args, **kws)#
optional: Describe how to store this data in a NeXus HDF5 file.
- class spec2nexus.plugins.unicat.UNICAT_MetadataValues[source]#
Bases:
ControlLineBase
#V – UNICAT metadata values (numbered rows: #V0, #V1, …)
Individual metadata values are expected to be numbers but may be multi-word strings as long as the words in the string are separated by only one space. The delimiter between metadata values is two consecutive spaces. A tab (
'\t'
) character is also acceptable but should be avoided.All numerical values will be converted into floating point numbers. Only if that conversion fails, the text of the value will be reported verbatim.
IN-MEMORY REPRESENTATION
(SpecDataFileScan): V : values
(SpecDataFileScan): metadata : {labels: values}
HDF5/NeXus REPRESENTATION
NXnote group named metadata below the NXentry group, such as /entry/metadata
datasets created from dictionary <scan>.metadata
- key = '#V\\d+'#
- known_keys = {'#@CHANN': <spec2nexus.plugins.spec_common.SPEC_MCA_ChannelInformation object>, '#@CTIME': <spec2nexus.plugins.spec_common.SPEC_MCA_CountTime object>, '#@MCA': <spec2nexus.plugins.spec_common.SPEC_MCA object>, '#@ROI': <spec2nexus.plugins.spec_common.SPEC_MCA_RegionOfInterest object>, '#@[cC][aA][lL][iI][bB]': <spec2nexus.plugins.spec_common.SPEC_MCA_Calibration object>, '#C': <spec2nexus.plugins.spec_common.SPEC_Comment object>, '#CCD': <spec2nexus.plugins.XPCS.XPCS_CCD object>, '#D': <spec2nexus.plugins.spec_common.SPEC_Date object>, '#E': <spec2nexus.plugins.spec_common.SPEC_Epoch object>, '#F': <spec2nexus.plugins.spec_common.SPEC_File object>, '#G\\d+': <spec2nexus.plugins.spec_common.SPEC_Geometry object>, '#H\\d+': <unicat.UNICAT_MetadataMnemonics object>, '#I': <spec2nexus.plugins.spec_common.SPEC_NormalizingFactor object>, '#J\\d+': <spec2nexus.plugins.spec_common.SPEC_CounterNames object>, '#L': <spec2nexus.plugins.spec_common.SPEC_Labels object>, '#M': <spec2nexus.plugins.spec_common.SPEC_Monitor object>, '#MD\\w*': <spec2nexus.plugins.apstools_specwriter.MD_apstools object>, '#N': <spec2nexus.plugins.spec_common.SPEC_NumColumns object>, '#O\\d+': <spec2nexus.plugins.spec_common.SPEC_PositionerNames object>, '#P\\d+': <spec2nexus.plugins.spec_common.SPEC_Positioners object>, '#Q': <spec2nexus.plugins.spec_common.SPEC_HKL object>, '#R': <spec2nexus.plugins.spec_common.SPEC_UserResults object>, '#S': <spec2nexus.plugins.spec_common.SPEC_Scan object>, '#T': <spec2nexus.plugins.spec_common.SPEC_CountTime object>, '#U': <spec2nexus.plugins.spec_common.SPEC_UserReserved object>, '#UIM\\w*': <spec2nexus.plugins.uim.UIM_generic object>, '#UXML': <uxml.UXML_metadata object>, '#VA\\d+': <spec2nexus.plugins.XPCS.XPCS_VA object>, '#VD\\d+': <spec2nexus.plugins.XPCS.XPCS_VD object>, '#VE\\d+': <spec2nexus.plugins.XPCS.XPCS_VE object>, '#V\\d+': <unicat.UNICAT_MetadataValues object>, '#X': <spec2nexus.plugins.spec_common.SPEC_TemperatureSetPoint object>, '#XPCS': <spec2nexus.plugins.XPCS.XPCS_XPCS object>, '#j\\d+': <spec2nexus.plugins.spec_common.SPEC_CounterMnemonics object>, '#o\\d+': <spec2nexus.plugins.spec_common.SPEC_PositionerMnemonics object>, '@A\\d*': <spec2nexus.plugins.spec_common.SPEC_MCA_Array object>, 'scan_data': <spec2nexus.plugins.spec_common.SPEC_DataLine object>, 'unrecognized_control_line': <spec2nexus.plugins.fallback.UnrecognizedControlLine object>}#
- lazy_attributes = ['H', 'V', 'metadata', 'UXML', 'UXML_root', 'MD', '_unrecognized', 'UIM', 'comments', 'G', 'diffractometer', 'I', 'J', 'j', 'L', 'column_first', 'column_last', 'M', 'monitor_name', 'N', 'O', 'o', 'P', 'positioner', 'Q', 'R', 'T', 'time_name', 'U', 'TEMP_SP', 'DEGC_SP', 'data', 'data_lines', 'MCA', 'VA', 'VD', 'VE', 'XPCS', 'CCD']#
- match_key(text)#
Test if this handler’s key matches text.
- Parameters:
text (str) – first word on the line, up to but not including the first whitespace
- Returns:
key or None
Applies a regular expression match using each handler’s
key
as the regular expression to match withtext
.
- plugins = [<spec2nexus.plugins.unicat.UNICAT_MetadataMnemonics object>, <spec2nexus.plugins.unicat.UNICAT_MetadataValues object>, <spec2nexus.plugins.uxml.UXML_metadata object>, <apstools_specwriter.MD_apstools object>, <fallback.UnrecognizedControlLine object>, <unicat.UNICAT_MetadataMnemonics object>, <unicat.UNICAT_MetadataValues object>, <uxml.UXML_metadata object>, <uim.UIM_generic object>, <spec_common.SPEC_File object>, <spec_common.SPEC_Epoch object>, <spec_common.SPEC_Date object>, <spec_common.SPEC_Comment object>, <spec_common.SPEC_Scan object>, <spec_common.SPEC_Geometry object>, <spec_common.SPEC_NormalizingFactor object>, <spec_common.SPEC_CounterNames object>, <spec_common.SPEC_CounterMnemonics object>, <spec_common.SPEC_Labels object>, <spec_common.SPEC_Monitor object>, <spec_common.SPEC_NumColumns object>, <spec_common.SPEC_PositionerNames object>, <spec_common.SPEC_PositionerMnemonics object>, <spec_common.SPEC_Positioners object>, <spec_common.SPEC_HKL object>, <spec_common.SPEC_UserResults object>, <spec_common.SPEC_CountTime object>, <spec_common.SPEC_UserReserved object>, <spec_common.SPEC_TemperatureSetPoint object>, <spec_common.SPEC_DataLine object>, <spec_common.SPEC_MCA object>, <spec_common.SPEC_MCA_Array object>, <spec_common.SPEC_MCA_Calibration object>, <spec_common.SPEC_MCA_ChannelInformation object>, <spec_common.SPEC_MCA_CountTime object>, <spec_common.SPEC_MCA_RegionOfInterest object>, <XPCS.XPCS_VA object>, <XPCS.XPCS_VD object>, <XPCS.XPCS_VE object>, <XPCS.XPCS_XPCS object>, <XPCS.XPCS_CCD object>, <spec2nexus.plugins.uim.UIM_generic object>, <spec2nexus.plugins.apstools_specwriter.MD_apstools object>, <spec2nexus.plugins.XPCS.XPCS_VA object>, <spec2nexus.plugins.XPCS.XPCS_VD object>, <spec2nexus.plugins.XPCS.XPCS_VE object>, <spec2nexus.plugins.XPCS.XPCS_XPCS object>, <spec2nexus.plugins.XPCS.XPCS_CCD object>, <spec2nexus.plugins.fallback.UnrecognizedControlLine object>, <spec2nexus.plugins.spec_common.SPEC_File object>, <spec2nexus.plugins.spec_common.SPEC_Epoch object>, <spec2nexus.plugins.spec_common.SPEC_Date object>, <spec2nexus.plugins.spec_common.SPEC_Comment object>, <spec2nexus.plugins.spec_common.SPEC_Scan object>, <spec2nexus.plugins.spec_common.SPEC_Geometry object>, <spec2nexus.plugins.spec_common.SPEC_NormalizingFactor object>, <spec2nexus.plugins.spec_common.SPEC_CounterNames object>, <spec2nexus.plugins.spec_common.SPEC_CounterMnemonics object>, <spec2nexus.plugins.spec_common.SPEC_Labels object>, <spec2nexus.plugins.spec_common.SPEC_Monitor object>, <spec2nexus.plugins.spec_common.SPEC_NumColumns object>, <spec2nexus.plugins.spec_common.SPEC_PositionerNames object>, <spec2nexus.plugins.spec_common.SPEC_PositionerMnemonics object>, <spec2nexus.plugins.spec_common.SPEC_Positioners object>, <spec2nexus.plugins.spec_common.SPEC_HKL object>, <spec2nexus.plugins.spec_common.SPEC_UserResults object>, <spec2nexus.plugins.spec_common.SPEC_CountTime object>, <spec2nexus.plugins.spec_common.SPEC_UserReserved object>, <spec2nexus.plugins.spec_common.SPEC_TemperatureSetPoint object>, <spec2nexus.plugins.spec_common.SPEC_DataLine object>, <spec2nexus.plugins.spec_common.SPEC_MCA object>, <spec2nexus.plugins.spec_common.SPEC_MCA_Array object>, <spec2nexus.plugins.spec_common.SPEC_MCA_Calibration object>, <spec2nexus.plugins.spec_common.SPEC_MCA_ChannelInformation object>, <spec2nexus.plugins.spec_common.SPEC_MCA_CountTime object>, <spec2nexus.plugins.spec_common.SPEC_MCA_RegionOfInterest object>]#
- postprocess(scan, *args, **kws)[source]#
interpret the UNICAT metadata (mostly floating point) from the scan header
- Parameters:
scan (SpecDataFileScan) – data from a single SPEC scan (instance of SpecDataFileScan)
- process(text, scan, *args, **kws)[source]#
required: Handle this line from a SPEC data file.
PARAMETERS
- text str:
?raw text?
- spec_obj obj:
Instance of
SpecDataFile
,SpecDataFileHeader
, orSpecDataFileScan
- scan_attributes_defined = ['V', 'metadata']#