Skip to content

Commit

Permalink
fix momentum correction (bin_ranges) when no image is loaded
Browse files Browse the repository at this point in the history
fix for missing lens voltages
  • Loading branch information
rettigl committed Jan 7, 2024
1 parent 90c7e4d commit 4fc3b52
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sed/calibrator/momentum.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
self.slice: np.ndarray = None
self.slice_corrected: np.ndarray = None
self.slice_transformed: np.ndarray = None
self.bin_ranges: List[Tuple] = []
self.bin_ranges: List[Tuple] = self._config["momentum"].get("bin_ranges", [])

if data is not None:
self.load_data(data=data, bin_ranges=bin_ranges)
Expand Down
2 changes: 1 addition & 1 deletion sed/loader/mpes/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ def gather_metadata(
].keys()

lens_volts = np.array(
[metadata["file"][f"KTOF:Lens:{lens}:V"] for lens in lens_list],
[metadata["file"].get(f"KTOF:Lens:{lens}:V", np.NaN) for lens in lens_list],
)
for mode, value in self._config["metadata"]["lens_mode_config"].items():
lens_volts_config = np.array([value[k] for k in lens_list])
Expand Down
2 changes: 1 addition & 1 deletion tests/calibrator/test_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def test_add_offsets_functionality(energy_scale: str) -> None:
loader=get_loader("flash", config=config),
)
t_df = dask.dataframe.from_pandas(df.copy(), npartitions=2)
res, meta = ec.add_offsets(t_df, **params) # type: ignore[arg-type] # pylint disable=unexpected-keyword-arg
res, meta = ec.add_offsets(t_df, **params) # type: ignore
np.testing.assert_allclose(res["energy"].values, exp_vals.values)
exp_meta = {}
exp_meta["applied"] = True
Expand Down
6 changes: 2 additions & 4 deletions tests/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from importlib.util import find_spec
from pathlib import Path
from typing import Any
from typing import cast
from typing import Dict
from typing import List
from typing import Tuple
Expand All @@ -20,7 +19,6 @@

from sed import SedProcessor
from sed.core.config import parse_config
from sed.loader.flash.loader import FlashLoader
from sed.loader.loader_interface import get_loader

# pylint: disable=duplicate-code
Expand Down Expand Up @@ -335,11 +333,11 @@ def test_pose_adjustment() -> None:
verbose=True,
)
# pose adjustment w/o loaded image
processor.pose_adjustment(**adjust_params, use_correction=False, apply=True) # type: ignore[arg-type]
processor.pose_adjustment(**adjust_params, use_correction=False, apply=True) # type: ignore

processor.bin_and_load_momentum_calibration(apply=True)
# test pose adjustment
processor.pose_adjustment(**adjust_params, use_correction=False, apply=True) # type: ignore[arg-type]
processor.pose_adjustment(**adjust_params, use_correction=False, apply=True) # type: ignore

processor = SedProcessor(
folder=df_folder,
Expand Down

0 comments on commit 4fc3b52

Please sign in to comment.