-
Notifications
You must be signed in to change notification settings - Fork 3
Ewm3645 mask workspace diffcal #658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from 27 commits
210cb06
7d0a0a6
71a2b7d
77c403d
86b67eb
20474a7
f1b8bb1
c3a2129
9abb5f9
a35ecd9
b79efe2
e0e5e50
9a7d97f
a6b9904
958f62a
d0ce8b6
19fc749
62711f2
e28fb28
ad8d71a
a00a324
6499fcb
b720b8c
a87bd8f
9a79dc5
ce8f52a
a46a16d
9e9c8ba
02fdbfe
6fc6cf3
3a23790
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1515,6 +1515,33 @@ def fetchGroceryList(self, groceryList: Iterable[GroceryListItem]) -> List[Works | |
|
|
||
| return groceries | ||
|
|
||
| def combinePixelMasks(self, outputMaskWsName: WorkspaceName, masks2Combine: List[WorkspaceName]): | ||
| startingIndex = 0 | ||
| if len(masks2Combine) <= 0: | ||
| raise ValueError("Lists of masks to combine is empty") | ||
|
|
||
| if not self.mantidSnapper.mtd.doesExist(outputMaskWsName): | ||
| self.renameWorkspace(masks2Combine[0], outputMaskWsName) | ||
|
||
| startingIndex = 1 | ||
|
|
||
| for maskWsName in masks2Combine[startingIndex:]: | ||
| if maskWsName == outputMaskWsName: | ||
| continue | ||
| if not self.mantidSnapper.mtd.doesExist(maskWsName): | ||
| raise ValueError( | ||
| f"Mask {maskWsName} of mask set {masks2Combine} does not exist, cannot combine into pixel mask." | ||
| ) | ||
| self.mantidSnapper.BinaryOperateMasks( | ||
| f"combine from pixel mask: '{maskWsName}'...", | ||
| InputWorkspace1=outputMaskWsName, | ||
| InputWorkspace2=maskWsName, | ||
| OperationType="OR", | ||
| OutputWorkspace=outputMaskWsName, | ||
| ) | ||
|
|
||
| self.mantidSnapper.executeQueue() | ||
| return outputMaskWsName | ||
|
|
||
| def fetchGroceryDict(self, groceryDict: Dict[str, GroceryListItem], **kwargs) -> Dict[str, WorkspaceName]: | ||
| """ | ||
| This is the primary method you should use for fetching groceries, in almost all cases. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -429,25 +429,22 @@ def prepCombinedMask(self, request: ReductionRequest) -> WorkspaceName: | |
| raise RuntimeError( | ||
| f"reduction pixel mask '{mask}' has unexpected workspace-type '{mask.tokens('workspaceType')}'" # noqa: E501 | ||
| ) | ||
|
|
||
| # Load all pixel masks | ||
| allMasks = self.groceryService.fetchGroceryDict( | ||
| self.groceryClerk.buildDict(), | ||
| **residentMasks, | ||
| allMasks = list( | ||
| self.groceryService.fetchGroceryDict( | ||
| self.groceryClerk.buildDict(), | ||
| **residentMasks, | ||
| ).values() | ||
| ) | ||
| # purge empty string, diffcalmask comes back as one if it doesnt exist | ||
| allMasks = [m for m in allMasks if m] | ||
| allMasks.append(self.groceryService.fetchCompatiblePixelMask(combinedMask, runNumber, useLiteMode)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As in the comment at |
||
| if len(allMasks) > 0: | ||
| combinedMask = self.groceryService.combinePixelMasks(combinedMask, allMasks) | ||
| else: | ||
| combinedMask = "" | ||
|
|
||
| self.groceryService.fetchCompatiblePixelMask(combinedMask, runNumber, useLiteMode) | ||
| for mask in allMasks.values(): | ||
| # If there is no mask corresponding to the diffraction calibration, it will be set to the empty string. | ||
| if bool(mask): | ||
| self.mantidSnapper.BinaryOperateMasks( | ||
| f"combine from pixel mask: '{mask}'...", | ||
| InputWorkspace1=combinedMask, | ||
| InputWorkspace2=mask, | ||
| OperationType="OR", | ||
| OutputWorkspace=combinedMask, | ||
| ) | ||
|
|
||
| self.mantidSnapper.executeQueue() | ||
| return combinedMask | ||
|
|
||
| @FromString | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pythonically, this would be
if not masks2Combine:, and if it were< 0something would be really messed up withlen. :)