diff --git a/docs/changelog.md b/docs/changelog.md index f825702d..f19ce742 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -50,6 +50,8 @@ Fixed: Changed: +- [SpectrometerCalibration][extra.gui.jupyter.SpectrometerCalibration] no longer + saves loaded data to cache if `user_cache=False`. - `extra.recipes` package renamed to `extra.applications` - [XGM.pulse_energy()][extra.components.XGM.pulse_energy] will now insert NaNs instead of zeros as a fill value for runs with a varying number of pulses diff --git a/src/extra/gui/jupyter/spectrometer_calibration.py b/src/extra/gui/jupyter/spectrometer_calibration.py index e6dcc96f..995dd82b 100644 --- a/src/extra/gui/jupyter/spectrometer_calibration.py +++ b/src/extra/gui/jupyter/spectrometer_calibration.py @@ -240,7 +240,8 @@ def __init__( run (int): run number source (tuple[str, str]): data source image_data (np.ndarray): 2D array - use_cache (bool): try loading data from cache if True (default) + use_cache (bool): try loading data from cache if True (default). + If set to False, data will neither be loaded from nor written to cache. """ self.image_data = image_data if image_data is None: @@ -359,9 +360,11 @@ def _load_data(proposal: int, run: int, source: tuple[str, str], use_cache: bool data = kd.xarray().squeeze() mean_data = data.mean(dim="trainId") - # cache data for faster loading - cache_path.mkdir(mode=666, exist_ok=True, parents=True) - np.save(cache_path / fname, mean_data) + # cache data for faster loading unless use_cache=False + if use_cache: + cache_path.mkdir(mode=666, exist_ok=True, parents=True) + np.save(cache_path / fname, mean_data) + return mean_data # Widget Initialization Methods