Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion extra_data/cli/make_virtual_cxi.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def main(argv=None):
' incorrect train IDs in the data, but may mean less data is'
' available.'
)
ap.add_argument(
'--detector-name', default=None,
help='Name of the detector to make a VDS for. This can be omitted if'
' only one multi-module detector is being used.'
)
args = ap.parse_args(argv)
out_file = args.output
fill_values = None
Expand Down Expand Up @@ -100,7 +105,7 @@ def main(argv=None):
inc_suspect = not args.exc_suspect_trains
run = RunDirectory(run_dir, inc_suspect_trains=inc_suspect)

_, det_class = identify_multimod_detectors(run, single=True)
_, det_class = identify_multimod_detectors(run, detector_name=args.detector_name, single=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi James,
I'm afraid this would not work in the current implementation, because this argument, 'detector_name', is not currently used by the 'identify_multimod_detectors' function at all 😓


n_modules = det_class.n_modules
kwargs = {}
Expand Down
5 changes: 4 additions & 1 deletion extra_data/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,10 @@ def identify_multimod_detectors(
res = set()
for cls in clses:
for name in cls._find_detector_names(data):
res.add((name, cls))
if (detector_name is None
or detector_name in name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you're specifying a name, it should be exact; this matches how thedetector_name is used when instatiating a component.

Suggested change
or detector_name in name
or detector_name == name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Thomas, looks good to me. James, would you like to commit this?

):
res.add((name, cls))
Comment on lines +2016 to +2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest this change to 'identify_multimod_detectors' function to solve my previous comment.


if single:
if len(res) < 1:
Expand Down
6 changes: 6 additions & 0 deletions extra_data/tests/cli/test_make_virtual_cxi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ def test_make_virtual_cxi_jungfrau(mock_jungfrau_run, tmpdir):
output = osp.join(str(tmpdir), 'test.cxi')
main([mock_jungfrau_run, '-o', output])
assert_isfile(output)

os.remove(output)

# Test passing an explicit detector name
main([mock_jungfrau_run, '-o', output, '--detector-name', 'SPB_IRDA_JF4M'])
assert_isfile(output)