def generate_meta_data_device(self) -> dict: device_creator = DeviceMetaDataCreator() device_creator.set_general_information( uuid="c771111c-36ba-425d-9f53-84b8ff092059", fov=np.asarray([0, 0, 0, 0.0384, 0, 0.0384])) start_y_position = 0.00015 for y_idx in range(128): cur_y_position = start_y_position + 0.0003 * y_idx detection_element_creator = DetectionElementCreator() detection_element_creator.set_detector_position( np.asarray([0, cur_y_position, 0])) detection_element_creator.set_detector_orientation( np.asarray([0, 0, 1])) detection_element_creator.set_detector_geometry_type("CUBOID") detection_element_creator.set_detector_geometry( np.asarray([0.0003, 0.0003, 0.0001])) detection_element_creator.set_frequency_response( np.asarray([np.linspace(700, 900, 100), np.ones(100)])) detection_element_creator.set_angular_response( np.asarray([np.linspace(700, 900, 100), np.ones(100)])) device_creator.add_detection_element( detection_element_creator.get_dictionary()) for y_idx in range(2): illumination_element_creator = IlluminationElementCreator() illumination_element_creator.set_beam_divergence_angles(0.20944) illumination_element_creator.set_wavelength_range( np.asarray([700, 950, 1])) if y_idx == 0: illumination_element_creator.set_illuminator_position( np.asarray([0.0083, 0.0192, -0.001])) illumination_element_creator.set_illuminator_orientation( np.asarray([-0.383972, 0, 1])) elif y_idx == 1: illumination_element_creator.set_illuminator_position( np.asarray([-0.0083, 0.0192, -0.001])) illumination_element_creator.set_illuminator_orientation( np.asarray([0.383972, 0, 1])) illumination_element_creator.set_illuminator_geometry( np.asarray([0, 0.025, 0])) illumination_element_creator.set_illuminator_geometry_type( "CUBOID") illumination_element_creator.set_laser_energy_profile( np.asarray([np.linspace(700, 900, 100), np.ones(100)])) illumination_element_creator.set_laser_stability_profile( np.asarray([np.linspace(700, 900, 100), np.ones(100)])) illumination_element_creator.set_pulse_width(7e-9) device_creator.add_illumination_element( illumination_element_creator.get_dictionary()) return device_creator.finalize_device_meta_data()
class DeviceMetaDataCreatorTest(TestCase): def setUp(self): self.device_dict_creator = DeviceMetaDataCreator() print("setUp") def tearDown(self): print("tearDown") def test_set_general_information(self): test_array = create_random_testing_parameters()['test_array'] test_string = create_random_testing_parameters()['test_string'] self.device_dict_creator.set_general_information( test_string, test_array) device_dict = self.device_dict_creator.finalize_device_meta_data() assert device_dict[self.device_dict_creator.GENERAL][ MetadataDeviceTags.UUID.tag] == test_string assert (device_dict[self.device_dict_creator.GENERAL][ MetadataDeviceTags.FIELD_OF_VIEW.tag] == test_array).all() def test_add_detection_element(self): test_dict = create_random_testing_parameters()['test_dict'] test_string = create_random_testing_parameters()['test_string'] self.device_dict_creator.add_detection_element(test_string, test_dict) device_dict = self.device_dict_creator.finalize_device_meta_data() assert device_dict[ self.device_dict_creator.DETECTORS][test_string] == test_dict def test_add_illumination_element(self): test_dict = create_random_testing_parameters()['test_dict'] test_string = create_random_testing_parameters()['test_string'] self.device_dict_creator.add_illumination_element( test_string, test_dict) device_dict = self.device_dict_creator.finalize_device_meta_data() assert device_dict[ self.device_dict_creator.ILLUMINATORS][test_string] == test_dict
def setUp(self): self.device_dict_creator = DeviceMetaDataCreator() print("setUp")
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from ipasc_tool import DeviceMetaDataCreator from ipasc_tool import DetectionElementCreator from ipasc_tool import IlluminationElementCreator from ipasc_tool import CompletenessChecker device_metadata_creator = DeviceMetaDataCreator() illumination_element_creator = IlluminationElementCreator() illumination_element_creator.set_pulse_width(12.5) illumination_element_creator.set_beam_divergence_angles(0.5) illuminator = illumination_element_creator.get_dictionary() device_metadata_creator.add_illumination_element("illuminator_1", illuminator) detection_element_creator = DetectionElementCreator() detection_element_creator.set_detector_position([0.3, 0.5, 0.2]) detection_element_creator.set_detector_orientation([0.1, 0.1, 0.1]) detector = detection_element_creator.get_dictionary() device_metadata_creator.add_detection_element("detector_1", detector)