Skip to content

Commit

Permalink
add: edd.ScanToMapReader
Browse files Browse the repository at this point in the history
  • Loading branch information
keara-soloway committed Feb 21, 2024
1 parent f45707f commit b280efd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHAP/edd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""This subpackage contains `PipelineItems` unique to EDD data
processing workflows.
"""
from CHAP.edd.reader import EddMapReader
from CHAP.edd.reader import EddMapReader, ScanToMapReader
from CHAP.edd.processor import (DiffractionVolumeLengthProcessor,
LatticeParameterRefinementProcessor,
MCACeriaCalibrationProcessor,
Expand Down
49 changes: 49 additions & 0 deletions CHAP/edd/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,55 @@ def add_fly_axis(fly_axis_index):
return map_config_dict


class ScanToMapReader(Reader):
"""Reader for turning a single SPEC scan into a MapConfig."""
def read(self, spec_file, scan_number):
"""Return a dictionary representing a valid map configuration
consisting of the single SPEC scan specified.
:param spec_file: Name of the SPEC file.
:type spec_file: str
:param scan_number: Number of the SPEC scan.
:type scan_number: int
:returns: Map configuration dictionary
:rtype: dict
"""
from CHAP.utils.scanparsers import SMBMCAScanParser as ScanParser

scanparser = ScanParser(spec_file, scan_number)

if scanparser.spec_macro in ('tseries', 'loopscan') or \
(scanparser.spec_macro == 'flyscan' and \
not len(scanparser.spec_args) ==5):
independent_dimensions = [
{'label': 'Time',
'units': 'seconds',
'data_type': 'scan_column',
'name': 'Time'}]
else:
independent_dimensions = [
{'label': mne,
'units': 'unknown units',
'data_type': 'spec_motor',
'name': mne}
for mne in scanparser.spec_scan_motor_mnes]

map_config_dict = dict(
title=f'{scanparser.scan_name}_{scan_number:03d}',
station='id1a3',
experiment_type='EDD',
sample=dict(name=scanparser.scan_name),
spec_scans=[
dict(spec_file=spec_file, scan_numbers=[scan_number])],
independent_dimensions=independent_dimensions,
presample_intensity=dict(name='a3ic1', data_type='scan_column'),
postsample_intensity=dict(name='diode', data_type='scan_column'),
dwell_time_actual=dict(name='count_time', data_type='smb_par')
)

return map_config_dict


if __name__ == '__main__':
from CHAP.reader import main
main()

0 comments on commit b280efd

Please sign in to comment.