From af1191b7d288077e19e552108f0a60e3693624b1 Mon Sep 17 00:00:00 2001 From: rettigl Date: Wed, 29 Jan 2025 20:44:11 +0100 Subject: [PATCH 1/2] fix matplotlib warnings --- pyproject.toml | 2 +- src/specsanalyzer/core.py | 4 ++-- src/specsscan/core.py | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b10deec..22e74e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ dependencies = [ "imutils>=0.5.4", "ipympl>=0.9.1", "ipywidgets>=7.7.1", - "matplotlib>=3.5.1,<3.10.0", + "matplotlib>=3.5.1", "numpy>=1.21.6", "opencv-python>=4.8.1.78", "pynxtools-mpes>=0.2.1", diff --git a/src/specsanalyzer/core.py b/src/specsanalyzer/core.py index 7e80ef1..be7d74b 100755 --- a/src/specsanalyzer/core.py +++ b/src/specsanalyzer/core.py @@ -753,8 +753,8 @@ def update(v_vals, pos_x, pos_y, sigma_x, sigma_y, amplitude): fft_filt.set_data(np.abs(fft_filtered_new.T)) nonlocal cont - for i in range(len(cont.collections)): - cont.collections[i].remove() + for path in cont.get_paths(): + path.remove() cont = ax.contour(msk.T) edc.set_ydata(np.sum(filtered_new, 0)) diff --git a/src/specsscan/core.py b/src/specsscan/core.py index 039d7b4..d257c05 100755 --- a/src/specsscan/core.py +++ b/src/specsscan/core.py @@ -5,7 +5,6 @@ import os import pathlib from importlib.util import find_spec -from logging import warn from pathlib import Path from typing import Any from typing import Sequence @@ -671,7 +670,7 @@ def process_sweep_scan( """ ekin_step = kinetic_energy[1] - kinetic_energy[0] if not (np.diff(kinetic_energy) == ekin_step).all(): - warn( + logger.warning( "Conversion of sweep scans with non-equidistant energy steps " "might produce wrong results!", ) From e3871b37d8530845d79bf35505f853def6ea87d7 Mon Sep 17 00:00:00 2001 From: rettigl Date: Wed, 29 Jan 2025 21:00:00 +0100 Subject: [PATCH 2/2] fix time-zone warning --- src/specsscan/helpers.py | 4 ++-- src/specsscan/metadata.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/specsscan/helpers.py b/src/specsscan/helpers.py index f67d580..8980d7c 100644 --- a/src/specsscan/helpers.py +++ b/src/specsscan/helpers.py @@ -423,10 +423,10 @@ def handle_meta( ts_from = dt.datetime.timestamp(datetime_list[0]) # POSIX timestamp ts_to = dt.datetime.timestamp(datetime_list[-1]) # POSIX timestamp metadata["timing"] = { - "acquisition_start": dt.datetime.utcfromtimestamp(ts_from) + "acquisition_start": dt.datetime.fromtimestamp(ts_from, dt.timezone.utc) .replace(tzinfo=dt.timezone.utc) .isoformat(), - "acquisition_stop": dt.datetime.utcfromtimestamp(ts_to) + "acquisition_stop": dt.datetime.fromtimestamp(ts_to, dt.timezone.utc) .replace(tzinfo=dt.timezone.utc) .isoformat(), "acquisition_duration": int(ts_to - ts_from), diff --git a/src/specsscan/metadata.py b/src/specsscan/metadata.py index e2c1776..fb8c56a 100644 --- a/src/specsscan/metadata.py +++ b/src/specsscan/metadata.py @@ -92,7 +92,7 @@ def fetch_epics_metadata(self, ts_from: float, ts_to: float, metadata: dict) -> Returns: dict: Updated metadata dictionary. """ - start = datetime.datetime.utcfromtimestamp(ts_from) + start = datetime.datetime.fromtimestamp(ts_from, datetime.timezone.utc).isoformat() # replace metadata names by epics channels try: @@ -315,8 +315,8 @@ def get_archiver_data( Returns: tuple[np.ndarray, np.ndarray]: The extracted time stamps and corresponding data """ - iso_from = datetime.datetime.utcfromtimestamp(ts_from).isoformat() - iso_to = datetime.datetime.utcfromtimestamp(ts_to).isoformat() + iso_from = datetime.datetime.fromtimestamp(ts_from, datetime.timezone.utc).isoformat() + iso_to = datetime.datetime.fromtimestamp(ts_to, datetime.timezone.utc).isoformat() req_str = archiver_url + archiver_channel + "&from=" + iso_from + "Z&to=" + iso_to + "Z" with urlopen(req_str) as req: data = json.load(req)