Repository: slaclab/lcls-tools

Issue:
Add Z-location as property
**Is your feature request related to a problem? Please describe.**
The Z-location is confusingly called sum_l.  It would be nice to alias sum_l to z_location or something similar.

Discussion:
nneveu: closes #179 

Patch:
diff --git a/lcls_tools/common/devices/device.py b/lcls_tools/common/devices/device.py
index ecfb03a..2ed8e1d 100644
--- a/lcls_tools/common/devices/device.py
+++ b/lcls_tools/common/devices/device.py
@@ -111,6 +111,11 @@ class Device(BaseModel):
         """The position for this device in the design in meters"""
         return self.metadata.sum_l_meters
 
+    @property
+    def z_location(self) -> float:
+        """The position for this device in the design in meters (alias for sum_l_meters)"""
+        return self.metadata.sum_l_meters
+
     @property
     def beam_path(self) -> List[str]:
         """The list of beampaths that include this device"""


Test patch:
diff --git a/tests/unit_tests/lcls_tools/common/devices/test_device.py b/tests/unit_tests/lcls_tools/common/devices/test_device.py
index 820a025..9890b30 100644
--- a/tests/unit_tests/lcls_tools/common/devices/test_device.py
+++ b/tests/unit_tests/lcls_tools/common/devices/test_device.py
@@ -24,6 +24,12 @@ class TestDevice(unittest.TestCase):
         self.pv_obj = PV("SOLN:GUNB:212:BACT")
         return super().setUp()
 
+    def test_sum_l_meters_and_z_location_match(self):
+        self.assertEqual(
+            self.device.sum_l_meters,
+            self.device.z_location,
+        )
+
     def test_config_with_no_control_information_field_raises(self):
         name_of_device_with_missing_data = "DEVICE_2"
         with self.assertRaises(ValidationError):