From 8a6740eee6e93ea816f4a49a3952fd6b5c9789b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Thu, 26 Oct 2023 07:57:24 +0200 Subject: [PATCH] FIX: prevent integer overflow when calculating azimuth in FURUNO scn files (#138) --- docs/history.md | 1 + xradar/io/backends/furuno.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/history.md b/docs/history.md index f741361..51c1d0e 100644 --- a/docs/history.md +++ b/docs/history.md @@ -5,6 +5,7 @@ * FIX: Add history to cfradial1 output, and fix minor error in CfRadial1_Export.ipynb notebook({pull}`132`) by [@syedhamidali](https://github.com/syedhamidali) * FIX: fix readthedocs build for python 3.12 ({pull}`140`) by [@kmuehlbauer](https://github.com/kmuehlbauer). * FIX: align coordinates in backends ({pull}`139`) by [@kmuehlbauer](https://github.com/kmuehlbauer) +* FIX: prevent integer overflow when calculating azimuth in FURUNO scn files ({issue}`137`) by [@giacant](https://github.com/giacant) , ({pull}`138`) by [@kmuehlbauer](https://github.com/kmuehlbauer) ## 0.4.0 (2023-09-27) diff --git a/xradar/io/backends/furuno.py b/xradar/io/backends/furuno.py index c26bd6a..afff3b5 100644 --- a/xradar/io/backends/furuno.py +++ b/xradar/io/backends/furuno.py @@ -362,8 +362,10 @@ def get_data(self): self._data[item] = data[:, i, :] # get angles angles = raw_data[:, :4].reshape(rays, 4) + # need to promote to uint32 to prevent integer overflow + # https://github.com/openradar/xradar/issues/137 self._data["azimuth"] = np.fmod( - angles[:, 1] + self.header["azimuth_offset"], 36000 + angles[:, 1].astype("uint32") + self.header["azimuth_offset"], 36000 ) # elevation angles are dtype "int16" # which was tested against a sweep with -1deg elevation