doppy 0.3.0__cp310-abi3-macosx_11_0_arm64.whl → 0.3.2__cp310-abi3-macosx_11_0_arm64.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/stare.py CHANGED
@@ -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,
@@ -1,9 +1,18 @@
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
+
1
8
  import numpy as np
2
9
  import numpy.typing as npt
3
10
 
11
+ from doppy import options
4
12
  from doppy.product.stare import Stare
5
13
 
6
14
 
15
+ @dataclass
7
16
  class StareDepol:
8
17
  """
9
18
  Stare product with depolarisation ratio derived from co-polarised and
@@ -21,6 +30,9 @@ class StareDepol:
21
30
  beta
22
31
  An array of backscatter coefficients for the co-polarised signal, in
23
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.
24
36
  radial_velocity
25
37
  An array of radial velocities of the co-polarised signal, in m s-1.
26
38
  mask
@@ -33,26 +45,55 @@ class StareDepol:
33
45
  system_id
34
46
  A string identifier for the lidar.
35
47
 
48
+
36
49
  Raises
37
50
  ------
38
51
  ValueError
39
52
  If the input `co` and `cross` products have mismatched wavelengths,
40
53
  system IDs, radial distances, or elevation angles, this exception is
41
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
42
63
  """
43
64
 
44
65
  time: npt.NDArray[np.datetime64]
45
66
  radial_distance: npt.NDArray[np.float64]
46
67
  elevation: npt.NDArray[np.float64]
47
68
  beta: npt.NDArray[np.float64]
69
+ beta_cross: npt.NDArray[np.float64]
48
70
  radial_velocity: npt.NDArray[np.float64]
49
71
  mask: npt.NDArray[np.bool_]
50
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
51
76
  wavelength: float
52
77
  system_id: str
53
78
 
54
- def __init__(self, co: Stare, cross: Stare):
55
- if co.wavelength != cross.wavelength:
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):
56
97
  raise ValueError(
57
98
  "Different wavelength in co and cross: "
58
99
  f"{co.wavelength} vs {cross.wavelength}"
@@ -62,22 +103,78 @@ class StareDepol:
62
103
  "Different system ID in co and cross: "
63
104
  f"{co.system_id} vs {cross.system_id}"
64
105
  )
65
- if not np.allclose(co.radial_distance, cross.radial_distance):
106
+ if not np.allclose(co.radial_distance, cross.radial_distance, atol=1):
66
107
  raise ValueError("Different radial distance in co and cross")
67
108
 
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, :]
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
71
122
 
72
- if not np.allclose(co.elevation, cross_elevation):
123
+ if not np.allclose(
124
+ co.elevation[pick_ind], cross.elevation[ind[pick_ind]], atol=1
125
+ ):
73
126
  raise ValueError("Different elevation in co and cross")
74
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
+
75
136
  self.time = co.time
76
137
  self.radial_distance = co.radial_distance
77
138
  self.elevation = co.elevation
78
139
  self.beta = co.beta
140
+ self.beta_cross = cross_beta
79
141
  self.radial_velocity = co.radial_velocity
80
142
  self.mask = co.mask
81
- self.depolarisation = cross_beta / co.beta
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
82
147
  self.wavelength = co.wavelength
83
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)
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.0
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
@@ -1,13 +1,13 @@
1
- doppy-0.3.0.dist-info/METADATA,sha256=_RBIW8LjmfrQG1DiFhhtYM0P7nPta48JCzszwAPkueI,4146
2
- doppy-0.3.0.dist-info/WHEEL,sha256=8YVHbP9g43_6FVsydzNKX35DdPN9RlBfh4bOfODYltg,103
3
- doppy-0.3.0.dist-info/entry_points.txt,sha256=9b_Ca7vJoh6AwL3W8qAPh_UmJ_1Pa6hi-TDfCTDjvSk,43
4
- doppy-0.3.0.dist-info/license_files/LICENSE,sha256=V-0iroMNMI8ctnLgUau1kdFvwhkYhr9vi-5kWKxw2wc,1089
1
+ doppy-0.3.2.dist-info/METADATA,sha256=3SJc4Ud6JiZQHAjBfekQaHIluO7nCU-YZeVwB3MTw9M,4146
2
+ doppy-0.3.2.dist-info/WHEEL,sha256=GmPQBnUDZgDWUSmU3r_BHIfcmbjw_LVs138d_NT7BE4,103
3
+ doppy-0.3.2.dist-info/entry_points.txt,sha256=9b_Ca7vJoh6AwL3W8qAPh_UmJ_1Pa6hi-TDfCTDjvSk,43
4
+ doppy-0.3.2.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
7
  doppy/product/wind.py,sha256=MXm5HDoO3X6AzvpPHYPlpUXB_MYp_TBPP81aZ151wj8,13043
8
8
  doppy/product/__init__.py,sha256=C6s9cX20m9UwRsKo1lZH6TnYFfM5KmsX5MPUyShbgl4,235
9
- doppy/product/stare_depol.py,sha256=wlRVQPcWm14b1Gy_poXSNP8dzGw1qKlgT0KJ3YAXyKA,2897
10
- doppy/product/stare.py,sha256=jt1vHptufBFwUH5Un_0pk44eHKbAWnkhrU7HUI7gYJ4,19908
9
+ doppy/product/stare_depol.py,sha256=vvOSYWfxEuQTDlohB72szhGVqMCDYA3yNkMAaU9wcD0,6209
10
+ doppy/product/stare.py,sha256=4eV9xBNE1IPaOBLOr_whqj-9nHVEDGSZZH_AeIdCiMo,20603
11
11
  doppy/bench.py,sha256=iVNYveMVGGRES2oe3Orsn31jQFCKTXOmxRFuFiJ8_OA,248
12
12
  doppy/netcdf.py,sha256=FX151GC8fuRhm-veg94BGeOWqszGn6nnWT9BxbzoSO8,3895
13
13
  doppy/utils.py,sha256=qPtIYBJPaKKTmRWwJI93TFUuhJg7CAoecpyHCm5ZyxI,214
@@ -25,5 +25,5 @@ doppy/raw/halo_bg.py,sha256=kO03yGlKS-DpMMGHYuy_BuidyeUL38TxT5vMn8H_8lE,4809
25
25
  doppy/raw/halo_hpl.py,sha256=YFTepAWXvIfAVGgLZCadsc1d-VaOh7j2RB3cpb6Sv6k,18486
26
26
  doppy/raw/windcube.py,sha256=ZaOswQJbVDPBYj5oU1pTYmsX8F-mKIbjJRZmLYEMXP0,9906
27
27
  doppy/__main__.py,sha256=zrKQJVj0k0ypBQCGK65Czt9G9FZ_qx3ussw6Q9VJ14g,346
28
- doppy/rs.abi3.so,sha256=_qOfbxDJ1ZioH82IcB4shWiLvmWwmUyfFJGjqR6lmKA,2566816
29
- doppy-0.3.0.dist-info/RECORD,,
28
+ doppy/rs.abi3.so,sha256=FBKhzC6ZkjrSdxVPaPQQ4yf724NjlRLACxWo_z_-msw,2566816
29
+ doppy-0.3.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.7.0)
2
+ Generator: maturin (1.7.1)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp310-abi3-macosx_11_0_arm64