cloudnetpy 1.85.0__py3-none-any.whl → 1.85.2__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.
@@ -9,6 +9,7 @@ from os import PathLike
9
9
  from tempfile import NamedTemporaryFile, TemporaryDirectory
10
10
  from uuid import UUID
11
11
 
12
+ import numpy as np
12
13
  from numpy import ma
13
14
 
14
15
  from cloudnetpy import concat_lib, output, utils
@@ -74,9 +75,7 @@ def mira2nc(
74
75
  mira.sort_timestamps()
75
76
  mira.remove_duplicate_timestamps()
76
77
  mira.linear_to_db(("Zh", "ldr", "SNR"))
77
- n_profiles = utils.n_elements(mira.time, 5, "time")
78
- valid_ind = utils.remove_masked_blocks(mira.data["Zh"][:], limit=n_profiles)
79
- mira.screen_time_indices(valid_ind)
78
+ mira.screen_low_power()
80
79
 
81
80
  if "snr_limit" in site_meta and site_meta["snr_limit"] is not None:
82
81
  snr_limit = site_meta["snr_limit"]
@@ -151,6 +150,24 @@ class Mira(NcRadar):
151
150
  time_stamps = self.getvar("time")
152
151
  return utils.seconds2date(float(time_stamps[0]), self.epoch).date()
153
152
 
153
+ def screen_low_power(self) -> None:
154
+ """Screen times with average transmit power close to zero."""
155
+ if "tpow" not in self.data:
156
+ logging.warning("Variable tpow is missing")
157
+ return
158
+ tpow = self.data["tpow"][:]
159
+ # Threshold for abnormally low power e.g. Limassol 2024-10-20. Average
160
+ # power should 30 to 60 W according to MIRA-35 data sheet. Based on a
161
+ # random sample, typical range is 15 to 25 W. In Lampedusa, the power is
162
+ # constantly as low as 1.9 W.
163
+ is_low = tpow < 1
164
+ n_removed = np.count_nonzero(is_low)
165
+ if n_removed > 0:
166
+ logging.warning(
167
+ "Filtering %s profiles due to low average transmit power", n_removed
168
+ )
169
+ self.screen_time_indices(~is_low)
170
+
154
171
  def screen_invalid_ldr(self) -> None:
155
172
  """Masks LDR in MIRA STSR mode data.
156
173
  Is there a better way to identify this mode?
@@ -284,6 +301,7 @@ def _get_keymap(filetype: str) -> dict[str, str]:
284
301
  ("prf", "prf"),
285
302
  ("rg0", "rg0"),
286
303
  ("NyquistVelocity", "NyquistVelocity"), # variable in some mmclx files
304
+ ("tpow", "tpow"),
287
305
  ]
288
306
  ),
289
307
  }
@@ -311,6 +329,9 @@ ATTRIBUTES = {
311
329
  "prf": MetaData(
312
330
  long_name="Pulse Repetition Frequency", units="Hz", dimensions=("time",)
313
331
  ),
332
+ "tpow": MetaData(
333
+ long_name="Average Transmit Power", units="W", dimensions=("time",)
334
+ ),
314
335
  "zenith_offset": MetaData(
315
336
  long_name="Zenith offset of the instrument",
316
337
  units="degrees",
@@ -83,6 +83,10 @@ def rpg2nc(
83
83
  valid_ind = fmcw.add_zenith_angle()
84
84
  fmcw.screen_time_indices(valid_ind)
85
85
  fmcw.add_height()
86
+ if len(np.unique(fmcw.data["time"][:].astype("f4"))) != len(fmcw.data["time"][:]):
87
+ msg = "Convert time to f8 to keep values unique in netCDF"
88
+ logging.info(msg)
89
+ fmcw.data["time"].data_type = "f8"
86
90
  attributes = output.add_time_attribute(RPG_ATTRIBUTES, fmcw.date)
87
91
  output.update_attributes(fmcw.data, attributes)
88
92
  output.save_level1b(fmcw, output_file, uuid)
@@ -137,19 +141,17 @@ def _reduce_header(header: dict) -> dict:
137
141
  """Removes duplicate header data. Otherwise, we would need n_files dimension."""
138
142
  reduced_header = {}
139
143
  for key, data in header.items():
144
+ # Handle outliers in latitude and longitude (e.g. Galati 2024-02-11):
145
+ if key in ("latitude", "longitude"):
146
+ reduced_header[key] = ma.median(data)
147
+ continue
140
148
  first_profile_value = data[0]
141
149
  is_identical_value = bool(
142
150
  np.isclose(data, first_profile_value, rtol=1e-2).all(),
143
151
  )
144
152
  if is_identical_value is False:
145
153
  msg = f"Inconsistent header: {key}: {data}"
146
- if key in (
147
- "latitude",
148
- "longitude",
149
- "sample_duration",
150
- "calibration_interval",
151
- "noise_threshold",
152
- ):
154
+ if key in ("sample_duration", "calibration_interval", "noise_threshold"):
153
155
  logging.warning(msg)
154
156
  else:
155
157
  raise InconsistentDataError(msg)
@@ -138,12 +138,12 @@ def _horizontal_wind_from_doppler_lidar_file(
138
138
  t = np.broadcast_to(time[:, None], mask.shape)[~mask]
139
139
  h = np.broadcast_to(height[None, :], mask.shape)[~mask]
140
140
 
141
- if len(np.unique(t)) < 2 or len(np.unique(h)) < 2:
141
+ if len(np.unique(t)) < 3 or len(np.unique(h)) < 3:
142
142
  msg = "Not enough unique values for interpolation"
143
143
  raise ValidTimeStampError(msg)
144
144
 
145
- interp_linear = LinearNDInterpolator(list(zip(t, h, strict=False)), V[~mask])
146
- interp_nearest = NearestNDInterpolator(list(zip(t, h, strict=False)), V[~mask])
145
+ interp_linear = LinearNDInterpolator(list(zip(t, h, strict=True)), V[~mask])
146
+ interp_nearest = NearestNDInterpolator(list(zip(t, h, strict=True)), V[~mask])
147
147
  T, H = np.meshgrid(time, height, indexing="ij")
148
148
  V_linear = interp_linear(T, H)
149
149
  V_nearest = interp_nearest(T, H)
cloudnetpy/utils.py CHANGED
@@ -1035,17 +1035,6 @@ def path_lengths_from_ground(height: npt.NDArray) -> npt.NDArray:
1035
1035
  return np.diff(height, prepend=0)
1036
1036
 
1037
1037
 
1038
- def remove_masked_blocks(array: ma.MaskedArray, limit: int = 50) -> npt.NDArray:
1039
- """Filters out large blocks of completely masked profiles."""
1040
- if array.ndim == 1:
1041
- return np.array(not ma.all(array.mask))
1042
- masked_profiles = ma.all(array.mask, axis=1)
1043
- labeled_array, _ = ndimage.label(masked_profiles)
1044
- mask = np.bincount(labeled_array) < limit
1045
- mask[0] = True
1046
- return mask[labeled_array]
1047
-
1048
-
1049
1038
  def sha256sum(filename: str | PathLike) -> str:
1050
1039
  """Calculates hash of file using sha-256."""
1051
1040
  return _calc_hash_sum(filename, "sha256", is_base64=False)
cloudnetpy/version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  MAJOR = 1
2
2
  MINOR = 85
3
- PATCH = 0
3
+ PATCH = 2
4
4
  __version__ = f"{MAJOR}.{MINOR}.{PATCH}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudnetpy
3
- Version: 1.85.0
3
+ Version: 1.85.2
4
4
  Summary: Python package for Cloudnet processing
5
5
  Author: Simo Tukiainen
6
6
  License: MIT License
@@ -8,8 +8,8 @@ cloudnetpy/exceptions.py,sha256=ZB3aUwjVRznR0CcZ5sZHrB0yz13URDf52Ksv7G7C7EA,1817
8
8
  cloudnetpy/metadata.py,sha256=CFpXmdEkVPzvLPv2xHIR-aMMQ-TR26KfESYw-98j7sk,7213
9
9
  cloudnetpy/output.py,sha256=0bybnILsgKHWIuw2GYkqTz2iMCJDZLUN25IQ9o_v3Cg,14968
10
10
  cloudnetpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- cloudnetpy/utils.py,sha256=O5kEXMt03fFKabPxRiCfuahVfTqa4fWWZ11orQnQeXU,33530
12
- cloudnetpy/version.py,sha256=lLtOfbPTOgEcz4-gTcFPYaor-U52n66zRHoLKjGWJ30,72
11
+ cloudnetpy/utils.py,sha256=x3hukn7wuOyF3ctG8EOhvLbSUHOVKLW9ez2LzTjeolU,33110
12
+ cloudnetpy/version.py,sha256=n8Y4NlhyE8jS82m6d9Bxhu9NW4bStS8hn1r3KqZrqfA,72
13
13
  cloudnetpy/categorize/__init__.py,sha256=gtvzWr0IDRn2oA6yHBvinEhTGTuub-JkrOv93lBsgrE,61
14
14
  cloudnetpy/categorize/atmos_utils.py,sha256=uWc9TABVYPI0sn4H5Az9Jf6NVRaWyEKIi17f0pAJQxE,10679
15
15
  cloudnetpy/categorize/attenuation.py,sha256=Y_-fzmQTltWTqIZTulJhovC7a6ifpMcaAazDJcnMIOc,990
@@ -46,14 +46,14 @@ cloudnetpy/instruments/galileo.py,sha256=f_-GkRxhNaQPbI8HpOwSmoKfGqyjmD16A0ZFgwL
46
46
  cloudnetpy/instruments/hatpro.py,sha256=TGOqwW0TfoPEYk13MFvFzwgJGzm6MVE5AsPavcIoj3I,10248
47
47
  cloudnetpy/instruments/instruments.py,sha256=WZgH7HjzM9Ane1CSnYCSLidbST8hunUeSt2lPntq9As,4999
48
48
  cloudnetpy/instruments/lufft.py,sha256=G6KeJOeltLUlGCHHEk8ns2K7WJ9ImAr25rSB2JltawE,4286
49
- cloudnetpy/instruments/mira.py,sha256=XqmbytpeCJ2-hNugxdsXSBUDB8SAUc97_6lo5mHFG8E,11840
49
+ cloudnetpy/instruments/mira.py,sha256=jJ17xJmXwqfvZ7hgJaongRrRxoQpivMEQYssgSQFYbA,12638
50
50
  cloudnetpy/instruments/mrr.py,sha256=z50VYLOBW2o7enU7FHZYNFQRW2goEQpeGe7-iCBRQtg,6020
51
51
  cloudnetpy/instruments/nc_lidar.py,sha256=PtZauDdI3bX3bv4gIVvV6N53e2Co-ehBL_tByHM9hj8,1713
52
52
  cloudnetpy/instruments/nc_radar.py,sha256=XFKxPLKivnhHTgjE5HFrxjWZ0oCifhDUAog051vkMiY,7533
53
53
  cloudnetpy/instruments/pollyxt.py,sha256=IFq_RJrhgJ79OVyuo48PwYQK_zZ6VZFB_S5bEirRyzs,10566
54
54
  cloudnetpy/instruments/radiometrics.py,sha256=QKfnrZlQ0sFcFjmv1ShnCMTJQv64w4akjK-JAIY4gCg,16116
55
55
  cloudnetpy/instruments/rain_e_h3.py,sha256=fjv3SgeUNx9GisYqLrBnX9AjnO17VtouyoPh12VE9uo,5465
56
- cloudnetpy/instruments/rpg.py,sha256=R1rUdeSADvB1IMkGOF1S0rUEJDGEI_19SPrmErZpn5M,18825
56
+ cloudnetpy/instruments/rpg.py,sha256=d7qlfez1Pe326d4xkQrTk2xRxvs3g68LEGehErdoBoc,19122
57
57
  cloudnetpy/instruments/rpg_reader.py,sha256=NaOtTxXx20PozNTj1xNvmbsEsAxuplFXRzBiM1_-Zg4,11651
58
58
  cloudnetpy/instruments/toa5.py,sha256=CfmmBMv5iMGaWHIGBK01Rw24cuXC1R1RMNTXkmsm340,1760
59
59
  cloudnetpy/instruments/vaisala.py,sha256=tu7aljkMKep0uCWz-Sd-GuBXF_Yy421a4nHy0ffpMoc,4725
@@ -111,17 +111,17 @@ cloudnetpy/products/der.py,sha256=UXdAxmmwChVVWSI4QSGAXphfMnbymGRTtGdKWEvh-J4,13
111
111
  cloudnetpy/products/drizzle.py,sha256=0h1N_WVjC2GgIkAN-4ydOwl7WJn3psxeqmPHfX8WHhQ,11935
112
112
  cloudnetpy/products/drizzle_error.py,sha256=QN98Io9UsBoEYxKBqfwoS88OGBiK5U5RYnVQjyTWHCI,6220
113
113
  cloudnetpy/products/drizzle_tools.py,sha256=xYMB8Qxp-_wKzMv_XC6u6iMfRnEhEtmDpCHSQAbDToo,11201
114
- cloudnetpy/products/epsilon.py,sha256=a796W_OuHxbSiG7yL2pcTArnaMNwYG8eAA8sQ93dIrY,7930
114
+ cloudnetpy/products/epsilon.py,sha256=EHrpfAbykQv4PYdi2yk7cQxOrg-kL-FhzGPVnPm98C0,7928
115
115
  cloudnetpy/products/ier.py,sha256=Eb5AK-6l5mN_7vWP1cxcXQzj886zAwDDsHXueUju0N0,6262
116
116
  cloudnetpy/products/iwc.py,sha256=pXl0xOFDD6AzGaAp_GzD2yapjOc7hXKTno9Q5G6HCOo,9826
117
117
  cloudnetpy/products/lwc.py,sha256=xsNiiG6dGKIkWaFk0xWTabc1bZ4ULf6SqcqHs7itAUk,19339
118
118
  cloudnetpy/products/mie_lu_tables.nc,sha256=It4fYpqJXlqOgL8jeZ-PxGzP08PMrELIDVe55y9ob58,16637951
119
119
  cloudnetpy/products/mwr_tools.py,sha256=MMWnp68U7bv157-CPB2VeTQvaR6zl7sexbBT_kJ_pn8,6734
120
120
  cloudnetpy/products/product_tools.py,sha256=eyqIw_0KhlpmmYQE69RpGdRIAOW7JVPlEgkTBp2kdps,11302
121
- cloudnetpy-1.85.0.dist-info/licenses/LICENSE,sha256=wcZF72bdaoG9XugpyE95Juo7lBQOwLuTKBOhhtANZMM,1094
121
+ cloudnetpy-1.85.2.dist-info/licenses/LICENSE,sha256=wcZF72bdaoG9XugpyE95Juo7lBQOwLuTKBOhhtANZMM,1094
122
122
  docs/source/conf.py,sha256=IKiFWw6xhUd8NrCg0q7l596Ck1d61XWeVjIFHVSG9Og,1490
123
- cloudnetpy-1.85.0.dist-info/METADATA,sha256=RWZNjL4m1yNEhDoSpqzyUODXSsh3AULjma2QRrNd2HU,5836
124
- cloudnetpy-1.85.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
125
- cloudnetpy-1.85.0.dist-info/entry_points.txt,sha256=HhY7LwCFk4qFgDlXx_Fy983ZTd831WlhtdPIzV-Y3dY,51
126
- cloudnetpy-1.85.0.dist-info/top_level.txt,sha256=ibSPWRr6ojS1i11rtBFz2_gkIe68mggj7aeswYfaOo0,16
127
- cloudnetpy-1.85.0.dist-info/RECORD,,
123
+ cloudnetpy-1.85.2.dist-info/METADATA,sha256=0Hi0m1LJX0OWv2eGf1x4wQY4qiiqb2UxmBiA5BYStLQ,5836
124
+ cloudnetpy-1.85.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
125
+ cloudnetpy-1.85.2.dist-info/entry_points.txt,sha256=HhY7LwCFk4qFgDlXx_Fy983ZTd831WlhtdPIzV-Y3dY,51
126
+ cloudnetpy-1.85.2.dist-info/top_level.txt,sha256=ibSPWRr6ojS1i11rtBFz2_gkIe68mggj7aeswYfaOo0,16
127
+ cloudnetpy-1.85.2.dist-info/RECORD,,