Closed ZLLentz closed 3 years ago
I'll make a describe_bitmask function, it's easy enough to do.
In [1]: from pcdscalc.pmps import get_bitmask, describe_bitmask
In [2]: bitmask = get_bitmask(1400, 3000, True, 'KFE')
In [3]: describe_bitmask(bitmask, 'KFE')
Bit 1: 0 ( 0, 250) disallowed
Bit 2: 0 ( 250, 270) disallowed
Bit 3: 0 ( 270, 350) disallowed
Bit 4: 0 ( 350, 400) disallowed
Bit 5: 0 ( 400, 450) disallowed
Bit 6: 0 ( 450, 540) disallowed
Bit 7: 0 ( 540, 850) disallowed
Bit 8: 0 ( 850, 1150.0) disallowed
Bit 9: 0 (1150.0, 1250.0) disallowed
Bit 10: 0 (1250.0, 1450.0) disallowed
Bit 11: 1 (1450.0, 1550.0) allowed
Bit 12: 1 (1550.0, 1650.0) allowed
Bit 13: 1 (1650.0, 1750.0) allowed
Bit 14: 1 (1750.0, 1820.0) allowed
Bit 15: 1 (1820.0, 2000.0) allowed
Bit 16: 1 (2000.0, 2300.0) allowed
Awesome!
Description
Add some functions for predicting PMPS behavior and producing the eV bitmasks:
get_bitmask
: given an upper/lower of a range, return the bitmask that matches that range.check_bitmask
: given a bitmask and an eV value, return True if the energy is allowed.check_actual_range
: given an upper/lower requested range, return the actual effective range based on the precision of the bitmask values. (we can't get exactly the range we want due to the bitmask architecture)Note that the eV ranges used are going to be updated in pmps lib soon and will need to be updated again.
Also establishes a new doctr deploy key (the old needed to be revoked).
Motivation and Context
This code will a useful utility for understanding the PMPS and for predicting its behavior. The
get_bitmask
function will be ported to TwinCAT in the PMPS library as a PLC-side utility, and on that end will help keep the PLC code up-to-date as the PMPS bitmask definitions change. https://jira.slac.stanford.edu/projects/LCLSPC/issues/LCLSPC-121How Has This Been Tested?
Added appropriate unit tests.
Where Has This Been Documented?
Added docstrings and an automodule page.