doppy 0.3.1__tar.gz → 0.3.2__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 (42) hide show
  1. {doppy-0.3.1 → doppy-0.3.2}/Cargo.lock +2 -2
  2. {doppy-0.3.1 → doppy-0.3.2}/Cargo.toml +1 -1
  3. {doppy-0.3.1 → doppy-0.3.2}/PKG-INFO +1 -1
  4. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/product/stare.py +22 -0
  5. doppy-0.3.2/src/doppy/product/stare_depol.py +180 -0
  6. doppy-0.3.1/src/doppy/product/stare_depol.py +0 -83
  7. {doppy-0.3.1 → doppy-0.3.2}/LICENSE +0 -0
  8. {doppy-0.3.1 → doppy-0.3.2}/README.md +0 -0
  9. {doppy-0.3.1 → doppy-0.3.2}/crates/doppy_rs/Cargo.toml +0 -0
  10. {doppy-0.3.1 → doppy-0.3.2}/crates/doppy_rs/src/lib.rs +0 -0
  11. {doppy-0.3.1 → doppy-0.3.2}/crates/doppy_rs/src/raw/halo_hpl.rs +0 -0
  12. {doppy-0.3.1 → doppy-0.3.2}/crates/doppy_rs/src/raw/wls70.rs +0 -0
  13. {doppy-0.3.1 → doppy-0.3.2}/crates/doppy_rs/src/raw.rs +0 -0
  14. {doppy-0.3.1 → doppy-0.3.2}/crates/doprs/.gitignore +0 -0
  15. {doppy-0.3.1 → doppy-0.3.2}/crates/doprs/Cargo.toml +0 -0
  16. {doppy-0.3.1 → doppy-0.3.2}/crates/doprs/src/lib.rs +0 -0
  17. {doppy-0.3.1 → doppy-0.3.2}/crates/doprs/src/raw/error.rs +0 -0
  18. {doppy-0.3.1 → doppy-0.3.2}/crates/doprs/src/raw/halo_hpl.rs +0 -0
  19. {doppy-0.3.1 → doppy-0.3.2}/crates/doprs/src/raw/wls70.rs +0 -0
  20. {doppy-0.3.1 → doppy-0.3.2}/crates/doprs/src/raw.rs +0 -0
  21. {doppy-0.3.1 → doppy-0.3.2}/pyproject.toml +0 -0
  22. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/__init__.py +0 -0
  23. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/__main__.py +0 -0
  24. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/bench.py +0 -0
  25. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/data/__init__.py +0 -0
  26. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/data/api.py +0 -0
  27. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/data/cache.py +0 -0
  28. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/data/exceptions.py +0 -0
  29. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/defaults.py +0 -0
  30. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/exceptions.py +0 -0
  31. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/netcdf.py +0 -0
  32. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/options.py +0 -0
  33. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/product/__init__.py +0 -0
  34. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/product/wind.py +0 -0
  35. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/py.typed +0 -0
  36. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/raw/__init__.py +0 -0
  37. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/raw/halo_bg.py +0 -0
  38. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/raw/halo_hpl.py +0 -0
  39. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/raw/halo_sys_params.py +0 -0
  40. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/raw/windcube.py +0 -0
  41. {doppy-0.3.1 → doppy-0.3.2}/src/doppy/raw/wls70.py +0 -0
  42. {doppy-0.3.1 → doppy-0.3.2}/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.1"
109
+ version = "0.3.2"
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.1"
118
+ version = "0.3.2"
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.1"
7
+ version = "0.3.2"
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.1
3
+ Version: 0.3.2
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -29,6 +29,28 @@ class Stare:
29
29
  wavelength: float
30
30
  system_id: str
31
31
 
32
+ def __getitem__(
33
+ self,
34
+ index: int
35
+ | slice
36
+ | list[int]
37
+ | npt.NDArray[np.int64]
38
+ | npt.NDArray[np.bool_]
39
+ | tuple[slice, slice],
40
+ ) -> Stare:
41
+ if isinstance(index, (int, slice, list, np.ndarray)):
42
+ return Stare(
43
+ time=self.time[index],
44
+ radial_distance=self.radial_distance,
45
+ elevation=self.elevation[index],
46
+ beta=self.beta[index],
47
+ radial_velocity=self.radial_velocity[index],
48
+ mask=self.mask[index],
49
+ wavelength=self.wavelength,
50
+ system_id=self.system_id,
51
+ )
52
+ raise TypeError
53
+
32
54
  @classmethod
33
55
  def from_halo_data(
34
56
  cls,
@@ -0,0 +1,180 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from io import BufferedIOBase
5
+ from pathlib import Path
6
+ from typing import Sequence
7
+
8
+ import numpy as np
9
+ import numpy.typing as npt
10
+
11
+ from doppy import options
12
+ from doppy.product.stare import Stare
13
+
14
+
15
+ @dataclass
16
+ class StareDepol:
17
+ """
18
+ Stare product with depolarisation ratio derived from co-polarised and
19
+ cross-polarised stare data.
20
+
21
+ Attributes:
22
+ -----------
23
+ time
24
+ An array of datetime64 objects representing the observation times.
25
+ radial_distance
26
+ An array of radial distances from the observation point, in meters.
27
+ elevation
28
+ An array of elevation angles corresponding to the observation points, in
29
+ degrees.
30
+ beta
31
+ An array of backscatter coefficients for the co-polarised signal, in
32
+ sr-1 m-1.
33
+ beta_cross
34
+ An array of backscatter coefficients for the cross-polarised signal, in
35
+ sr-1 m-1.
36
+ radial_velocity
37
+ An array of radial velocities of the co-polarised signal, in m s-1.
38
+ mask
39
+ A boolean array indicating signal (True) or noise (False) data points.
40
+ depolarisation
41
+ An array of depolarisation ratios calculated as the ratio of
42
+ co-polarised to cross-polarised backscatter coefficients.
43
+ wavelength
44
+ The wavelength of the lidar, in meters.
45
+ system_id
46
+ A string identifier for the lidar.
47
+
48
+
49
+ Raises
50
+ ------
51
+ ValueError
52
+ If the input `co` and `cross` products have mismatched wavelengths,
53
+ system IDs, radial distances, or elevation angles, this exception is
54
+ raised.
55
+
56
+
57
+ References
58
+ ----------
59
+ Aerosol particle depolarization ratio at 1565 nm measured with a Halo Doppler lidar
60
+ authors: Ville Vakkari, Holger Baars, Stephanie Bohlmann, Johannes Bühl,
61
+ Mika Komppula, Rodanthi-Elisavet Mamouri, and Ewan James O'Connor
62
+ doi: https://doi.org/10.5194/acp-21-5807-2021
63
+ """
64
+
65
+ time: npt.NDArray[np.datetime64]
66
+ radial_distance: npt.NDArray[np.float64]
67
+ elevation: npt.NDArray[np.float64]
68
+ beta: npt.NDArray[np.float64]
69
+ beta_cross: npt.NDArray[np.float64]
70
+ radial_velocity: npt.NDArray[np.float64]
71
+ mask: npt.NDArray[np.bool_]
72
+ depolarisation: npt.NDArray[np.float64]
73
+ mask_depolarisation: npt.NDArray[np.bool_]
74
+ mask_beta_cross: npt.NDArray[np.bool_]
75
+ polariser_bleed_through: float
76
+ wavelength: float
77
+ system_id: str
78
+
79
+ def __init__(
80
+ self,
81
+ co: Stare,
82
+ cross: Stare,
83
+ polariser_bleed_through: float = 0.0,
84
+ ):
85
+ """
86
+ Parameters
87
+ ----------
88
+ co: Stare
89
+ The co-polarised data.
90
+ cross: Stare
91
+ The cross-polarised data. The `cross.time` array is expected to be sorted.
92
+ polariser_bleed_through: float, default=0.0
93
+ The amount of bleed-through from the polariser.
94
+ """
95
+
96
+ if not np.isclose(co.wavelength, cross.wavelength):
97
+ raise ValueError(
98
+ "Different wavelength in co and cross: "
99
+ f"{co.wavelength} vs {cross.wavelength}"
100
+ )
101
+ if co.system_id != cross.system_id:
102
+ raise ValueError(
103
+ "Different system ID in co and cross: "
104
+ f"{co.system_id} vs {cross.system_id}"
105
+ )
106
+ if not np.allclose(co.radial_distance, cross.radial_distance, atol=1):
107
+ raise ValueError("Different radial distance in co and cross")
108
+
109
+ if co.beta.shape[1] != cross.beta.shape[1]:
110
+ raise ValueError(
111
+ "Range dimension mismatch in co and cross: "
112
+ f"{co.beta.shape[1]} vs {cross.beta.shape[1]}"
113
+ )
114
+
115
+ ind = np.searchsorted(cross.time, co.time, side="left")
116
+ pick_ind = ind < len(cross.time)
117
+ time_diff_threshold = 2 * np.median(np.diff(co.time))
118
+ co_cross_timediff_below_threshold = (
119
+ cross.time[ind[pick_ind]] - co.time[pick_ind] < time_diff_threshold
120
+ )
121
+ pick_ind[pick_ind] &= co_cross_timediff_below_threshold
122
+
123
+ if not np.allclose(
124
+ co.elevation[pick_ind], cross.elevation[ind[pick_ind]], atol=1
125
+ ):
126
+ raise ValueError("Different elevation in co and cross")
127
+
128
+ depolarisation = np.full_like(co.beta, np.nan)
129
+ co_beta = co.beta[pick_ind]
130
+ depolarisation[pick_ind] = (
131
+ cross.beta[ind[pick_ind]] - polariser_bleed_through * co_beta
132
+ ) / co_beta
133
+ cross_beta = np.full_like(co.beta, np.nan)
134
+ cross_beta[pick_ind] = cross.beta[ind[pick_ind]]
135
+
136
+ self.time = co.time
137
+ self.radial_distance = co.radial_distance
138
+ self.elevation = co.elevation
139
+ self.beta = co.beta
140
+ self.beta_cross = cross_beta
141
+ self.radial_velocity = co.radial_velocity
142
+ self.mask = co.mask
143
+ self.depolarisation = depolarisation
144
+ self.mask_depolarisation = np.isnan(depolarisation)
145
+ self.mask_beta_cross = np.isnan(self.beta_cross)
146
+ self.polariser_bleed_through = polariser_bleed_through
147
+ self.wavelength = co.wavelength
148
+ self.system_id = co.system_id
149
+
150
+ @classmethod
151
+ def from_halo_data(
152
+ cls,
153
+ co_data: Sequence[str]
154
+ | Sequence[Path]
155
+ | Sequence[bytes]
156
+ | Sequence[BufferedIOBase],
157
+ co_data_bg: Sequence[str]
158
+ | Sequence[Path]
159
+ | Sequence[tuple[bytes, str]]
160
+ | Sequence[tuple[BufferedIOBase, str]],
161
+ cross_data: Sequence[str]
162
+ | Sequence[Path]
163
+ | Sequence[bytes]
164
+ | Sequence[BufferedIOBase],
165
+ cross_data_bg: Sequence[str]
166
+ | Sequence[Path]
167
+ | Sequence[tuple[bytes, str]]
168
+ | Sequence[tuple[BufferedIOBase, str]],
169
+ bg_correction_method: options.BgCorrectionMethod,
170
+ polariser_bleed_through: float = 0,
171
+ ) -> StareDepol:
172
+ co = Stare.from_halo_data(
173
+ data=co_data, data_bg=co_data_bg, bg_correction_method=bg_correction_method
174
+ )
175
+ cross = Stare.from_halo_data(
176
+ data=cross_data,
177
+ data_bg=cross_data_bg,
178
+ bg_correction_method=bg_correction_method,
179
+ )
180
+ return cls(co, cross, polariser_bleed_through)
@@ -1,83 +0,0 @@
1
- import numpy as np
2
- import numpy.typing as npt
3
-
4
- from doppy.product.stare import Stare
5
-
6
-
7
- class StareDepol:
8
- """
9
- Stare product with depolarisation ratio derived from co-polarised and
10
- cross-polarised stare data.
11
-
12
- Attributes:
13
- -----------
14
- time
15
- An array of datetime64 objects representing the observation times.
16
- radial_distance
17
- An array of radial distances from the observation point, in meters.
18
- elevation
19
- An array of elevation angles corresponding to the observation points, in
20
- degrees.
21
- beta
22
- An array of backscatter coefficients for the co-polarised signal, in
23
- sr-1 m-1.
24
- radial_velocity
25
- An array of radial velocities of the co-polarised signal, in m s-1.
26
- mask
27
- A boolean array indicating signal (True) or noise (False) data points.
28
- depolarisation
29
- An array of depolarisation ratios calculated as the ratio of
30
- co-polarised to cross-polarised backscatter coefficients.
31
- wavelength
32
- The wavelength of the lidar, in meters.
33
- system_id
34
- A string identifier for the lidar.
35
-
36
- Raises
37
- ------
38
- ValueError
39
- If the input `co` and `cross` products have mismatched wavelengths,
40
- system IDs, radial distances, or elevation angles, this exception is
41
- raised.
42
- """
43
-
44
- time: npt.NDArray[np.datetime64]
45
- radial_distance: npt.NDArray[np.float64]
46
- elevation: npt.NDArray[np.float64]
47
- beta: npt.NDArray[np.float64]
48
- radial_velocity: npt.NDArray[np.float64]
49
- mask: npt.NDArray[np.bool_]
50
- depolarisation: npt.NDArray[np.float64]
51
- wavelength: float
52
- system_id: str
53
-
54
- def __init__(self, co: Stare, cross: Stare):
55
- if co.wavelength != cross.wavelength:
56
- raise ValueError(
57
- "Different wavelength in co and cross: "
58
- f"{co.wavelength} vs {cross.wavelength}"
59
- )
60
- if co.system_id != cross.system_id:
61
- raise ValueError(
62
- "Different system ID in co and cross: "
63
- f"{co.system_id} vs {cross.system_id}"
64
- )
65
- if not np.allclose(co.radial_distance, cross.radial_distance, atol=1):
66
- raise ValueError("Different radial distance in co and cross")
67
-
68
- time_ind = np.argmin(np.abs(co.time - cross.time[:, np.newaxis]), axis=0)
69
- cross_elevation = cross.elevation[time_ind]
70
- cross_beta = cross.beta[time_ind, :]
71
-
72
- if not np.allclose(co.elevation, cross_elevation, atol=1):
73
- raise ValueError("Different elevation in co and cross")
74
-
75
- self.time = co.time
76
- self.radial_distance = co.radial_distance
77
- self.elevation = co.elevation
78
- self.beta = co.beta
79
- self.radial_velocity = co.radial_velocity
80
- self.mask = co.mask
81
- self.depolarisation = cross_beta / co.beta
82
- self.wavelength = co.wavelength
83
- self.system_id = co.system_id
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
File without changes
File without changes
File without changes