s1-denoise 0.0.0.dev0__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.
@@ -0,0 +1,40 @@
1
+ # Python
2
+ __pycache__/
3
+ .venv/
4
+ dist/
5
+
6
+ # Editor / tool config
7
+ .cache/
8
+ .config/
9
+ .vscode/
10
+
11
+ # Archives & logs
12
+ *.tar
13
+ *.xz
14
+ *.gz
15
+ *.log
16
+ *.out
17
+ *.csv
18
+
19
+ # Test data
20
+ aux-files/
21
+ test/batch*
22
+ test/input*
23
+ test/aux-files
24
+ test/fonts
25
+ test/*.png
26
+
27
+ # Documentation
28
+ *.pdf
29
+
30
+ # Sentinel-1 data & products
31
+ *.SAFE
32
+ job-orders/*
33
+
34
+ # Pipeline output
35
+ output/
36
+ compare-noise-plots/
37
+
38
+ # Documentation site
39
+ site/
40
+ documentation*.zip
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) Aresys S.r.l. <info@aresys.it>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.5
2
+ Name: s1-denoise
3
+ Version: 0.0.0.dev0
4
+ Summary: Noise vector reconstruction for Level 1 Sentinel-1 products
5
+ Project-URL: Homepage, https://github.com/aresys-srl/s1-denoise
6
+ Project-URL: Documentation, https://opensource.aresys.it/s1-denoise/
7
+ Project-URL: Repository, https://github.com/aresys-srl/s1-denoise
8
+ Project-URL: Issues, https://github.com/aresys-srl/s1-denoise/issues
9
+ Project-URL: Changelog, https://opensource.aresys.it/s1-denoise/API/changelog/
10
+ Author-email: "Aresys S.R.L." <info@aresys.it>
11
+ License: MIT License
12
+
13
+ Copyright (C) Aresys S.r.l. <info@aresys.it>
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+ License-File: LICENSE
33
+ Classifier: Operating System :: OS Independent
34
+ Classifier: Programming Language :: Python :: 3
35
+ Requires-Python: >=3.11
36
+ Requires-Dist: click
37
+ Requires-Dist: colorlog
38
+ Requires-Dist: lxml
39
+ Requires-Dist: matplotlib
40
+ Requires-Dist: numpy
41
+ Requires-Dist: perseo-core
42
+ Requires-Dist: pillow
43
+ Requires-Dist: rasterio
44
+ Requires-Dist: scipy
45
+ Requires-Dist: sentinel1decoder
46
+ Requires-Dist: xmltodict
47
+ Description-Content-Type: text/markdown
48
+
49
+ # Sentinel-1 Level 1 Noise Processor
50
+
51
+ #### Thermal noise vector reconstruction for Sentinel-1 Level 1 products
52
+
53
+ The S1 L1N Processor reconstructs the thermal noise range vectors for Sentinel-1 IW and EW products (both SLC and GRD) and writes them to output XML files that follow the standard Sentinel-1 annotation format. The reconstructed vectors can then be compared against the nominal noise annotations embedded in the SAFE product to assess noise estimation quality.
54
+
55
+ For each processed channel the processor:
56
+
57
+ 1. reads acquisition geometry and calibration data from auxiliary files (PP1, CAL, INS);
58
+ 2. models the thermal noise using range spread loss, elevation antenna pattern, and calibration LUT;
59
+ 3. optionally refines the noise power correction using an associated Level 0 Noise (L0N) product;
60
+ 4. discards noise pulses whose power deviates from the expected noise level in AUX_INS by more than −3/+1 dB;
61
+ 5. for GRD products, handles sub-swath separation, per-subswath noise reconstruction and cross-subswath merging;
62
+ 6. writes the output noise XML files and, if nominal noise annotations are present in the SAFE product, reports the Mean Absolute Error (MAE) and maximum absolute error in dB.
63
+
64
+ 📖 **Documentation:** <https://opensource.aresys.it/s1-denoise/>
65
+
66
+ ---
67
+
68
+ ## Installation
69
+
70
+ **Requirements:** Python ≥ 3.11, pip.
71
+
72
+ Install the package from PyPI into a virtual environment of your choice:
73
+
74
+ ```bash
75
+ pip install s1-denoise
76
+ ```
77
+
78
+ Alternatively, install the wheel attached to a [GitHub release](https://github.com/aresys-srl/s1-denoise/releases):
79
+
80
+ ```bash
81
+ pip install s1_denoise-<version>-py3-none-any.whl
82
+ ```
83
+
84
+ Both options install the `denoise` command into the active Python environment.
85
+
86
+ ---
87
+
88
+ ## Usage
89
+
90
+ The processor is driven by a **Job Order XML file** that specifies input products, auxiliary files, and the output path.
91
+
92
+ ```bash
93
+ denoise "/path/to/job/order.xml"
94
+ ```
95
+
96
+ The processor reads each L1 SAFE product listed in the Job Order, generates the noise profiles, and writes the output XML files to the configured output directory. If nominal noise annotations are found inside the SAFE product, the MAE against them is logged automatically.
97
+
98
+ For all available options:
99
+
100
+ ```bash
101
+ denoise --help
102
+ ```
103
+
104
+ To print the installed version:
105
+
106
+ ```bash
107
+ denoise --version
108
+ ```
109
+
110
+ ### Job Order structure
111
+
112
+ The Job Order is an XML file that configures:
113
+
114
+ | Field | Description |
115
+ |---|---|
116
+ | Input L1 SAFE products | One or more Sentinel-1 SAFE folders to process |
117
+ | Input L0N products (optional) | Associated Level 0 Noise products for refined power correction |
118
+ | Auxiliary files | AUX_PP1, AUX_CAL, AUX_INS product paths |
119
+ | Output path | Directory where output XML files are written |
120
+ | Log level | Verbosity of the processor log |
121
+
122
+ A Job Order template is provided in [`templates/JobOrder.xml`](templates/JobOrder.xml). See the [Job Order documentation](https://opensource.aresys.it/s1-denoise/user-guide/job-order/) for the supported file types.
123
+
124
+ ---
125
+
126
+ ## Visualisation
127
+
128
+ To visually compare the original noise annotation with the reconstructed one:
129
+
130
+ ```bash
131
+ ./scripts/compare_noise.py <noise_xml_filepath> <denoise_xml_filepath> --colorbar 0.01
132
+ ```
133
+
134
+ The `--colorbar` argument sets the symmetric boundary (in dB) for the 2D difference plot colorbar.
135
+
136
+ ---
137
+
138
+ ## Documentation
139
+
140
+ The documentation is built with [Zensical](https://zensical.org/). To build it locally:
141
+
142
+ ```bash
143
+ pip install zensical mkdocstrings-python
144
+ python tools/build_doc.py
145
+ ```
146
+
147
+ The site is generated in the `site/` folder. Use `zensical serve` for a live preview while editing the pages in `docs/`.
@@ -0,0 +1,99 @@
1
+ # Sentinel-1 Level 1 Noise Processor
2
+
3
+ #### Thermal noise vector reconstruction for Sentinel-1 Level 1 products
4
+
5
+ The S1 L1N Processor reconstructs the thermal noise range vectors for Sentinel-1 IW and EW products (both SLC and GRD) and writes them to output XML files that follow the standard Sentinel-1 annotation format. The reconstructed vectors can then be compared against the nominal noise annotations embedded in the SAFE product to assess noise estimation quality.
6
+
7
+ For each processed channel the processor:
8
+
9
+ 1. reads acquisition geometry and calibration data from auxiliary files (PP1, CAL, INS);
10
+ 2. models the thermal noise using range spread loss, elevation antenna pattern, and calibration LUT;
11
+ 3. optionally refines the noise power correction using an associated Level 0 Noise (L0N) product;
12
+ 4. discards noise pulses whose power deviates from the expected noise level in AUX_INS by more than −3/+1 dB;
13
+ 5. for GRD products, handles sub-swath separation, per-subswath noise reconstruction and cross-subswath merging;
14
+ 6. writes the output noise XML files and, if nominal noise annotations are present in the SAFE product, reports the Mean Absolute Error (MAE) and maximum absolute error in dB.
15
+
16
+ 📖 **Documentation:** <https://opensource.aresys.it/s1-denoise/>
17
+
18
+ ---
19
+
20
+ ## Installation
21
+
22
+ **Requirements:** Python ≥ 3.11, pip.
23
+
24
+ Install the package from PyPI into a virtual environment of your choice:
25
+
26
+ ```bash
27
+ pip install s1-denoise
28
+ ```
29
+
30
+ Alternatively, install the wheel attached to a [GitHub release](https://github.com/aresys-srl/s1-denoise/releases):
31
+
32
+ ```bash
33
+ pip install s1_denoise-<version>-py3-none-any.whl
34
+ ```
35
+
36
+ Both options install the `denoise` command into the active Python environment.
37
+
38
+ ---
39
+
40
+ ## Usage
41
+
42
+ The processor is driven by a **Job Order XML file** that specifies input products, auxiliary files, and the output path.
43
+
44
+ ```bash
45
+ denoise "/path/to/job/order.xml"
46
+ ```
47
+
48
+ The processor reads each L1 SAFE product listed in the Job Order, generates the noise profiles, and writes the output XML files to the configured output directory. If nominal noise annotations are found inside the SAFE product, the MAE against them is logged automatically.
49
+
50
+ For all available options:
51
+
52
+ ```bash
53
+ denoise --help
54
+ ```
55
+
56
+ To print the installed version:
57
+
58
+ ```bash
59
+ denoise --version
60
+ ```
61
+
62
+ ### Job Order structure
63
+
64
+ The Job Order is an XML file that configures:
65
+
66
+ | Field | Description |
67
+ |---|---|
68
+ | Input L1 SAFE products | One or more Sentinel-1 SAFE folders to process |
69
+ | Input L0N products (optional) | Associated Level 0 Noise products for refined power correction |
70
+ | Auxiliary files | AUX_PP1, AUX_CAL, AUX_INS product paths |
71
+ | Output path | Directory where output XML files are written |
72
+ | Log level | Verbosity of the processor log |
73
+
74
+ A Job Order template is provided in [`templates/JobOrder.xml`](templates/JobOrder.xml). See the [Job Order documentation](https://opensource.aresys.it/s1-denoise/user-guide/job-order/) for the supported file types.
75
+
76
+ ---
77
+
78
+ ## Visualisation
79
+
80
+ To visually compare the original noise annotation with the reconstructed one:
81
+
82
+ ```bash
83
+ ./scripts/compare_noise.py <noise_xml_filepath> <denoise_xml_filepath> --colorbar 0.01
84
+ ```
85
+
86
+ The `--colorbar` argument sets the symmetric boundary (in dB) for the 2D difference plot colorbar.
87
+
88
+ ---
89
+
90
+ ## Documentation
91
+
92
+ The documentation is built with [Zensical](https://zensical.org/). To build it locally:
93
+
94
+ ```bash
95
+ pip install zensical mkdocstrings-python
96
+ python tools/build_doc.py
97
+ ```
98
+
99
+ The site is generated in the `site/` folder. Use `zensical serve` for a live preview while editing the pages in `docs/`.
@@ -0,0 +1,56 @@
1
+ [project]
2
+ name = "s1-denoise"
3
+ description = "Noise vector reconstruction for Level 1 Sentinel-1 products"
4
+ authors = [
5
+ { name="Aresys S.R.L.", email="info@aresys.it" }
6
+ ]
7
+ readme = "README.md"
8
+ requires-python = ">=3.11"
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "Operating System :: OS Independent",
12
+ ]
13
+ dynamic = ["version"]
14
+ license = { file = "LICENSE" }
15
+ dependencies = [
16
+ "click",
17
+ "colorlog",
18
+ "lxml",
19
+ "matplotlib",
20
+ "numpy",
21
+ "Pillow",
22
+ "rasterio",
23
+ "scipy",
24
+ "sentinel1decoder",
25
+ "xmltodict",
26
+ "perseo-core"
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/aresys-srl/s1-denoise"
31
+ Documentation = "https://opensource.aresys.it/s1-denoise/"
32
+ Repository = "https://github.com/aresys-srl/s1-denoise"
33
+ Issues = "https://github.com/aresys-srl/s1-denoise/issues"
34
+ Changelog = "https://opensource.aresys.it/s1-denoise/API/changelog/"
35
+
36
+ [project.scripts]
37
+ denoise = "s1_denoise.__main__:main"
38
+
39
+ [build-system]
40
+ requires = ["hatchling"]
41
+ build-backend = "hatchling.build"
42
+
43
+ [tool.hatch.version]
44
+ path = "src/s1_denoise/__init__.py"
45
+
46
+ [tool.hatch.build.targets.wheel]
47
+ packages = ["src/s1_denoise"]
48
+
49
+ [tool.hatch.build.targets.sdist]
50
+ include = [
51
+ "src/s1_denoise/**/*.py",
52
+ "README.md",
53
+ "LICENSE",
54
+ "pyproject.toml",
55
+ "scripts/compare_noise.py"
56
+ ]
@@ -0,0 +1,230 @@
1
+ #!.venv/bin/python3
2
+
3
+ """
4
+ Compare a nominal and a reconstructed Sentinel-1 noise XML file and plot their differences.
5
+
6
+ Prints the mean and maximum absolute errors in dB and saves to ``compare-noise-plots/`` a 2D map of the difference
7
+ and range profiles at a few azimuth times.
8
+ """
9
+
10
+ import numpy as np
11
+ import argparse
12
+ import sys
13
+ import matplotlib.pyplot as plt
14
+ from pathlib import Path
15
+ from math import nan
16
+
17
+ from s1_denoise.error_calculation import compare_noise, DN_VALUES
18
+ from s1_denoise.utils import linear_to_db
19
+
20
+ OUTPUT_DIR = Path("compare-noise-plots")
21
+
22
+
23
+ def plot_2d(common_pixels, common_times_sec, diff_db, out_name, colorbar, pol, subswath, prod_type):
24
+ """
25
+ Plot the 2D map of the noise difference and save it as ``whole_raster.png``.
26
+
27
+ Parameters
28
+ ----------
29
+ common_pixels : numpy.ndarray
30
+ Range pixel axis.
31
+ common_times_sec : numpy.ndarray
32
+ Azimuth time axis [s] from acquisition start.
33
+ diff_db : numpy.ndarray
34
+ Reconstructed minus nominal noise [dB], shape ``(len(common_times_sec), len(common_pixels))``.
35
+ out_name : str
36
+ Product name, shown as subtitle.
37
+ colorbar : float or None
38
+ Symmetric color scale limit [dB]; if None, the maximum absolute difference is used.
39
+ pol : str
40
+ Polarization.
41
+ subswath : str
42
+ Subswath, shown in the title for non-GRD products.
43
+ prod_type : str
44
+ Product type (``"GRD"`` or ``"SLC"``).
45
+ """
46
+
47
+ plt.figure(figsize=(9, 7))
48
+ if colorbar is not None:
49
+ vmax = colorbar
50
+ else:
51
+ vmax = np.nanmax(np.abs(diff_db))
52
+ vmin = -vmax # symmetric range
53
+
54
+ plt.pcolormesh(
55
+ common_pixels,
56
+ common_times_sec,
57
+ diff_db,
58
+ shading="auto",
59
+ cmap="RdBu",
60
+ vmax=vmax,
61
+ vmin=vmin
62
+ )
63
+ plt.colorbar(label="Noise difference [dB]")
64
+ plt.xlabel("Range pixel")
65
+ plt.ylabel("Azimuth time from acquisition start [s]")
66
+ if prod_type == "GRD":
67
+ plt.title(f"Denoising results ({pol})", weight="bold", pad=25, fontsize=14)
68
+ else:
69
+ plt.title(f"Denoising results ({pol}, {subswath})", weight="bold", pad=25, fontsize=14)
70
+ plt.gca().text(0.5, 1.02, f"{out_name}", transform=plt.gca().transAxes, ha="center", fontsize=10, fontfamily="monospace")
71
+
72
+ plt.tight_layout()
73
+ out_path = OUTPUT_DIR / "whole_raster.png"
74
+ plt.savefig(out_path, dpi=300)
75
+ plt.close()
76
+ print(f"Saved plot to {out_path}")
77
+
78
+
79
+ def plot_cut_profiles(common_pixels, f_noise, f_denoise, cut_times_sec, product_name, dn, pol, subswath, prod_type):
80
+ """
81
+ Plot the 1D noise range profiles and their difference at the given azimuth times.
82
+
83
+ One figure per azimuth time is saved as ``cut_profile_<t>s.png``: the top panel shows nominal and reconstructed noise
84
+ in dB, the bottom panel their difference, where points with a jump larger than 0.01 dB between adjacent pixels
85
+ (subswath transitions) are masked.
86
+
87
+ Parameters
88
+ ----------
89
+ common_pixels : numpy.ndarray
90
+ Range pixel axis.
91
+ f_noise : scipy.interpolate.RegularGridInterpolator
92
+ Interpolator of the nominal noise over (azimuth time [s], range pixel).
93
+ f_denoise : scipy.interpolate.RegularGridInterpolator
94
+ Interpolator of the reconstructed noise over (azimuth time [s], range pixel).
95
+ cut_times_sec : numpy.ndarray
96
+ Azimuth times [s] of the cuts.
97
+ product_name : str
98
+ Product name, shown as title.
99
+ dn : float
100
+ Digital number scaling factor; noise values are divided by ``dn**2``.
101
+ pol : str
102
+ Polarization.
103
+ subswath : str
104
+ Subswath, shown in the title for SLC products.
105
+ prod_type : str
106
+ Product type (``"GRD"`` or ``"SLC"``).
107
+ """
108
+
109
+ for t_sec in cut_times_sec:
110
+ # Query points: shape (num_pixels, 2) = (time, pixel)
111
+ points = np.column_stack([np.full_like(common_pixels, t_sec), common_pixels])
112
+
113
+ # Evaluate interpolators
114
+ noise_profile = f_noise(points) / (dn**2)
115
+ denoise_profile = f_denoise(points) / (dn**2)
116
+
117
+ # Avoid zero values for log10
118
+ noise_profile[noise_profile == 0] = nan
119
+ denoise_profile[denoise_profile == 0] = nan
120
+
121
+ noise_db = linear_to_db(noise_profile)
122
+ denoise_db = linear_to_db(denoise_profile)
123
+ diff_db = denoise_db - noise_db
124
+
125
+ # Plot
126
+ fig, axs = plt.subplots(2, 1, figsize=(8, 9), sharex=True)
127
+ fig.suptitle(f"{product_name}", fontfamily = "monospace", fontweight="bold")
128
+
129
+ # Top panel: original vs denoised
130
+ axs[0].plot(common_pixels, noise_db, label="noise", linestyle="--")
131
+ axs[0].plot(common_pixels, denoise_db, label="denoise", alpha=0.7)
132
+ axs[0].set_ylabel("Noise power [dB]")
133
+ if prod_type == "SLC":
134
+ axs[0].set_title(f"Profiles ({pol}, {subswath}) at azimuth ≈ {t_sec:.2f} s")
135
+ else:
136
+ axs[0].set_title(f"Profiles ({pol}) at azimuth ≈ {t_sec:.2f} s")
137
+ axs[0].legend()
138
+ axs[0].grid(True)
139
+
140
+ # Bottom panel: difference (remove swath jumps)
141
+ deriv = (diff_db[1:] - diff_db[:-1])
142
+ deriv = np.insert(deriv, 0, 0.0)
143
+ mask = abs(deriv) > 0.01
144
+
145
+ # print(max(abs(deriv)))
146
+
147
+ diff_db[mask] = np.nan
148
+
149
+ axs[1].plot(common_pixels, diff_db, color="red")
150
+ axs[1].set_xlabel("Range pixel")
151
+ axs[1].set_ylabel("Noise difference [dB]")
152
+ if prod_type == "SLC":
153
+ axs[1].set_title("Difference")
154
+ else:
155
+ axs[1].set_title("Difference (filtering subswath jumps)")
156
+ axs[1].grid(True)
157
+
158
+ plt.tight_layout()
159
+ out_path = OUTPUT_DIR / f"cut_profile_{int(t_sec)}s.png"
160
+ plt.savefig(out_path, dpi=300)
161
+ plt.close()
162
+ print(f"Saved plot to {out_path}")
163
+
164
+
165
+ def main():
166
+ """
167
+ Run the command line interface.
168
+
169
+ Parses the two noise XML files, checks that subswath, product type and polarization (from the file names) match,
170
+ computes the errors and generates the plots.
171
+
172
+ Raises
173
+ ------
174
+ SystemExit
175
+ If the two files refer to different subswaths, product types or polarizations (exit code 128).
176
+ """
177
+
178
+ parser = argparse.ArgumentParser(
179
+ description="Compare two Sentinel-1 noise XML files (GRD or SLC)"
180
+ )
181
+
182
+ parser.add_argument("noise_file", type=Path, help="Nominal noise XML")
183
+ parser.add_argument("denoise_file", type=Path, help="Candidate denoise XML")
184
+ parser.add_argument("--colorbar", type=float, default=None, help="Colorbar symmetric limit value for plotting")
185
+
186
+ args = parser.parse_args()
187
+
188
+ OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
189
+
190
+ product_name = args.noise_file.parent.parent.parent.stem
191
+
192
+ parts_noise = args.noise_file.stem.split("-")
193
+ parts_denoise = args.denoise_file.stem.split("-")
194
+
195
+ subswath = parts_noise[2].upper()
196
+ prod_type = parts_noise[3].upper()
197
+ pol = parts_noise[4].upper()
198
+
199
+ subswath_d = parts_denoise[2].upper()
200
+ prod_type_d = parts_denoise[3].upper()
201
+ pol_d = parts_denoise[4].upper()
202
+
203
+ if subswath != subswath_d:
204
+ print(f"Incompatible subswaths: {subswath} for noise file, {subswath_d} for denoise file")
205
+ sys.exit(128)
206
+ elif prod_type != prod_type_d:
207
+ print(f"Incompatible product type: {prod_type} for noise file, {prod_type_d} for denoise file")
208
+ sys.exit(128)
209
+ elif pol != pol_d:
210
+ print(f"Incompatible polarization: {pol} for noise file, {pol_d} for denoise file")
211
+ sys.exit(128)
212
+
213
+ mode = product_name[4:6]
214
+ dn = DN_VALUES.get((mode, prod_type))
215
+
216
+ print(f"Mode: {mode}\nProduct type: {prod_type}")
217
+
218
+ common_pixels, common_times_sec, diff_db, f1, f2, mean_error, max_error = compare_noise(args.noise_file, args.denoise_file, dn)
219
+ print(f"Absolute mean error on denoising: {mean_error:.2e} dB")
220
+ print(f"Maximum absolute error on denoising: {max_error:.2e} dB")
221
+
222
+ plot_2d(common_pixels, common_times_sec, diff_db, product_name, args.colorbar, pol, subswath, prod_type)
223
+
224
+ # azimuth cut times in seconds
225
+ cut_times_sec = np.linspace(1, max(common_times_sec), 6, endpoint=False)[1:]
226
+ plot_cut_profiles(common_pixels, f1, f2, cut_times_sec, product_name, dn, pol, subswath, prod_type)
227
+
228
+
229
+ if __name__ == "__main__":
230
+ main()
@@ -0,0 +1,18 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """
5
+ Configuration and constants module for the S1 L1N processor.
6
+
7
+ Defines the package version, the processor name used in log records, the reference slant range ``R_REF``
8
+ (in meters) and the noise pulse outlier detection bounds ``NOISE_LOWER_BOUND`` / ``NOISE_UPPER_BOUND`` (in dB).
9
+ """
10
+
11
+ __version__ = '0.0.0.dev0'
12
+
13
+ PROCESSOR_NAME = 's1_l1n_processor'
14
+
15
+ # CONSTANTS
16
+ R_REF = 8e5 # [m]
17
+
18
+ NOISE_LOWER_BOUND, NOISE_UPPER_BOUND = 3.0, 1.0 # [dB] bounds for noise pulse outlier detection
@@ -0,0 +1,36 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Entry point module for the denoising command-line interface."""
5
+
6
+ import sys
7
+ import click
8
+
9
+ from s1_denoise.cli import denoise_cli
10
+
11
+ def main():
12
+ """
13
+ Run the denoising CLI, mapping Click errors to exit code 128.
14
+
15
+ The command is invoked with ``standalone_mode=False`` so that Click usage errors and user aborts are
16
+ reported here and terminate the processor with exit code 128 instead of Click's default exit codes.
17
+
18
+ Raises
19
+ ------
20
+ SystemExit
21
+ With code 128 on a Click usage error or abort; exit codes raised by the CLI itself are propagated.
22
+ """
23
+ # standalone_mode=False lets click errors (e.g. invalid arguments) propagate,
24
+ # so that the processor exits with code 128 also in these cases
25
+ try:
26
+ denoise_cli(standalone_mode=False)
27
+ except click.ClickException as e:
28
+ e.show()
29
+ sys.exit(128)
30
+ except click.Abort:
31
+ click.echo("Aborted!", err=True)
32
+ sys.exit(128)
33
+
34
+
35
+ if __name__ == "__main__":
36
+ main()