Skip to content

Commit

Permalink
fix: numpy v2.0 incompatibility (#118)
Browse files Browse the repository at this point in the history
* fix: numpy v2.0 incompatibility

* linter
  • Loading branch information
pysoer authored Sep 12, 2024
1 parent 38900d4 commit 593e74f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
12 changes: 6 additions & 6 deletions cinrad/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ def get_section(
if start_polar and end_polar:
stlat = self.rl[0].site_latitude
stlon = self.rl[0].site_longitude
stp = np.round_(
stp = np.round(
get_coordinate(
start_polar[0], start_polar[1] * deg2rad, 0, stlon, stlat
),
2,
)
enp = np.round_(
enp = np.round(
get_coordinate(end_polar[0], end_polar[1] * deg2rad, 0, stlon, stlat), 2
)
elif start_cart and end_cart:
Expand Down Expand Up @@ -410,10 +410,10 @@ def __init__(self, fields: Volume_T, max_dist: Number_T = 0.1):
self.attr = fields[0].attrs.copy()

def _process_grid(self, x_step: Number_T, y_step: Number_T) -> Tuple[np.ndarray]:
x_lower = np.round_(self.lon_ravel.min(), 2)
x_upper = np.round_(self.lon_ravel.max(), 2)
y_lower = np.round_(self.lat_ravel.min(), 2)
y_upper = np.round_(self.lat_ravel.max(), 2)
x_lower = np.round(self.lon_ravel.min(), 2)
x_upper = np.round(self.lon_ravel.max(), 2)
y_lower = np.round(self.lat_ravel.min(), 2)
y_upper = np.round(self.lat_ravel.max(), 2)
x_grid = np.arange(x_lower, x_upper + x_step, x_step)
y_grid = np.arange(y_lower, y_upper + y_step, y_step)
return np.meshgrid(x_grid, y_grid)
Expand Down
24 changes: 15 additions & 9 deletions cinrad/io/level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ class StandardData(RadarBase):
Args:
file (str, IO): Path points to the file or a file object.
"""

# fmt: off
dtype_corr = {1:'TREF', 2:'REF', 3:'VEL', 4:'SW', 5:'SQI', 6:'CPA', 7:'ZDR', 8:'LDR',
9:'RHO', 10:'PHI', 11:'KDP', 12:'CP', 14:'HCL', 15:'CF', 16:'SNRH',
Expand Down Expand Up @@ -616,7 +617,9 @@ def _parse(self):
self.scantime = epoch_seconds_to_utc(epoch_seconds)
if self._is_phased_array:
san_beam_number = task["san_beam_number"][0]
self.pa_beam = np.frombuffer(self.f.read(san_beam_number * 640),PA_SDD_beam)
self.pa_beam = np.frombuffer(
self.f.read(san_beam_number * 640), PA_SDD_beam
)
cut_num = task["cut_number"][0]
scan_config = np.frombuffer(self.f.read(256 * cut_num), cut_config_dtype)
self.scan_config = list()
Expand Down Expand Up @@ -926,16 +929,19 @@ def __init__(self, file):
except IndexError:
self.code = self.name = "None"
self._d = data = np.frombuffer(f.read(), dtype=PA_radial)
self.stationlon = data["header"]["longitude"][0] * 360 / 65535
self.stationlat = data["header"]["latitude"][0] * 360 / 65535
self.radarheight = data["header"]["height"][0] * 1000 / 65535
self.scantime = epoch_seconds_to_utc(data["data"]["radial_time"][0])
self.reso = np.round(data["data"]["gate_length"][0] * 1000 / 65535) / 1000
self.stationlon = data["header"]["longitude"][0].astype(int) * 360 / 65535
self.stationlat = data["header"]["latitude"][0].astype(int) * 360 / 65535
self.radarheight = data["header"]["height"][0].astype(int) * 1000 / 65535
self.scantime = epoch_seconds_to_utc(data["data"]["radial_time"][0].astype(int))
self.reso = (
np.round(data["data"]["gate_length"][0].astype(int) * 1000 / 65535) / 1000
)
self.first_gate_dist = (
np.round(data["data"]["first_gate_dist"][0] * 1000 / 65535) / 1000
np.round(data["data"]["first_gate_dist"][0].astype(int) * 1000 / 65535)
/ 1000
)
el_num = data["data"]["el_num"][0]
az_num = data["data"]["az_num"][0]
el_num = data["data"]["el_num"][0].astype(int)
az_num = data["data"]["az_num"][0].astype(int)
radial_num = 2000
el = data["data"]["elevation"].astype(int) * 360 / 65535
self.el = el.reshape(az_num, el_num).max(axis=0)
Expand Down

0 comments on commit 593e74f

Please sign in to comment.