ceilopyter 0.2.2__tar.gz → 0.2.4__tar.gz
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.
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/CHANGELOG.md +10 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/PKG-INFO +1 -1
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/instruments/chm15k.py +37 -11
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/instruments/ct25k.py +4 -2
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/instruments/ld40.py +32 -2
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/noise.py +2 -2
- ceilopyter-0.2.4/ceilopyter/version.py +1 -0
- ceilopyter-0.2.2/ceilopyter/version.py +0 -1
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/.github/workflows/publish.yml +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/.github/workflows/test.yml +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/.gitignore +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/.pre-commit-config.yaml +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/LICENSE +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/README.md +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/__init__.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/ceilo.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/ceilo_raw.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/cli.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/common.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/instruments/cl31.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/instruments/cl51.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/instruments/cl61.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/instruments/cs135.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/py.typed +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/readers/read_cl.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/readers/read_cs.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/readers/read_ct.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/ceilopyter/utils.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/pyproject.toml +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/tests/data/celio_chennai_2025-03-11.dat +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/tests/data/kauniainen_cl31.dat +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/tests/data/kenttarova_cl31_msg.dat +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/tests/data/palaiseau_cl31_msg.dat +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/tests/data/uto_cl31_msg.dat +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/tests/test_cl.py +0 -0
- {ceilopyter-0.2.2 → ceilopyter-0.2.4}/tests/test_utils.py +0 -0
|
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 0.2.4 – 2026-10-14
|
|
9
|
+
|
|
10
|
+
- Fix errors with old CHM 15k files
|
|
11
|
+
- Handle empty LD40 files
|
|
12
|
+
|
|
13
|
+
## 0.2.3 – 2026-10-13
|
|
14
|
+
|
|
15
|
+
- Add noise screening for LD40
|
|
16
|
+
- Add mask to `beta_smooth`
|
|
17
|
+
|
|
8
18
|
## 0.2.2 – 2026-10-01
|
|
9
19
|
|
|
10
20
|
- Improve CHM 15k processing
|
|
@@ -7,7 +7,7 @@ import numpy.typing as npt
|
|
|
7
7
|
from cftime import num2pydate
|
|
8
8
|
from numpy import ma
|
|
9
9
|
|
|
10
|
-
from ceilopyter.noise import remove_noise
|
|
10
|
+
from ceilopyter.noise import calc_cloud_mask, remove_noise
|
|
11
11
|
from ceilopyter.utils import awful_overlap
|
|
12
12
|
|
|
13
13
|
from ..ceilo import Ceilo
|
|
@@ -30,14 +30,17 @@ def read_chm15k(
|
|
|
30
30
|
beta_raw = concat.beta * calibration_factor
|
|
31
31
|
|
|
32
32
|
beta_uncorr = beta_raw / (concat.range * 1e-3) ** 2
|
|
33
|
+
cloud_mask = calc_cloud_mask(concat.time, concat.range, beta_uncorr)
|
|
33
34
|
is_noise, beta_smooth = remove_noise(
|
|
34
35
|
concat.time,
|
|
35
36
|
concat.range,
|
|
36
37
|
beta_uncorr,
|
|
37
38
|
noise_floor=4e-9,
|
|
39
|
+
cloud_mask=cloud_mask,
|
|
38
40
|
filter_above_negative=True,
|
|
39
41
|
)
|
|
40
42
|
beta = ma.masked_where(is_noise, beta_raw)
|
|
43
|
+
beta_smooth = ma.masked_where(is_noise, beta_smooth)
|
|
41
44
|
|
|
42
45
|
return Ceilo(
|
|
43
46
|
concat,
|
|
@@ -50,22 +53,47 @@ def read_chm15k(
|
|
|
50
53
|
|
|
51
54
|
def _read_file(file: str | PathLike) -> CeiloRaw:
|
|
52
55
|
with netCDF4.Dataset(file) as nc:
|
|
53
|
-
time =
|
|
54
|
-
|
|
55
|
-
beta = _get_beta(nc)
|
|
56
|
-
wavelength =
|
|
56
|
+
time, time_ind = _get_time(nc)
|
|
57
|
+
rng = _get_range(nc)
|
|
58
|
+
beta = _get_beta(nc, rng)[time_ind]
|
|
59
|
+
wavelength = 1064.0
|
|
57
60
|
zenith_angle = nc["zenith"][:] if "zenith" in nc.variables else None
|
|
58
61
|
serial_number = nc.source
|
|
59
|
-
return CeiloRaw(time,
|
|
62
|
+
return CeiloRaw(time, rng, beta, wavelength, zenith_angle, serial_number)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# Filter outliers in some files (e.g. Lindenberg 2010-12-02 and 2010-12-18).
|
|
66
|
+
_TIME_MIN = 0 # 1904-01-01 00:00:00
|
|
67
|
+
_TIME_MAX = 255485145599 # 9999-12-31 23:59:59
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _get_time(nc: netCDF4.Dataset):
|
|
71
|
+
time = nc["time"][:]
|
|
72
|
+
time_ind = (time >= _TIME_MIN) & (time <= _TIME_MAX)
|
|
73
|
+
time = num2pydate(time[time_ind], nc["time"].units)
|
|
74
|
+
return time, time_ind
|
|
60
75
|
|
|
61
76
|
|
|
62
77
|
def _get_range(nc: netCDF4.Dataset):
|
|
63
78
|
rng = nc["range"][:]
|
|
64
|
-
|
|
65
|
-
|
|
79
|
+
if ma.getmaskarray(rng).all():
|
|
80
|
+
# Variable range, and sometimes range_gate, are masked in some old files
|
|
81
|
+
# (e.g. Lindenberg 2008-06-04 and 2010-10-15). According to the manual,
|
|
82
|
+
# NetCDF data resolution is 5 m – 30 m in 5 m steps (can be set by the
|
|
83
|
+
# user, default 15 m).
|
|
84
|
+
rng_gate = 5 * round(15000 / (5 * len(rng)))
|
|
85
|
+
logging.warning(
|
|
86
|
+
"range is masked, calculating it assuming resolution of %s m", rng_gate
|
|
87
|
+
)
|
|
88
|
+
rng = rng_gate * np.arange(1, len(rng) + 1)
|
|
89
|
+
else:
|
|
90
|
+
rng_gate = rng[1] - rng[0]
|
|
91
|
+
return rng - rng_gate / 2
|
|
66
92
|
|
|
67
93
|
|
|
68
|
-
def _get_beta(
|
|
94
|
+
def _get_beta(
|
|
95
|
+
nc: netCDF4.Dataset, rng: npt.NDArray[np.floating]
|
|
96
|
+
) -> npt.NDArray[np.floating]:
|
|
69
97
|
"""Get range-corrected backscatter coefficient.
|
|
70
98
|
|
|
71
99
|
References:
|
|
@@ -88,14 +116,12 @@ def _get_beta(nc: netCDF4.Dataset) -> npt.NDArray[np.floating]:
|
|
|
88
116
|
# beta_raw = P_raw
|
|
89
117
|
laser_pulses = nc["laser_pulses"][:]
|
|
90
118
|
base = np.mean(beta[:, -5:], axis=1) / laser_pulses
|
|
91
|
-
rng = nc["range"][:]
|
|
92
119
|
overlap = awful_overlap(rng, 200, 800)
|
|
93
120
|
signal = beta / laser_pulses[:, np.newaxis] - base[:, np.newaxis]
|
|
94
121
|
beta = signal / overlap * rng**2
|
|
95
122
|
elif isinstance(sw_version, np.integer) or sw_version < "0.702":
|
|
96
123
|
# beta_raw = (P_raw / laser_pulses - base) / stddev
|
|
97
124
|
apd = _get_nn(nc)
|
|
98
|
-
rng = nc["range"][:]
|
|
99
125
|
overlap = awful_overlap(rng, 200, 800)
|
|
100
126
|
stddev = nc["stddev"][:]
|
|
101
127
|
signal = beta * stddev[:, np.newaxis]
|
|
@@ -8,7 +8,7 @@ from numpy import ma
|
|
|
8
8
|
from ..ceilo import Ceilo
|
|
9
9
|
from ..ceilo_raw import concatenate_raw
|
|
10
10
|
from ..common import read_msgs
|
|
11
|
-
from ..noise import remove_noise
|
|
11
|
+
from ..noise import calc_cloud_mask, remove_noise
|
|
12
12
|
from ..readers.read_ct import read_ct_file
|
|
13
13
|
|
|
14
14
|
|
|
@@ -28,11 +28,13 @@ def read_ct25k(
|
|
|
28
28
|
beta_calib = concat.beta * calibration_factor
|
|
29
29
|
beta_uncorr = beta_calib / r2 if noise_h2 else _fix_beta(r2, beta_calib)
|
|
30
30
|
|
|
31
|
+
cloud_mask = calc_cloud_mask(concat.time, concat.range, beta_uncorr)
|
|
31
32
|
is_noise, beta_smooth = remove_noise(
|
|
32
|
-
concat.time, concat.range, beta_uncorr, noise_floor=6e-8
|
|
33
|
+
concat.time, concat.range, beta_uncorr, noise_floor=6e-8, cloud_mask=cloud_mask
|
|
33
34
|
)
|
|
34
35
|
beta_raw = beta_uncorr * r2
|
|
35
36
|
beta = ma.masked_where(is_noise, beta_raw)
|
|
37
|
+
beta_smooth = ma.masked_where(is_noise, beta_smooth)
|
|
36
38
|
|
|
37
39
|
return Ceilo(
|
|
38
40
|
concat,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import logging
|
|
3
|
+
import os.path
|
|
3
4
|
from os import PathLike
|
|
4
5
|
|
|
5
6
|
import numpy as np
|
|
6
7
|
from numpy import ma
|
|
7
8
|
|
|
9
|
+
from ceilopyter.noise import remove_noise
|
|
8
10
|
from ceilopyter.utils import awful_overlap
|
|
9
11
|
|
|
10
12
|
from ..ceilo import Ceilo
|
|
@@ -23,10 +25,36 @@ def read_ld40(
|
|
|
23
25
|
logging.warning("Using default calibration factor: %s", calibration_factor)
|
|
24
26
|
raw = []
|
|
25
27
|
for file in files:
|
|
26
|
-
|
|
28
|
+
try:
|
|
29
|
+
raw.append(_read_file(file))
|
|
30
|
+
except InvalidMessageError as e:
|
|
31
|
+
logging.warning("Failed to read %s: %s", os.path.basename(file), e)
|
|
32
|
+
continue
|
|
27
33
|
concat = concatenate_raw(raw)
|
|
34
|
+
r2 = (concat.range * 1e-3) ** 2
|
|
28
35
|
beta_raw = concat.beta * calibration_factor
|
|
29
|
-
|
|
36
|
+
beta_uncorr = beta_raw / r2
|
|
37
|
+
cloud_mask = beta_uncorr > 1e-5
|
|
38
|
+
is_noise, beta_smooth = remove_noise(
|
|
39
|
+
concat.time,
|
|
40
|
+
concat.range,
|
|
41
|
+
beta_uncorr,
|
|
42
|
+
noise_floor=0,
|
|
43
|
+
cloud_mask=cloud_mask,
|
|
44
|
+
snr_limit=12,
|
|
45
|
+
)
|
|
46
|
+
# Filter constant artefact at 8 km and assume noise above.
|
|
47
|
+
is_noise[:, concat.range > 7500] = True
|
|
48
|
+
beta = ma.masked_where(is_noise, beta_raw)
|
|
49
|
+
beta_smooth = ma.masked_where(is_noise, beta_smooth)
|
|
50
|
+
|
|
51
|
+
return Ceilo(
|
|
52
|
+
concat,
|
|
53
|
+
beta_raw=beta_raw,
|
|
54
|
+
beta=beta,
|
|
55
|
+
beta_smooth=beta_smooth,
|
|
56
|
+
calibration_factor=calibration_factor,
|
|
57
|
+
)
|
|
30
58
|
|
|
31
59
|
|
|
32
60
|
def _read_file(filename: str | PathLike) -> CeiloRaw:
|
|
@@ -52,6 +80,8 @@ def _read_file(filename: str | PathLike) -> CeiloRaw:
|
|
|
52
80
|
)
|
|
53
81
|
)
|
|
54
82
|
betas.append(np.array([int(v) for v in values[2:]]))
|
|
83
|
+
if len(times) == 0:
|
|
84
|
+
raise InvalidMessageError("No data")
|
|
55
85
|
res = rng[1] - rng[0]
|
|
56
86
|
rng = rng + res / 2
|
|
57
87
|
time = np.array(times)
|
|
@@ -15,6 +15,7 @@ def remove_noise(
|
|
|
15
15
|
rng: npt.NDArray[np.floating],
|
|
16
16
|
beta_uncorr: npt.NDArray[np.floating],
|
|
17
17
|
noise_floor: float,
|
|
18
|
+
cloud_mask: npt.NDArray[np.bool],
|
|
18
19
|
snr_limit: float = 5,
|
|
19
20
|
filter_above_negative: bool = False,
|
|
20
21
|
) -> tuple[npt.NDArray[np.bool_], npt.NDArray[np.floating]]:
|
|
@@ -29,7 +30,6 @@ def remove_noise(
|
|
|
29
30
|
beta_uncorr = np.where(is_above_negative, noise_floor, beta_uncorr)
|
|
30
31
|
|
|
31
32
|
smooth, smooth_uncorr = _calc_beta_smooth(time, rng, beta_uncorr)
|
|
32
|
-
cloud_mask = _calc_cloud_mask(time, rng, beta_uncorr)
|
|
33
33
|
|
|
34
34
|
fraction = 0.1
|
|
35
35
|
n_top_gates = round(n_range * fraction)
|
|
@@ -88,7 +88,7 @@ def _calc_sigma_units(
|
|
|
88
88
|
return x_std, y_std
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
def
|
|
91
|
+
def calc_cloud_mask(
|
|
92
92
|
time: npt.NDArray,
|
|
93
93
|
rng: npt.NDArray[np.floating],
|
|
94
94
|
beta_uncorr: npt.NDArray[np.floating],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.4"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|