doppy 0.1.3__cp310-abi3-win_amd64.whl → 0.2.0__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/data/api.py CHANGED
@@ -37,7 +37,13 @@ class Api:
37
37
  return self.get(
38
38
  "raw-files",
39
39
  params={
40
- "instrument": ["halo-doppler-lidar", "wls100s", "wls200s", "wls400s"],
40
+ "instrument": [
41
+ "halo-doppler-lidar",
42
+ "wls100s",
43
+ "wls200s",
44
+ "wls400s",
45
+ "wls70",
46
+ ],
41
47
  "site": site,
42
48
  "date": date,
43
49
  },
doppy/product/stare.py CHANGED
@@ -50,6 +50,7 @@ class Stare:
50
50
  doppy.raw.HaloHpl.merge(_select_raws_for_stare(raws))
51
51
  .sorted_by_time()
52
52
  .non_strictly_increasing_timesteps_removed()
53
+ .nans_removed()
53
54
  )
54
55
 
55
56
  bgs = doppy.raw.HaloBg.from_srcs(data_bg)
@@ -65,6 +66,8 @@ class Stare:
65
66
  .non_strictly_increasing_timesteps_removed()
66
67
  )
67
68
  raw, intensity_bg_corrected = _correct_background(raw, bg, bg_correction_method)
69
+ if len(raw.time) == 0:
70
+ raise doppy.exceptions.NoDataError("No matching data and bg files")
68
71
  intensity_noise_bias_corrected = _correct_intensity_noise_bias(
69
72
  raw, intensity_bg_corrected
70
73
  )
doppy/product/wind.py CHANGED
@@ -54,6 +54,7 @@ class Wind:
54
54
  doppy.raw.HaloHpl.merge(_select_raws_for_wind(raws))
55
55
  .sorted_by_time()
56
56
  .non_strictly_increasing_timesteps_removed()
57
+ .nans_removed()
57
58
  )
58
59
  if len(raw.time) == 0:
59
60
  raise doppy.exceptions.NoDataError("No suitable data for the wind product")
@@ -148,6 +149,38 @@ class Wind:
148
149
  mask=mask,
149
150
  )
150
151
 
152
+ @classmethod
153
+ def from_wls70_data(
154
+ cls,
155
+ data: Sequence[str]
156
+ | Sequence[Path]
157
+ | Sequence[bytes]
158
+ | Sequence[BufferedIOBase],
159
+ ) -> Wind:
160
+ raws = doppy.raw.Wls70.from_srcs(data)
161
+
162
+ if len(raws) == 0:
163
+ raise doppy.exceptions.NoDataError("Wls70 data missing")
164
+
165
+ raw = (
166
+ doppy.raw.Wls70.merge(raws)
167
+ .sorted_by_time()
168
+ .non_strictly_increasing_timesteps_removed()
169
+ )
170
+ mask = (
171
+ np.isnan(raw.meridional_wind)
172
+ | np.isnan(raw.zonal_wind)
173
+ | np.isnan(raw.vertical_wind)
174
+ )
175
+ return Wind(
176
+ time=raw.time,
177
+ height=raw.altitude,
178
+ zonal_wind=raw.zonal_wind,
179
+ meridional_wind=raw.meridional_wind,
180
+ vertical_wind=raw.vertical_wind,
181
+ mask=mask,
182
+ )
183
+
151
184
 
152
185
  def _compute_wind(
153
186
  raw: doppy.raw.HaloHpl | doppy.raw.WindCube,
doppy/raw/__init__.py CHANGED
@@ -2,5 +2,6 @@ from .halo_bg import HaloBg
2
2
  from .halo_hpl import HaloHpl
3
3
  from .halo_sys_params import HaloSysParams
4
4
  from .windcube import WindCube
5
+ from .wls70 import Wls70
5
6
 
6
- __all__ = ["HaloHpl", "HaloBg", "HaloSysParams", "WindCube"]
7
+ __all__ = ["HaloHpl", "HaloBg", "HaloSysParams", "WindCube", "Wls70"]
doppy/raw/halo_hpl.py CHANGED
@@ -187,6 +187,10 @@ class HaloHpl:
187
187
  latest_time = t
188
188
  return self[mask]
189
189
 
190
+ def nans_removed(self) -> HaloHpl:
191
+ is_ok = ~np.isnan(self.intensity).any(axis=1)
192
+ return self[is_ok]
193
+
190
194
 
191
195
  @dataclass(slots=True)
192
196
  class HaloHplHeader:
doppy/raw/wls70.py ADDED
@@ -0,0 +1,188 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from datetime import datetime
5
+ from io import BufferedIOBase
6
+ from pathlib import Path
7
+ from typing import Sequence
8
+
9
+ import numpy as np
10
+ import numpy.typing as npt
11
+ from numpy import datetime64
12
+
13
+ import doppy
14
+ from doppy import exceptions
15
+
16
+
17
+ @dataclass
18
+ class Wls70:
19
+ time: npt.NDArray[datetime64] # dim: (time, )
20
+ altitude: npt.NDArray[np.float64] # dim: (altitude, )
21
+ position: npt.NDArray[np.float64] # dim: (time, )
22
+ temperature: npt.NDArray[np.float64] # dim: (time, )
23
+ wiper: npt.NDArray[np.bool_] # dim: (time, )
24
+ cnr: npt.NDArray[np.float64] # dim: (time, altitude)
25
+ radial_velocity: npt.NDArray[np.float64] # dim: (time, altitude)
26
+ radial_velocity_deviation: npt.NDArray[np.float64] # dim: (time, altitude)
27
+ vh: npt.NDArray[np.float64] # dim: (time, altitude)
28
+ wind_direction: npt.NDArray[np.float64] # dim: (time, altitude)
29
+ zonal_wind: npt.NDArray[np.float64] # u := zonal wind?, dim: (time, altitude)
30
+ meridional_wind: npt.NDArray[
31
+ np.float64
32
+ ] # v := meridional wind?, dim: (time, altitude)
33
+ vertical_wind: npt.NDArray[np.float64] # w := vertical wind?, dim: (time, altitude)
34
+
35
+ @classmethod
36
+ def from_srcs(
37
+ cls,
38
+ data: Sequence[str]
39
+ | Sequence[Path]
40
+ | Sequence[bytes]
41
+ | Sequence[BufferedIOBase],
42
+ ) -> list[Wls70]:
43
+ if not isinstance(data, (list, tuple)):
44
+ raise TypeError("data should be list or tuple")
45
+ if all(isinstance(src, bytes) for src in data):
46
+ data_bytes = data
47
+ elif all(isinstance(src, str) for src in data):
48
+ data_bytes = []
49
+ for src in data:
50
+ with Path(src).open("rb") as f:
51
+ data_bytes.append(f.read())
52
+ elif all(isinstance(src, Path) for src in data):
53
+ data_bytes = []
54
+ for src in data:
55
+ with src.open("rb") as f:
56
+ data_bytes.append(f.read())
57
+ elif all(isinstance(src, BufferedIOBase) for src in data):
58
+ data_bytes = [src.read() for src in data]
59
+ else:
60
+ raise TypeError("Unexpected types in data")
61
+ raws = doppy.rs.raw.wls70.from_bytes_srcs(data_bytes)
62
+ try:
63
+ return [_raw_rs_to_wls70(r) for r in raws]
64
+ except RuntimeError as err:
65
+ raise exceptions.RawParsingError(err) from err
66
+
67
+ @classmethod
68
+ def from_src(cls, data: str | Path | bytes | BufferedIOBase) -> Wls70:
69
+ if isinstance(data, str):
70
+ path = Path(data)
71
+ with path.open("rb") as f:
72
+ data_bytes = f.read()
73
+ elif isinstance(data, Path):
74
+ with data.open("rb") as f:
75
+ data_bytes = f.read()
76
+ elif isinstance(data, bytes):
77
+ data_bytes = data
78
+ elif isinstance(data, BufferedIOBase):
79
+ data_bytes = data.read()
80
+ else:
81
+ raise TypeError("Unsupported data type")
82
+ try:
83
+ return _raw_rs_to_wls70(doppy.rs.raw.wls70.from_bytes_src(data_bytes))
84
+ except RuntimeError as err:
85
+ raise exceptions.RawParsingError(err) from err
86
+
87
+ def __getitem__(
88
+ self,
89
+ index: int
90
+ | slice
91
+ | list[int]
92
+ | npt.NDArray[np.int64]
93
+ | npt.NDArray[np.bool_]
94
+ | tuple[slice, slice],
95
+ ) -> Wls70:
96
+ if isinstance(index, (int, slice, list, np.ndarray)):
97
+ return Wls70(
98
+ time=self.time[index],
99
+ altitude=self.altitude,
100
+ position=self.position[index],
101
+ temperature=self.temperature[index],
102
+ wiper=self.wiper[index],
103
+ cnr=self.cnr[index],
104
+ radial_velocity=self.radial_velocity[index],
105
+ radial_velocity_deviation=self.radial_velocity_deviation[index],
106
+ vh=self.vh[index],
107
+ wind_direction=self.wind_direction[index],
108
+ zonal_wind=self.zonal_wind[index],
109
+ meridional_wind=self.meridional_wind[index],
110
+ vertical_wind=self.vertical_wind[index],
111
+ )
112
+ raise TypeError
113
+
114
+ def sorted_by_time(self) -> Wls70:
115
+ sort_indices = np.argsort(self.time)
116
+ return self[sort_indices]
117
+
118
+ @classmethod
119
+ def merge(cls, raws: Sequence[Wls70]) -> Wls70:
120
+ return cls(
121
+ time=np.concatenate(tuple(r.time for r in raws)),
122
+ altitude=raws[0].altitude,
123
+ position=np.concatenate(tuple(r.position for r in raws)),
124
+ temperature=np.concatenate(tuple(r.temperature for r in raws)),
125
+ wiper=np.concatenate(tuple(r.wiper for r in raws)),
126
+ cnr=np.concatenate(tuple(r.cnr for r in raws)),
127
+ radial_velocity=np.concatenate(tuple(r.radial_velocity for r in raws)),
128
+ radial_velocity_deviation=np.concatenate(
129
+ tuple(r.radial_velocity_deviation for r in raws)
130
+ ),
131
+ vh=np.concatenate(tuple(r.vh for r in raws)),
132
+ wind_direction=np.concatenate(tuple(r.wind_direction for r in raws)),
133
+ zonal_wind=np.concatenate(tuple(r.zonal_wind for r in raws)),
134
+ meridional_wind=np.concatenate(tuple(r.meridional_wind for r in raws)),
135
+ vertical_wind=np.concatenate(tuple(r.vertical_wind for r in raws)),
136
+ )
137
+
138
+ def non_strictly_increasing_timesteps_removed(self) -> Wls70:
139
+ if len(self.time) == 0:
140
+ return self
141
+ mask = np.ones_like(self.time, dtype=np.bool_)
142
+ latest_time = self.time[0]
143
+ for i, t in enumerate(self.time[1:], start=1):
144
+ if t <= latest_time:
145
+ mask[i] = False
146
+ else:
147
+ latest_time = t
148
+ return self[mask]
149
+
150
+
151
+ def _raw_rs_to_wls70(
152
+ raw_rs: tuple[
153
+ dict[str, npt.NDArray[np.float64]], list[str], npt.NDArray[np.float64]
154
+ ],
155
+ ) -> Wls70:
156
+ info, cols, data = raw_rs
157
+ altitude = info["altitude"]
158
+ data = data.reshape(-1, len(cols))
159
+ time_ts = data[:, 0]
160
+ time = np.array([datetime64(datetime.utcfromtimestamp(ts)) for ts in time_ts])
161
+
162
+ position = data[:, 1]
163
+ temperature = data[:, 2]
164
+ wiper = np.array(np.isclose(data[:, 3], 1), dtype=np.bool_)
165
+ cnr = data[:, 4::8]
166
+ rws = data[:, 5::8]
167
+ rwsd = data[:, 6::8]
168
+ vh = data[:, 7::8]
169
+ direction = data[:, 8::8]
170
+ u = data[:, 9::8]
171
+ v = data[:, 10::8]
172
+ w = data[:, 11::8]
173
+
174
+ return Wls70(
175
+ time=time,
176
+ altitude=altitude,
177
+ position=position,
178
+ temperature=temperature,
179
+ wiper=wiper,
180
+ cnr=cnr,
181
+ radial_velocity=rws,
182
+ radial_velocity_deviation=rwsd,
183
+ vh=vh,
184
+ wind_direction=direction,
185
+ zonal_wind=u,
186
+ meridional_wind=v,
187
+ vertical_wind=w,
188
+ )
doppy/rs.pyd CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: doppy
3
- Version: 0.1.3
3
+ Version: 0.2.0
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -13,7 +13,7 @@ Requires-Dist: requests
13
13
  Requires-Dist: urllib3
14
14
  Requires-Dist: numpy
15
15
  Requires-Dist: netcdf4
16
- Requires-Dist: typer[all]
16
+ Requires-Dist: typer
17
17
  Requires-Dist: matplotlib
18
18
  Requires-Dist: scikit-learn
19
19
  Requires-Dist: scipy
@@ -1,10 +1,10 @@
1
- doppy-0.1.3.dist-info/METADATA,sha256=Rggbnzd618Rv2jQA_aBtjYEiAK6cUL4AZg57LHFFLK0,1798
2
- doppy-0.1.3.dist-info/WHEEL,sha256=Q2npN4Wz3hcQ5uc7KmG7fh3MaY55ijiBnwI7N8UUMDM,95
3
- doppy-0.1.3.dist-info/entry_points.txt,sha256=9b_Ca7vJoh6AwL3W8qAPh_UmJ_1Pa6hi-TDfCTDjvSk,43
4
- doppy-0.1.3.dist-info/license_files/LICENSE,sha256=RIAxFjJLTw0wQ3_SM73JoTeppoD99DJJ72cjvVuRrW4,1110
5
- doppy-0.1.3.dist-info/license_files/LICENSE,sha256=RIAxFjJLTw0wQ3_SM73JoTeppoD99DJJ72cjvVuRrW4,1110
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
6
6
  doppy/bench.py,sha256=fLN2iS5mmoYH4qZjD80Vl1h9lp3C-KDfhj9fteWRPtM,260
7
- doppy/data/api.py,sha256=yzniozSzs8N1sJe5ht4Y5SwyZn06RlGSkiwm0GvBTUE,1787
7
+ doppy/data/api.py,sha256=c3zbZI3IV7HnzhyFzJpUPOFT20eYFuQlJ5K_1ZEe1Pg,1921
8
8
  doppy/data/cache.py,sha256=VNPB3XsWGwY2bNXBs1r_sEWF4qBq_U7sJSlSmt1Rxm8,1033
9
9
  doppy/data/exceptions.py,sha256=JOyekvUO-Ew4ZVezf3_IxZOrPN0IksfUILd8R2YcSts,95
10
10
  doppy/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -12,16 +12,17 @@ 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=GBw5P16smTLtTdNtLTucb4NP2nUcW2WEj0sXysYSvZY,20314
16
- doppy/product/wind.py,sha256=WNPPMY71HKIpnj3T96jqWNcScYT5Fa3vB7PKnm4FP_I,11452
15
+ doppy/product/stare.py,sha256=Er_LA_tk16hpBL7cWJxQaVO914GAtzOC03cGY4Ij85Q,20456
16
+ doppy/product/wind.py,sha256=H8bBZChAPcjlnYLj7HhqGs__kcCHrRGeKr2tf2E_LlU,12394
17
17
  doppy/product/__init__.py,sha256=dOyY9_lLv6l3-_vtmJU18zOrE86SL0LHovQWQtwynnU,107
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=Yrk9YY4zErAfiyHJMWmPfWPr1fjGK3TxnznIXyp8poc,19028
20
+ doppy/raw/halo_hpl.py,sha256=x1xJVJKsKtNXPHqgIVyBseV9KpTifTK15URcBlAfRfE,19153
21
21
  doppy/raw/halo_sys_params.py,sha256=L3cFf1jATLMkVf2ViSbrmom-rZu7dn1Nq1J354xO98A,4041
22
22
  doppy/raw/windcube.py,sha256=aHAKN1tgyPNpCVBY4co9FwM6vMLu4swqVoFFhpDT33M,9939
23
- doppy/raw/__init__.py,sha256=5szGvPn_KS7PViMPQ1umGrbd9jkJzQUZpTiST1z2MvQ,200
23
+ doppy/raw/wls70.py,sha256=yZKz1UO5ghqU6XO9-7poABwSKVgUr9BDgoKZ59E006E,6980
24
+ doppy/raw/__init__.py,sha256=J06q7iykSAWIif4XAxI1jOszkARvLFBR1eU-B9yUXMw,235
24
25
  doppy/__init__.py,sha256=Af7_8p3oN1nTqS9fo0mVKVuiKf5CAEK69uQa32CSFBA,197
25
26
  doppy/__main__.py,sha256=38hIWWfanILuBBGorQiAaleSC4qYJoIxuzVBkxf7Dng,371
26
- doppy/rs.pyd,sha256=cDmKpyhfWzQ6xrCdGTJFv5KtOQOAkATFdW4FKnbLRzw,2088960
27
- doppy-0.1.3.dist-info/RECORD,,
27
+ doppy/rs.pyd,sha256=k_6SKD65g3DHSNWmDaNeqUfnVv_mZ8cLBJ_EeLK-FYA,2157568
28
+ doppy-0.2.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.5.0)
2
+ Generator: maturin (1.5.1)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp310-abi3-win_amd64