Skip to content

Commit f210bbb

Browse files
committed
Implement polarized property
RE mantidproject#38523
1 parent 89a4c38 commit f210bbb

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSave.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
from sans.common.constant_containers import SANSInstrument_string_as_key_NoInstrument
1717
from sans.common.enums import SaveType
1818

19+
FILE_FORMAT_DOC_SUFFIX = (
20+
"Note that if file formats of the same type, e.g. .xml are chosen, then the file format is appended to the file name."
21+
)
22+
1923

2024
class SANSSave(DataProcessorAlgorithm):
2125
def category(self):
@@ -50,49 +54,43 @@ def PyInit(self):
5054
"Nexus",
5155
False,
5256
direction=Direction.Input,
53-
doc="Save as nexus format. "
54-
"Note that if file formats of the same type, e.g. .xml are chosen, then the "
55-
"file format is appended to the file name.",
57+
doc="Save as nexus format. " + FILE_FORMAT_DOC_SUFFIX,
5658
)
5759
self.declareProperty(
5860
"CanSAS",
5961
False,
6062
direction=Direction.Input,
61-
doc="Save as CanSAS xml format."
62-
"Note that if file formats of the same type, e.g. .xml are chosen, then the "
63-
"file format is appended to the file name.",
63+
doc="Save as CanSAS xml format. " + FILE_FORMAT_DOC_SUFFIX,
6464
)
6565
self.declareProperty(
6666
"NXcanSAS",
6767
False,
6868
direction=Direction.Input,
69-
doc="Save as NXcanSAS format."
70-
"Note that if file formats of the same type, e.g. .xml are chosen, then the "
71-
"file format is appended to the file name.",
69+
doc="Save as NXcanSAS format. " + FILE_FORMAT_DOC_SUFFIX,
70+
)
71+
self.declareProperty(
72+
"PolarizedNXcanSAS",
73+
False,
74+
direction=Direction.Input,
75+
doc="Save in PolarizedNXcanSAS format. " + FILE_FORMAT_DOC_SUFFIX,
7276
)
7377
self.declareProperty(
7478
"NistQxy",
7579
False,
7680
direction=Direction.Input,
77-
doc="Save as Nist Qxy format."
78-
"Note that if file formats of the same type, e.g. .xml are chosen, then the "
79-
"file format is appended to the file name.",
81+
doc="Save as Nist Qxy format. " + FILE_FORMAT_DOC_SUFFIX,
8082
)
8183
self.declareProperty(
8284
"RKH",
8385
False,
8486
direction=Direction.Input,
85-
doc="Save as RKH format."
86-
"Note that if file formats of the same type, e.g. .xml are chosen, then the "
87-
"file format is appended to the file name.",
87+
doc="Save as RKH format. " + FILE_FORMAT_DOC_SUFFIX,
8888
)
8989
self.declareProperty(
9090
"CSV",
9191
False,
9292
direction=Direction.Input,
93-
doc="Save as CSV format."
94-
"Note that if file formats of the same type, e.g. .xml are chosen, then the "
95-
"file format is appended to the file name.",
93+
doc="Save as CSV format. " + FILE_FORMAT_DOC_SUFFIX,
9694
)
9795

9896
self.setPropertyGroup("Nexus", "FileFormats")
@@ -275,6 +273,7 @@ def _get_file_formats(self):
275273
self._check_file_types(file_types, "Nexus", SaveType.NEXUS)
276274
self._check_file_types(file_types, "CanSAS", SaveType.CAN_SAS)
277275
self._check_file_types(file_types, "NXcanSAS", SaveType.NX_CAN_SAS)
276+
self._check_file_types(file_types, "PolarizedNXcanSAS", SaveType.POL_NX_CAN_SAS)
278277
self._check_file_types(file_types, "NistQxy", SaveType.NIST_QXY)
279278
self._check_file_types(file_types, "RKH", SaveType.RKH)
280279
self._check_file_types(file_types, "CSV", SaveType.CSV)
@@ -289,6 +288,9 @@ def _get_file_formats(self):
289288
# SaveNXcanSAS clashes with SaveNexusProcessed
290289
self.add_file_format_with_appended_name_requirement(file_formats, SaveType.NX_CAN_SAS, file_types, [])
291290

291+
# SavePolarizedNXcanSAS clashes with SaveNXcanSAS
292+
self.add_file_format_with_appended_name_requirement(file_formats, SaveType.POL_NX_CAN_SAS, file_types, [SaveType.NX_CAN_SAS])
293+
292294
# SaveNISTDAT clashes with SaveRKH, both can save to .dat
293295
self.add_file_format_with_appended_name_requirement(file_formats, SaveType.NIST_QXY, file_types, [SaveType.RKH])
294296

scripts/SANS/sans/algorithm_detail/save_workspace.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def get_save_strategy(file_format_bundle, file_name, save_options, additional_pr
6161
save_name = "SaveNXcanSAS"
6262
save_options.update(additional_properties)
6363
save_options.update(additional_run_numbers)
64+
elif file_format is SaveType.POL_NX_CAN_SAS:
65+
file_name = get_file_name(file_format_bundle, file_name, "_polnxcansas", ".h5")
66+
save_name = "SavePolarizedNXcanSAS"
67+
save_options.update(additional_properties)
68+
save_options.update(additional_run_numbers)
6469
elif file_format is SaveType.NIST_QXY:
6570
file_name = get_file_name(file_format_bundle, file_name, "_nistqxy", ".dat")
6671
save_name = "SaveNISTDAT"

scripts/SANS/sans/common/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ class SaveType(Enum):
200200
NIST_QXY = "NistQxy"
201201
NO_TYPE = "NoType"
202202
NX_CAN_SAS = "NXcanSAS"
203+
POL_NX_CAN_SAS = "PolarizedNXcanSAS"
203204
RKH = "RKH"
204205

205206

0 commit comments

Comments
 (0)