sct_ambiguities_analysis 1.0.0.dev0__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.
@@ -0,0 +1,9 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Target Ambiguity Ratio Analysis feature.
5
+
6
+ Discovered by SCT via the ``sct.analyses`` entry-point namespace.
7
+ """
8
+
9
+ __version__ = "1.0.0.dev0"
@@ -0,0 +1,71 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Command Line Interface for Target Ambiguity Ratio Analysis."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from pathlib import Path
9
+
10
+ import typer
11
+ from sct.cli import common
12
+ from sct.configuration.config import GeneralConfiguration
13
+ from sct.configuration.logger import sct_logger
14
+
15
+ from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
16
+
17
+
18
+ def ptar_analysis(
19
+ ctx: typer.Context,
20
+ product: common.InputProductOption,
21
+ point_target_source: common.InputPointTargetSource,
22
+ output_directory: common.OutputDirectoryOption,
23
+ ) -> None:
24
+ """Point Target Ambiguity Ratio Analysis."""
25
+
26
+ config: GeneralConfiguration = ctx.obj
27
+
28
+ log_path = output_directory / "sct_tar_analysis.log" if config.save_log else None
29
+
30
+ with common.logging_to_file(log_path):
31
+ sct_logger.info(f"Product: {product}")
32
+ sct_logger.info(f"Point targets: {point_target_source}")
33
+ sct_logger.info(f"Output folder: {output_directory}")
34
+
35
+ common.display_title("Ambiguity Ratio Analysis")
36
+
37
+ analysis_config = (
38
+ SCTTargetAmbiguityRatioConfig.from_toml(config.toml_path)
39
+ if config.toml_path is not None
40
+ else SCTTargetAmbiguityRatioConfig()
41
+ )
42
+ pt_ambiguity_ratio_analysis_implementation(
43
+ product=product,
44
+ point_target_source=point_target_source,
45
+ output_directory=output_directory,
46
+ config=analysis_config,
47
+ graphs=True,
48
+ dump_config=config.save_config_copy,
49
+ )
50
+
51
+
52
+ @common.log_elapsed_time("Point Target Ambiguity Ratio Analysis")
53
+ @common.graceful_exit("Point Target Ambiguity Ratio Analysis")
54
+ def pt_ambiguity_ratio_analysis_implementation(
55
+ product: Path,
56
+ point_target_source: Path,
57
+ output_directory: Path,
58
+ config: SCTTargetAmbiguityRatioConfig,
59
+ graphs: bool,
60
+ dump_config: bool,
61
+ ) -> None:
62
+ """Implement the point target ambiguity ratio analysis command."""
63
+ from sct_ambiguities_analysis.main import full_pt_ambiguity_ratio_analysis
64
+
65
+ full_pt_ambiguity_ratio_analysis(
66
+ product=product,
67
+ point_target_source=point_target_source,
68
+ output_directory=output_directory,
69
+ config=config,
70
+ graphs=graphs,
71
+ )
@@ -0,0 +1,32 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Ambiguity Ratio Analysis configuration."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from dataclasses import asdict, dataclass, field
9
+ from pathlib import Path
10
+
11
+ from perseo_quality.tar_analysis.config import AmbiguityRatioConfig
12
+ from sct.configuration.config_abc import AnalysisConfigABC
13
+
14
+ from sct_ambiguities_analysis.resources import config_schema
15
+
16
+
17
+ @dataclass
18
+ class SCTTargetAmbiguityRatioConfig(AnalysisConfigABC):
19
+ """SCT Target Ambiguity Ratio Analysis configuration"""
20
+
21
+ base_config: AmbiguityRatioConfig = field(default_factory=AmbiguityRatioConfig)
22
+ config_group_name = "ambiguity_ratio_analysis"
23
+ validation_schema = Path(config_schema)
24
+
25
+ @classmethod
26
+ def from_dict(cls, arg: dict) -> SCTTargetAmbiguityRatioConfig:
27
+ """Convert from dict"""
28
+ return cls(base_config=AmbiguityRatioConfig.from_dict(arg))
29
+
30
+ def to_dict(self):
31
+ """Convert to dict"""
32
+ return {self.config_group_name: asdict(self.base_config)}
@@ -0,0 +1,8 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Target Ambiguity Ratio Analysis - Core implementation"""
5
+
6
+ from sct_ambiguities_analysis.core.analysis import sct_point_target_ambiguity_ratio_analysis
7
+
8
+ __all__ = ["sct_point_target_ambiguity_ratio_analysis"]
@@ -0,0 +1,65 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Target Ambiguity Ratio Analysis"""
5
+
6
+ from __future__ import annotations
7
+
8
+ from pathlib import Path
9
+
10
+ from perseo_quality.tar_analysis.analysis import point_target_ambiguity_ratio_analysis
11
+ from perseo_quality.tar_analysis.custom_dataclasses import PointTargetAmbiguityRatioDataOutput
12
+ from sct.configuration.logger import sct_logger
13
+ from sct.io.io_manager import InvalidProductType, product_loader
14
+ from sct.io.point_target_manager import convert_df_to_nominal_point_target, extract_point_target_data_from_source
15
+
16
+ from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
17
+
18
+
19
+ def sct_point_target_ambiguity_ratio_analysis(
20
+ product_path: str | Path, external_target_source: str | Path, config: SCTTargetAmbiguityRatioConfig | None = None
21
+ ) -> list[PointTargetAmbiguityRatioDataOutput]:
22
+ """Point Target Ambiguity Ratio Analysis performed on the input product.
23
+
24
+ Parameters
25
+ ----------
26
+ product_path : str | Path
27
+ path to the product to be analyzed
28
+ external_target_source : str | Path
29
+ path to external point target source
30
+ config : SCTTargetAmbiguityRatioConfig | None, optional
31
+ configuration parameters, by default None
32
+
33
+ Returns
34
+ -------
35
+ list[PointTargetAmbiguityRatioDataOutput]
36
+ list of PointTargetAmbiguityRatioDataOutput analysis output, one for each product channel and each Point Target
37
+ """
38
+ # Input parameters analysis
39
+ product_path = Path(product_path)
40
+ sct_logger.info(f"Input product: {product_path}")
41
+
42
+ external_target_source = Path(external_target_source)
43
+ sct_logger.info(f"Using external target source provided: {external_target_source}")
44
+
45
+ config = config or SCTTargetAmbiguityRatioConfig()
46
+
47
+ # LOADING PRODUCT
48
+ try:
49
+ product, _ = product_loader(
50
+ product_path=product_path,
51
+ )
52
+ except InvalidProductType as err:
53
+ sct_logger.critical(f"Unknown product type {product_path}.")
54
+ sct_logger.critical("Please check that the dedicated format plugin is installed.")
55
+ raise InvalidProductType from err
56
+
57
+ # external target source
58
+ point_targets_df = extract_point_target_data_from_source(source=external_target_source)
59
+
60
+ # converting point target data frame in list of NominalPointTarget dataclasses
61
+ point_targets_data = convert_df_to_nominal_point_target(data_df=point_targets_df)
62
+
63
+ return point_target_ambiguity_ratio_analysis(
64
+ product=product, point_targets=point_targets_data, config=config.base_config
65
+ )
@@ -0,0 +1,47 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Target Ambiguity Ratio Analysis plugin entry point.
5
+
6
+ Lightweight module: importing it must not pull in the heavy analysis implementation
7
+ or the scientific stack. All heavy imports are deferred to the accessor methods.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from typing import TYPE_CHECKING, Callable
13
+
14
+ from sct import __version__
15
+
16
+ if TYPE_CHECKING:
17
+ from sct.core.base import AnalysisHandler
18
+ from typer import Typer
19
+
20
+ ANALYSIS_NAME = "ambiguity_ratio"
21
+
22
+
23
+ class TargetAmbiguityRatioAnalysisPlugin:
24
+ """Target Ambiguity Ratio Analysis plugin."""
25
+
26
+ version = __version__
27
+ short_help = "Point Target Ambiguity Ratio Analysis."
28
+
29
+ @classmethod
30
+ def get_cli(cls) -> Typer | Callable:
31
+ from sct_ambiguities_analysis.cli import ptar_analysis
32
+
33
+ return ptar_analysis
34
+
35
+ @classmethod
36
+ def get_handlers(cls) -> dict[str, AnalysisHandler]:
37
+ from sct.core.base import AnalysisHandler
38
+
39
+ from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
40
+
41
+ return {
42
+ ANALYSIS_NAME: AnalysisHandler(
43
+ config=SCTTargetAmbiguityRatioConfig,
44
+ cli=cls.get_cli(),
45
+ testing=None,
46
+ )
47
+ }
@@ -0,0 +1,64 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Ambiguity Ratio Analysis implementation."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Callable
9
+ from pathlib import Path
10
+
11
+ from sct.configuration.logger import sct_logger
12
+
13
+ from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
14
+ from sct_ambiguities_analysis.core.analysis import sct_point_target_ambiguity_ratio_analysis
15
+
16
+
17
+ def full_pt_ambiguity_ratio_analysis(
18
+ product: Path,
19
+ point_target_source: Path,
20
+ output_directory: Path,
21
+ config: SCTTargetAmbiguityRatioConfig | None,
22
+ graphs: bool,
23
+ ) -> None:
24
+ """Full implementation of Point Target Ambiguity Ratio Analysis.
25
+
26
+ Parameters
27
+ ----------
28
+ product : Path
29
+ Path to the product to be analyzed
30
+ point_target_source : Path
31
+ Path to the point target source file
32
+ output_directory : Path
33
+ Path to the output directory
34
+ config : SCTTargetAmbiguityRatioConfig | None
35
+ analysis configuration parameters, if needed
36
+ graphs : bool
37
+ flag to enable graphs generation
38
+ """
39
+ graphs_func = _import_ptar_graphs_func(graphs)
40
+ output = sct_point_target_ambiguity_ratio_analysis(
41
+ product_path=product,
42
+ external_target_source=point_target_source,
43
+ config=config,
44
+ )
45
+
46
+ if graphs_func is not None:
47
+ sct_logger.info("Generating graphs...")
48
+ output_graphs_dir = output_directory.joinpath("graphs")
49
+ output_graphs_dir.mkdir(exist_ok=True)
50
+ graphs_func(data=output, output_dir=output_graphs_dir)
51
+
52
+
53
+ def _import_ptar_graphs_func(graphs: bool) -> Callable | None:
54
+ """Importing the target ambiguity ratio analysis graphs plotting function."""
55
+ ambiguities_graphs = None
56
+ if graphs:
57
+ try:
58
+ from perseo_quality.tar_analysis.graphical_output import ambiguities_graphs
59
+ except ImportError as err:
60
+ sct_logger.critical(
61
+ 'Cannot generate graphical output: install graphs requirements "pip install sct[graphs]"'
62
+ )
63
+ raise ImportError from err
64
+ return ambiguities_graphs
@@ -0,0 +1,8 @@
1
+ # SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """Target Ambiguity Ratio Analysis resources"""
5
+
6
+ from importlib import resources
7
+
8
+ config_schema = resources.files(__package__).joinpath("config_schema.json")
@@ -0,0 +1,38 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "ambiguity_ratio_analysis": {
6
+ "type": "object",
7
+ "description": "Ambiguity ratio analysis configuration",
8
+ "properties": {
9
+ "cropping_size": {
10
+ "type": "array",
11
+ "description": "ROI cropping size in pixels",
12
+ "items": [
13
+ {
14
+ "type": "integer",
15
+ "description": "number of samples"
16
+ },
17
+ {
18
+ "type": "integer",
19
+ "description": "number of lines"
20
+ }
21
+ ],
22
+ "minItems": 2,
23
+ "maxItems": 2
24
+ },
25
+ "interpolation_factor": {
26
+ "type": "integer",
27
+ "description": "ROI interpolation factor"
28
+ }
29
+ },
30
+ "required": [
31
+ "cropping_size"
32
+ ]
33
+ }
34
+ },
35
+ "required": [
36
+ "ambiguity_ratio_analysis"
37
+ ]
38
+ }
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.5
2
+ Name: sct_ambiguities_analysis
3
+ Version: 1.0.0.dev0
4
+ Summary: SCT Plugin for Point and Distributed Ambiguity Ratio Analysis of L1 SAR Products.
5
+ Project-URL: Homepage, https://github.com/aresys-srl/sct_plugins_analyses
6
+ Project-URL: Repository, https://github.com/aresys-srl/sct_plugins_analyses
7
+ Project-URL: Documentation, https://opensource.aresys.it/sct_plugins_analyses
8
+ Author-email: "Aresys S.R.L." <info@aresys.it>
9
+ License: MIT License
10
+
11
+ Copyright (C) Aresys S.r.l. <info@aresys.it>
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE.txt
31
+ Classifier: Development Status :: 5 - Production/Stable
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: Intended Audience :: Education
34
+ Classifier: Intended Audience :: Science/Research
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Natural Language :: English
37
+ Classifier: Operating System :: OS Independent
38
+ Classifier: Programming Language :: Python
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Classifier: Programming Language :: Python :: 3.13
42
+ Classifier: Programming Language :: Python :: 3.14
43
+ Classifier: Topic :: Scientific/Engineering
44
+ Classifier: Topic :: Software Development :: Libraries
45
+ Classifier: Topic :: Utilities
46
+ Classifier: Typing :: Typed
47
+ Requires-Python: >=3.11
48
+ Requires-Dist: jsonschema
49
+ Requires-Dist: numpy>2
50
+ Requires-Dist: perseo-core>=1.0.0
51
+ Requires-Dist: perseo-quality>=1.1.0
52
+ Requires-Dist: sct
53
+ Requires-Dist: typer>=0.24.1
54
+ Provides-Extra: dev
55
+ Requires-Dist: pylint; extra == 'dev'
56
+ Requires-Dist: ruff; extra == 'dev'
57
+ Provides-Extra: docs
58
+ Requires-Dist: mkdocstrings-python; extra == 'docs'
59
+ Requires-Dist: zensical; extra == 'docs'
60
+ Provides-Extra: test
61
+ Requires-Dist: pytest; extra == 'test'
62
+ Requires-Dist: pytest-cov; extra == 'test'
63
+ Requires-Dist: pytest-mock; extra == 'test'
64
+ Requires-Dist: sct[graphs]>=3.1.0; extra == 'test'
65
+ Description-Content-Type: text/markdown
66
+
67
+ # SCT Plugin: Ambiguity Ratio Analysis
68
+
69
+ [![PyPI version](https://img.shields.io/pypi/v/sct-ambiguities-analysis)](https://pypi.org/project/sct-ambiguities-analysis/)
70
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://python.org)
71
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.txt)
72
+
73
+ [![CI](https://github.com/aresys-srl/sct_plugins_analyses/actions/workflows/ambiguities.yml/badge.svg)](https://github.com/aresys-srl/sct_plugins_analyses/actions/workflows/ambiguities.yml)
74
+
75
+ [SCT (SAR Calibration Toolbox)](https://github.com/aresys-srl/sct) plugin for performing
76
+ Point and Distributed Target Ambiguity Ratio Analysis on L1 SAR products. Enables
77
+ evaluation of signal-to-ambiguity ratios for quality assessment through SCT.
78
+
79
+ ## Installation
80
+
81
+ ``` bash
82
+ pip install sct-ambiguities-analysis
83
+ ```
84
+
85
+ SCT is automatically installed as a dependency.
86
+
87
+ ## Compatibility
88
+
89
+ This plugin must be installed in the same Python environment as SCT. Once installed,
90
+ the plugin is automatically discovered and registered by SCT through its entry-point
91
+ based plugin system; no additional configuration is required.
92
+
93
+ ## Documentation
94
+
95
+ - [SCT documentation](https://opensource.aresys.it/sct/)
96
+ - [Quality Analysis documentation](https://opensource.aresys.it/perseo/documentation/quality/)
97
+ - [Analysis Plugins documentation](https://opensource.aresys.it/sct_plugins_analyses)
98
+
99
+ ## License
100
+
101
+ This project is licensed under the MIT License. See the [LICENSE.txt](LICENSE.txt) file for details.
102
+
103
+ Copyright &copy; 2026-present Aresys S.r.l. <info@aresys.it>
@@ -0,0 +1,14 @@
1
+ sct_ambiguities_analysis/__init__.py,sha256=W5ZpVUizua0toxBTEhmrMP25EScZukSp-htGeA-OnvY,241
2
+ sct_ambiguities_analysis/cli.py,sha256=9dG1zKqaDY9QlBillJeU3vZOMfYRGsX09sHeh8a_vf4,2385
3
+ sct_ambiguities_analysis/config.py,sha256=cFG6rZqteKK7kghEgNVWGGz3t0hjGsntf0c4n1Kz2-0,1083
4
+ sct_ambiguities_analysis/interface.py,sha256=MXRAukiSEWW2bcG3-dzPJauJJEqjvbhrw0g0-aUlZyg,1343
5
+ sct_ambiguities_analysis/main.py,sha256=IPbwcsHQZ2BJuE3oDGOBIGImvinmQwlInG7Oej3Sm4E,2209
6
+ sct_ambiguities_analysis/core/__init__.py,sha256=rQSWdSrY8xub4Qe6UcgVCOzdVQsSckSDf0DHupVxNIA,308
7
+ sct_ambiguities_analysis/core/analysis.py,sha256=75dZpAwlQShDvjTRs1x9cyYu7NHbCdIIVeW2UJJ1p6s,2648
8
+ sct_ambiguities_analysis/resources/__init__.py,sha256=tPdJQcLywPGlbvc5GptYmLe3zYG2kZY8ikwFVpV_5i0,255
9
+ sct_ambiguities_analysis/resources/config_schema.json,sha256=cGuprSWCPWd_2sb1NFSbb3rrEVijJq74o7khSpcr8PI,1232
10
+ sct_ambiguities_analysis-1.0.0.dev0.dist-info/METADATA,sha256=WFp7fscvKWYj9zFzuCDAeoowjnj1er_jwKXYRjCGIa4,4706
11
+ sct_ambiguities_analysis-1.0.0.dev0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
12
+ sct_ambiguities_analysis-1.0.0.dev0.dist-info/entry_points.txt,sha256=tErVaPRw5u9AruNgSyKrEX2jdWq97cVa00rgsfNPyYM,99
13
+ sct_ambiguities_analysis-1.0.0.dev0.dist-info/licenses/LICENSE.txt,sha256=ghpoTMO3cD8pZJfaY7VtSv57JvZOsLuSCiysG-ERAuY,1103
14
+ sct_ambiguities_analysis-1.0.0.dev0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [sct.analyses]
2
+ ambiguities = sct_ambiguities_analysis.interface:TargetAmbiguityRatioAnalysisPlugin
@@ -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.