openforis-whisp 2.0.0a6__tar.gz → 2.0.0b1__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.
Files changed (18) hide show
  1. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/LICENSE +21 -21
  2. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/PKG-INFO +2 -2
  3. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/pyproject.toml +85 -85
  4. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/__init__.py +74 -75
  5. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/data_conversion.py +493 -493
  6. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/datasets.py +1377 -1384
  7. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/logger.py +75 -75
  8. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/parameters/__init__.py +15 -15
  9. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/parameters/config_runtime.py +44 -44
  10. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/parameters/lookup_context_and_metadata.csv +13 -13
  11. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/parameters/lookup_gee_datasets.csv +2 -1
  12. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/pd_schemas.py +77 -77
  13. openforis_whisp-2.0.0b1/src/openforis_whisp/reformat.py +696 -0
  14. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/risk.py +848 -771
  15. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/stats.py +1228 -1134
  16. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/src/openforis_whisp/utils.py +194 -154
  17. openforis_whisp-2.0.0a6/src/openforis_whisp/reformat.py +0 -495
  18. {openforis_whisp-2.0.0a6 → openforis_whisp-2.0.0b1}/README.md +0 -0
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 lecrabe
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 lecrabe
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.
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openforis-whisp
3
- Version: 2.0.0a6
3
+ Version: 2.0.0b1
4
4
  Summary: Whisp (What is in that plot) is an open-source solution which helps to produce relevant forest monitoring information and support compliance with deforestation-related regulations.
5
5
  License: MIT
6
6
  Keywords: whisp,geospatial,data-processing
7
7
  Author: Andy Arnell
8
- Author-email: and.arnell@fao.org
8
+ Author-email: andrew.arnell@fao.org
9
9
  Requires-Python: >=3.10
10
10
  Classifier: Development Status :: 3 - Alpha
11
11
  Classifier: Intended Audience :: Developers
@@ -1,85 +1,85 @@
1
- [build-system]
2
- requires = ["poetry-core>=1.0.0"]
3
- build-backend = "poetry.core.masonry.api"
4
-
5
- [tool.poetry]
6
- name = "openforis-whisp"
7
- version = "2.0.0a6"
8
- description = "Whisp (What is in that plot) is an open-source solution which helps to produce relevant forest monitoring information and support compliance with deforestation-related regulations."
9
- repository = "https://github.com/forestdatapartnership/whisp"
10
- authors = ["Andy Arnell <and.arnell@fao.org>"]
11
- readme = "README.md"
12
- license = "MIT"
13
- keywords = ["whisp", "geospatial", "data-processing"]
14
- classifiers = [
15
- "Development Status :: 3 - Alpha",
16
- "Programming Language :: Python :: 3.10",
17
- "License :: OSI Approved :: MIT License",
18
- "Intended Audience :: Developers",
19
- "Intended Audience :: Science/Research",
20
- "Topic :: Software Development :: Libraries :: Python Modules"
21
- ]
22
-
23
- [tool.poetry.urls]
24
- "Documentation" = "https://github.com/forestdatapartnership/whisp#readme"
25
- "Development Branch" = "https://github.com/forestdatapartnership/whisp/tree/main"
26
- "Issues" = "https://github.com/forestdatapartnership/whisp/issues"
27
-
28
- [tool.poetry.dependencies]
29
- python = ">=3.10"
30
- earthengine-api = "*"
31
- numpy = ">=1.21.0,<3.0.0" # Updated version constraint
32
- pandas = ">=1.3.0,<3.0.0"
33
- pandera = {extras = ["io"], version = ">=0.22.1,<1.0.0"}
34
- country_converter = ">=0.7,<2.0.0"
35
- geojson = ">=2.5.0,<3.0.0"
36
- python-dotenv = ">=1.0.1,<2.0.0"
37
- pydantic-core = ">=2.14.0,<3.0.0" # Updated version constraint
38
- rsa = ">=4.2,<5.0.0" # Updated version constraint
39
- ipykernel = ">=6.17.1,<7.0.0" # Compatible with Colab
40
- shapely = "^2.0.2"
41
- geopandas = "^1.0.1"
42
-
43
- [tool.poetry.group.dev.dependencies]
44
- pytest = ">=6.2.5,<7.0.0"
45
- pre-commit = ">=2.15.0,<3.0.0"
46
- ruff = ">=0.0.1,<1.0.0"
47
-
48
- [tool.setuptools]
49
- package-dir = {"" = "src"}
50
- include-package-data = true
51
-
52
- [tool.setuptools.packages.find]
53
- where = ["src"]
54
-
55
- [tool.setuptools.package-data]
56
- "whisp.parameters" = ["lookup_gee_datasets.csv", "lookup_context_and_metadata.csv"]
57
-
58
- [tool.pytest.ini_options]
59
- log_cli = true
60
- log_cli_level = "DEBUG"
61
-
62
- [tool.ruff]
63
- fix = true
64
- select = [
65
- "A", "ANN", "ARG", "B", "C", "COM", "C90", "E", "ERA", "F", "I", "N", "PGH", "PL", "PLE", "PLR", "PLW", "PT",
66
- "PTH", "Q", "RET", "RUF", "SLF", "SIM", "TID", "TRY", "UP", "W", "YTT"
67
- ]
68
- ignore = [
69
- "A003", "ANN002", "ANN003", "ANN101", "ANN102", "ANN401", "N805", "N818", "PLR0913", "RET504", "RET505"
70
- ]
71
- fixable = [
72
- "A", "ANN", "ARG", "B", "C", "COM", "C90", "E", "ERA", "F", "I", "PGH", "PL", "PLE", "PLR", "PLW", "PT",
73
- "PTH", "Q", "RET", "RUF", "SLF", "SIM", "TID", "TRY", "UP", "W", "YTT"
74
- ]
75
- unfixable = []
76
-
77
- exclude = [
78
- ".bzr", ".direnv",
79
- ]
80
-
81
- line-length = 120
82
- dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
83
-
84
- [tool.ruff.mccabe]
85
- max-complexity = 10
1
+ [build-system]
2
+ requires = ["poetry-core>=1.0.0"]
3
+ build-backend = "poetry.core.masonry.api"
4
+
5
+ [tool.poetry]
6
+ name = "openforis-whisp"
7
+ version = "2.0.0b1"
8
+ description = "Whisp (What is in that plot) is an open-source solution which helps to produce relevant forest monitoring information and support compliance with deforestation-related regulations."
9
+ repository = "https://github.com/forestdatapartnership/whisp"
10
+ authors = ["Andy Arnell <andrew.arnell@fao.org>"]
11
+ readme = "README.md"
12
+ license = "MIT"
13
+ keywords = ["whisp", "geospatial", "data-processing"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Programming Language :: Python :: 3.10",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Intended Audience :: Developers",
19
+ "Intended Audience :: Science/Research",
20
+ "Topic :: Software Development :: Libraries :: Python Modules"
21
+ ]
22
+
23
+ [tool.poetry.urls]
24
+ "Documentation" = "https://github.com/forestdatapartnership/whisp#readme"
25
+ "Development Branch" = "https://github.com/forestdatapartnership/whisp/tree/main"
26
+ "Issues" = "https://github.com/forestdatapartnership/whisp/issues"
27
+
28
+ [tool.poetry.dependencies]
29
+ python = ">=3.10"
30
+ earthengine-api = "*"
31
+ numpy = ">=1.21.0,<3.0.0" # Updated version constraint
32
+ pandas = ">=1.3.0,<3.0.0"
33
+ pandera = {extras = ["io"], version = ">=0.22.1,<1.0.0"}
34
+ country_converter = ">=0.7,<2.0.0"
35
+ geojson = ">=2.5.0,<3.0.0"
36
+ python-dotenv = ">=1.0.1,<2.0.0"
37
+ pydantic-core = ">=2.14.0,<3.0.0" # Updated version constraint
38
+ rsa = ">=4.2,<5.0.0" # Updated version constraint
39
+ ipykernel = ">=6.17.1,<7.0.0" # Compatible with Colab
40
+ shapely = "^2.0.2"
41
+ geopandas = "^1.0.1"
42
+
43
+ [tool.poetry.group.dev.dependencies]
44
+ pytest = ">=6.2.5,<7.0.0"
45
+ pre-commit = ">=2.15.0,<3.0.0"
46
+ ruff = ">=0.0.1,<1.0.0"
47
+
48
+ [tool.setuptools]
49
+ package-dir = {"" = "src"}
50
+ include-package-data = true
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = ["src"]
54
+
55
+ [tool.setuptools.package-data]
56
+ "whisp.parameters" = ["lookup_gee_datasets.csv", "lookup_context_and_metadata.csv"]
57
+
58
+ [tool.pytest.ini_options]
59
+ log_cli = true
60
+ log_cli_level = "DEBUG"
61
+
62
+ [tool.ruff]
63
+ fix = true
64
+ select = [
65
+ "A", "ANN", "ARG", "B", "C", "COM", "C90", "E", "ERA", "F", "I", "N", "PGH", "PL", "PLE", "PLR", "PLW", "PT",
66
+ "PTH", "Q", "RET", "RUF", "SLF", "SIM", "TID", "TRY", "UP", "W", "YTT"
67
+ ]
68
+ ignore = [
69
+ "A003", "ANN002", "ANN003", "ANN101", "ANN102", "ANN401", "N805", "N818", "PLR0913", "RET504", "RET505"
70
+ ]
71
+ fixable = [
72
+ "A", "ANN", "ARG", "B", "C", "COM", "C90", "E", "ERA", "F", "I", "PGH", "PL", "PLE", "PLR", "PLW", "PT",
73
+ "PTH", "Q", "RET", "RUF", "SLF", "SIM", "TID", "TRY", "UP", "W", "YTT"
74
+ ]
75
+ unfixable = []
76
+
77
+ exclude = [
78
+ ".bzr", ".direnv",
79
+ ]
80
+
81
+ line-length = 120
82
+ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
83
+
84
+ [tool.ruff.mccabe]
85
+ max-complexity = 10
@@ -1,75 +1,74 @@
1
- import ee
2
- from google.oauth2 import service_account
3
-
4
-
5
- def initialize_ee(credentials_path=None):
6
- """Initializes Google Earth Engine using the provided path or defaults to normal if no path is given."""
7
- try:
8
- if not ee.data._initialized:
9
- print(credentials_path)
10
- if credentials_path:
11
- credentials = service_account.Credentials.from_service_account_file(
12
- credentials_path,
13
- scopes=["https://www.googleapis.com/auth/earthengine"],
14
- )
15
- ee.Initialize(credentials)
16
- print("EE initialized with credentials from:", credentials_path)
17
- else:
18
- ee.Initialize()
19
- print("EE initialized with default credentials.")
20
- except Exception as e:
21
- print("Error initializing EE:", e)
22
-
23
-
24
- # Default to normal initialize if nobody calls whisp.initialize_ee.
25
- try:
26
- if not ee.data._initialized:
27
- ee.Initialize()
28
- print("EE auto-initialized with default credentials.")
29
- except Exception as e:
30
- print("Error in default EE initialization:", e)
31
-
32
- from openforis_whisp.datasets import (
33
- combine_datasets,
34
- )
35
-
36
- from openforis_whisp.stats import (
37
- whisp_stats_ee_to_ee,
38
- whisp_stats_ee_to_df,
39
- whisp_stats_geojson_to_df,
40
- whisp_stats_geojson_to_ee,
41
- whisp_stats_geojson_to_geojson,
42
- whisp_stats_ee_to_drive,
43
- whisp_stats_geojson_to_drive,
44
- whisp_formatted_stats_ee_to_df,
45
- whisp_formatted_stats_ee_to_geojson,
46
- whisp_formatted_stats_geojson_to_df,
47
- whisp_formatted_stats_geojson_to_geojson,
48
- convert_iso3_to_iso2,
49
- )
50
-
51
- # temporary parameters to be removed once isio3 to iso2 conversion server side is implemented
52
- from openforis_whisp.parameters.config_runtime import (
53
- iso3_country_column,
54
- iso2_country_column,
55
- )
56
-
57
- from openforis_whisp.reformat import (
58
- validate_dataframe_using_lookups,
59
- validate_dataframe,
60
- create_schema_from_dataframe,
61
- load_schema_if_any_file_changed,
62
- # log_missing_columns,
63
- )
64
-
65
- from openforis_whisp.data_conversion import (
66
- convert_ee_to_df,
67
- convert_geojson_to_ee,
68
- convert_df_to_geojson,
69
- convert_csv_to_geojson,
70
- convert_ee_to_geojson,
71
- )
72
-
73
- from openforis_whisp.risk import whisp_risk, detect_unit_type
74
-
75
- from openforis_whisp.utils import get_example_data_path
1
+ import ee
2
+ from google.oauth2 import service_account
3
+
4
+
5
+ def initialize_ee(credentials_path=None):
6
+ """Initializes Google Earth Engine using the provided path or defaults to normal if no path is given."""
7
+ try:
8
+ if not ee.data._initialized:
9
+ print(credentials_path)
10
+ if credentials_path:
11
+ credentials = service_account.Credentials.from_service_account_file(
12
+ credentials_path,
13
+ scopes=["https://www.googleapis.com/auth/earthengine"],
14
+ )
15
+ ee.Initialize(credentials)
16
+ print("EE initialized with credentials from:", credentials_path)
17
+ else:
18
+ ee.Initialize()
19
+ print("EE initialized with default credentials.")
20
+ except Exception as e:
21
+ print("Error initializing EE:", e)
22
+
23
+
24
+ # Default to normal initialize if nobody calls whisp.initialize_ee.
25
+ try:
26
+ if not ee.data._initialized:
27
+ ee.Initialize()
28
+ print("EE auto-initialized with default credentials.")
29
+ except Exception as e:
30
+ print("Error in default EE initialization:", e)
31
+
32
+ from openforis_whisp.datasets import combine_datasets, combine_custom_bands
33
+
34
+ from openforis_whisp.stats import (
35
+ whisp_stats_ee_to_ee,
36
+ whisp_stats_ee_to_df,
37
+ whisp_stats_geojson_to_df,
38
+ whisp_stats_geojson_to_ee,
39
+ whisp_stats_geojson_to_geojson,
40
+ whisp_stats_ee_to_drive,
41
+ whisp_stats_geojson_to_drive,
42
+ whisp_formatted_stats_ee_to_df,
43
+ whisp_formatted_stats_ee_to_geojson,
44
+ whisp_formatted_stats_geojson_to_df,
45
+ whisp_formatted_stats_geojson_to_geojson,
46
+ convert_iso3_to_iso2,
47
+ )
48
+
49
+ # temporary parameters to be removed once isio3 to iso2 conversion server side is implemented
50
+ from openforis_whisp.parameters.config_runtime import (
51
+ iso3_country_column,
52
+ iso2_country_column,
53
+ )
54
+
55
+ from openforis_whisp.reformat import (
56
+ validate_dataframe_using_lookups,
57
+ validate_dataframe_using_lookups_flexible,
58
+ validate_dataframe,
59
+ create_schema_from_dataframe,
60
+ load_schema_if_any_file_changed,
61
+ # log_missing_columns,
62
+ )
63
+
64
+ from openforis_whisp.data_conversion import (
65
+ convert_ee_to_df,
66
+ convert_geojson_to_ee,
67
+ convert_df_to_geojson,
68
+ convert_csv_to_geojson,
69
+ convert_ee_to_geojson,
70
+ )
71
+
72
+ from openforis_whisp.risk import whisp_risk, detect_unit_type
73
+
74
+ from openforis_whisp.utils import get_example_data_path