Skip to content

Commit 593e74f

Browse files
authored
fix: numpy v2.0 incompatibility (#118)
* fix: numpy v2.0 incompatibility * linter
1 parent 38900d4 commit 593e74f

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

cinrad/calc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,13 @@ def get_section(
338338
if start_polar and end_polar:
339339
stlat = self.rl[0].site_latitude
340340
stlon = self.rl[0].site_longitude
341-
stp = np.round_(
341+
stp = np.round(
342342
get_coordinate(
343343
start_polar[0], start_polar[1] * deg2rad, 0, stlon, stlat
344344
),
345345
2,
346346
)
347-
enp = np.round_(
347+
enp = np.round(
348348
get_coordinate(end_polar[0], end_polar[1] * deg2rad, 0, stlon, stlat), 2
349349
)
350350
elif start_cart and end_cart:
@@ -410,10 +410,10 @@ def __init__(self, fields: Volume_T, max_dist: Number_T = 0.1):
410410
self.attr = fields[0].attrs.copy()
411411

412412
def _process_grid(self, x_step: Number_T, y_step: Number_T) -> Tuple[np.ndarray]:
413-
x_lower = np.round_(self.lon_ravel.min(), 2)
414-
x_upper = np.round_(self.lon_ravel.max(), 2)
415-
y_lower = np.round_(self.lat_ravel.min(), 2)
416-
y_upper = np.round_(self.lat_ravel.max(), 2)
413+
x_lower = np.round(self.lon_ravel.min(), 2)
414+
x_upper = np.round(self.lon_ravel.max(), 2)
415+
y_lower = np.round(self.lat_ravel.min(), 2)
416+
y_upper = np.round(self.lat_ravel.max(), 2)
417417
x_grid = np.arange(x_lower, x_upper + x_step, x_step)
418418
y_grid = np.arange(y_lower, y_upper + y_step, y_step)
419419
return np.meshgrid(x_grid, y_grid)

cinrad/io/level2.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ class StandardData(RadarBase):
554554
Args:
555555
file (str, IO): Path points to the file or a file object.
556556
"""
557+
557558
# fmt: off
558559
dtype_corr = {1:'TREF', 2:'REF', 3:'VEL', 4:'SW', 5:'SQI', 6:'CPA', 7:'ZDR', 8:'LDR',
559560
9:'RHO', 10:'PHI', 11:'KDP', 12:'CP', 14:'HCL', 15:'CF', 16:'SNRH',
@@ -616,7 +617,9 @@ def _parse(self):
616617
self.scantime = epoch_seconds_to_utc(epoch_seconds)
617618
if self._is_phased_array:
618619
san_beam_number = task["san_beam_number"][0]
619-
self.pa_beam = np.frombuffer(self.f.read(san_beam_number * 640),PA_SDD_beam)
620+
self.pa_beam = np.frombuffer(
621+
self.f.read(san_beam_number * 640), PA_SDD_beam
622+
)
620623
cut_num = task["cut_number"][0]
621624
scan_config = np.frombuffer(self.f.read(256 * cut_num), cut_config_dtype)
622625
self.scan_config = list()
@@ -926,16 +929,19 @@ def __init__(self, file):
926929
except IndexError:
927930
self.code = self.name = "None"
928931
self._d = data = np.frombuffer(f.read(), dtype=PA_radial)
929-
self.stationlon = data["header"]["longitude"][0] * 360 / 65535
930-
self.stationlat = data["header"]["latitude"][0] * 360 / 65535
931-
self.radarheight = data["header"]["height"][0] * 1000 / 65535
932-
self.scantime = epoch_seconds_to_utc(data["data"]["radial_time"][0])
933-
self.reso = np.round(data["data"]["gate_length"][0] * 1000 / 65535) / 1000
932+
self.stationlon = data["header"]["longitude"][0].astype(int) * 360 / 65535
933+
self.stationlat = data["header"]["latitude"][0].astype(int) * 360 / 65535
934+
self.radarheight = data["header"]["height"][0].astype(int) * 1000 / 65535
935+
self.scantime = epoch_seconds_to_utc(data["data"]["radial_time"][0].astype(int))
936+
self.reso = (
937+
np.round(data["data"]["gate_length"][0].astype(int) * 1000 / 65535) / 1000
938+
)
934939
self.first_gate_dist = (
935-
np.round(data["data"]["first_gate_dist"][0] * 1000 / 65535) / 1000
940+
np.round(data["data"]["first_gate_dist"][0].astype(int) * 1000 / 65535)
941+
/ 1000
936942
)
937-
el_num = data["data"]["el_num"][0]
938-
az_num = data["data"]["az_num"][0]
943+
el_num = data["data"]["el_num"][0].astype(int)
944+
az_num = data["data"]["az_num"][0].astype(int)
939945
radial_num = 2000
940946
el = data["data"]["elevation"].astype(int) * 360 / 65535
941947
self.el = el.reshape(az_num, el_num).max(axis=0)

0 commit comments

Comments
 (0)