doppy 0.2.0__cp310-abi3-win_amd64.whl → 0.2.2__cp310-abi3-win_amd64.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/product/__init__.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from doppy.product.stare import Stare
2
+ from doppy.product.wind import Options as WindOptions
2
3
  from doppy.product.wind import Wind
3
4
 
4
- __all__ = ["Stare", "Wind"]
5
+ __all__ = ["Stare", "Wind", "WindOptions"]
doppy/product/stare.py CHANGED
@@ -27,6 +27,7 @@ class Stare:
27
27
  radial_velocity: npt.NDArray[np.float64]
28
28
  mask: npt.NDArray[np.bool_]
29
29
  wavelength: float
30
+ system_id: str
30
31
 
31
32
  @classmethod
32
33
  def from_halo_data(
@@ -89,6 +90,7 @@ class Stare:
89
90
  radial_velocity=raw.radial_velocity,
90
91
  mask=mask,
91
92
  wavelength=wavelength,
93
+ system_id=raw.header.system_id,
92
94
  )
93
95
 
94
96
 
doppy/product/wind.py CHANGED
@@ -18,6 +18,11 @@ import doppy
18
18
  SelectionGroupKeyType: TypeAlias = tuple[int, int, tuple[int, ...]]
19
19
 
20
20
 
21
+ @dataclass
22
+ class Options:
23
+ azimuth_offset_deg: float | None
24
+
25
+
21
26
  @dataclass
22
27
  class Wind:
23
28
  time: npt.NDArray[np.datetime64]
@@ -26,6 +31,7 @@ class Wind:
26
31
  meridional_wind: npt.NDArray[np.float64]
27
32
  vertical_wind: npt.NDArray[np.float64]
28
33
  mask: npt.NDArray[np.bool_]
34
+ system_id: str
29
35
 
30
36
  @functools.cached_property
31
37
  def horizontal_wind_speed(self) -> npt.NDArray[np.float64]:
@@ -44,6 +50,7 @@ class Wind:
44
50
  | Sequence[Path]
45
51
  | Sequence[bytes]
46
52
  | Sequence[BufferedIOBase],
53
+ options: Options | None = None,
47
54
  ) -> Wind:
48
55
  raws = doppy.raw.HaloHpl.from_srcs(data)
49
56
 
@@ -59,6 +66,9 @@ class Wind:
59
66
  if len(raw.time) == 0:
60
67
  raise doppy.exceptions.NoDataError("No suitable data for the wind product")
61
68
 
69
+ if options and options.azimuth_offset_deg:
70
+ raw.azimuth += options.azimuth_offset_deg
71
+
62
72
  groups = _group_scans_by_azimuth_rotation(raw)
63
73
  time_list = []
64
74
  elevation_list = []
@@ -93,6 +103,7 @@ class Wind:
93
103
  meridional_wind=wind[:, :, 1],
94
104
  vertical_wind=wind[:, :, 2],
95
105
  mask=mask,
106
+ system_id=raw.header.system_id,
96
107
  )
97
108
 
98
109
  @classmethod
@@ -102,6 +113,7 @@ class Wind:
102
113
  | Sequence[Path]
103
114
  | Sequence[bytes]
104
115
  | Sequence[BufferedIOBase],
116
+ options: Options | None = None,
105
117
  ) -> Wind:
106
118
  raws = doppy.raw.WindCube.from_vad_srcs(data)
107
119
 
@@ -117,6 +129,9 @@ class Wind:
117
129
  if len(raw.time) == 0:
118
130
  raise doppy.exceptions.NoDataError("No suitable data for the wind product")
119
131
 
132
+ if options and options.azimuth_offset_deg:
133
+ raw.azimuth += options.azimuth_offset_deg
134
+
120
135
  time_list = []
121
136
  elevation_list = []
122
137
  wind_list = []
@@ -147,6 +162,7 @@ class Wind:
147
162
  meridional_wind=wind[:, :, 1],
148
163
  vertical_wind=wind[:, :, 2],
149
164
  mask=mask,
165
+ system_id=raw.system_id,
150
166
  )
151
167
 
152
168
  @classmethod
@@ -156,6 +172,7 @@ class Wind:
156
172
  | Sequence[Path]
157
173
  | Sequence[bytes]
158
174
  | Sequence[BufferedIOBase],
175
+ options: Options | None = None,
159
176
  ) -> Wind:
160
177
  raws = doppy.raw.Wls70.from_srcs(data)
161
178
 
@@ -167,6 +184,20 @@ class Wind:
167
184
  .sorted_by_time()
168
185
  .non_strictly_increasing_timesteps_removed()
169
186
  )
187
+
188
+ if options and options.azimuth_offset_deg:
189
+ theta = np.deg2rad(options.azimuth_offset_deg)
190
+ cos_theta = np.cos(theta)
191
+ sin_theta = np.sin(theta)
192
+
193
+ meridional_wind = (
194
+ sin_theta * raw.zonal_wind + cos_theta * raw.meridional_wind
195
+ )
196
+ zonal_wind = cos_theta * raw.zonal_wind - sin_theta * raw.meridional_wind
197
+ else:
198
+ meridional_wind = raw.meridional_wind
199
+ zonal_wind = raw.zonal_wind
200
+
170
201
  mask = (
171
202
  np.isnan(raw.meridional_wind)
172
203
  | np.isnan(raw.zonal_wind)
@@ -175,10 +206,11 @@ class Wind:
175
206
  return Wind(
176
207
  time=raw.time,
177
208
  height=raw.altitude,
178
- zonal_wind=raw.zonal_wind,
179
- meridional_wind=raw.meridional_wind,
209
+ zonal_wind=zonal_wind,
210
+ meridional_wind=meridional_wind,
180
211
  vertical_wind=raw.vertical_wind,
181
212
  mask=mask,
213
+ system_id=raw.system_id,
182
214
  )
183
215
 
184
216
 
doppy/raw/halo_hpl.py CHANGED
@@ -8,7 +8,7 @@ from datetime import datetime, timedelta
8
8
  from io import BufferedIOBase
9
9
  from os.path import commonprefix
10
10
  from pathlib import Path
11
- from typing import Any, Sequence, TypeVar, cast
11
+ from typing import Any, Sequence, cast
12
12
 
13
13
  import numpy as np
14
14
  import numpy.typing as npt
@@ -16,8 +16,7 @@ from numpy import datetime64, timedelta64
16
16
 
17
17
  import doppy
18
18
  from doppy import exceptions
19
-
20
- T = TypeVar("T")
19
+ from doppy.utils import merge_all_equal
21
20
 
22
21
 
23
22
  @dataclass
@@ -258,18 +257,12 @@ class HaloHplHeader:
258
257
  )
259
258
 
260
259
 
261
- def _merger(key: str, lst: list[T]) -> T:
262
- if len(set(lst)) != 1:
263
- raise ValueError(f"Cannot merge header key {key} values {lst}")
264
- return lst[0]
265
-
266
-
267
260
  def _merge_headers(headers: list[HaloHplHeader]) -> HaloHplHeader:
268
261
  return HaloHplHeader(
269
262
  filename=commonprefix([h.filename for h in headers]),
270
263
  start_time=np.min([h.start_time for h in headers]),
271
264
  **{
272
- key: _merger(key, [getattr(h, key) for h in headers])
265
+ key: merge_all_equal(key, [getattr(h, key) for h in headers])
273
266
  for key in (
274
267
  "gate_points",
275
268
  "nrays",
doppy/raw/windcube.py CHANGED
@@ -10,6 +10,8 @@ import numpy.typing as npt
10
10
  from netCDF4 import Dataset, num2date
11
11
  from numpy import datetime64
12
12
 
13
+ from doppy.utils import merge_all_equal
14
+
13
15
 
14
16
  @dataclass
15
17
  class WindCube:
@@ -22,6 +24,7 @@ class WindCube:
22
24
  radial_velocity: npt.NDArray[np.float64] # dim: (time, radial_distance)
23
25
  radial_velocity_confidence: npt.NDArray[np.float64] # dim: (time, radial_distance)
24
26
  scan_index: npt.NDArray[np.int64]
27
+ system_id: str
25
28
 
26
29
  @classmethod
27
30
  def from_vad_srcs(
@@ -53,6 +56,7 @@ class WindCube:
53
56
  [r.radial_velocity_confidence for r in raws]
54
57
  ),
55
58
  cnr=np.concatenate([r.cnr for r in raws]),
59
+ system_id=merge_all_equal("system_id", [r.system_id for r in raws]),
56
60
  )
57
61
 
58
62
  def __getitem__(
@@ -75,6 +79,7 @@ class WindCube:
75
79
  radial_velocity_confidence=self.radial_velocity_confidence[index],
76
80
  cnr=self.cnr[index],
77
81
  scan_index=self.scan_index[index],
82
+ system_id=self.system_id,
78
83
  )
79
84
  raise TypeError
80
85
 
@@ -189,6 +194,7 @@ def _from_vad_src(nc: Dataset) -> WindCube:
189
194
  radial_velocity=np.concatenate(radial_wind_speed_list),
190
195
  radial_velocity_confidence=np.concatenate(radial_wind_speed_confidence_list),
191
196
  cnr=np.concatenate(cnr_list),
197
+ system_id=nc.instrument_name,
192
198
  )
193
199
 
194
200
 
doppy/raw/wls70.py CHANGED
@@ -4,7 +4,7 @@ from dataclasses import dataclass
4
4
  from datetime import datetime
5
5
  from io import BufferedIOBase
6
6
  from pathlib import Path
7
- from typing import Sequence
7
+ from typing import Any, Sequence
8
8
 
9
9
  import numpy as np
10
10
  import numpy.typing as npt
@@ -12,6 +12,7 @@ from numpy import datetime64
12
12
 
13
13
  import doppy
14
14
  from doppy import exceptions
15
+ from doppy.utils import merge_all_equal
15
16
 
16
17
 
17
18
  @dataclass
@@ -31,6 +32,7 @@ class Wls70:
31
32
  np.float64
32
33
  ] # v := meridional wind?, dim: (time, altitude)
33
34
  vertical_wind: npt.NDArray[np.float64] # w := vertical wind?, dim: (time, altitude)
35
+ system_id: str
34
36
 
35
37
  @classmethod
36
38
  def from_srcs(
@@ -108,6 +110,7 @@ class Wls70:
108
110
  zonal_wind=self.zonal_wind[index],
109
111
  meridional_wind=self.meridional_wind[index],
110
112
  vertical_wind=self.vertical_wind[index],
113
+ system_id=self.system_id,
111
114
  )
112
115
  raise TypeError
113
116
 
@@ -133,6 +136,7 @@ class Wls70:
133
136
  zonal_wind=np.concatenate(tuple(r.zonal_wind for r in raws)),
134
137
  meridional_wind=np.concatenate(tuple(r.meridional_wind for r in raws)),
135
138
  vertical_wind=np.concatenate(tuple(r.vertical_wind for r in raws)),
139
+ system_id=merge_all_equal("system_id", [r.system_id for r in raws]),
136
140
  )
137
141
 
138
142
  def non_strictly_increasing_timesteps_removed(self) -> Wls70:
@@ -149,12 +153,11 @@ class Wls70:
149
153
 
150
154
 
151
155
  def _raw_rs_to_wls70(
152
- raw_rs: tuple[
153
- dict[str, npt.NDArray[np.float64]], list[str], npt.NDArray[np.float64]
154
- ],
156
+ raw_rs: tuple[dict[str, Any], list[str], npt.NDArray[np.float64]],
155
157
  ) -> Wls70:
156
158
  info, cols, data = raw_rs
157
159
  altitude = info["altitude"]
160
+ system_id = info["system_id"]
158
161
  data = data.reshape(-1, len(cols))
159
162
  time_ts = data[:, 0]
160
163
  time = np.array([datetime64(datetime.utcfromtimestamp(ts)) for ts in time_ts])
@@ -185,4 +188,5 @@ def _raw_rs_to_wls70(
185
188
  zonal_wind=u,
186
189
  meridional_wind=v,
187
190
  vertical_wind=w,
191
+ system_id=system_id,
188
192
  )
doppy/rs.pyd CHANGED
Binary file
doppy/utils.py ADDED
@@ -0,0 +1,9 @@
1
+ from typing import TypeVar
2
+
3
+ T = TypeVar("T")
4
+
5
+
6
+ def merge_all_equal(key: str, lst: list[T]) -> T:
7
+ if len(set(lst)) != 1:
8
+ raise ValueError(f"Cannot merge header key {key} values {lst}")
9
+ return lst[0]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: doppy
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -1,8 +1,8 @@
1
- doppy-0.2.0.dist-info/METADATA,sha256=40KlrlwFO1uGDar8ehIYYYXltszTCDSi2grzI4wPgb0,1793
2
- doppy-0.2.0.dist-info/WHEEL,sha256=d75zPPyDx5l542fz5cKSMKvSEn203Dzoi4bYqdZk0D8,95
3
- doppy-0.2.0.dist-info/entry_points.txt,sha256=9b_Ca7vJoh6AwL3W8qAPh_UmJ_1Pa6hi-TDfCTDjvSk,43
4
- doppy-0.2.0.dist-info/license_files/LICENSE,sha256=RIAxFjJLTw0wQ3_SM73JoTeppoD99DJJ72cjvVuRrW4,1110
5
- doppy-0.2.0.dist-info/license_files/LICENSE,sha256=RIAxFjJLTw0wQ3_SM73JoTeppoD99DJJ72cjvVuRrW4,1110
1
+ doppy-0.2.2.dist-info/METADATA,sha256=pB8rf-ENhdOyoHh9mbT0IOuxQeQ1_weyuWro8BpE5MU,1793
2
+ doppy-0.2.2.dist-info/WHEEL,sha256=d75zPPyDx5l542fz5cKSMKvSEn203Dzoi4bYqdZk0D8,95
3
+ doppy-0.2.2.dist-info/entry_points.txt,sha256=9b_Ca7vJoh6AwL3W8qAPh_UmJ_1Pa6hi-TDfCTDjvSk,43
4
+ doppy-0.2.2.dist-info/license_files/LICENSE,sha256=RIAxFjJLTw0wQ3_SM73JoTeppoD99DJJ72cjvVuRrW4,1110
5
+ doppy-0.2.2.dist-info/license_files/LICENSE,sha256=RIAxFjJLTw0wQ3_SM73JoTeppoD99DJJ72cjvVuRrW4,1110
6
6
  doppy/bench.py,sha256=fLN2iS5mmoYH4qZjD80Vl1h9lp3C-KDfhj9fteWRPtM,260
7
7
  doppy/data/api.py,sha256=c3zbZI3IV7HnzhyFzJpUPOFT20eYFuQlJ5K_1ZEe1Pg,1921
8
8
  doppy/data/cache.py,sha256=VNPB3XsWGwY2bNXBs1r_sEWF4qBq_U7sJSlSmt1Rxm8,1033
@@ -12,17 +12,18 @@ doppy/defaults.py,sha256=nhxcZcFd2jyDVbq0azwtekEJEjiz8k21MZmXFlSXAjo,40
12
12
  doppy/exceptions.py,sha256=YNEyz4r0ObzZHZ9re83K3wZlR2CRI1GyhH0vvFGasgQ,148
13
13
  doppy/netcdf.py,sha256=UnuecY_yEijEDpsuOBCj3EGeWMXtyRIOlLAC1UVUVHY,3527
14
14
  doppy/options.py,sha256=uyIKM_G2GtbmV6Gve8o13eIShQqUwsnYZ41mhX2ypGE,218
15
- doppy/product/stare.py,sha256=Er_LA_tk16hpBL7cWJxQaVO914GAtzOC03cGY4Ij85Q,20456
16
- doppy/product/wind.py,sha256=H8bBZChAPcjlnYLj7HhqGs__kcCHrRGeKr2tf2E_LlU,12394
17
- doppy/product/__init__.py,sha256=dOyY9_lLv6l3-_vtmJU18zOrE86SL0LHovQWQtwynnU,107
15
+ doppy/product/stare.py,sha256=hJPGujuMiOM424XtbCWWEdnD21zl9qg4dgZXnT-CDfk,20521
16
+ doppy/product/wind.py,sha256=JT4DAwE1hl7NbE53mkZl4a-5RQb30IlydzfpDwkOoZM,13454
17
+ doppy/product/__init__.py,sha256=kHVF77la8tzWKKpiM9eNWT-eAkAUd4uwb0wJFp62QLk,177
18
18
  doppy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  doppy/raw/halo_bg.py,sha256=9K7E9smahGOqDIYnA-9m-Di3QsDY0PR2FH4Yd_oYiEY,4951
20
- doppy/raw/halo_hpl.py,sha256=x1xJVJKsKtNXPHqgIVyBseV9KpTifTK15URcBlAfRfE,19153
20
+ doppy/raw/halo_hpl.py,sha256=OMVa6K8TqUnhwE5w3w_qy5Qi_Vg6S2lHwKEaIq5iGG0,19006
21
21
  doppy/raw/halo_sys_params.py,sha256=L3cFf1jATLMkVf2ViSbrmom-rZu7dn1Nq1J354xO98A,4041
22
- doppy/raw/windcube.py,sha256=aHAKN1tgyPNpCVBY4co9FwM6vMLu4swqVoFFhpDT33M,9939
23
- doppy/raw/wls70.py,sha256=yZKz1UO5ghqU6XO9-7poABwSKVgUr9BDgoKZ59E006E,6980
22
+ doppy/raw/windcube.py,sha256=h_kqlQf2Pz59xg5EVSROiUlcA2RQp2jkGIxohmN1QOE,10166
23
+ doppy/raw/wls70.py,sha256=n5I9T7mWPIb1LI0kUrUz4gP9v8mjX76kx1EUBFeeyA0,7200
24
24
  doppy/raw/__init__.py,sha256=J06q7iykSAWIif4XAxI1jOszkARvLFBR1eU-B9yUXMw,235
25
+ doppy/utils.py,sha256=lENDTzMVjCOA15Va9WZ6cou-foL5bGbNt4-NbDcnXpc,223
25
26
  doppy/__init__.py,sha256=Af7_8p3oN1nTqS9fo0mVKVuiKf5CAEK69uQa32CSFBA,197
26
27
  doppy/__main__.py,sha256=38hIWWfanILuBBGorQiAaleSC4qYJoIxuzVBkxf7Dng,371
27
- doppy/rs.pyd,sha256=k_6SKD65g3DHSNWmDaNeqUfnVv_mZ8cLBJ_EeLK-FYA,2157568
28
- doppy-0.2.0.dist-info/RECORD,,
28
+ doppy/rs.pyd,sha256=meDRBEyGkaPwvDvu0Xx0w13e7y6TPcju4J4M6dXvFLU,2111488
29
+ doppy-0.2.2.dist-info/RECORD,,
File without changes