geocif 0.1.44__tar.gz → 0.1.46__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 (55) hide show
  1. {geocif-0.1.44/geocif.egg-info → geocif-0.1.46}/PKG-INFO +1 -1
  2. {geocif-0.1.44 → geocif-0.1.46}/geocif/geocif.py +9 -0
  3. {geocif-0.1.44 → geocif-0.1.46}/geocif/indices_runner.py +3 -0
  4. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/correlations.py +50 -41
  5. {geocif-0.1.44 → geocif-0.1.46/geocif.egg-info}/PKG-INFO +1 -1
  6. {geocif-0.1.44 → geocif-0.1.46}/setup.py +1 -1
  7. {geocif-0.1.44 → geocif-0.1.46}/LICENSE +0 -0
  8. {geocif-0.1.44 → geocif-0.1.46}/MANIFEST.in +0 -0
  9. {geocif-0.1.44 → geocif-0.1.46}/README.md +0 -0
  10. {geocif-0.1.44 → geocif-0.1.46}/geocif/__init__.py +0 -0
  11. {geocif-0.1.44 → geocif-0.1.46}/geocif/agmet/__init__.py +0 -0
  12. {geocif-0.1.44 → geocif-0.1.46}/geocif/agmet/geoagmet.py +0 -0
  13. {geocif-0.1.44 → geocif-0.1.46}/geocif/agmet/plot.py +0 -0
  14. {geocif-0.1.44 → geocif-0.1.46}/geocif/agmet/utils.py +0 -0
  15. {geocif-0.1.44 → geocif-0.1.46}/geocif/analysis.py +0 -0
  16. {geocif-0.1.44 → geocif-0.1.46}/geocif/backup/__init__.py +0 -0
  17. {geocif-0.1.44 → geocif-0.1.46}/geocif/backup/constants.py +0 -0
  18. {geocif-0.1.44 → geocif-0.1.46}/geocif/backup/features.py +0 -0
  19. {geocif-0.1.44 → geocif-0.1.46}/geocif/backup/geo.py +0 -0
  20. {geocif-0.1.44 → geocif-0.1.46}/geocif/backup/geocif.py +0 -0
  21. {geocif-0.1.44 → geocif-0.1.46}/geocif/backup/metadata.py +0 -0
  22. {geocif-0.1.44 → geocif-0.1.46}/geocif/backup/models.py +0 -0
  23. {geocif-0.1.44 → geocif-0.1.46}/geocif/cei/__init__.py +0 -0
  24. {geocif-0.1.44 → geocif-0.1.46}/geocif/cei/definitions.py +0 -0
  25. {geocif-0.1.44 → geocif-0.1.46}/geocif/cei/indices.py +0 -0
  26. {geocif-0.1.44 → geocif-0.1.46}/geocif/experiments.py +0 -0
  27. {geocif-0.1.44 → geocif-0.1.46}/geocif/indices_runner_v2.py +0 -0
  28. {geocif-0.1.44 → geocif-0.1.46}/geocif/logger.py +0 -0
  29. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/__init__.py +0 -0
  30. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/correlations_backup.py +0 -0
  31. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/embedding.py +0 -0
  32. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/feature_engineering.py +0 -0
  33. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/feature_selection.py +0 -0
  34. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/outliers.py +0 -0
  35. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/outlook.py +0 -0
  36. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/output.py +0 -0
  37. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/spatial_autocorrelation.py +0 -0
  38. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/stages.py +0 -0
  39. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/stats.py +0 -0
  40. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/trainers.py +0 -0
  41. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/trend.py +0 -0
  42. {geocif-0.1.44 → geocif-0.1.46}/geocif/ml/xai.py +0 -0
  43. {geocif-0.1.44 → geocif-0.1.46}/geocif/playground/__init__.py +0 -0
  44. {geocif-0.1.44 → geocif-0.1.46}/geocif/playground/automl.py +0 -0
  45. {geocif-0.1.44 → geocif-0.1.46}/geocif/playground/misc.py +0 -0
  46. {geocif-0.1.44 → geocif-0.1.46}/geocif/utils.py +0 -0
  47. {geocif-0.1.44 → geocif-0.1.46}/geocif/viz/__init__.py +0 -0
  48. {geocif-0.1.44 → geocif-0.1.46}/geocif/viz/plot.py +0 -0
  49. {geocif-0.1.44 → geocif-0.1.46}/geocif.egg-info/SOURCES.txt +0 -0
  50. {geocif-0.1.44 → geocif-0.1.46}/geocif.egg-info/dependency_links.txt +0 -0
  51. {geocif-0.1.44 → geocif-0.1.46}/geocif.egg-info/not-zip-safe +0 -0
  52. {geocif-0.1.44 → geocif-0.1.46}/geocif.egg-info/top_level.txt +0 -0
  53. {geocif-0.1.44 → geocif-0.1.46}/requirements.txt +0 -0
  54. {geocif-0.1.44 → geocif-0.1.46}/setup.cfg +0 -0
  55. {geocif-0.1.44 → geocif-0.1.46}/tests/test_geocif.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geocif
3
- Version: 0.1.44
3
+ Version: 0.1.46
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
@@ -114,6 +114,12 @@ class Geocif:
114
114
  self.analogous_year_yield_as_feature = self.parser.getboolean(
115
115
  "ML", "analogous_year_yield_as_feature"
116
116
  )
117
+ self.plot_map_for_correlation_plot = self.parser.getboolean(
118
+ "ML", "plot_map_for_correlation_plot"
119
+ )
120
+ self.correlation_threshold = self.parser.getfloat(
121
+ "ML", "correlation_threshold"
122
+ )
117
123
  self.include_lat_lon = self.parser.getboolean("ML", "include_lat_lon")
118
124
  self.spatial_autocorrelation = self.parser.getboolean(
119
125
  "ML", "spatial_autocorrelation"
@@ -859,8 +865,11 @@ class Geocif:
859
865
  dict_kwargs["method"] = self.method
860
866
  dict_kwargs["national_correlation"] = self.national_correlation
861
867
  dict_kwargs["groupby"] = self.correlation_plot_groupby
868
+ dict_kwargs["cluster_strategy"] = self.cluster_strategy
862
869
  dict_kwargs["dg_country"] = self.dg_country
863
870
  dict_kwargs["combined_dict"] = self.combined_dict
871
+ dict_kwargs["plot_map"] = self.plot_map_for_correlation_plot
872
+ dict_kwargs["correlation_threshold"] = self.correlation_threshold
864
873
 
865
874
  if self.spatial_autocorrelation:
866
875
  sa.compute_spatial_autocorrelation(self.df_results, **dict_kwargs)
@@ -172,6 +172,9 @@ class cei_runner(base.BaseGeo):
172
172
  or "zimbabwe_maize" in i[3]
173
173
  or "south_africa_maize" in i[3]
174
174
  or "mozambique_maize" in i[3]
175
+ or "united_states_of_america" in i[3]
176
+ or "russian_federation" in i[3]
177
+ or "ukraine" in i[3]
175
178
  ]
176
179
  # "malawi" in i[2]]
177
180
 
@@ -74,18 +74,24 @@ def plot_feature_corr_by_time(df, **kwargs):
74
74
  forecast_season = kwargs.get("forecast_season")
75
75
  national_correlation = kwargs.get("national_correlation")
76
76
  group_by = kwargs.get("groupby")
77
+ plot_map = kwargs.get("plot_map")
78
+ region_name = kwargs.get("region_name")
77
79
 
78
80
  # Setup the figure and gridspec
79
81
  fig = plt.figure(figsize=(10, 5))
80
- gs = fig.add_gridspec(
81
- 3, 2, height_ratios=[6, 5, 1], width_ratios=[5, 1.5], hspace=0.6, wspace=0.0
82
- )
82
+ if plot_map:
83
+ gs = fig.add_gridspec(
84
+ 3, 2, height_ratios=[6, 5, 1], width_ratios=[5, 1.5], hspace=0.6, wspace=0.0
85
+ )
86
+ else:
87
+ gs = fig.add_gridspec(3, 1, height_ratios=[6, 5, 1], hspace=0.6, wspace=0.0)
83
88
 
84
89
  # Assign subplots
85
90
  ax_heatmap = fig.add_subplot(gs[0:2, 0])
86
- ax_map = fig.add_subplot(gs[0, 1])
87
91
  cbar_ax = fig.add_subplot(gs[2, 0])
88
- ax4 = fig.add_subplot(gs[2, 1])
92
+ if plot_map:
93
+ ax_map = fig.add_subplot(gs[0, 1])
94
+ ax4 = fig.add_subplot(gs[2, 1])
89
95
 
90
96
  # Transpose and reverse the columns of the dataframe
91
97
  df_transpose = df.T
@@ -107,43 +113,43 @@ def plot_feature_corr_by_time(df, **kwargs):
107
113
  )
108
114
  ax_heatmap.tick_params(left=False, bottom=False)
109
115
 
110
- # Plot the map using GeoPandas
111
- dg_country = kwargs.get("dg_country")
112
-
113
- ax_map = dg_country.plot(
114
- ax=ax_map,
115
- color="white",
116
- edgecolor="black",
117
- linewidth=1.0,
118
- facecolor=None,
119
- legend=False,
120
- )
121
-
122
- if not national_correlation:
123
- id = kwargs["region_id"]
124
- dg_region = dg_country[dg_country[group_by] == id]
125
- ax_map = dg_region.plot(
126
- ax=ax_map, color="blue", edgecolor="blue", linewidth=1.0, legend=False
116
+ if plot_map:
117
+ # Plot the map using GeoPandas
118
+ dg_country = kwargs.get("dg_country")
119
+
120
+ ax_map = dg_country.plot(
121
+ ax=ax_map,
122
+ color="white",
123
+ edgecolor="black",
124
+ linewidth=1.0,
125
+ facecolor=None,
126
+ legend=False,
127
127
  )
128
- # Set title with color blue
129
- ax_map.set_title(f"Region: {id}", color="blue")
130
-
131
- # No colorbar for the map
132
- ax_map.axis("off")
133
- # Remove borders
134
- ax_map.spines["top"].set_visible(False)
135
- ax_map.spines["right"].set_visible(False)
136
- ax_map.spines["bottom"].set_visible(False)
137
- ax_map.spines["left"].set_visible(False)
138
- # ax4 should not be visible
139
- ax4.axis("off")
128
+
129
+ id = kwargs["region_id"]
130
+ if plot_map:
131
+ if not national_correlation:
132
+ dg_region = dg_country[dg_country[group_by] == id]
133
+ ax_map = dg_region.plot(
134
+ ax=ax_map, color="blue", edgecolor="blue", linewidth=1.0, legend=False
135
+ )
136
+ # Set title with color blue
137
+ ax_map.set_title(f"Region: {id}", color="blue")
138
+
139
+ # No colorbar for the map
140
+ ax_map.axis("off")
141
+ # Remove borders
142
+ ax_map.spines["top"].set_visible(False)
143
+ ax_map.spines["right"].set_visible(False)
144
+ ax_map.spines["bottom"].set_visible(False)
145
+ ax_map.spines["left"].set_visible(False)
146
+ # ax4 should not be visible
147
+ ax4.axis("off")
140
148
 
141
149
  # Add colorbar label
142
150
  # cbar_ax.set_xlabel("Correlation Coefficient", labelpad=3, size="small")
143
151
  cbar_ax.set_title("Correlation Coefficient", loc="left", size="small")
144
- ax_heatmap.set_xticklabels(
145
- ax_heatmap.get_xticklabels(), size="x-small", rotation=0, fontsize=5
146
- )
152
+ ax_heatmap.set_xticklabels(ax_heatmap.get_xticklabels(), size="x-small", rotation=0, fontsize=5)
147
153
  ax_heatmap.set_yticklabels(ax_heatmap.get_yticklabels(), size="x-small", fontsize=5)
148
154
  ax_heatmap.set_xlabel("")
149
155
  ax_heatmap.set_ylabel(" ")
@@ -151,12 +157,13 @@ def plot_feature_corr_by_time(df, **kwargs):
151
157
  cbar_ax.tick_params(axis="both", which="major", labelsize=5)
152
158
 
153
159
  _country = country.title().replace("_", " ")
154
- _crop = crop.title().replace("_", " ")
160
+ _region_name = region_name.replace("_", " ") if not national_correlation else ""
161
+ _crop = "Poppy" # crop.title().replace("_", " ")
155
162
  if not national_correlation:
156
163
  fname = f"{country}_{crop}_{id}_corr_feature_by_time.png"
157
164
  else:
158
165
  fname = f"{country}_{crop}_corr_feature_by_time.png"
159
- ax_heatmap.set_title(f"{_country}\n{_crop}")
166
+ ax_heatmap.set_title(f"{_country}, {_crop}\n{_region_name}")
160
167
 
161
168
  # plt.tight_layout()
162
169
  os.makedirs(dir_output, exist_ok=True)
@@ -246,14 +253,14 @@ def all_correlated_feature_by_time(df, **kwargs):
246
253
  Returns:
247
254
 
248
255
  """
249
- THRESHOLD = 0.1
250
256
  national_correlation = kwargs.get("national_correlation")
251
257
  group_by = kwargs.get("groupby")
252
258
  combined_dict = kwargs.get("combined_dict")
259
+ THRESHOLD = kwargs.get("correlation_threshold")
253
260
 
254
261
  dict_selected_features = {}
255
262
  dict_best_cei = {}
256
- breakpoint()
263
+
257
264
  if not national_correlation:
258
265
  groups = df.groupby(group_by)
259
266
  for region_id, group in tqdm(
@@ -297,6 +304,8 @@ def all_correlated_feature_by_time(df, **kwargs):
297
304
  )
298
305
 
299
306
  kwargs["region_id"] = region_id
307
+ _region_names = "_".join([str(x) for x in group['Region'].unique()])
308
+ kwargs["region_name"] = _region_names
300
309
  plot_feature_corr_by_time(df_tmp, **kwargs)
301
310
  # For each element in dict_best_cei, add the type of the cei
302
311
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geocif
3
- Version: 0.1.44
3
+ Version: 0.1.46
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
@@ -50,6 +50,6 @@ setup(
50
50
  test_suite="tests",
51
51
  tests_require=test_requirements,
52
52
  url="https://ritviksahajpal.github.io/yield_forecasting/",
53
- version="0.1.44",
53
+ version="0.1.46",
54
54
  zip_safe=False,
55
55
  )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes