cloudnetpy 1.78.3__py3-none-any.whl → 1.79.0__py3-none-any.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.
cloudnetpy/exceptions.py CHANGED
@@ -23,6 +23,13 @@ class RadarDataError(CloudnetException):
23
23
  super().__init__(msg)
24
24
 
25
25
 
26
+ class LidarDataError(CloudnetException):
27
+ """Internal exception class."""
28
+
29
+ def __init__(self, msg: str):
30
+ super().__init__(msg)
31
+
32
+
26
33
  class PlottingError(CloudnetException):
27
34
  """Internal exception class."""
28
35
 
@@ -117,11 +117,10 @@ def _get_n_negatives(ceilo_obj: ClCeilo | Ct25k | LufftCeilo | Cl61d | Cs135) ->
117
117
  is_old_chm_version = (
118
118
  hasattr(ceilo_obj, "is_old_version") and ceilo_obj.is_old_version
119
119
  )
120
- is_ct25k = (
121
- ceilo_obj.instrument is not None
122
- and getattr(ceilo_obj.instrument, "model", "").lower() == "ct25k"
123
- )
124
- if is_old_chm_version or is_ct25k:
120
+ is_old_vaisala_model = ceilo_obj.instrument is not None and getattr(
121
+ ceilo_obj.instrument, "model", ""
122
+ ).lower() in ("ct25k", "cl31")
123
+ if is_old_chm_version or is_old_vaisala_model:
125
124
  return 20
126
125
  return 5
127
126
 
@@ -4,6 +4,8 @@ import logging
4
4
 
5
5
  import netCDF4
6
6
 
7
+ from cloudnetpy import utils
8
+ from cloudnetpy.exceptions import LidarDataError
7
9
  from cloudnetpy.instruments import instruments
8
10
  from cloudnetpy.instruments.nc_lidar import NcLidar
9
11
 
@@ -39,6 +41,9 @@ class Cl61d(NcLidar):
39
41
  msg = "No dataset found"
40
42
  raise RuntimeError(msg)
41
43
  beta_raw = self.dataset.variables["beta_att"][:]
44
+ if utils.is_all_masked(beta_raw):
45
+ msg = "All beta_raw values are masked. Check the input file(s)."
46
+ raise LidarDataError(msg)
42
47
  if calibration_factor is None:
43
48
  logging.warning("Using default calibration factor")
44
49
  calibration_factor = 1
@@ -206,10 +206,11 @@ class Thies(Disdrometer):
206
206
  self.serial_number = first_id
207
207
 
208
208
  def _read_line(self, line: str, timestamp: datetime.datetime | None = None):
209
- raw_values = line.split(";")
209
+ raw_values = line.strip().strip(";").split(";")
210
210
  # Support custom truncated format used in Leipzig LIM.
211
- expected_columns = self.site_meta.get("truncate_columns", 521)
212
- if len(raw_values) != expected_columns:
211
+ expected_columns = self.site_meta.get("truncate_columns", 521) - 1
212
+ # Length matches telegram 4 or 5 (has 4 additional columns).
213
+ if len(raw_values) not in (expected_columns, expected_columns + 4):
213
214
  return
214
215
  for i, key in TELEGRAM4:
215
216
  if i >= expected_columns - 1:
@@ -246,7 +247,7 @@ class Thies(Disdrometer):
246
247
  self.raw_data[key].append(value)
247
248
  if expected_columns > 79:
248
249
  self.raw_data["spectrum"].append(
249
- np.array(list(map(int, raw_values[79:-2])), dtype="i2").reshape(
250
+ np.array(list(map(int, raw_values[79:519])), dtype="i2").reshape(
250
251
  self.n_diameter, self.n_velocity
251
252
  )
252
253
  )
cloudnetpy/utils.py CHANGED
@@ -8,9 +8,9 @@ import re
8
8
  import textwrap
9
9
  import uuid
10
10
  import warnings
11
- from collections.abc import Iterator
11
+ from collections.abc import Callable, Iterator
12
12
  from datetime import timezone
13
- from typing import Any, Literal, TypeVar
13
+ from typing import Literal, TypeVar
14
14
 
15
15
  import netCDF4
16
16
  import numpy as np
@@ -139,11 +139,19 @@ def binvec(x: np.ndarray | list) -> np.ndarray:
139
139
  return np.linspace(edge1, edge2, len(x) + 1)
140
140
 
141
141
 
142
+ REBIN_STAT = Literal["mean", "std", "max"]
143
+ REBIN_STAT_FN: dict[REBIN_STAT, Callable] = {
144
+ "mean": ma.mean,
145
+ "std": ma.std,
146
+ "max": ma.max,
147
+ }
148
+
149
+
142
150
  def rebin_2d(
143
151
  x_in: np.ndarray,
144
152
  array: np.ndarray,
145
153
  x_new: np.ndarray,
146
- statistic: Literal["mean", "std", "max"] = "mean",
154
+ statistic: REBIN_STAT = "mean",
147
155
  n_min: int = 1,
148
156
  *,
149
157
  keepdim: bool = False,
@@ -154,11 +162,7 @@ def rebin_2d(
154
162
  n_bins = len(x_new)
155
163
  counts = np.bincount(binn[binn >= 0], minlength=n_bins)
156
164
 
157
- stat_fn: Any = {
158
- "mean": ma.mean,
159
- "std": ma.std,
160
- "max": ma.max,
161
- }[statistic]
165
+ stat_fn = REBIN_STAT_FN[statistic]
162
166
 
163
167
  shape = array.shape if keepdim else (n_bins, array.shape[1])
164
168
  result: ma.MaskedArray = ma.masked_array(np.ones(shape, dtype="float32"), mask=True)
@@ -183,7 +187,7 @@ def rebin_1d(
183
187
  x_in: np.ndarray,
184
188
  array: np.ndarray | ma.MaskedArray,
185
189
  x_new: np.ndarray,
186
- statistic: str = "mean",
190
+ statistic: REBIN_STAT = "mean",
187
191
  ) -> ma.MaskedArray:
188
192
  """Rebins 1D array.
189
193
 
cloudnetpy/version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  MAJOR = 1
2
- MINOR = 78
3
- PATCH = 3
2
+ MINOR = 79
3
+ PATCH = 0
4
4
  __version__ = f"{MAJOR}.{MINOR}.{PATCH}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudnetpy
3
- Version: 1.78.3
3
+ Version: 1.79.0
4
4
  Summary: Python package for Cloudnet processing
5
5
  Author: Simo Tukiainen
6
6
  License: MIT License
@@ -4,12 +4,12 @@ cloudnetpy/cloudnetarray.py,sha256=uOYgpQ8hHh5fuHyip1HjnhsEda9_7dg7orYnbCRkTtI,4
4
4
  cloudnetpy/concat_lib.py,sha256=XQ5Sk8kfXqI0Q5HoomKWWhdZ1-m2thYDKGL7SKapITE,12851
5
5
  cloudnetpy/constants.py,sha256=YnoSzZm35NDooJfhlulSJBc7g0eSchT3yGytRaTaJEI,845
6
6
  cloudnetpy/datasource.py,sha256=Vx_I8S14nFAWKI0VbsW_-sllbVCRjTYxB7XH9b9PedQ,6268
7
- cloudnetpy/exceptions.py,sha256=hYbUtBwjCIfxnPe_5mELDEw87AWITBrwuo7WYIEKmJ8,1579
7
+ cloudnetpy/exceptions.py,sha256=GBrqCkGxX7qD78LPUxwHpJrEfIeVzbvhs6peWQSBmhM,1723
8
8
  cloudnetpy/metadata.py,sha256=lO7BCbVAzFoH3Nq-VuezYX0f7MnbG1Zp11g5GSiuQwM,6189
9
9
  cloudnetpy/output.py,sha256=gupxt4f_-eUrFsWMto8tnknoV-p9QauC9L6CJAqBILU,15988
10
10
  cloudnetpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- cloudnetpy/utils.py,sha256=HdcSNIgdxoZlP_jHl66ItheHLw_cDYZb7u6mZ5dfMNE,31952
12
- cloudnetpy/version.py,sha256=pYMEbxEa9ahzrcn_G9DIIY9enBLmzjF9ZpI-AB73HTw,72
11
+ cloudnetpy/utils.py,sha256=WczDeGN408XSgGeaRLXFmlLjgAS67lK1osV0YEuKmwo,32027
12
+ cloudnetpy/version.py,sha256=r_RTjOqOnzkut6bsKX5hTeLYlrSoHQYJsg8Ca85nAOQ,72
13
13
  cloudnetpy/categorize/__init__.py,sha256=s-SJaysvVpVVo5kidiruWQO6p3gv2TXwY1wEHYO5D6I,44
14
14
  cloudnetpy/categorize/atmos_utils.py,sha256=RcmbKxm2COkE7WEya0mK3yX5rzUbrewRVh3ekm01RtM,10598
15
15
  cloudnetpy/categorize/attenuation.py,sha256=Y_-fzmQTltWTqIZTulJhovC7a6ifpMcaAazDJcnMIOc,990
@@ -35,9 +35,9 @@ cloudnetpy/categorize/attenuations/rain_attenuation.py,sha256=qazJzRyXf9vbjJhh4y
35
35
  cloudnetpy/instruments/__init__.py,sha256=PEgrrQNoiOuN_ctYilmt4LV2QCLg1likPjJdWtuGlLs,528
36
36
  cloudnetpy/instruments/basta.py,sha256=Lb_EhQTI93S5Bd9osDbCE_tC8gZreRsHz7D2_dFOjmE,3793
37
37
  cloudnetpy/instruments/bowtie.py,sha256=EyE8HAE8rjO7JelJDbQte_rnwE3VoVJVc6TBpSNK3IU,3930
38
- cloudnetpy/instruments/ceilo.py,sha256=qM3AkQKHUblhRCD42HsB6lr82giBH-0g_VzoWHZDgeA,9535
38
+ cloudnetpy/instruments/ceilo.py,sha256=GnJYW6oadOApyQSKhzNyJXT4PhoQZlCY9QE4QcqLX8I,9559
39
39
  cloudnetpy/instruments/ceilometer.py,sha256=ati9-fUQ54K9tvynIPB-nlBYwtvBVaQtUCjVCLNB67w,12059
40
- cloudnetpy/instruments/cl61d.py,sha256=g6DNBFju3wYhLFl32DKmC8pUup7y-EupXoUU0fuoGGA,1990
40
+ cloudnetpy/instruments/cl61d.py,sha256=0QMqXHIy0hn2mksAwTdaKMOaEWjsZmj7QZ8hCbcHwxE,2225
41
41
  cloudnetpy/instruments/cloudnet_instrument.py,sha256=SGPsRYYoGPoRoDY7hHJcKUVX0A23X0Telc00Fu01PnY,4495
42
42
  cloudnetpy/instruments/copernicus.py,sha256=hCphEKyFCc3f1uLRdjL2435kuh64M5q-V1bI68bzGbA,6528
43
43
  cloudnetpy/instruments/fd12p.py,sha256=aGYpkczdSl7FSmK1bByMnpUBD5GAl7RTKkopt0cpWas,6822
@@ -60,7 +60,7 @@ cloudnetpy/instruments/weather_station.py,sha256=pZK7I5bk1USDRoTeIhZoWzbka9ciea5
60
60
  cloudnetpy/instruments/disdrometer/__init__.py,sha256=lyjwttWvFvuwYxEkusoAvgRcbBmglmOp5HJOpXUqLWo,93
61
61
  cloudnetpy/instruments/disdrometer/common.py,sha256=g52iK2aNp3Z88kovUmGVpC54NZomPa9D871gzO0AmQ4,9267
62
62
  cloudnetpy/instruments/disdrometer/parsivel.py,sha256=HJZrEysQkx9MiIVPDV25CYHpXi_SjgZlgO-otoaKK34,25640
63
- cloudnetpy/instruments/disdrometer/thies.py,sha256=4T15XW5Hu0SviL_a_PWieIWkZzaVJY92Qm7psSa1kPU,10943
63
+ cloudnetpy/instruments/disdrometer/thies.py,sha256=JwwXExDePJy-57hdWXy0kC84oLqcJbwYopGvmsH605E,11064
64
64
  cloudnetpy/model_evaluation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  cloudnetpy/model_evaluation/file_handler.py,sha256=jnpTxwxLSZdt08By0cjFDmq1KWC4fhJaN_MfjgA8ijQ,6440
66
66
  cloudnetpy/model_evaluation/metadata.py,sha256=PAsnOqcUoV3CJwplgWiVCF9Zt4io8tqj7CIgS4fEL-8,8412
@@ -117,10 +117,10 @@ cloudnetpy/products/lwc.py,sha256=sl6Al2tuH3KkCBrPbWTmuz3jlD5UQJ4D6qBsn1tt2CQ,18
117
117
  cloudnetpy/products/mie_lu_tables.nc,sha256=It4fYpqJXlqOgL8jeZ-PxGzP08PMrELIDVe55y9ob58,16637951
118
118
  cloudnetpy/products/mwr_tools.py,sha256=8HPZpQMTojKZP1JS1S83IE0sxmbDE9bxlaWoqmGnUZE,6199
119
119
  cloudnetpy/products/product_tools.py,sha256=uu4l6reuGbPcW3TgttbaSrqIKbyYGhBVTdnC7opKvmg,11101
120
- cloudnetpy-1.78.3.dist-info/licenses/LICENSE,sha256=wcZF72bdaoG9XugpyE95Juo7lBQOwLuTKBOhhtANZMM,1094
120
+ cloudnetpy-1.79.0.dist-info/licenses/LICENSE,sha256=wcZF72bdaoG9XugpyE95Juo7lBQOwLuTKBOhhtANZMM,1094
121
121
  docs/source/conf.py,sha256=IKiFWw6xhUd8NrCg0q7l596Ck1d61XWeVjIFHVSG9Og,1490
122
- cloudnetpy-1.78.3.dist-info/METADATA,sha256=rwmnbibL2ih6Bub0PwnyBbDzEYoSFQLS_IAuERyxDb0,5796
123
- cloudnetpy-1.78.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
124
- cloudnetpy-1.78.3.dist-info/entry_points.txt,sha256=HhY7LwCFk4qFgDlXx_Fy983ZTd831WlhtdPIzV-Y3dY,51
125
- cloudnetpy-1.78.3.dist-info/top_level.txt,sha256=ibSPWRr6ojS1i11rtBFz2_gkIe68mggj7aeswYfaOo0,16
126
- cloudnetpy-1.78.3.dist-info/RECORD,,
122
+ cloudnetpy-1.79.0.dist-info/METADATA,sha256=Z5jTV-IAQDqCM5oV-TQuODjFGDm9K0Iy6itew-2qD4g,5796
123
+ cloudnetpy-1.79.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
124
+ cloudnetpy-1.79.0.dist-info/entry_points.txt,sha256=HhY7LwCFk4qFgDlXx_Fy983ZTd831WlhtdPIzV-Y3dY,51
125
+ cloudnetpy-1.79.0.dist-info/top_level.txt,sha256=ibSPWRr6ojS1i11rtBFz2_gkIe68mggj7aeswYfaOo0,16
126
+ cloudnetpy-1.79.0.dist-info/RECORD,,