Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@SimonHeybrock
Copy link
Member

Related to https://confluence.esss.lu.se/display/DAM/DREAM+-+Save+mask+to+file. #176 will later use this to save masks created by users.

Note that this depends on ScippNexus features that have not been released yet, expect tests to fail on CI for now.

import scipp as sc


def save_detector_masks(
Copy link
Member

Choose a reason for hiding this comment

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

So is saving masks on detector pixels the main application for this?
I guess you usually don't have a semi-permanent and re-usable mask on a time log because that is most often very run-dependent.
Could you have a wavelength mask that is always the same on some intrument? (e.g. masking some Bragg peaks from the guide or sample environment?)
I'm just asking if we need a different function name, or additional functions to mask other things than detector pixels.

Copy link
Member Author

@SimonHeybrock SimonHeybrock May 2, 2023

Choose a reason for hiding this comment

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

This function should work fine for saving tof (or wavelength) masks of detectors. One thing that people may want to do is saving monitor masks, which would work in the same way (but set NX_class='NXmonitor'). If we had attrs we could even do that automatically. Until then we will need to make a separate function.

Comment on lines +63 to +70
with h5py.File(filename, "w-") as f:
entry = f.require_group("entry")
entry.attrs["NX_class"] = "NXentry"
if entry_metadata:
for key, value in entry_metadata.items():
entry[key] = value
instrument = entry.require_group("instrument")
instrument.attrs["NX_class"] = "NXinstrument"
Copy link
Member

Choose a reason for hiding this comment

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

Can we use scippnexus to do some of the work for us instead of using h5py directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really, no. In such simple cases it would actually be more code.

Copy link
Member

@nvaytet nvaytet left a comment

Choose a reason for hiding this comment

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

Is it still true that the required scippnexus features are not released yet? CI appears to be passing now.

@SimonHeybrock
Copy link
Member Author

Is it still true that the required scippnexus features are not released yet? CI appears to be passing now.

It has been released last week.

@SimonHeybrock SimonHeybrock merged commit 89e20d2 into main May 16, 2023
@SimonHeybrock SimonHeybrock deleted the save-detector-masks branch May 16, 2023 11:13
@SimonHeybrock SimonHeybrock mentioned this pull request Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants