doppy 0.3.5__tar.gz → 0.3.6__tar.gz

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.

Files changed (41) hide show
  1. {doppy-0.3.5 → doppy-0.3.6}/Cargo.lock +2 -2
  2. {doppy-0.3.5 → doppy-0.3.6}/Cargo.toml +1 -1
  3. {doppy-0.3.5 → doppy-0.3.6}/PKG-INFO +2 -2
  4. {doppy-0.3.5 → doppy-0.3.6}/README.md +1 -1
  5. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/data/cache.py +7 -1
  6. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/product/wind.py +11 -2
  7. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/raw/windcube.py +13 -26
  8. {doppy-0.3.5 → doppy-0.3.6}/LICENSE +0 -0
  9. {doppy-0.3.5 → doppy-0.3.6}/crates/doppy_rs/Cargo.toml +0 -0
  10. {doppy-0.3.5 → doppy-0.3.6}/crates/doppy_rs/src/lib.rs +0 -0
  11. {doppy-0.3.5 → doppy-0.3.6}/crates/doppy_rs/src/raw/halo_hpl.rs +0 -0
  12. {doppy-0.3.5 → doppy-0.3.6}/crates/doppy_rs/src/raw/wls70.rs +0 -0
  13. {doppy-0.3.5 → doppy-0.3.6}/crates/doppy_rs/src/raw.rs +0 -0
  14. {doppy-0.3.5 → doppy-0.3.6}/crates/doprs/.gitignore +0 -0
  15. {doppy-0.3.5 → doppy-0.3.6}/crates/doprs/Cargo.toml +0 -0
  16. {doppy-0.3.5 → doppy-0.3.6}/crates/doprs/src/lib.rs +0 -0
  17. {doppy-0.3.5 → doppy-0.3.6}/crates/doprs/src/raw/error.rs +0 -0
  18. {doppy-0.3.5 → doppy-0.3.6}/crates/doprs/src/raw/halo_hpl.rs +0 -0
  19. {doppy-0.3.5 → doppy-0.3.6}/crates/doprs/src/raw/wls70.rs +0 -0
  20. {doppy-0.3.5 → doppy-0.3.6}/crates/doprs/src/raw.rs +0 -0
  21. {doppy-0.3.5 → doppy-0.3.6}/pyproject.toml +0 -0
  22. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/__init__.py +0 -0
  23. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/__main__.py +0 -0
  24. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/bench.py +0 -0
  25. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/data/__init__.py +0 -0
  26. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/data/api.py +0 -0
  27. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/data/exceptions.py +0 -0
  28. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/defaults.py +0 -0
  29. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/exceptions.py +0 -0
  30. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/netcdf.py +0 -0
  31. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/options.py +0 -0
  32. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/product/__init__.py +0 -0
  33. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/product/stare.py +0 -0
  34. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/product/stare_depol.py +0 -0
  35. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/py.typed +0 -0
  36. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/raw/__init__.py +0 -0
  37. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/raw/halo_bg.py +0 -0
  38. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/raw/halo_hpl.py +0 -0
  39. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/raw/halo_sys_params.py +0 -0
  40. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/raw/wls70.py +0 -0
  41. {doppy-0.3.5 → doppy-0.3.6}/src/doppy/utils.py +0 -0
@@ -106,7 +106,7 @@ checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
106
106
 
107
107
  [[package]]
108
108
  name = "doppy_rs"
109
- version = "0.3.5"
109
+ version = "0.3.6"
110
110
  dependencies = [
111
111
  "doprs",
112
112
  "numpy",
@@ -115,7 +115,7 @@ dependencies = [
115
115
 
116
116
  [[package]]
117
117
  name = "doprs"
118
- version = "0.3.5"
118
+ version = "0.3.6"
119
119
  dependencies = [
120
120
  "chrono",
121
121
  "rayon",
@@ -4,6 +4,6 @@ resolver = "2"
4
4
 
5
5
  [workspace.package]
6
6
  edition = "2021"
7
- version = "0.3.5"
7
+ version = "0.3.6"
8
8
  authors = ["Niko Leskinen <niko.leskinen@fmi.fi>"]
9
9
  license-file = "LICENSE"
@@ -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)
@@ -92,7 +92,7 @@ raws_bg = doppy.raw.HaloBg.from_srcs(LIST_OF_BACKGROUND_FILES)
92
92
  raw_system_params = doppy.raw.HaloSysParams.from_src(SYSTEM_PARAMS_FILENAME)
93
93
 
94
94
  # Windcube WLS200S
95
- raws_wls200s = doppy.raw.WindCube.from_vad_srcs(LIST_OF_VAD_NETCDF_FILES)
95
+ raws_wls200s = doppy.raw.WindCube.from_vad_or_dbs_srcs(LIST_OF_VAD_NETCDF_FILES)
96
96
 
97
97
  # Windcube WLS70
98
98
  raws_wls70 = doppy.raw.Wls70.from_srcs(LIST_OF_RTD_FILES)
@@ -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)
@@ -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,
@@ -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),
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes