bluesky / hklpy

Diffractometer computation library with ophyd pseudopositioner support
https://blueskyproject.io/hklpy
BSD 3-Clause "New" or "Revised" License
4 stars 12 forks source link

KeyError: 'energy' during restore_energy(orientation, diffractometer) #216

Closed prjemian closed 2 years ago

prjemian commented 2 years ago

@gfabbris reported was raised KeyError: 'energy' by this sequence:

orientation = run_orientation_info(cat[63])["fourc"]
restore_energy(orientation, diffractometer)

On inspection of the orientation object, the energy key is missing:

In [23]: orientation
Out[23]: 
{'energy_units': 'keV',
 'energy_offset': 0,
 'geometry_name': 'E4CV',
 'class_name': 'FourCircleDiffractometer',
 'sample_name': 'Na2IrO3',

The diffractometer was configured with fourc.energy.kind = "omitted".

prjemian commented 2 years ago

Should hklpy ignore the .kind? Or should the user suffer the consequences of this unplanned setting?

prjemian commented 2 years ago

Might be trickier than it seems to ignore the .kind setting. At this time, we put the orientation information in the primary stream, in the configuration. https://github.com/bluesky/hklpy/blob/c99a17d9b9087752141fb5f2055e59d4c2040f0c/hkl/util.py#L300-L303

prjemian commented 2 years ago

Maybe this means we should reconsider how to store the orientation so that the details are secure against this type of reconfiguration.

prjemian commented 2 years ago

Should be considered with #189.

prjemian commented 2 years ago

hkl.util.list_orientation_runs(cat) can take a long time for large catalogs. Add a progress bar?

prjemian commented 2 years ago

For now, raise an error when a key is missing.