geocif 0.1.49__tar.gz → 0.1.50__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 (57) hide show
  1. {geocif-0.1.49/geocif.egg-info → geocif-0.1.50}/PKG-INFO +1 -1
  2. {geocif-0.1.49 → geocif-0.1.50}/geocif/analysis.py +12 -5
  3. {geocif-0.1.49 → geocif-0.1.50}/geocif/geocif.py +23 -11
  4. {geocif-0.1.49 → geocif-0.1.50}/geocif/logger.py +24 -1
  5. {geocif-0.1.49 → geocif-0.1.50/geocif.egg-info}/PKG-INFO +1 -1
  6. {geocif-0.1.49 → geocif-0.1.50}/setup.py +1 -1
  7. {geocif-0.1.49 → geocif-0.1.50}/LICENSE +0 -0
  8. {geocif-0.1.49 → geocif-0.1.50}/MANIFEST.in +0 -0
  9. {geocif-0.1.49 → geocif-0.1.50}/README.md +0 -0
  10. {geocif-0.1.49 → geocif-0.1.50}/geocif/__init__.py +0 -0
  11. {geocif-0.1.49 → geocif-0.1.50}/geocif/agmet/__init__.py +0 -0
  12. {geocif-0.1.49 → geocif-0.1.50}/geocif/agmet/geoagmet.py +0 -0
  13. {geocif-0.1.49 → geocif-0.1.50}/geocif/agmet/plot.py +0 -0
  14. {geocif-0.1.49 → geocif-0.1.50}/geocif/agmet/utils.py +0 -0
  15. {geocif-0.1.49 → geocif-0.1.50}/geocif/backup/__init__.py +0 -0
  16. {geocif-0.1.49 → geocif-0.1.50}/geocif/backup/constants.py +0 -0
  17. {geocif-0.1.49 → geocif-0.1.50}/geocif/backup/features.py +0 -0
  18. {geocif-0.1.49 → geocif-0.1.50}/geocif/backup/geo.py +0 -0
  19. {geocif-0.1.49 → geocif-0.1.50}/geocif/backup/geocif.py +0 -0
  20. {geocif-0.1.49 → geocif-0.1.50}/geocif/backup/metadata.py +0 -0
  21. {geocif-0.1.49 → geocif-0.1.50}/geocif/backup/models.py +0 -0
  22. {geocif-0.1.49 → geocif-0.1.50}/geocif/cei/__init__.py +0 -0
  23. {geocif-0.1.49 → geocif-0.1.50}/geocif/cei/definitions.py +0 -0
  24. {geocif-0.1.49 → geocif-0.1.50}/geocif/cei/indices.py +0 -0
  25. {geocif-0.1.49 → geocif-0.1.50}/geocif/experiments.py +0 -0
  26. {geocif-0.1.49 → geocif-0.1.50}/geocif/indices_runner.py +0 -0
  27. {geocif-0.1.49 → geocif-0.1.50}/geocif/indices_runner_v2.py +0 -0
  28. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/__init__.py +0 -0
  29. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/aa.py +0 -0
  30. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/correlations.py +0 -0
  31. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/embedding.py +0 -0
  32. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/feature_engineering.py +0 -0
  33. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/feature_selection.py +0 -0
  34. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/misc.py +0 -0
  35. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/outliers.py +0 -0
  36. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/outlook.py +0 -0
  37. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/output.py +0 -0
  38. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/spatial_autocorrelation.py +0 -0
  39. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/stages.py +0 -0
  40. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/stats.py +0 -0
  41. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/trainers.py +0 -0
  42. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/trend.py +0 -0
  43. {geocif-0.1.49 → geocif-0.1.50}/geocif/ml/xai.py +0 -0
  44. {geocif-0.1.49 → geocif-0.1.50}/geocif/playground/__init__.py +0 -0
  45. {geocif-0.1.49 → geocif-0.1.50}/geocif/playground/automl.py +0 -0
  46. {geocif-0.1.49 → geocif-0.1.50}/geocif/playground/misc.py +0 -0
  47. {geocif-0.1.49 → geocif-0.1.50}/geocif/utils.py +0 -0
  48. {geocif-0.1.49 → geocif-0.1.50}/geocif/viz/__init__.py +0 -0
  49. {geocif-0.1.49 → geocif-0.1.50}/geocif/viz/misc.py +0 -0
  50. {geocif-0.1.49 → geocif-0.1.50}/geocif/viz/plot.py +0 -0
  51. {geocif-0.1.49 → geocif-0.1.50}/geocif.egg-info/SOURCES.txt +0 -0
  52. {geocif-0.1.49 → geocif-0.1.50}/geocif.egg-info/dependency_links.txt +0 -0
  53. {geocif-0.1.49 → geocif-0.1.50}/geocif.egg-info/not-zip-safe +0 -0
  54. {geocif-0.1.49 → geocif-0.1.50}/geocif.egg-info/top_level.txt +0 -0
  55. {geocif-0.1.49 → geocif-0.1.50}/requirements.txt +0 -0
  56. {geocif-0.1.49 → geocif-0.1.50}/setup.cfg +0 -0
  57. {geocif-0.1.49 → geocif-0.1.50}/tests/test_geocif.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geocif
3
- Version: 0.1.49
3
+ Version: 0.1.50
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
@@ -163,6 +163,7 @@ class Geoanalysis:
163
163
 
164
164
  df_metrics = self._compute_metrics(df)
165
165
  df_metrics = self._process_metrics(df_metrics)
166
+
166
167
  self._plot_metrics(df_metrics)
167
168
 
168
169
  df_regional_metrics_by_year = self._compute_regional_metrics(
@@ -183,6 +184,11 @@ class Geoanalysis:
183
184
  return df_metrics, df_regional_metrics, df_national_yield
184
185
 
185
186
  def _clean_data(self):
187
+ # Hack exclude 2012 if country == "illinois"
188
+ if self.country == "illinois":
189
+ self.df_analysis = self.df_analysis[
190
+ self.df_analysis["Harvest Year"] != 2012
191
+ ]
186
192
  # Remove rows with missing values in Observed Yield (tn per ha)
187
193
  return self.df_analysis.dropna(subset=["Observed Yield (tn per ha)"])
188
194
 
@@ -196,11 +202,12 @@ class Geoanalysis:
196
202
  .reset_index()
197
203
  )
198
204
 
199
- return df_metrics.pivot_table(
200
- index=["Country", "Model", "Harvest Year", "Stage Name", "Stage Range"],
201
- columns="level_5",
202
- values=0,
203
- ).reset_index()
205
+ #return df_metrics.pivot_table(
206
+ # index=["Country", "Model", "Harvest Year", "Stage Name", "Stage Range"],
207
+ # columns="level_5",
208
+ # values=0,
209
+ #).reset_index()
210
+ return df_metrics
204
211
 
205
212
  def _process_metrics(self, df_metrics):
206
213
  # Assign each unique Stage Name a unique integer identifier
@@ -82,6 +82,13 @@ class Geocif:
82
82
  self.today_full = self._date.format("MMMM_DD_YYYY_HH_mm")
83
83
 
84
84
  self.df_forecast = pd.DataFrame()
85
+ """
86
+ ====================================================================
87
+ Config file: Logging
88
+ ====================================================================
89
+ """
90
+ self.log_level = self.parser.get("LOGGING", "log_level")
91
+
85
92
  """
86
93
  ====================================================================
87
94
  Config file: Default
@@ -875,12 +882,15 @@ class Geocif:
875
882
  group.columns.str.contains(self.stage_info["Stage_ID"])
876
883
  ].tolist()
877
884
 
878
- group = group[
879
- self.fixed_columns
880
- + [self.target]
881
- + self.statistics_columns
882
- + all_columns
883
- ]
885
+ try:
886
+ group = group[
887
+ self.fixed_columns
888
+ + [self.target]
889
+ + self.statistics_columns
890
+ + all_columns
891
+ ]
892
+ except:
893
+ continue
884
894
  # rename all_columns to self.stage_info["CEI"]
885
895
  group.rename(
886
896
  columns={
@@ -1144,7 +1154,7 @@ class Geocif:
1144
1154
  self.do_xai = False
1145
1155
  self.estimate_ci = False
1146
1156
  self.estimate_ci_for_all = False
1147
- self.check_yield_trend = False
1157
+ self.check_yield_trend = True
1148
1158
  self.cluster_strategy = "single"
1149
1159
  self.select_cei_by = "Index"
1150
1160
  self.use_cumulative_features = True
@@ -1325,7 +1335,7 @@ def loop_execute(inputs):
1325
1335
  )
1326
1336
 
1327
1337
  with PyCallGraph(output=graphviz, config=config):
1328
- country, crop, season, model, logger, parser = inputs
1338
+ country, crop, season, model, logger, parser, index = inputs
1329
1339
 
1330
1340
  logger.info("=====================================================")
1331
1341
  logger.info(f"\tStarting GEOCIF: {country} {crop} {season} {model}")
@@ -1334,8 +1344,10 @@ def loop_execute(inputs):
1334
1344
  obj = Geocif(logger=logger, parser=parser)
1335
1345
  obj.read_data(country, crop, season)
1336
1346
 
1337
- # Store config file in database
1338
- output.config_to_db(obj.db_path, obj.parser, obj.today)
1347
+ # Store config file in database, only execute this for
1348
+ # the first iteration of the loop
1349
+ if index == 0:
1350
+ output.config_to_db(obj.db_path, obj.parser, obj.today)
1339
1351
 
1340
1352
  # Setup metadata and run ML code
1341
1353
  obj.setup(season, model)
@@ -1380,7 +1392,7 @@ def execute_models(inputs, logger, parser):
1380
1392
  do_parallel = parser.getboolean("DEFAULT", "do_parallel")
1381
1393
 
1382
1394
  # Add logger and parser to each element in inputs
1383
- inputs = [item + [logger, parser] for item in inputs]
1395
+ inputs = [item + [logger, parser, idx] for idx, item in enumerate(inputs)]
1384
1396
 
1385
1397
  if do_parallel:
1386
1398
  cpu_count = int(mp.cpu_count() * 0.3)
@@ -71,8 +71,29 @@ class Logger:
71
71
  self.logger.error(msg)
72
72
 
73
73
 
74
+ def get_logging_level(level):
75
+ """
76
+
77
+ Args:
78
+ level:
79
+
80
+ Returns:
81
+
82
+ """
83
+ if level == "DEBUG":
84
+ return logging.DEBUG
85
+ elif level == "INFO":
86
+ return logging.INFO
87
+ elif level == "WARNING":
88
+ return logging.WARNING
89
+ elif level == "ERROR":
90
+ return logging.ERROR
91
+ else:
92
+ return logging.INFO
93
+
94
+
74
95
  def setup_logger_parser(
75
- path_config_file, name_project="geocif", name_file="ml", level=logging.DEBUG
96
+ path_config_file, name_project="geocif", name_file="ml"
76
97
  ):
77
98
  """
78
99
 
@@ -87,6 +108,8 @@ def setup_logger_parser(
87
108
  """
88
109
  parser = read_config(path_config_file)
89
110
  dir_log = parser.get("PATHS", "dir_log")
111
+ level = parser.get("LOGGING", "log_level")
112
+ level = get_logging_level(level)
90
113
 
91
114
  logger = Logger(
92
115
  dir_log=dir_log,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geocif
3
- Version: 0.1.49
3
+ Version: 0.1.50
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.49",
53
+ version="0.1.50",
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
File without changes