slaclab / lcls-tools

Python tools for LCLS: post processing data, PV handling, pulling archive settings, etc.
Apache License 2.0
2 stars 21 forks source link

Add z location as property #180

Closed MattKing06 closed 2 months ago

MattKing06 commented 2 months ago

Summary of Changes

Added a property in the Device class (./lcls_tools/common/devices/device.py) for z_location that returns the value of the sum_l_meters property so all devices that inherit from it get the property.

Added unit test to ensure that Device.z_location and Device.sum_l_meters are equal

To Test

Try running the below script. To try with alternative devices you will have to find a machine area that has those kinds of devices.

from lcls_tools.common.devices.reader import create_area
L1B = create_area("L1B")
# access magnet collection
magnet_names = L1B.magnet_collection.device_names
# pick an arbitrary magnet
magnet = L1B.magnets[magnet_names[0]]
assert(magnet.sum_l_meters == magnet.z_location)

Additional Notes

Currently we only return z co-ordinate, it may be needed in the future to return x/y values too in the case that two components have the same z-location (two beamlines separated at the dipole)

closes #179

nneveu commented 2 months ago

closes #179