doppy 0.3.5__cp310-abi3-macosx_10_12_x86_64.whl → 0.3.6__cp310-abi3-macosx_10_12_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of doppy might be problematic. Click here for more details.

doppy/data/cache.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import gzip
2
+ import logging
2
3
  import shutil
3
4
  from io import BytesIO
4
5
  from pathlib import Path
@@ -25,7 +26,12 @@ def cached_record(
25
26
  path.parent.mkdir(parents=True, exist_ok=True)
26
27
  content = session.get(record["downloadUrl"]).content
27
28
  if record["filename"].endswith(".gz"):
28
- content = gzip.decompress(content)
29
+ try:
30
+ content = gzip.decompress(content)
31
+ except EOFError:
32
+ logging.error(f"Failed to recompress {record['filename']}")
33
+ raise
34
+
29
35
  with path.open("wb") as f:
30
36
  f.write(content)
31
37
  return BytesIO(content)
doppy/product/wind.py CHANGED
@@ -129,7 +129,7 @@ class Wind:
129
129
  | Sequence[BufferedIOBase],
130
130
  options: Options | None = None,
131
131
  ) -> Wind:
132
- raws = doppy.raw.WindCube.from_vad_srcs(data)
132
+ raws = doppy.raw.WindCube.from_vad_or_dbs_srcs(data)
133
133
 
134
134
  if len(raws) == 0:
135
135
  raise doppy.exceptions.NoDataError("WindCube data missing")
@@ -140,6 +140,13 @@ class Wind:
140
140
  .non_strictly_increasing_timesteps_removed()
141
141
  .reindex_scan_indices()
142
142
  )
143
+ # select scans with most frequent elevation angle from range (15,85)
144
+ raw = raw[(raw.elevation > 15) & (raw.elevation < 85)]
145
+ elevation_ints = raw.elevation.round().astype(int)
146
+ unique_elevations, counts = np.unique(elevation_ints, return_counts=True)
147
+ most_frequent_elevation = unique_elevations[np.argmax(counts)]
148
+ raw = raw[elevation_ints == most_frequent_elevation]
149
+
143
150
  if len(raw.time) == 0:
144
151
  raise doppy.exceptions.NoDataError("No suitable data for the wind product")
145
152
 
@@ -168,7 +175,9 @@ class Wind:
168
175
  mask = _compute_mask(wind, rmse) | np.any(np.isnan(wind), axis=2)
169
176
  if not np.allclose(elevation, elevation[0]):
170
177
  raise ValueError("Elevation is expected to stay same")
171
- height = np.array(raw.height, dtype=np.float64)
178
+ if not (raw.height == raw.height[0]).all():
179
+ raise ValueError("Unexpected heights")
180
+ height = np.array(raw.height[0], dtype=np.float64)
172
181
  return Wind(
173
182
  time=time,
174
183
  height=height,
doppy/raw/windcube.py CHANGED
@@ -16,8 +16,8 @@ from doppy.utils import merge_all_equal
16
16
  @dataclass
17
17
  class WindCube:
18
18
  time: npt.NDArray[datetime64] # dim: (time, )
19
- radial_distance: npt.NDArray[np.int64] # dim: (radial_distance, )
20
- height: npt.NDArray[np.int64] # dim: (radial_distance, )
19
+ radial_distance: npt.NDArray[np.int64] # dim: (time, radial_distance)
20
+ height: npt.NDArray[np.int64] # dim: (time,radial_distance)
21
21
  azimuth: npt.NDArray[np.float64] # dim: (time, )
22
22
  elevation: npt.NDArray[np.float64] # dim: (time, )
23
23
  cnr: npt.NDArray[np.float64] # dim: (time, radial_distance)
@@ -27,28 +27,28 @@ class WindCube:
27
27
  system_id: str
28
28
 
29
29
  @classmethod
30
- def from_vad_srcs(
30
+ def from_vad_or_dbs_srcs(
31
31
  cls,
32
32
  data: Sequence[str]
33
33
  | Sequence[Path]
34
34
  | Sequence[bytes]
35
35
  | Sequence[BufferedIOBase],
36
36
  ) -> list[WindCube]:
37
- return [WindCube.from_vad_src(src) for src in data]
37
+ return [WindCube.from_vad_or_dbs_src(src) for src in data]
38
38
 
39
39
  @classmethod
40
- def from_vad_src(cls, data: str | Path | bytes | BufferedIOBase) -> WindCube:
40
+ def from_vad_or_dbs_src(cls, data: str | Path | bytes | BufferedIOBase) -> WindCube:
41
41
  data_bytes = _src_to_bytes(data)
42
42
  nc = Dataset("inmemory.nc", "r", memory=data_bytes)
43
- return _from_vad_src(nc)
43
+ return _from_vad_or_dbs_src(nc)
44
44
 
45
45
  @classmethod
46
46
  def merge(cls, raws: list[WindCube]) -> WindCube:
47
47
  return WindCube(
48
48
  scan_index=_merge_scan_index([r.scan_index for r in raws]),
49
49
  time=np.concatenate([r.time for r in raws]),
50
- height=_merge_range_vars([r.height for r in raws]),
51
- radial_distance=_merge_range_vars([r.radial_distance for r in raws]),
50
+ height=np.concatenate([r.height for r in raws]),
51
+ radial_distance=np.concatenate([r.radial_distance for r in raws]),
52
52
  azimuth=np.concatenate([r.azimuth for r in raws]),
53
53
  elevation=np.concatenate([r.elevation for r in raws]),
54
54
  radial_velocity=np.concatenate([r.radial_velocity for r in raws]),
@@ -71,8 +71,8 @@ class WindCube:
71
71
  if isinstance(index, (int, slice, list, np.ndarray)):
72
72
  return WindCube(
73
73
  time=self.time[index],
74
- radial_distance=self.radial_distance,
75
- height=self.height,
74
+ radial_distance=self.radial_distance[index],
75
+ height=self.height[index],
76
76
  azimuth=self.azimuth[index],
77
77
  elevation=self.elevation[index],
78
78
  radial_velocity=self.radial_velocity[index],
@@ -113,13 +113,6 @@ class WindCube:
113
113
  return self
114
114
 
115
115
 
116
- def _merge_range_vars(vars: list[npt.NDArray[np.int64]]) -> npt.NDArray[np.int64]:
117
- var = np.concatenate([v[np.newaxis, :] for v in vars])
118
- if not (var[0] == var).all():
119
- raise ValueError("Cannot merge unequal range variable")
120
- return np.array(var[0], dtype=np.int64)
121
-
122
-
123
116
  def _merge_scan_index(index_list: list[npt.NDArray[np.int64]]) -> npt.NDArray[np.int64]:
124
117
  if len(index_list) == 0:
125
118
  raise ValueError("cannot merge empty list")
@@ -150,7 +143,7 @@ def _src_to_bytes(data: str | Path | bytes | BufferedIOBase) -> bytes:
150
143
  raise TypeError("Unsupported data type")
151
144
 
152
145
 
153
- def _from_vad_src(nc: Dataset) -> WindCube:
146
+ def _from_vad_or_dbs_src(nc: Dataset) -> WindCube:
154
147
  scan_index_list = []
155
148
  time_list = []
156
149
  cnr_list = []
@@ -181,17 +174,11 @@ def _from_vad_src(nc: Dataset) -> WindCube:
181
174
  height_list.append(_extract_int64_or_raise(group["measurement_height"]))
182
175
  scan_index_list.append(np.full(group["time"][:].shape, i, dtype=np.int64))
183
176
 
184
- height = np.concatenate(height_list)
185
- if not (height == height[0]).all():
186
- raise ValueError("Unexpected heights")
187
- radial_distance = np.concatenate(range_list)
188
- if not (radial_distance == radial_distance[0]).all():
189
- raise ValueError("Unexpected range")
190
177
  return WindCube(
191
178
  scan_index=np.concatenate(scan_index_list),
192
179
  time=np.concatenate(time_list),
193
- radial_distance=radial_distance[0],
194
- height=height[0],
180
+ radial_distance=np.concatenate(range_list),
181
+ height=np.concatenate(height_list),
195
182
  azimuth=np.concatenate(azimuth_list),
196
183
  elevation=np.concatenate(elevation_list),
197
184
  radial_velocity=np.concatenate(radial_wind_speed_list),
doppy/rs.abi3.so CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: doppy
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -131,7 +131,7 @@ raws_bg = doppy.raw.HaloBg.from_srcs(LIST_OF_BACKGROUND_FILES)
131
131
  raw_system_params = doppy.raw.HaloSysParams.from_src(SYSTEM_PARAMS_FILENAME)
132
132
 
133
133
  # Windcube WLS200S
134
- raws_wls200s = doppy.raw.WindCube.from_vad_srcs(LIST_OF_VAD_NETCDF_FILES)
134
+ raws_wls200s = doppy.raw.WindCube.from_vad_or_dbs_srcs(LIST_OF_VAD_NETCDF_FILES)
135
135
 
136
136
  # Windcube WLS70
137
137
  raws_wls70 = doppy.raw.Wls70.from_srcs(LIST_OF_RTD_FILES)
@@ -1,10 +1,10 @@
1
- doppy-0.3.5.dist-info/METADATA,sha256=Elbf8GWld1QLg3qAvBvl2_Wpp59I2nexthXgAaWXSfU,4175
2
- doppy-0.3.5.dist-info/WHEEL,sha256=5DSfM1TQ9gpjw2oUlJRyYVl2IqhTvHFIzdmuvKLQUkc,105
3
- doppy-0.3.5.dist-info/entry_points.txt,sha256=9b_Ca7vJoh6AwL3W8qAPh_UmJ_1Pa6hi-TDfCTDjvSk,43
4
- doppy-0.3.5.dist-info/licenses/LICENSE,sha256=V-0iroMNMI8ctnLgUau1kdFvwhkYhr9vi-5kWKxw2wc,1089
1
+ doppy-0.3.6.dist-info/METADATA,sha256=rIdxynFJ0EY_sbL0ATtBX4OTvQfS6zcsPeqTI6FG8eU,4182
2
+ doppy-0.3.6.dist-info/WHEEL,sha256=-Y1xyYTN3M_8ej0ZmEausOjKRIhVhpqcBKtfhemr-pc,105
3
+ doppy-0.3.6.dist-info/entry_points.txt,sha256=9b_Ca7vJoh6AwL3W8qAPh_UmJ_1Pa6hi-TDfCTDjvSk,43
4
+ doppy-0.3.6.dist-info/licenses/LICENSE,sha256=V-0iroMNMI8ctnLgUau1kdFvwhkYhr9vi-5kWKxw2wc,1089
5
5
  doppy/options.py,sha256=73BDODO4OYHn2qOshhwz6u6G3J1kNd3uj6P0a3V4HBE,205
6
6
  doppy/__init__.py,sha256=Z9aEUlbPRWRUAoB8_-djkgrJuS4-6pjem4-mVSB6Z9I,191
7
- doppy/product/wind.py,sha256=dRXXBGRN5GY0ICqkdqEikS-UaKz0jM3V-qc6IKXMIPw,16030
7
+ doppy/product/wind.py,sha256=hkSzAyi4tfPoGwUx8iE3l65oCDyzl_tRgtF2loxaEpY,16557
8
8
  doppy/product/__init__.py,sha256=C6s9cX20m9UwRsKo1lZH6TnYFfM5KmsX5MPUyShbgl4,235
9
9
  doppy/product/stare_depol.py,sha256=thrWzCpvdH3AiA6gmR37vrH_pDACNY2QTtqPteJ2s8Y,9653
10
10
  doppy/product/stare.py,sha256=OD9Ff0IUVvRVR-KRIfOiWIQq3sC5KKhYtlmnif81HcU,22625
@@ -14,7 +14,7 @@ doppy/utils.py,sha256=qPtIYBJPaKKTmRWwJI93TFUuhJg7CAoecpyHCm5ZyxI,214
14
14
  doppy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  doppy/exceptions.py,sha256=OzdLXmKs3qZrvzwaI0pxjzpM2w9J5Of7dCo_Ekygecc,183
16
16
  doppy/defaults.py,sha256=-il4DWU1HPttlGFoVQTPC7R4pDZERoPvt3kw6xwMKrw,38
17
- doppy/data/cache.py,sha256=2rxmkWFn-FPy2LNGuCW2Vu4KKLBwIV9sb2gPBA-Jfck,996
17
+ doppy/data/cache.py,sha256=cxCZ7HyEQt2EKAGEiMqx3wJ2-5Y3hEAEPQ_XB4gKlkk,1160
18
18
  doppy/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  doppy/data/api.py,sha256=QaVKj304OPcu8OF5xgtduQzDis8Srn-I6UgR9qb2u9E,1863
20
20
  doppy/data/exceptions.py,sha256=6CS6OHIWq8CqlxiceEvC1j0EfWUYoIfM7dW88apQVn4,89
@@ -23,7 +23,7 @@ doppy/raw/__init__.py,sha256=AMHyONuH0aUJUQz20EhlANaq9UjWJtSZf7kWUVx3ZjA,228
23
23
  doppy/raw/wls70.py,sha256=PMyr_JYTiKuYv1JpWHgVX6OA5zU83DOnr8vBCxFyFAw,7420
24
24
  doppy/raw/halo_bg.py,sha256=8t9j-SUF1yJht3vrT6KAYJQyxcg3W-0zr8h0jAEhWes,5815
25
25
  doppy/raw/halo_hpl.py,sha256=YFTepAWXvIfAVGgLZCadsc1d-VaOh7j2RB3cpb6Sv6k,18486
26
- doppy/raw/windcube.py,sha256=MlN6glTwlfoqFL7ejehqQdRECMAt3Jt5nr5WO6MTCfg,10442
26
+ doppy/raw/windcube.py,sha256=LO5TXxWGdVxYD-kGwjaIebwEnEegB0AyxMXynkdrJqE,9952
27
27
  doppy/__main__.py,sha256=zrKQJVj0k0ypBQCGK65Czt9G9FZ_qx3ussw6Q9VJ14g,346
28
- doppy/rs.abi3.so,sha256=cLyiErRQtFlREptac0qEOGZDcDzikSHQebyE_AdHZKU,2655056
29
- doppy-0.3.5.dist-info/RECORD,,
28
+ doppy/rs.abi3.so,sha256=sJc44vpekTdry6zsIVs23pn1DrByFH2V2lE58_JsWE0,2682528
29
+ doppy-0.3.6.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.7.1)
2
+ Generator: maturin (1.7.4)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp310-abi3-macosx_10_12_x86_64