pcdshub / solid-attenuator

LCLS Solid Attenuator System IOC
https://pcdshub.github.io/solid-attenuator
Other
1 stars 4 forks source link

ENH: add get_best_config_with_material_priority and tests #56

Closed klauer closed 3 years ago

klauer commented 3 years ago

Context

See linked issues for context: Closes #58 Closes #47

Steps

Tests

Tests are passing locally, but failing on Travis. This will be resolved at a later date.

Future

(Separate PR/issue) I think in its current form, find_configs won't work for the SXR ladder-style variant and will require further thought.

klauer commented 3 years ago

Have a preliminary working material prioritization function that matches up with those expected from Matt's beamline config prototype.

~I don't much like its API, so that may get refactored prior to merging, along with some different tests.~

klauer commented 3 years ago

Some interesting things during testing. The following plots are based on the filter material priority algorithm:

Plots The `x` marker indicates the normalized transmission value when all _diamond_ filters are inserted at the annotated energy. 1. Assuming all filters are working: ![image](https://user-images.githubusercontent.com/5139267/102552202-a34cc200-4075-11eb-90b7-ec5b0eeb3c69.png) As transmission is a function of material, thickness, and the photon energy, we see the algorithm failing to match what the user requests at lower energies and above `t_all_diamond`. This is where the silicon filters may not be inserted to compensate. 2. Assuming just the 1280µm diamond filter is stuck out: ![image](https://user-images.githubusercontent.com/5139267/102552651-69c88680-4076-11eb-88cb-99e1cdc24086.png) 3. Assuming the two 10µm and 20µm diamond filters are stuck out: ![image](https://user-images.githubusercontent.com/5139267/102552692-777e0c00-4076-11eb-908a-c90041a768ce.png) The above show the piecewise behavior you'd expect from discrete filters, and show the calculations doing roughly doing what we ask. While it was a useful exercise for me, I'm not sure there's much to gain from it. Regardless, the above is now in the test suite, along with checks to ensure the algorithm doesn't insert silicon filters when it shouldn't.

Separately, I've reintroduced floor/ceiling and explicit checks to be extra-certain that all diamond filters are marked for insertion prior to silicon filters. I think the tests are reasonably exhaustive and straightforward now, so 🤞 this should be good to go.

klauer commented 3 years ago

Merging before the break, before I forget that this was in (what I think) an OK state.