geocif 0.1.77__tar.gz → 0.1.78__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 (85) hide show
  1. {geocif-0.1.77/geocif.egg-info → geocif-0.1.78}/PKG-INFO +1 -1
  2. {geocif-0.1.77 → geocif-0.1.78}/geocif/analysis.py +32 -14
  3. geocif-0.1.78/geocif/cei/indices.py +917 -0
  4. {geocif-0.1.77 → geocif-0.1.78}/geocif/geocif.py +18 -10
  5. {geocif-0.1.77 → geocif-0.1.78}/geocif/geocif_runner.py +54 -30
  6. {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner.py +1 -1
  7. {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_angola.py +2 -0
  8. {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_madagascar.py +2 -0
  9. {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_malawi.py +2 -0
  10. {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_mozambique.py +2 -0
  11. {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_south_africa.py +2 -0
  12. {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_zambia.py +2 -0
  13. {geocif-0.1.77 → geocif-0.1.78}/geocif/indices_runner_zimbabwe.py +2 -0
  14. geocif-0.1.78/geocif/mm.py +446 -0
  15. {geocif-0.1.77 → geocif-0.1.78/geocif.egg-info}/PKG-INFO +1 -1
  16. {geocif-0.1.77 → geocif-0.1.78}/setup.py +1 -1
  17. geocif-0.1.77/geocif/cei/indices.py +0 -880
  18. geocif-0.1.77/geocif/mm.py +0 -298
  19. {geocif-0.1.77 → geocif-0.1.78}/LICENSE +0 -0
  20. {geocif-0.1.77 → geocif-0.1.78}/MANIFEST.in +0 -0
  21. {geocif-0.1.77 → geocif-0.1.78}/README.md +0 -0
  22. {geocif-0.1.77 → geocif-0.1.78}/geocif/__init__.py +0 -0
  23. {geocif-0.1.77 → geocif-0.1.78}/geocif/agmet/__init__.py +0 -0
  24. {geocif-0.1.77 → geocif-0.1.78}/geocif/agmet/geoagmet.py +0 -0
  25. {geocif-0.1.77 → geocif-0.1.78}/geocif/agmet/plot.py +0 -0
  26. {geocif-0.1.77 → geocif-0.1.78}/geocif/agmet/utils.py +0 -0
  27. {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/__init__.py +0 -0
  28. {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/constants.py +0 -0
  29. {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/features.py +0 -0
  30. {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/geo.py +0 -0
  31. {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/geocif.py +0 -0
  32. {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/metadata.py +0 -0
  33. {geocif-0.1.77 → geocif-0.1.78}/geocif/backup/models.py +0 -0
  34. {geocif-0.1.77 → geocif-0.1.78}/geocif/cei/__init__.py +0 -0
  35. {geocif-0.1.77 → geocif-0.1.78}/geocif/cei/definitions.py +0 -0
  36. {geocif-0.1.77 → geocif-0.1.78}/geocif/experiments.py +0 -0
  37. {geocif-0.1.77 → geocif-0.1.78}/geocif/logger.py +0 -0
  38. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/__init__.py +0 -0
  39. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/correlations.py +0 -0
  40. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/embedding.py +0 -0
  41. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/feature_engineering.py +0 -0
  42. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/feature_selection.py +0 -0
  43. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/outliers.py +0 -0
  44. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/outlook.py +0 -0
  45. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/output.py +0 -0
  46. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/spatial_autocorrelation.py +0 -0
  47. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/stages.py +0 -0
  48. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/stats.py +0 -0
  49. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/trainers.py +0 -0
  50. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/trend.py +0 -0
  51. {geocif-0.1.77 → geocif-0.1.78}/geocif/ml/xai.py +0 -0
  52. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/__init__.py +0 -0
  53. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/aa.py +0 -0
  54. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/area.py +0 -0
  55. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/automl.py +0 -0
  56. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/download_esi.py +0 -0
  57. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/enso.py +0 -0
  58. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/eval.py +0 -0
  59. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/gamtest.py +0 -0
  60. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/gee_access.py +0 -0
  61. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/misc.py +0 -0
  62. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/play_xagg.py +0 -0
  63. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/reg.py +0 -0
  64. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/sustain.py +0 -0
  65. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/test_catboost.py +0 -0
  66. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp.py +0 -0
  67. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp2.py +0 -0
  68. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp3.py +0 -0
  69. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp4.py +0 -0
  70. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/tmp5.py +0 -0
  71. {geocif-0.1.77 → geocif-0.1.78}/geocif/playground/wolayita_maize_mask.py +0 -0
  72. {geocif-0.1.77 → geocif-0.1.78}/geocif/risk/__init__.py +0 -0
  73. {geocif-0.1.77 → geocif-0.1.78}/geocif/risk/impact_assessment.py +0 -0
  74. {geocif-0.1.77 → geocif-0.1.78}/geocif/utils.py +0 -0
  75. {geocif-0.1.77 → geocif-0.1.78}/geocif/viz/__init__.py +0 -0
  76. {geocif-0.1.77 → geocif-0.1.78}/geocif/viz/gt.py +0 -0
  77. {geocif-0.1.77 → geocif-0.1.78}/geocif/viz/plot.py +0 -0
  78. {geocif-0.1.77 → geocif-0.1.78}/geocif/viz/tmp.py +0 -0
  79. {geocif-0.1.77 → geocif-0.1.78}/geocif.egg-info/SOURCES.txt +0 -0
  80. {geocif-0.1.77 → geocif-0.1.78}/geocif.egg-info/dependency_links.txt +0 -0
  81. {geocif-0.1.77 → geocif-0.1.78}/geocif.egg-info/not-zip-safe +0 -0
  82. {geocif-0.1.77 → geocif-0.1.78}/geocif.egg-info/top_level.txt +0 -0
  83. {geocif-0.1.77 → geocif-0.1.78}/requirements.txt +0 -0
  84. {geocif-0.1.77 → geocif-0.1.78}/setup.cfg +0 -0
  85. {geocif-0.1.77 → geocif-0.1.78}/tests/test_geocif.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geocif
3
- Version: 0.1.77
3
+ Version: 0.1.78
4
4
  Summary: Models to visualize and forecast crop conditions and yields
5
5
  Home-page: https://ritviksahajpal.github.io/yield_forecasting/
6
6
  Author: Ritvik Sahajpal
@@ -347,7 +347,9 @@ class Geoanalysis:
347
347
  df_tmp = df_region.copy()
348
348
 
349
349
  # Fill
350
- df_tmp[area_ha] = df_tmp.groupby("Country")[area_ha].transform(lambda x: x.fillna(x.median()))
350
+ df_tmp[area_ha] = df_tmp.groupby("Country")[area_ha].transform(
351
+ lambda x: x.fillna(x.median())
352
+ )
351
353
 
352
354
  # Log that we are filling missing values with the median
353
355
  self.logger.info(
@@ -379,7 +381,11 @@ class Geoanalysis:
379
381
  """
380
382
  Plot observed vs predicted yield for all regions and all years.
381
383
  """
382
- from sklearn.metrics import mean_squared_error, r2_score, mean_absolute_percentage_error
384
+ from sklearn.metrics import (
385
+ mean_squared_error,
386
+ r2_score,
387
+ mean_absolute_percentage_error,
388
+ )
383
389
 
384
390
  # Ensure 'Harvest Year' is numeric
385
391
  df.loc[:, "Harvest Year"] = pd.to_numeric(df["Harvest Year"], errors="coerce")
@@ -391,7 +397,9 @@ class Geoanalysis:
391
397
 
392
398
  # Generate colors for years
393
399
  cmap = plt.cm.viridis # Colormap for years
394
- norm = plt.Normalize(vmin=years.min(), vmax=years.max()) # Normalize years to colormap
400
+ norm = plt.Normalize(
401
+ vmin=years.min(), vmax=years.max()
402
+ ) # Normalize years to colormap
395
403
  colors = [cmap(norm(year)) for year in years]
396
404
 
397
405
  # Create the plot
@@ -442,7 +450,9 @@ class Geoanalysis:
442
450
  cbar.set_label("Harvest Year")
443
451
 
444
452
  # Set equispaced ticks for exactly 5 points
445
- ticks = np.linspace(years.min(), years.max(), 5, dtype=int) # 5 equispaced ticks
453
+ ticks = np.linspace(
454
+ years.min(), years.max(), 5, dtype=int
455
+ ) # 5 equispaced ticks
446
456
  cbar.set_ticks(ticks)
447
457
  cbar.ax.set_yticklabels([str(tick) for tick in ticks])
448
458
 
@@ -454,10 +464,16 @@ class Geoanalysis:
454
464
  plt.close()
455
465
 
456
466
  def _plot_national_yield(self, df_national_yield):
457
- from sklearn.metrics import mean_squared_error, r2_score, mean_absolute_percentage_error
467
+ from sklearn.metrics import (
468
+ mean_squared_error,
469
+ r2_score,
470
+ mean_absolute_percentage_error,
471
+ )
458
472
 
459
473
  # Ensure 'Harvest Year' is numeric
460
- df_national_yield["Harvest Year"] = pd.to_numeric(df_national_yield["Harvest Year"], errors="coerce")
474
+ df_national_yield["Harvest Year"] = pd.to_numeric(
475
+ df_national_yield["Harvest Year"], errors="coerce"
476
+ )
461
477
 
462
478
  # Extract data
463
479
  x = df_national_yield["Harvest Year"]
@@ -516,7 +532,9 @@ class Geoanalysis:
516
532
  # Add legend for years
517
533
  sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
518
534
  sm.set_array([])
519
- cbar = fig.colorbar(sm, ax=ax, aspect=50, pad=0.02) # Specify the axis explicitly
535
+ cbar = fig.colorbar(
536
+ sm, ax=ax, aspect=50, pad=0.02
537
+ ) # Specify the axis explicitly
520
538
  cbar.set_label("Harvest Year")
521
539
 
522
540
  # Set equispaced ticks for exactly 5 points
@@ -579,10 +597,8 @@ class Geoanalysis:
579
597
  )
580
598
 
581
599
  # Merge the median yield columns with the % of total production dataframe
582
- df_historic = (
583
- df_pct
584
- .merge(df_median_2018_2022, on="Region", how="left")
585
- .merge(df_median_2013_2017, on="Region", how="left")
600
+ df_historic = df_pct.merge(df_median_2018_2022, on="Region", how="left").merge(
601
+ df_median_2013_2017, on="Region", how="left"
586
602
  )
587
603
 
588
604
  return df_historic
@@ -1081,7 +1097,7 @@ class RegionalMapper(Geoanalysis):
1081
1097
  df_tmp = df_model[
1082
1098
  (df_model["% of total Area (ha)"] < 0.5)
1083
1099
  & (df_model["Mean Absolute Percentage Error"] > 100)
1084
- ]
1100
+ ]
1085
1101
 
1086
1102
  df_model = df_model.drop(df_tmp.index)
1087
1103
 
@@ -1113,7 +1129,9 @@ class RegionalMapper(Geoanalysis):
1113
1129
  # )
1114
1130
 
1115
1131
  plt.tight_layout()
1116
- plt.savefig(self.dir_analysis / f"histogram_region_{model}_mape.png", dpi=250)
1132
+ plt.savefig(
1133
+ self.dir_analysis / f"histogram_region_{model}_mape.png", dpi=250
1134
+ )
1117
1135
  plt.close()
1118
1136
 
1119
1137
  def plot_mape_map(self):
@@ -1140,7 +1158,7 @@ class RegionalMapper(Geoanalysis):
1140
1158
  col = "Mean Absolute Percentage Error"
1141
1159
  countries = df_model["Country"].unique().tolist()
1142
1160
  countries = [country.title().replace("_", " ") for country in countries]
1143
- crop = df_model["Crop"].unique()[0].title().replace('_', ' ')
1161
+ crop = df_model["Crop"].unique()[0].title().replace("_", " ")
1144
1162
  df = df_model[df_model["Country"].isin(countries)]
1145
1163
  self.dg = self.dg[self.dg["ADM0_NAME"].isin(countries)]
1146
1164