cloudnetpy 1.55.20__py3-none-any.whl → 1.55.22__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/categorize/atmos.py +46 -14
- cloudnetpy/categorize/atmos_utils.py +11 -1
- cloudnetpy/categorize/categorize.py +38 -21
- cloudnetpy/categorize/classify.py +31 -9
- cloudnetpy/categorize/containers.py +19 -7
- cloudnetpy/categorize/droplet.py +24 -8
- cloudnetpy/categorize/falling.py +17 -7
- cloudnetpy/categorize/freezing.py +19 -5
- cloudnetpy/categorize/insects.py +27 -14
- cloudnetpy/categorize/lidar.py +38 -36
- cloudnetpy/categorize/melting.py +19 -9
- cloudnetpy/categorize/model.py +28 -9
- cloudnetpy/categorize/mwr.py +4 -2
- cloudnetpy/categorize/radar.py +58 -22
- cloudnetpy/cloudnetarray.py +15 -6
- cloudnetpy/concat_lib.py +39 -16
- cloudnetpy/constants.py +7 -0
- cloudnetpy/datasource.py +39 -19
- cloudnetpy/instruments/basta.py +6 -2
- cloudnetpy/instruments/campbell_scientific.py +33 -16
- cloudnetpy/instruments/ceilo.py +30 -13
- cloudnetpy/instruments/ceilometer.py +76 -37
- cloudnetpy/instruments/cl61d.py +8 -3
- cloudnetpy/instruments/cloudnet_instrument.py +2 -1
- cloudnetpy/instruments/copernicus.py +27 -14
- cloudnetpy/instruments/disdrometer/common.py +51 -32
- cloudnetpy/instruments/disdrometer/parsivel.py +79 -48
- cloudnetpy/instruments/disdrometer/thies.py +10 -6
- cloudnetpy/instruments/galileo.py +23 -12
- cloudnetpy/instruments/hatpro.py +27 -11
- cloudnetpy/instruments/instruments.py +4 -1
- cloudnetpy/instruments/lufft.py +20 -11
- cloudnetpy/instruments/mira.py +60 -49
- cloudnetpy/instruments/mrr.py +31 -20
- cloudnetpy/instruments/nc_lidar.py +15 -6
- cloudnetpy/instruments/nc_radar.py +31 -22
- cloudnetpy/instruments/pollyxt.py +36 -21
- cloudnetpy/instruments/radiometrics.py +32 -18
- cloudnetpy/instruments/rpg.py +48 -22
- cloudnetpy/instruments/rpg_reader.py +39 -30
- cloudnetpy/instruments/vaisala.py +39 -27
- cloudnetpy/instruments/weather_station.py +15 -11
- cloudnetpy/metadata.py +3 -1
- cloudnetpy/model_evaluation/file_handler.py +31 -21
- cloudnetpy/model_evaluation/metadata.py +3 -1
- cloudnetpy/model_evaluation/model_metadata.py +1 -1
- cloudnetpy/model_evaluation/plotting/plot_tools.py +20 -15
- cloudnetpy/model_evaluation/plotting/plotting.py +114 -64
- cloudnetpy/model_evaluation/products/advance_methods.py +48 -28
- cloudnetpy/model_evaluation/products/grid_methods.py +44 -19
- cloudnetpy/model_evaluation/products/model_products.py +22 -18
- cloudnetpy/model_evaluation/products/observation_products.py +15 -9
- cloudnetpy/model_evaluation/products/product_resampling.py +14 -4
- cloudnetpy/model_evaluation/products/tools.py +16 -7
- cloudnetpy/model_evaluation/statistics/statistical_methods.py +28 -15
- cloudnetpy/model_evaluation/tests/e2e/conftest.py +3 -3
- cloudnetpy/model_evaluation/tests/e2e/process_cf/main.py +9 -5
- cloudnetpy/model_evaluation/tests/e2e/process_cf/tests.py +14 -13
- cloudnetpy/model_evaluation/tests/e2e/process_iwc/main.py +9 -5
- cloudnetpy/model_evaluation/tests/e2e/process_iwc/tests.py +14 -13
- cloudnetpy/model_evaluation/tests/e2e/process_lwc/main.py +9 -5
- cloudnetpy/model_evaluation/tests/e2e/process_lwc/tests.py +14 -13
- cloudnetpy/model_evaluation/tests/unit/conftest.py +11 -11
- cloudnetpy/model_evaluation/tests/unit/test_advance_methods.py +33 -27
- cloudnetpy/model_evaluation/tests/unit/test_grid_methods.py +83 -83
- cloudnetpy/model_evaluation/tests/unit/test_model_products.py +23 -21
- cloudnetpy/model_evaluation/tests/unit/test_observation_products.py +24 -25
- cloudnetpy/model_evaluation/tests/unit/test_plot_tools.py +40 -39
- cloudnetpy/model_evaluation/tests/unit/test_plotting.py +12 -11
- cloudnetpy/model_evaluation/tests/unit/test_statistical_methods.py +30 -30
- cloudnetpy/model_evaluation/tests/unit/test_tools.py +18 -17
- cloudnetpy/model_evaluation/utils.py +3 -2
- cloudnetpy/output.py +45 -19
- cloudnetpy/plotting/plot_meta.py +35 -11
- cloudnetpy/plotting/plotting.py +172 -104
- cloudnetpy/products/classification.py +20 -8
- cloudnetpy/products/der.py +25 -10
- cloudnetpy/products/drizzle.py +41 -26
- cloudnetpy/products/drizzle_error.py +10 -5
- cloudnetpy/products/drizzle_tools.py +43 -24
- cloudnetpy/products/ier.py +10 -5
- cloudnetpy/products/iwc.py +16 -9
- cloudnetpy/products/lwc.py +34 -12
- cloudnetpy/products/mwr_multi.py +4 -1
- cloudnetpy/products/mwr_single.py +4 -1
- cloudnetpy/products/product_tools.py +33 -10
- cloudnetpy/utils.py +175 -74
- cloudnetpy/version.py +1 -1
- {cloudnetpy-1.55.20.dist-info → cloudnetpy-1.55.22.dist-info}/METADATA +11 -10
- cloudnetpy-1.55.22.dist-info/RECORD +114 -0
- docs/source/conf.py +2 -2
- cloudnetpy-1.55.20.dist-info/RECORD +0 -114
- {cloudnetpy-1.55.20.dist-info → cloudnetpy-1.55.22.dist-info}/LICENSE +0 -0
- {cloudnetpy-1.55.20.dist-info → cloudnetpy-1.55.22.dist-info}/WHEEL +0 -0
- {cloudnetpy-1.55.20.dist-info → cloudnetpy-1.55.22.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
"""General helper classes and functions for all products."""
|
2
2
|
import os
|
3
|
-
from
|
3
|
+
from typing import NamedTuple
|
4
4
|
|
5
5
|
import netCDF4
|
6
6
|
import numpy as np
|
@@ -11,16 +11,26 @@ from cloudnetpy import constants, utils
|
|
11
11
|
from cloudnetpy.categorize import atmos_utils
|
12
12
|
from cloudnetpy.datasource import DataSource
|
13
13
|
|
14
|
-
|
14
|
+
|
15
|
+
class IceCoefficients(NamedTuple):
|
16
|
+
"""Coefficients for ice effective radius retrieval."""
|
17
|
+
|
18
|
+
K2liquid0: float
|
19
|
+
ZT: float
|
20
|
+
T: float
|
21
|
+
Z: float
|
22
|
+
c: float
|
15
23
|
|
16
24
|
|
17
25
|
class CategorizeBits:
|
18
26
|
"""Class holding information about category and quality bits.
|
19
27
|
|
20
28
|
Args:
|
29
|
+
----
|
21
30
|
categorize_file (str): Categorize file name.
|
22
31
|
|
23
32
|
Attributes:
|
33
|
+
----------
|
24
34
|
category_bits (dict): Dictionary containing boolean fields for `droplet`,
|
25
35
|
`falling`, `cold`, `melting`, `aerosol`, `insect`.
|
26
36
|
|
@@ -60,8 +70,7 @@ class CategorizeBits:
|
|
60
70
|
except KeyError as err:
|
61
71
|
raise KeyError from err
|
62
72
|
keys = getattr(CategorizeBits, f"{bit_type}_keys")
|
63
|
-
|
64
|
-
return bits
|
73
|
+
return {key: utils.isbit(bitfield, i) for i, key in enumerate(keys)}
|
65
74
|
|
66
75
|
|
67
76
|
class ProductClassification(CategorizeBits):
|
@@ -69,9 +78,11 @@ class ProductClassification(CategorizeBits):
|
|
69
78
|
of various Cloudnet products. Child of CategorizeBits class.
|
70
79
|
|
71
80
|
Args:
|
81
|
+
----
|
72
82
|
categorize_file (str): Categorize file name.
|
73
83
|
|
74
84
|
Attributes:
|
85
|
+
----------
|
75
86
|
is_rain (ndarray): 1D array denoting rainy profiles.
|
76
87
|
|
77
88
|
"""
|
@@ -147,7 +158,8 @@ class IceSource(DataSource):
|
|
147
158
|
self.coefficients = self._get_coefficients()
|
148
159
|
|
149
160
|
def append_main_variable_including_rain(
|
150
|
-
self,
|
161
|
+
self,
|
162
|
+
ice_classification: IceClassification,
|
151
163
|
) -> None:
|
152
164
|
"""Adds the main variable (including ice above rain)."""
|
153
165
|
data_including_rain = self._convert_z()
|
@@ -177,7 +189,8 @@ class IceSource(DataSource):
|
|
177
189
|
def _get_coefficients(self) -> IceCoefficients:
|
178
190
|
"""Returns coefficients for ice effective radius retrieval.
|
179
191
|
|
180
|
-
References
|
192
|
+
References
|
193
|
+
----------
|
181
194
|
Hogan et.al. 2006, https://doi.org/10.1175/JAM2340.1
|
182
195
|
"""
|
183
196
|
if self.product == "ier":
|
@@ -190,8 +203,12 @@ class IceSource(DataSource):
|
|
190
203
|
|
191
204
|
def _convert_z(self, z_variable: str = "Z") -> np.ndarray:
|
192
205
|
"""Calculates temperature weighted z, i.e. ice effective radius [m]."""
|
193
|
-
|
194
|
-
|
206
|
+
if self.product not in ("iwc", "ier"):
|
207
|
+
msg = f"Invalid product: {self.product}"
|
208
|
+
raise ValueError(msg)
|
209
|
+
if z_variable not in ("Z", "Z_sensitivity"):
|
210
|
+
msg = f"Invalid z_variable: {z_variable}"
|
211
|
+
raise ValueError(msg)
|
195
212
|
temperature = (
|
196
213
|
self.temperature if z_variable == "Z" else ma.mean(self.temperature, axis=0)
|
197
214
|
)
|
@@ -214,7 +231,8 @@ class IceSource(DataSource):
|
|
214
231
|
|
215
232
|
def _get_z_factor(self) -> float:
|
216
233
|
"""Returns empirical scaling factor for radar echo."""
|
217
|
-
|
234
|
+
k2 = np.array(self.coefficients.K2liquid0) / 0.93
|
235
|
+
return float(utils.lin2db(k2))
|
218
236
|
|
219
237
|
|
220
238
|
def get_is_rain(filename: str) -> np.ndarray:
|
@@ -223,7 +241,8 @@ def get_is_rain(filename: str) -> np.ndarray:
|
|
223
241
|
except KeyError:
|
224
242
|
rainfall_rate = read_nc_fields(filename, "rain_rate")
|
225
243
|
is_rain = rainfall_rate != 0
|
226
|
-
|
244
|
+
if not isinstance(is_rain, ma.MaskedArray):
|
245
|
+
is_rain = ma.array(is_rain)
|
227
246
|
is_rain[is_rain.mask] = True
|
228
247
|
return np.array(is_rain)
|
229
248
|
|
@@ -232,10 +251,12 @@ def read_nc_fields(nc_file: str, names: str | list) -> ma.MaskedArray | list:
|
|
232
251
|
"""Reads selected variables from a netCDF file.
|
233
252
|
|
234
253
|
Args:
|
254
|
+
----
|
235
255
|
nc_file: netCDF file name.
|
236
256
|
names: Variables to be read, e.g. 'temperature' or ['ldr', 'lwp'].
|
237
257
|
|
238
258
|
Returns:
|
259
|
+
-------
|
239
260
|
ndarray/list: Array in case of one variable passed as a string.
|
240
261
|
List of arrays otherwise.
|
241
262
|
|
@@ -250,11 +271,13 @@ def interpolate_model(cat_file: str, names: str | list) -> dict[str, np.ndarray]
|
|
250
271
|
"""Interpolates 2D model field into dense Cloudnet grid.
|
251
272
|
|
252
273
|
Args:
|
274
|
+
----
|
253
275
|
cat_file: Categorize file name.
|
254
276
|
names: Model variable to be interpolated, e.g. 'temperature' or ['temperature',
|
255
277
|
'pressure'].
|
256
278
|
|
257
279
|
Returns:
|
280
|
+
-------
|
258
281
|
dict: Interpolated variables.
|
259
282
|
|
260
283
|
"""
|