openforis-whisp 2.0.0a5__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.0a5 → openforis_whisp-2.0.0b1}/PKG-INFO +2 -2
  2. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/pyproject.toml +2 -2
  3. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/__init__.py +2 -3
  4. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/datasets.py +29 -36
  5. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/parameters/lookup_gee_datasets.csv +2 -1
  6. openforis_whisp-2.0.0b1/src/openforis_whisp/reformat.py +696 -0
  7. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/risk.py +85 -8
  8. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/stats.py +145 -51
  9. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/utils.py +40 -0
  10. openforis_whisp-2.0.0a5/src/openforis_whisp/reformat.py +0 -495
  11. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/LICENSE +0 -0
  12. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/README.md +0 -0
  13. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/data_conversion.py +0 -0
  14. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/logger.py +0 -0
  15. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/parameters/__init__.py +0 -0
  16. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/parameters/config_runtime.py +0 -0
  17. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/parameters/lookup_context_and_metadata.csv +0 -0
  18. {openforis_whisp-2.0.0a5 → openforis_whisp-2.0.0b1}/src/openforis_whisp/pd_schemas.py +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openforis-whisp
3
- Version: 2.0.0a5
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
@@ -4,10 +4,10 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "openforis-whisp"
7
- version = "2.0.0a5"
7
+ version = "2.0.0b1"
8
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
9
  repository = "https://github.com/forestdatapartnership/whisp"
10
- authors = ["Andy Arnell <and.arnell@fao.org>"]
10
+ authors = ["Andy Arnell <andrew.arnell@fao.org>"]
11
11
  readme = "README.md"
12
12
  license = "MIT"
13
13
  keywords = ["whisp", "geospatial", "data-processing"]
@@ -29,9 +29,7 @@ try:
29
29
  except Exception as e:
30
30
  print("Error in default EE initialization:", e)
31
31
 
32
- from openforis_whisp.datasets import (
33
- combine_datasets,
34
- )
32
+ from openforis_whisp.datasets import combine_datasets, combine_custom_bands
35
33
 
36
34
  from openforis_whisp.stats import (
37
35
  whisp_stats_ee_to_ee,
@@ -56,6 +54,7 @@ from openforis_whisp.parameters.config_runtime import (
56
54
 
57
55
  from openforis_whisp.reformat import (
58
56
  validate_dataframe_using_lookups,
57
+ validate_dataframe_using_lookups_flexible,
59
58
  validate_dataframe,
60
59
  create_schema_from_dataframe,
61
60
  load_schema_if_any_file_changed,
@@ -1215,40 +1215,6 @@ def nci_ocs2020_prep():
1215
1215
 
1216
1216
  ###Combining datasets
1217
1217
 
1218
- ###Combining datasets
1219
-
1220
- # def combine_datasets():
1221
- # """Combines datasets into a single multiband image, with fallback if assets are missing."""
1222
- # img_combined = ee.Image(1).rename(geometry_area_column)
1223
-
1224
- # # Combine images directly
1225
- # for img in [func() for func in list_functions()]:
1226
- # try:
1227
- # img_combined = img_combined.addBands(img)
1228
- # except ee.EEException as e:
1229
- # # logger.error(f"Error adding image: {e}")
1230
- # print(f"Error adding image: {e}")
1231
-
1232
- # try:
1233
- # # Attempt to print band names to check for errors
1234
- # print(img_combined.bandNames().getInfo())
1235
- # except ee.EEException as e:
1236
- # # logger.error(f"Error printing band names: {e}")
1237
- # # logger.info("Running code for filtering to only valid datasets due to error in input")
1238
- # print("using valid datasets filter due to error in input")
1239
- # # Validate images
1240
- # images_to_test = [func() for func in list_functions()]
1241
- # valid_imgs = keep_valid_images(images_to_test) # Validate images
1242
-
1243
- # # Retry combining images after validation
1244
- # img_combined = ee.Image(1).rename(geometry_area_column)
1245
- # for img in valid_imgs:
1246
- # img_combined = img_combined.addBands(img)
1247
-
1248
- # img_combined = img_combined.multiply(ee.Image.pixelArea())
1249
-
1250
- # return img_combined
1251
-
1252
1218
 
1253
1219
  def combine_datasets(national_codes=None):
1254
1220
  """Combines datasets into a single multiband image, with fallback if assets are missing."""
@@ -1380,5 +1346,32 @@ def ee_image_checker(image):
1380
1346
  return False
1381
1347
 
1382
1348
 
1383
- # print(combine_valid_datasets().bandNames().getInfo())
1384
- # print(combine_datasets().bandNames().getInfo())
1349
+ # preparation steps for multiband image with area per pixel values
1350
+ # function for notebook environment
1351
+ # user provides custom_images dict and custom_bands_info dict
1352
+ def combine_custom_bands(custom_images, custom_bands_info):
1353
+ """
1354
+ Combine custom Earth Engine images into a single multiband image with area conversion.
1355
+
1356
+ Returns
1357
+ -------
1358
+ ee.Image
1359
+ Combined bands converted to area values
1360
+ """
1361
+ # ... existing validation code ...
1362
+
1363
+ # Step 3: Rename and combine images
1364
+ band_names = list(custom_bands_info.keys())
1365
+
1366
+ # Start with first image
1367
+ custom_ee_image = custom_images[band_names[0]].rename(band_names[0])
1368
+
1369
+ # Add remaining images if any
1370
+ for name in band_names[1:]:
1371
+ next_image = custom_images[name].rename(name)
1372
+ custom_ee_image = custom_ee_image.addBands(next_image)
1373
+
1374
+ # Convert to area values
1375
+ custom_ee_image = custom_ee_image.multiply(ee.Image.pixelArea())
1376
+
1377
+ return custom_ee_image # Only return the image
@@ -2,7 +2,7 @@ name,order,ISO2_code,theme,theme_timber,use_for_risk,use_for_risk_timber,exclude
2
2
  EUFO_2020,10,,treecover,naturally_reg_2020,1,1,0,float32,1,0,g_jrc_gfc_2020_prep
3
3
  GLAD_Primary,20,,treecover,primary,1,1,0,float32,1,0,g_glad_pht_prep
4
4
  TMF_undist,30,,treecover,primary,1,1,0,float32,1,0,g_jrc_tmf_undisturbed_prep
5
- GFC_TC_2020,50,,treecover,naturally_reg_2020,1,1,0,float32,1,0,g_glad_gfc_10pc_prep
5
+ GFC_TC_2020,50,,treecover,naturally_reg_2020,1,1,0,float32,1,0,g_gfc_tc_2020_prep
6
6
  Forest_FDaP,60,,treecover,naturally_reg_2020,1,1,0,float32,1,0,g_glad_gfc_10pc_prep
7
7
  ESA_TC_2020,70,,treecover,naturally_reg_2020,1,1,0,float32,1,0,g_esa_worldcover_trees_prep
8
8
  TMF_plant,80,,commodities,NA,1,1,0,float32,1,0,g_jrc_tmf_plantation_prep
@@ -199,3 +199,4 @@ nBR_INPE_TCamz_pasture_2020,2422,BR,commodities,NA,1,1,0,float32,1,0,nbr_terracl
199
199
  nBR_INPE_TCcer_pasture_2020,2423,BR,commodities,NA,1,1,0,float32,1,0,nbr_terraclass_cer20_ac_prep
200
200
  nBR_MapBiomas_col9_pasture_2020,2424,BR,commodities,NA,1,1,0,float32,1,0,nbr_mapbiomasc9_pasture_prep
201
201
  nCI_Cocoa_bnetd,3000,CI,commodities,NA,1,1,0,float32,1,0,nci_ocs2020_prep
202
+