doppy 0.5.4__cp310-abi3-macosx_11_0_arm64.whl → 0.5.6__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
@@ -113,7 +113,7 @@ class Stare:
113
113
  mask_radial_velocity=mask_radial_velocity,
114
114
  wavelength=wavelength,
115
115
  system_id=raw.system_id,
116
- ray_info=RayAccumulationTime(raw.ray_accumulation_time),
116
+ ray_info=RayAccumulationTime(raw.ray_accumulation_time.astype(float)),
117
117
  )
118
118
 
119
119
  @classmethod
doppy/product/utils.py ADDED
@@ -0,0 +1,12 @@
1
+ from collections import Counter
2
+
3
+ import numpy as np
4
+ import numpy.typing as npt
5
+
6
+
7
+ def arr_to_rounded_set(arr: npt.NDArray[np.float64]) -> set[int]:
8
+ return set(int(x) for x in np.round(arr))
9
+
10
+
11
+ def count_rounded(arr: npt.NDArray[np.float64]) -> Counter[int]:
12
+ return Counter(int(x) for x in np.round(arr))
doppy/product/wind.py CHANGED
@@ -1,21 +1,18 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import functools
4
- from collections import defaultdict
4
+ from collections import Counter
5
5
  from dataclasses import dataclass
6
6
  from io import BufferedIOBase
7
7
  from pathlib import Path
8
- from typing import Sequence, TypeAlias
8
+ from typing import Sequence
9
9
 
10
10
  import numpy as np
11
11
  import numpy.typing as npt
12
12
  from scipy.ndimage import generic_filter
13
- from sklearn.cluster import KMeans
14
13
 
15
14
  import doppy
16
-
17
- # ngates, gate points, elevation angle, tuple of sorted azimuth angles
18
- SelectionGroupKeyType: TypeAlias = tuple[int, int, tuple[int, ...]]
15
+ from doppy.product.utils import arr_to_rounded_set
19
16
 
20
17
 
21
18
  @dataclass
@@ -413,99 +410,45 @@ def _wrap_and_round_angle(a: np.float64) -> int:
413
410
  return int(np.round(a)) % 360
414
411
 
415
412
 
416
- def _group_scans(raw: doppy.raw.HaloHpl) -> npt.NDArray[np.int64]:
417
- if len(raw.time) < 4:
418
- raise ValueError("Expected at least 4 profiles to compute wind profile")
419
- if raw.time.dtype != "<M8[us]":
420
- raise TypeError("time expected to be in numpy datetime[us]")
421
- time = raw.time.astype(np.float64) * 1e-6
422
- timediff_in_seconds = np.diff(time)
423
- kmeans = KMeans(n_clusters=2, n_init="auto").fit(timediff_in_seconds.reshape(-1, 1))
424
- centers = kmeans.cluster_centers_.flatten()
425
- scanstep_timediff = centers[np.argmin(centers)]
426
-
427
- if scanstep_timediff < 0.1 or scanstep_timediff > 30:
428
- raise ValueError(
429
- "Time difference between profiles in one scan "
430
- "expected to be between 0.1 and 30 seconds"
431
- )
432
- scanstep_timediff_upperbound = 2 * scanstep_timediff
433
- groups_by_time = -1 * np.ones_like(time, dtype=np.int64)
434
- groups_by_time[0] = 0
435
- scan_index = 0
436
- for i, (t_prev, t) in enumerate(zip(time[:-1], time[1:]), start=1):
437
- if t - t_prev > scanstep_timediff_upperbound:
438
- scan_index += 1
439
- groups_by_time[i] = scan_index
440
-
441
- return _subgroup_scans(raw, groups_by_time)
442
-
443
-
444
- def _subgroup_scans(
445
- raw: doppy.raw.HaloHpl, time_groups: npt.NDArray[np.int64]
446
- ) -> npt.NDArray[np.int64]:
447
- """
448
- Groups scans further based on the azimuth angles
449
- """
450
- group = -1 * np.ones_like(raw.time, dtype=np.int64)
451
- i = -1
452
- for time_group in set(time_groups):
453
- i += 1
454
- (pick,) = np.where(time_group == time_groups)
455
- raw_group = raw[pick]
456
- first_azimuth_angle = int(np.round(raw_group.azimuth[0])) % 360
457
- group[pick[0]] = i
458
- for j, azi in enumerate(
459
- (int(np.round(azi)) % 360 for azi in raw_group.azimuth[1:]), start=1
460
- ):
461
- if azi == first_azimuth_angle:
462
- i += 1
463
- group[pick[j]] = i
464
- return group
465
-
466
-
467
413
  def _select_raws_for_wind(
468
414
  raws: Sequence[doppy.raw.HaloHpl],
469
415
  ) -> Sequence[doppy.raw.HaloHpl]:
470
- if len(raws) == 0:
471
- raise doppy.exceptions.NoDataError(
472
- "Cannot select raws for wind from empty list"
473
- )
474
- raws_wind = [
475
- raw
476
- for raw in raws
477
- if len(raw.elevation_angles) == 1
478
- and (el := next(iter(raw.elevation_angles))) < 80
479
- and el > 25
480
- and len(raw.azimuth_angles) > 3
481
- ]
482
- if len(raws_wind) == 0:
416
+ counter: Counter[tuple[int, int]] = Counter()
417
+ filtered_raws = []
418
+ for raw in raws:
419
+ select = (1 < raw.elevation) & (raw.elevation < 85)
420
+ for el in arr_to_rounded_set(raw.elevation[select]):
421
+ select_el = raw.elevation.round().astype(int) == el
422
+ select_and = select & select_el
423
+
424
+ if _get_nrounded_angles(raw.azimuth[select_and]) > 3:
425
+ filtered_raws.append(raw[select_and])
426
+ counter.update(
427
+ Counter(
428
+ (raw.header.mergeable_hash(), el)
429
+ for el in raw.elevation[select_and].round().astype(int)
430
+ )
431
+ )
432
+ if len(counter) == 0:
483
433
  raise doppy.exceptions.NoDataError(
484
- "No data suitable for winds: "
485
- "Multiple elevation angles or "
486
- "elevation angle >= 80 or "
487
- "elevation angle <= 25 or "
488
- "no more than 3 azimuth angles"
434
+ "No scans with 1 < elevation angle < 85 and more than 3 azimuth angles"
489
435
  )
490
-
491
- groups: dict[SelectionGroupKeyType, int] = defaultdict(int)
492
-
493
- for raw in raws_wind:
494
- groups[_selection_key(raw)] += len(raw.time)
495
-
496
- def key_func(key: SelectionGroupKeyType) -> int:
497
- return groups[key]
498
-
499
- select_tuple = max(groups, key=key_func)
500
-
501
- return [raw for raw in raws_wind if _selection_key(raw) == select_tuple]
502
-
503
-
504
- def _selection_key(raw: doppy.raw.HaloHpl) -> SelectionGroupKeyType:
505
- if len(raw.elevation_angles) != 1:
506
- raise ValueError("Expected only one elevation angle")
507
- return (
508
- raw.header.mergeable_hash(),
509
- next(iter(raw.elevation_angles)),
510
- tuple(sorted(raw.azimuth_angles)),
511
- )
436
+ if len(counter) == 1:
437
+ return filtered_raws
438
+ # Else select angle closes to 75 from angles
439
+ # that have count larger than mean_count/2
440
+ mean_count = counter.total() / len(counter)
441
+ _, _, hash = sorted(
442
+ [
443
+ (el, abs(el - 75), hash)
444
+ for (hash, el), count in counter.items()
445
+ if count > mean_count / 2
446
+ ],
447
+ key=lambda x: x[1],
448
+ )[0]
449
+ raws = [raw for raw in filtered_raws if raw.header.mergeable_hash() == hash]
450
+ return raws
451
+
452
+
453
+ def _get_nrounded_angles(arr: npt.NDArray[np.float64]) -> int:
454
+ return len(set((x + 360) % 360 for x in arr_to_rounded_set(arr)))
doppy/raw/windcube.py CHANGED
@@ -97,7 +97,7 @@ class WindCubeFixed:
97
97
  return self[sort_indices]
98
98
 
99
99
  def nan_profiles_removed(self) -> WindCubeFixed:
100
- return self[np.array(~np.all(np.isnan(self.cnr), axis=1), dtype=np.bool)]
100
+ return self[np.array(~np.all(np.isnan(self.cnr), axis=1), dtype=np.bool_)]
101
101
 
102
102
 
103
103
  @dataclass
doppy/rs.abi3.so CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: doppy
3
- Version: 0.5.4
3
+ Version: 0.5.6
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -29,10 +29,10 @@ Requires-Dist: release-version ; extra == 'dev'
29
29
  Requires-Dist: pre-commit ; extra == 'dev'
30
30
  Requires-Dist: xarray[io] ; extra == 'dev'
31
31
  Requires-Dist: seaborn ; extra == 'dev'
32
+ Requires-Dist: tomli ; extra == 'dev'
32
33
  Provides-Extra: dev
33
34
  License-File: LICENSE
34
35
  License-File: LICENSE
35
- Author: Niko Leskinen <niko.leskinen@fmi.fi>
36
36
  Author-email: Niko Leskinen <niko.leskinen@fmi.fi>
37
37
  Requires-Python: >=3.10
38
38
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
@@ -1,33 +1,34 @@
1
- doppy-0.5.4.dist-info/METADATA,sha256=N1bqxe9UYs90KoIqm1wkU36fHGCq5LzAapk6-zx54wc,4355
2
- doppy-0.5.4.dist-info/WHEEL,sha256=WcVLymwUFXZZBOS7GhUoID5qvQcDPxnkUAYBKypRBtM,103
3
- doppy-0.5.4.dist-info/entry_points.txt,sha256=9b_Ca7vJoh6AwL3W8qAPh_UmJ_1Pa6hi-TDfCTDjvSk,43
4
- doppy-0.5.4.dist-info/licenses/LICENSE,sha256=V-0iroMNMI8ctnLgUau1kdFvwhkYhr9vi-5kWKxw2wc,1089
5
- doppy/options.py,sha256=73BDODO4OYHn2qOshhwz6u6G3J1kNd3uj6P0a3V4HBE,205
1
+ doppy-0.5.6.dist-info/METADATA,sha256=r0JtIKpQUNQBrF2a5o_kzuQ6e_oDhz4pBWeyoc-2lQI,4348
2
+ doppy-0.5.6.dist-info/WHEEL,sha256=Eg6gwEJKNVa1g53Yg4W5oLzLA6e9MoXTlIiHdDxmtOw,103
3
+ doppy-0.5.6.dist-info/entry_points.txt,sha256=9b_Ca7vJoh6AwL3W8qAPh_UmJ_1Pa6hi-TDfCTDjvSk,43
4
+ doppy-0.5.6.dist-info/licenses/LICENSE,sha256=V-0iroMNMI8ctnLgUau1kdFvwhkYhr9vi-5kWKxw2wc,1089
6
5
  doppy/__init__.py,sha256=Z9aEUlbPRWRUAoB8_-djkgrJuS4-6pjem4-mVSB6Z9I,191
7
- doppy/product/turbulence.py,sha256=hajTHFr6XXdul8oU9dw4Y58kBwRpUBIfiOfTcvSjq7M,8606
8
- doppy/product/wind.py,sha256=efBfYalILN2VvDiGpxP04mob-mCrdQFS9tdhReeyXiU,16787
9
- doppy/product/__init__.py,sha256=C6s9cX20m9UwRsKo1lZH6TnYFfM5KmsX5MPUyShbgl4,235
10
- doppy/product/stare_depol.py,sha256=gSlD13jGLRmHyTDADFs_MO6ECos6wwKF-TL7G7NwHAA,10718
11
- doppy/product/noise_utils.py,sha256=fP2bK2xfCUClQcDc_1FmLUUiU2d0KycrxkXLC5jmJAc,2629
12
- doppy/product/stare.py,sha256=RVHcW8eep91bH2GVobqDqsqswdRaFZ5SY4K_5fLSF3I,27180
6
+ doppy/__main__.py,sha256=zrKQJVj0k0ypBQCGK65Czt9G9FZ_qx3ussw6Q9VJ14g,346
13
7
  doppy/bench.py,sha256=xUsmwLCjNLXwO9l-_SCfq62jxXJ4eiwkS-WlCejcqZE,308
14
- doppy/netcdf.py,sha256=PuTCVK4yT4dkObo_w2D1lJroHg7l4DJFZxOi6jr1DkQ,4078
15
- doppy/utils.py,sha256=cY-tWrArrROX7lg_zJ2M4QJ6GUnU_BjhkUYL5aG9kbA,790
16
- doppy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- doppy/exceptions.py,sha256=OzdLXmKs3qZrvzwaI0pxjzpM2w9J5Of7dCo_Ekygecc,183
18
- doppy/defaults.py,sha256=-jR_xAVLf_soZNDu3uJ6mhOZa9L1tfKtt0k0tI6Rd9s,472
19
- doppy/data/cache.py,sha256=cxCZ7HyEQt2EKAGEiMqx3wJ2-5Y3hEAEPQ_XB4gKlkk,1160
20
8
  doppy/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
9
  doppy/data/api.py,sha256=hUIqyCq1wFu89gamK7xK8R58eXAODWvLQHaaS5eu6OY,1875
10
+ doppy/data/cache.py,sha256=cxCZ7HyEQt2EKAGEiMqx3wJ2-5Y3hEAEPQ_XB4gKlkk,1160
22
11
  doppy/data/exceptions.py,sha256=6CS6OHIWq8CqlxiceEvC1j0EfWUYoIfM7dW88apQVn4,89
23
- doppy/raw/halo_sys_params.py,sha256=jclE4RbVg63iS3rVNYzvErKYAa3CI1q64xj3oai5tMc,5250
12
+ doppy/defaults.py,sha256=-jR_xAVLf_soZNDu3uJ6mhOZa9L1tfKtt0k0tI6Rd9s,472
13
+ doppy/exceptions.py,sha256=OzdLXmKs3qZrvzwaI0pxjzpM2w9J5Of7dCo_Ekygecc,183
14
+ doppy/netcdf.py,sha256=PuTCVK4yT4dkObo_w2D1lJroHg7l4DJFZxOi6jr1DkQ,4078
15
+ doppy/options.py,sha256=73BDODO4OYHn2qOshhwz6u6G3J1kNd3uj6P0a3V4HBE,205
16
+ doppy/product/__init__.py,sha256=C6s9cX20m9UwRsKo1lZH6TnYFfM5KmsX5MPUyShbgl4,235
17
+ doppy/product/noise_utils.py,sha256=fP2bK2xfCUClQcDc_1FmLUUiU2d0KycrxkXLC5jmJAc,2629
18
+ doppy/product/stare.py,sha256=5cvctg4zrwwj4B7knhYFrEwKqhcIxXstcNSnhbB6K04,27194
19
+ doppy/product/stare_depol.py,sha256=gSlD13jGLRmHyTDADFs_MO6ECos6wwKF-TL7G7NwHAA,10718
20
+ doppy/product/turbulence.py,sha256=hajTHFr6XXdul8oU9dw4Y58kBwRpUBIfiOfTcvSjq7M,8606
21
+ doppy/product/utils.py,sha256=1mngeUrs_mlRO3Z-bq5OWoFEMxX5uuosLVge1Jrp76s,310
22
+ doppy/product/wind.py,sha256=QSypYTGuSKLoscpBiVHZSgwFT5ju2f8U9Yg4sCKvhF4,14927
23
+ doppy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  doppy/raw/__init__.py,sha256=HE-7x27dfw-LJTvReZfspqzNx63Nl0v5ACdYs9EuOFQ,325
25
- doppy/raw/wls70.py,sha256=OfPczHZPKX4iqCcyjSv0nmkr1osy4pu6krNUi0-G0vM,6319
26
- doppy/raw/wls77.py,sha256=ciRNy0U1a4OuxbsHGt9HMHAa3Qqukaw57QeNQdkWUj8,6460
27
- doppy/raw/utils.py,sha256=EOWIaxAZIiRYa9dI1j50cSd4I058Zq7sz1HOeipZFTg,422
28
25
  doppy/raw/halo_bg.py,sha256=8t9j-SUF1yJht3vrT6KAYJQyxcg3W-0zr8h0jAEhWes,5815
29
26
  doppy/raw/halo_hpl.py,sha256=tK0H6LAOcoWqF4vvNu8VRCYq_spvcSTHRM4ju4gx5Lo,16828
30
- doppy/raw/windcube.py,sha256=HKAlU-TUVqA1sefRLOY5skM1twQaVe-MExlZoI40rK4,19149
31
- doppy/__main__.py,sha256=zrKQJVj0k0ypBQCGK65Czt9G9FZ_qx3ussw6Q9VJ14g,346
32
- doppy/rs.abi3.so,sha256=mruqgPrAmoxZkd-QBjWrFSQMtM1gNxiwgaeQ7M4cR58,2593696
33
- doppy-0.5.4.dist-info/RECORD,,
27
+ doppy/raw/halo_sys_params.py,sha256=jclE4RbVg63iS3rVNYzvErKYAa3CI1q64xj3oai5tMc,5250
28
+ doppy/raw/utils.py,sha256=EOWIaxAZIiRYa9dI1j50cSd4I058Zq7sz1HOeipZFTg,422
29
+ doppy/raw/windcube.py,sha256=uL6htoeyrJ-zrHV_QM748TT0HyfA3rw7t2dQORx0OAU,19150
30
+ doppy/raw/wls70.py,sha256=OfPczHZPKX4iqCcyjSv0nmkr1osy4pu6krNUi0-G0vM,6319
31
+ doppy/raw/wls77.py,sha256=ciRNy0U1a4OuxbsHGt9HMHAa3Qqukaw57QeNQdkWUj8,6460
32
+ doppy/rs.abi3.so,sha256=Pj8q2Tw9W0JnGHvPCEPb9UCYVAlb2D5CxbT4lAMXP9k,2581200
33
+ doppy/utils.py,sha256=cY-tWrArrROX7lg_zJ2M4QJ6GUnU_BjhkUYL5aG9kbA,790
34
+ doppy-0.5.6.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.8.3)
2
+ Generator: maturin (1.9.4)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp310-abi3-macosx_11_0_arm64