def test_cache(self): fname = "PG3_46577.nxs.h5" props = PropertyManagerDataService.retrieve("props") cachedirs = [tempfile.gettempdir()] * 3 abs_s, _ = absorptioncorrutils.calculate_absorption_correction( fname, "SampleOnly", props, "Si", 1.165, element_size=2, cache_dirs=cachedirs, ) self.assertIsNotNone(abs_s) abs_s, _ = absorptioncorrutils.calculate_absorption_correction( fname, "SampleOnly", props, "Si", 1.165, element_size=2, cache_dirs=cachedirs, ) self.assertIsNotNone(abs_s)
def get_states_from_pmds(self): # 1. Find all sans state names sans_property_managers = {} for name in PropertyManagerDataService.getObjectNames(): if name.startswith(self.sans_property_manager_prefix): property_manager = PropertyManagerDataService.retrieve(name) index = self._get_index_from_name(name) sans_property_managers.update({index: property_manager}) # 2. Convert property managers to states states_map = self._convert_property_manager_to_state(sans_property_managers) # 3. Create a sequence container return self._get_states_list(states_map)
def test_correction_props(self): self.assertRaises(RuntimeError, absorptioncorrutils.create_absorption_input, '', None) props = PropertyManagerDataService.retrieve("props") # Sample only absorption correction abs_sample = absorptioncorrutils.calculate_absorption_correction( "PG3_46577.nxs.h5", "SampleOnly", props, "Si", 1.165, element_size=2) self.assertIsNotNone(abs_sample[0]) DeleteWorkspaces([abs_sample[0]])
def test_correction_props(self): # must supply the filename self.assertRaises(ValueError, absorptioncorrutils.create_absorption_input, '', None) # must supply some way of determining wavelength range self.assertRaises(ValueError, absorptioncorrutils.create_absorption_input, 'PG3_46577.nxs.h5', None) props = PropertyManagerDataService.retrieve("props") # Sample only absorption correction abs_sample = absorptioncorrutils.calculate_absorption_correction( "PG3_46577.nxs.h5", "SampleOnly", props, "Si", 1.165, element_size=2) self.assertIsNotNone(abs_sample[0]) DeleteWorkspaces([abs_sample[0]])