cloudnetpy 1.51.1__py3-none-any.whl → 1.52.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.
@@ -36,7 +36,7 @@ def hatpro2l1c(
36
36
  Args:
37
37
  mwr_dir: Folder containing one day of HATPRO files.
38
38
  output_file: Output file name.
39
- site_meta: Dictionary containing information about the site
39
+ site_meta: Dictionary containing information about the site and instrument
40
40
  uuid: Set specific UUID for the file.
41
41
  date: Expected date in the input files.
42
42
 
@@ -44,7 +44,16 @@ def hatpro2l1c(
44
44
  UUID of the generated file.
45
45
  """
46
46
 
47
- hatpro_raw = mwrpy.lev1_to_nc(site_meta["coeffs_dir"], "1C01", mwr_dir)
47
+ coeff_files = site_meta.get("coefficientFiles", None)
48
+
49
+ hatpro_raw = mwrpy.lev1_to_nc(
50
+ "1C01",
51
+ mwr_dir,
52
+ output_file=output_file,
53
+ coeff_files=coeff_files,
54
+ instrument_config=site_meta,
55
+ )
56
+
48
57
  hatpro = HatproL1c(hatpro_raw, site_meta)
49
58
 
50
59
  timestamps = hatpro.data["time"][:]
@@ -75,7 +84,7 @@ def hatpro2l1c(
75
84
  nc.cloudnet_file_type = "mwr-l1c"
76
85
  nc.title = nc.title.replace("radiometer", "radiometer Level 1c")
77
86
  nc.mwrpy_version = mwrpy_version
78
- nc.mwrpy_coefficients = site_meta["coeffs_dir"]
87
+ nc.mwrpy_coefficients = ", ".join(site_meta["coefficientLinks"])
79
88
 
80
89
  return uuid
81
90
 
@@ -483,8 +483,7 @@ def _plot_disdrometer(ax, data: ndarray, time: ndarray, name: str, unit: str):
483
483
 
484
484
  def _plot_hatpro(ax, data: dict, full_path: str):
485
485
  tb = _pointing_filter(full_path, data["tb"])
486
- time = _pointing_filter(full_path, data["time"])
487
- ax.plot(time, tb, color="royalblue", linestyle="-", linewidth=1)
486
+ ax.plot(data["time"], tb, color="royalblue", linestyle="-", linewidth=1)
488
487
  set_ax(
489
488
  ax,
490
489
  max_y=np.max(tb) + 0.5,
@@ -493,36 +492,21 @@ def _plot_hatpro(ax, data: dict, full_path: str):
493
492
  )
494
493
 
495
494
 
496
- def _elevation_filter(full_path: str, data_field: ndarray, ele_range: tuple) -> ndarray:
497
- """Filters data for specified range of elevation angles."""
498
- with netCDF4.Dataset(full_path) as nc:
499
- if "ele" in nc.variables:
500
- elevation = ptools.read_nc_fields(full_path, "ele")
501
- if data_field.ndim > 1:
502
- data_field = data_field[
503
- (elevation >= ele_range[0]) & (elevation <= ele_range[1]), :
504
- ]
505
- else:
506
- data_field = data_field[
507
- (elevation >= ele_range[0]) & (elevation <= ele_range[1])
508
- ]
509
- return data_field
510
-
511
-
512
495
  def _pointing_filter(
513
- full_path: str, data_field: ndarray, ele_range: tuple = (0, 91), status: int = 0
496
+ full_path: str, data: ndarray, zenith_limit=5, status: int = 0
514
497
  ) -> ndarray:
515
- """Filters data according to pointing flag."""
498
+ """Filters data according to pointing flag and zenith angle."""
516
499
  with netCDF4.Dataset(full_path) as nc:
517
500
  if "pointing_flag" in nc.variables:
518
501
  pointing = ptools.read_nc_fields(full_path, "pointing_flag")
519
- assert isinstance(pointing, ndarray)
520
- pointing_screened = _elevation_filter(full_path, pointing, ele_range)
521
- if data_field.ndim > 1:
522
- data_field = data_field[pointing_screened == status, :]
502
+ zenith_angle = ptools.read_nc_fields(full_path, "zenith_angle")
503
+ if data.ndim > 1:
504
+ data[np.abs(zenith_angle) > zenith_limit, :] = ma.masked
505
+ data[pointing != status, :] = ma.masked
523
506
  else:
524
- data_field = data_field[pointing_screened == status]
525
- return data_field
507
+ data[np.abs(zenith_angle) > zenith_limit] = ma.masked
508
+ data[pointing != status] = ma.masked
509
+ return data
526
510
 
527
511
 
528
512
  def _plot_weather_station(ax, data: ndarray, time: ndarray, name: str):
@@ -1,3 +1,4 @@
1
+ import tempfile
1
2
  from tempfile import NamedTemporaryFile
2
3
 
3
4
  import netCDF4
@@ -12,7 +13,6 @@ def generate_mwr_multi(
12
13
  mwr_l1c_file: str, output_file: str, uuid: str | None = None
13
14
  ) -> str:
14
15
  file_uuid = uuid if uuid is not None else utils.get_uuid()
15
- coeffs = product_tools.get_mwrpy_coeffs(mwr_l1c_file)
16
16
 
17
17
  with (
18
18
  NamedTemporaryFile() as temp_file,
@@ -20,16 +20,19 @@ def generate_mwr_multi(
20
20
  NamedTemporaryFile() as rel_hum_file,
21
21
  NamedTemporaryFile() as t_pot_file,
22
22
  NamedTemporaryFile() as eq_temp_file,
23
+ tempfile.TemporaryDirectory() as temp_dir,
23
24
  ):
25
+ coeffs = product_tools.get_read_mwrpy_coeffs(mwr_l1c_file, temp_dir)
26
+
24
27
  for prod, file in zip(
25
28
  ("2P02", "2P03", "2P04", "2P07", "2P08"),
26
29
  (temp_file, abs_hum_file, rel_hum_file, t_pot_file, eq_temp_file),
27
30
  ):
28
31
  lev2_to_nc(
29
- coeffs,
30
32
  prod,
31
33
  mwr_l1c_file,
32
34
  file.name,
35
+ coeff_files=coeffs,
33
36
  temp_file=temp_file.name if prod not in ("2P02", "2P03") else None,
34
37
  hum_file=abs_hum_file.name if prod not in ("2P02", "2P03") else None,
35
38
  )
@@ -1,3 +1,4 @@
1
+ import tempfile
1
2
  from tempfile import NamedTemporaryFile
2
3
 
3
4
  import netCDF4
@@ -12,19 +13,21 @@ def generate_mwr_single(
12
13
  mwr_l1c_file: str, output_file: str, uuid: str | None = None
13
14
  ) -> str:
14
15
  file_uuid = uuid if uuid is not None else utils.get_uuid()
15
- coeffs = product_tools.get_mwrpy_coeffs(mwr_l1c_file)
16
16
 
17
17
  with (
18
18
  NamedTemporaryFile() as lwp_file,
19
19
  NamedTemporaryFile() as iwv_file,
20
20
  NamedTemporaryFile() as t_prof_file,
21
21
  NamedTemporaryFile() as abs_hum_file,
22
+ tempfile.TemporaryDirectory() as temp_dir,
22
23
  ):
24
+ coeffs = product_tools.get_read_mwrpy_coeffs(mwr_l1c_file, temp_dir)
25
+
23
26
  for prod, file in zip(
24
27
  ("2I01", "2I02", "2P01", "2P03"),
25
28
  (lwp_file, iwv_file, t_prof_file, abs_hum_file),
26
29
  ):
27
- lev2_to_nc(coeffs, prod, mwr_l1c_file, file.name)
30
+ lev2_to_nc(prod, mwr_l1c_file, file.name, coeff_files=coeffs)
28
31
 
29
32
  with (
30
33
  netCDF4.Dataset(output_file, "w", format="NETCDF4_CLASSIC") as nc_output,
@@ -1,8 +1,10 @@
1
1
  """General helper classes and functions for all products."""
2
+ import os
2
3
  from collections import namedtuple
3
4
 
4
5
  import netCDF4
5
6
  import numpy as np
7
+ import requests
6
8
  from numpy import ma
7
9
 
8
10
  from cloudnetpy import constants, utils
@@ -276,4 +278,14 @@ def get_temperature(categorize_file: str) -> np.ndarray:
276
278
 
277
279
  def get_mwrpy_coeffs(nc_file: str) -> str:
278
280
  with netCDF4.Dataset(nc_file) as nc:
279
- return nc.mwrpy_coefficients
281
+ return nc.mwrpy_coefficients.split(", ")
282
+
283
+
284
+ def get_read_mwrpy_coeffs(mwr_l1c_file, folder: str) -> list:
285
+ coeffs = []
286
+ for link in get_mwrpy_coeffs(mwr_l1c_file):
287
+ full_path = os.path.join(folder, link.split("/")[-1])
288
+ with open(full_path, "wb") as f:
289
+ f.write(requests.get(link, timeout=10).content)
290
+ coeffs.append(full_path)
291
+ return coeffs
cloudnetpy/version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  MAJOR = 1
2
- MINOR = 51
3
- PATCH = 1
2
+ MINOR = 52
3
+ PATCH = 0
4
4
  __version__ = f"{MAJOR}.{MINOR}.{PATCH}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cloudnetpy
3
- Version: 1.51.1
3
+ Version: 1.52.0
4
4
  Summary: Python package for Cloudnet processing
5
5
  Author: Simo Tukiainen
6
6
  License: MIT License
@@ -39,18 +39,18 @@ Classifier: Topic :: Scientific/Engineering
39
39
  Requires-Python: >=3.10
40
40
  Description-Content-Type: text/markdown
41
41
  License-File: LICENSE
42
- Requires-Dist: cloudnetpy-qc (>=1.10.2)
42
+ Requires-Dist: cloudnetpy-qc >=1.10.2
43
43
  Requires-Dist: matplotlib
44
- Requires-Dist: mwrpy (>=0.1.6)
44
+ Requires-Dist: mwrpy >=0.4.1
45
45
  Requires-Dist: netCDF4
46
46
  Requires-Dist: requests
47
- Requires-Dist: rpgpy (>=0.14.2)
47
+ Requires-Dist: rpgpy >=0.14.2
48
48
  Requires-Dist: scikit-image
49
49
  Requires-Dist: scipy
50
50
  Provides-Extra: dev
51
51
  Requires-Dist: pre-commit ; extra == 'dev'
52
52
  Provides-Extra: extras
53
- Requires-Dist: voodoonet (>=0.1.1) ; extra == 'extras'
53
+ Requires-Dist: voodoonet >=0.1.1 ; extra == 'extras'
54
54
  Provides-Extra: test
55
55
  Requires-Dist: mypy ; extra == 'test'
56
56
  Requires-Dist: pylint ; extra == 'test'
@@ -8,7 +8,7 @@ cloudnetpy/metadata.py,sha256=-oRmr4HWjG_-P8jOjdBYMgRkOYnJKr6jmGIF-38Tno8,5023
8
8
  cloudnetpy/output.py,sha256=6ysoCcrk_pS_fWhyQoJX29V403f7UOloFw0SZjHCwKk,14236
9
9
  cloudnetpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  cloudnetpy/utils.py,sha256=lKVPF7VpbX2IPXTztI8eJZm8rLne9IuhMngQXKP12vg,26971
11
- cloudnetpy/version.py,sha256=Ja1UYLGffo0QdnwJpi9wS24Icrb4a0cV3o2mFuzPACo,72
11
+ cloudnetpy/version.py,sha256=umnfdBNz2LRH86t5ulPJADHW23wlT1a-rX-l2-1pqaQ,72
12
12
  cloudnetpy/categorize/__init__.py,sha256=gP5q3Vis1y9u9OWgA_idlbjfWXYN_S0IBSWdwBhL_uU,69
13
13
  cloudnetpy/categorize/atmos.py,sha256=_8VU0UpzKh7ZFh3TbGs-g3SYMRsRIR5mio0PmP66O7o,12372
14
14
  cloudnetpy/categorize/atmos_utils.py,sha256=6WdfGqzOvnaDW7vlMMrZBJIxW_eHQdjH-Xl_iPv1TTI,3716
@@ -33,7 +33,7 @@ cloudnetpy/instruments/cl61d.py,sha256=jETxUIIjILZwkMx9YKG8pI7cUodNjVoc6dYCqaxW1
33
33
  cloudnetpy/instruments/cloudnet_instrument.py,sha256=nnaOtJJotXzYdoMoYGKeLZ1MciDYBx7tqVBFKBQjKL0,3304
34
34
  cloudnetpy/instruments/copernicus.py,sha256=FDS7Rsunp4ieTPFh_T_LXvreNi5_HTv4ZzR3OnTcAX8,5013
35
35
  cloudnetpy/instruments/galileo.py,sha256=F_XyoAb9PR-ifGhqhXziKnv0KfyOh-yEBaE1NgRMzNg,4318
36
- cloudnetpy/instruments/hatpro.py,sha256=H0FgTIxIp3fl59nrTS9z8NyRX7ugkR32B2N1uwEOWtQ,7438
36
+ cloudnetpy/instruments/hatpro.py,sha256=kPIjHrLzMvZj4QBw0DjEMv8hofBSHdLb8hLcLlj6bKs,7631
37
37
  cloudnetpy/instruments/instruments.py,sha256=x_YV4UG05lF-39Yr-K3h5OrxSqrsndpF1K-KM0VURI0,2975
38
38
  cloudnetpy/instruments/lufft.py,sha256=lZr_fz2vWQdPr4ZiWW7_wT7WlrMmPsQ2ko6MKygZv50,3332
39
39
  cloudnetpy/instruments/mira.py,sha256=5wmmJGYHVglxaCpSuL92WIisADRD-85k_jlsC9mKLgQ,5063
@@ -91,7 +91,7 @@ cloudnetpy/model_evaluation/tests/unit/test_statistical_methods.py,sha256=CPbFwL
91
91
  cloudnetpy/model_evaluation/tests/unit/test_tools.py,sha256=84b1TxMogC1hyACQol7xthOWNkYXp3oZJF4GFokEkd4,3630
92
92
  cloudnetpy/plotting/__init__.py,sha256=3bhBlLx8o_SjVyuPxgT7mfZ145pd5erwcCoVNuj2z48,62
93
93
  cloudnetpy/plotting/plot_meta.py,sha256=CrRCwh5-YxOrIe2bJXnL9akdUGi-amsUCCHc5VoHAL8,26217
94
- cloudnetpy/plotting/plotting.py,sha256=ynjzRm6o5yUO2YI5robhVyiOYaGN88hoxU_FkPfhRaY,28174
94
+ cloudnetpy/plotting/plotting.py,sha256=Kj4Su_cq-znqAeDTUVBiWf1eilGYg00WX8zqetQ20lI,27523
95
95
  cloudnetpy/products/__init__.py,sha256=hGkngQT-YAC5cmDiHkSkQw2ZBrg0hN2z40Fizz0QU5Y,210
96
96
  cloudnetpy/products/classification.py,sha256=0Y5dEVDZFbq3UcFnyHomml5Au12SSMVznQTgAMyqh2I,7701
97
97
  cloudnetpy/products/der.py,sha256=zDehcsSCwDTADmxrK4Dmy5VcsrJmDbb-t_SiSU-C3M0,12241
@@ -102,12 +102,12 @@ cloudnetpy/products/ier.py,sha256=z0g0VKtnow9QlD492f6z1jPtslqvfmBBuITTrLYH3cI,77
102
102
  cloudnetpy/products/iwc.py,sha256=0sAGYcTGOJcVH3MxqGxuwxiUpiEG0NuPg49gPsI0wLo,10076
103
103
  cloudnetpy/products/lwc.py,sha256=8G8pJppEsLZjXOvX5xvXEqEVSCMZZLfIeOoAMX6Gnu8,18642
104
104
  cloudnetpy/products/mie_lu_tables.nc,sha256=It4fYpqJXlqOgL8jeZ-PxGzP08PMrELIDVe55y9ob58,16637951
105
- cloudnetpy/products/mwr_multi.py,sha256=9dw5DqU9uae54SDk0Pjzp4EKtQrjo1DeP-Xx41NEF_g,2804
106
- cloudnetpy/products/mwr_single.py,sha256=tfUYvkVf_Hh1GcpBnjjE8T30EYzyYc07UuzGJCBME-8,2931
107
- cloudnetpy/products/product_tools.py,sha256=Gk5e4N1m071IIFT9dy9lUvcDICsMYx-pMEtcWTJ54nw,9739
105
+ cloudnetpy/products/mwr_multi.py,sha256=DAehj30BjrkSvaEs1QrTN02lgHTdzSgP3E_vv35bvok,2903
106
+ cloudnetpy/products/mwr_single.py,sha256=nKl9eenNQXqpdsSxyKrnpCeoXRBcQnpkbESVceOdnRw,3030
107
+ cloudnetpy/products/product_tools.py,sha256=KLvQKRkPrzZXT4_mFh2O5oJ14kf6nEyYd0sCaWlR0gY,10119
108
108
  docs/source/conf.py,sha256=baQlgkkUGJi4952W6NRhLkIBbRtwFgqrIOBuEeSCLfk,1488
109
- cloudnetpy-1.51.1.dist-info/LICENSE,sha256=wcZF72bdaoG9XugpyE95Juo7lBQOwLuTKBOhhtANZMM,1094
110
- cloudnetpy-1.51.1.dist-info/METADATA,sha256=OChqYA3XkBzKFCvDLrrw90sY85E-OC6Si8_KQJINPN8,5759
111
- cloudnetpy-1.51.1.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
112
- cloudnetpy-1.51.1.dist-info/top_level.txt,sha256=ibSPWRr6ojS1i11rtBFz2_gkIe68mggj7aeswYfaOo0,16
113
- cloudnetpy-1.51.1.dist-info/RECORD,,
109
+ cloudnetpy-1.52.0.dist-info/LICENSE,sha256=wcZF72bdaoG9XugpyE95Juo7lBQOwLuTKBOhhtANZMM,1094
110
+ cloudnetpy-1.52.0.dist-info/METADATA,sha256=ZWYxghjfTvHgL8ke4sT5Lxg_Br6MuEhUD_0vGt9J6H0,5751
111
+ cloudnetpy-1.52.0.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
112
+ cloudnetpy-1.52.0.dist-info/top_level.txt,sha256=ibSPWRr6ojS1i11rtBFz2_gkIe68mggj7aeswYfaOo0,16
113
+ cloudnetpy-1.52.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.0)
2
+ Generator: bdist_wheel (0.41.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5