geocif 0.0.1__tar.gz → 0.1.2__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 (80) hide show
  1. geocif-0.1.2/PKG-INFO +80 -0
  2. geocif-0.1.2/geocif/__init__.py +7 -0
  3. geocif-0.1.2/geocif/agmet/geoagmet.py +170 -0
  4. geocif-0.1.2/geocif/agmet/plot.py +773 -0
  5. geocif-0.1.2/geocif/agmet/utils.py +255 -0
  6. geocif-0.1.2/geocif/backup/__init__.py +0 -0
  7. {geocif-0.0.1/geocif → geocif-0.1.2/geocif/backup}/constants.py +1 -1
  8. geocif-0.1.2/geocif/backup/features.py +306 -0
  9. geocif-0.1.2/geocif/backup/geo.py +291 -0
  10. geocif-0.1.2/geocif/backup/geocif.py +496 -0
  11. geocif-0.1.2/geocif/backup/metadata.py +39 -0
  12. geocif-0.1.2/geocif/backup/models.py +6 -0
  13. geocif-0.1.2/geocif/cei/__init__.py +4 -0
  14. geocif-0.1.2/geocif/cei/definitions.py +111 -0
  15. geocif-0.1.2/geocif/cei/indices.py +873 -0
  16. geocif-0.1.2/geocif/geocif.py +1015 -0
  17. geocif-0.1.2/geocif/indices_runner.py +193 -0
  18. geocif-0.1.2/geocif/logger.py +75 -0
  19. geocif-0.1.2/geocif/ml/__init__.py +0 -0
  20. geocif-0.1.2/geocif/ml/analysis.py +744 -0
  21. geocif-0.1.2/geocif/ml/correlations.py +343 -0
  22. geocif-0.1.2/geocif/ml/embedding.py +153 -0
  23. geocif-0.1.2/geocif/ml/feature_engineering.py +322 -0
  24. geocif-0.1.2/geocif/ml/feature_selection.py +192 -0
  25. geocif-0.1.2/geocif/ml/misc.py +365 -0
  26. geocif-0.1.2/geocif/ml/outliers.py +239 -0
  27. geocif-0.1.2/geocif/ml/outlook.py +22 -0
  28. geocif-0.1.2/geocif/ml/output.py +121 -0
  29. geocif-0.1.2/geocif/ml/stages.py +282 -0
  30. geocif-0.1.2/geocif/ml/stats.py +151 -0
  31. geocif-0.1.2/geocif/ml/trainers.py +311 -0
  32. geocif-0.1.2/geocif/ml/trend.py +88 -0
  33. geocif-0.1.2/geocif/ml/xai.py +81 -0
  34. geocif-0.1.2/geocif/utils.py +723 -0
  35. geocif-0.1.2/geocif.egg-info/PKG-INFO +80 -0
  36. geocif-0.1.2/geocif.egg-info/SOURCES.txt +47 -0
  37. geocif-0.1.2/geocif.egg-info/dependency_links.txt +41 -0
  38. geocif-0.1.2/geocif.egg-info/requires.txt +40 -0
  39. geocif-0.1.2/requirements.txt +40 -0
  40. {geocif-0.0.1 → geocif-0.1.2}/setup.py +55 -57
  41. {geocif-0.0.1 → geocif-0.1.2}/tests/test_geocif.py +19 -21
  42. geocif-0.0.1/.editorconfig +0 -21
  43. geocif-0.0.1/.github/ISSUE_TEMPLATE/bug_report.md +0 -25
  44. geocif-0.0.1/.github/ISSUE_TEMPLATE/config.yml +0 -10
  45. geocif-0.0.1/.github/ISSUE_TEMPLATE/feature_request.md +0 -18
  46. geocif-0.0.1/.github/workflows/build.yml +0 -41
  47. geocif-0.0.1/.github/workflows/docs.yml +0 -24
  48. geocif-0.0.1/.github/workflows/pypi.yml +0 -31
  49. geocif-0.0.1/.gitignore +0 -106
  50. geocif-0.0.1/PKG-INFO +0 -45
  51. geocif-0.0.1/docs/changelog.md +0 -11
  52. geocif-0.0.1/docs/contributing.md +0 -108
  53. geocif-0.0.1/docs/faq.md +0 -1
  54. geocif-0.0.1/docs/geocif.md +0 -4
  55. geocif-0.0.1/docs/index.md +0 -20
  56. geocif-0.0.1/docs/installation.md +0 -23
  57. geocif-0.0.1/docs/overrides/main.html +0 -11
  58. geocif-0.0.1/docs/usage.md +0 -7
  59. geocif-0.0.1/geocif/__init__.py +0 -9
  60. geocif-0.0.1/geocif/base.py +0 -4
  61. geocif-0.0.1/geocif/config/geocif.txt +0 -29
  62. geocif-0.0.1/geocif/features.py +0 -6
  63. geocif-0.0.1/geocif/geoagmet.py +0 -168
  64. geocif-0.0.1/geocif/geocif.py +0 -205
  65. geocif-0.0.1/geocif/models.py +0 -6
  66. geocif-0.0.1/geocif/plot.py +0 -468
  67. geocif-0.0.1/geocif/utils.py +0 -73
  68. geocif-0.0.1/geocif.egg-info/PKG-INFO +0 -45
  69. geocif-0.0.1/geocif.egg-info/SOURCES.txt +0 -41
  70. geocif-0.0.1/geocif.egg-info/dependency_links.txt +0 -1
  71. geocif-0.0.1/mkdocs.yml +0 -52
  72. geocif-0.0.1/requirements_dev.txt +0 -11
  73. geocif-0.0.1/tests/__init__.py +0 -1
  74. {geocif-0.0.1 → geocif-0.1.2}/LICENSE +0 -0
  75. {geocif-0.0.1 → geocif-0.1.2}/MANIFEST.in +0 -0
  76. {geocif-0.0.1 → geocif-0.1.2}/README.md +0 -0
  77. /geocif-0.0.1/requirements.txt → /geocif-0.1.2/geocif/agmet/__init__.py +0 -0
  78. {geocif-0.0.1 → geocif-0.1.2}/geocif.egg-info/not-zip-safe +0 -0
  79. {geocif-0.0.1 → geocif-0.1.2}/geocif.egg-info/top_level.txt +0 -0
  80. {geocif-0.0.1 → geocif-0.1.2}/setup.cfg +0 -0
geocif-0.1.2/PKG-INFO ADDED
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.1
2
+ Name: geocif
3
+ Version: 0.1.2
4
+ Summary: Models to visualize and forecast crop conditions and yields
5
+ Home-page: https://ritviksahajpal.github.io/yield_forecasting/
6
+ Author: Ritvik Sahajpal
7
+ Author-email: ritvik@umd.edu
8
+ License: MIT license
9
+ Keywords: geocif
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: arfs==2.2.5
20
+ Requires-Dist: arrow==1.3.0
21
+ Requires-Dist: Boruta==0.3
22
+ Requires-Dist: BorutaShap==1.0.17
23
+ Requires-Dist: BorutaShap==1.0.17
24
+ Requires-Dist: Bottleneck==1.3.7
25
+ Requires-Dist: catboost==1.2.5
26
+ Requires-Dist: cycler==0.12.1
27
+ Requires-Dist: GDAL==3.8.1
28
+ Requires-Dist: geopandas==0.14.1
29
+ Requires-Dist: geoprepare==0.4.8
30
+ Requires-Dist: icclim==6.4.0
31
+ Requires-Dist: kneed==0.8.5
32
+ Requires-Dist: logzero==1.7.0
33
+ Requires-Dist: MAPIE==0.8.3
34
+ Requires-Dist: matplotlib==3.8.2
35
+ Requires-Dist: neptune==1.10.3
36
+ Requires-Dist: numpy==1.25.2
37
+ Requires-Dist: optuna==3.5.0
38
+ Requires-Dist: palettable==3.3.3
39
+ Requires-Dist: pandas==2.2.2
40
+ Requires-Dist: pangres==4.2.1
41
+ Requires-Dist: pooch==1.8.1
42
+ Requires-Dist: powershap==0.0.11
43
+ Requires-Dist: pycallgraph2==1.1.3
44
+ Requires-Dist: pygam==0.9.1
45
+ Requires-Dist: pygeoutil==0.1.dev0
46
+ Requires-Dist: pymannkendall==1.4.3
47
+ Requires-Dist: python_dateutil==2.8.2
48
+ Requires-Dist: Rbeast==0.1.19
49
+ Requires-Dist: Rbeast==0.1.19
50
+ Requires-Dist: scikit_learn==1.4.2
51
+ Requires-Dist: scipy==1.13.0
52
+ Requires-Dist: seaborn==0.13.2
53
+ Requires-Dist: setuptools==68.2.2
54
+ Requires-Dist: shap==0.45.0
55
+ Requires-Dist: sklearn_genetic_opt==0.10.1
56
+ Requires-Dist: SQLAlchemy==2.0.25
57
+ Requires-Dist: statsmodels==0.14.0
58
+ Requires-Dist: tqdm==4.66.1
59
+
60
+ # geocif
61
+
62
+
63
+ [![image](https://img.shields.io/pypi/v/geocif.svg)](https://pypi.python.org/pypi/geocif)
64
+ [![image](https://img.shields.io/conda/vn/conda-forge/geocif.svg)](https://anaconda.org/conda-forge/geocif)
65
+
66
+
67
+ **Models to visualize and forecast crop conditions and yields**
68
+
69
+
70
+ - Free software: MIT license
71
+ - Documentation: https://ritviksahajpal.github.io/geocif
72
+
73
+
74
+ ## Features
75
+
76
+ - TODO
77
+
78
+ ## Credits
79
+
80
+ This package was created with [Cookiecutter](https://github.com/cookiecutter/cookiecutter) and the [giswqs/pypackage](https://github.com/giswqs/pypackage) project template.
@@ -0,0 +1,7 @@
1
+ """Top-level package for geocif."""
2
+
3
+ __author__ = """Ritvik Sahajpal"""
4
+ __email__ = "ritvik@umd.edu"
5
+ __version__ = "0.0.1"
6
+
7
+ __all__ = ["ml", "cei"]
@@ -0,0 +1,170 @@
1
+ import pandas as pd
2
+ from tqdm import tqdm
3
+
4
+ from geocif.backup import geo
5
+ from geocif.agmet import plot, utils
6
+
7
+
8
+ def create_title_for_plot(obj):
9
+ """
10
+
11
+ Args:
12
+ obj:
13
+
14
+ Returns:
15
+
16
+ """
17
+ region_name = obj.region.replace("_", " ").title()
18
+ calendar_region_name = obj.calendar_region.replace("_", " ").title()
19
+ country_name = obj.country.replace("_", " ").title()
20
+ long_crop_name = utils.get_crop_name(obj.crop)
21
+
22
+ # Get name of crop based on metadata/crop_per_season.csv file
23
+ df_crop_per_season = pd.read_csv(obj.dir_metadata / "crop_per_season.csv")
24
+
25
+ crop_name = df_crop_per_season[
26
+ (df_crop_per_season["country"] == obj.country)
27
+ & (df_crop_per_season["crop"] == obj.crop)
28
+ & (df_crop_per_season["season"] == int(obj.growing_season))
29
+ ]["name"].values
30
+
31
+ crop_name = crop_name[0] if crop_name else long_crop_name.replace("_", " ").title()
32
+
33
+ title_line_1 = f"{region_name} ({calendar_region_name}, {country_name})"
34
+ title_line_2 = f"{crop_name} {obj.plot_season}"
35
+
36
+ sup_title = f"{title_line_1}\n{title_line_2}"
37
+
38
+ return sup_title
39
+
40
+
41
+ def loop_agmet(path_config_file=None):
42
+ """
43
+ Args:
44
+ """
45
+ # Create geo object
46
+ obj = geo.geo(path_config_file)
47
+
48
+ # Read in data on crop names in each country
49
+ obj.read_statistics(read_countries=True)
50
+
51
+ # Create combinations of run parameters
52
+ all_combinations = obj.create_run_combinations()
53
+
54
+ pbar = tqdm(all_combinations, total=len(all_combinations))
55
+ for country, scale, crop, growing_season in pbar:
56
+ # Setup country information
57
+ obj.setup_country(country, scale, crop, growing_season)
58
+
59
+ # Loop through seasons and plot for each admin_1 region and calendar region
60
+ for plot_season in obj.plot_seasons:
61
+ # Get list of the years that are closest to the year which we want to plot
62
+ obj.get_closest_season(plot_season)
63
+
64
+ for region in obj.list_regions:
65
+ # Setup the region information
66
+ obj.setup_region(region, plot_season, "region")
67
+
68
+ # If available, add CHIRPS-GEFS data to the dataframe
69
+ if obj.precip_var == "chirps":
70
+ obj.add_precip_forecast(plot_season)
71
+
72
+ # Get crop calendar dates for region
73
+ dates_calendar = [
74
+ obj.date_planting,
75
+ obj.date_greenup,
76
+ obj.date_senescence,
77
+ obj.date_harvesting,
78
+ ]
79
+
80
+ # TODO: Only plot if dates_calendar has valid dates
81
+ # Create title for plot
82
+ sup_title = create_title_for_plot(obj)
83
+
84
+ ###############################################################
85
+ # Agmet plots for regions
86
+ ###############################################################
87
+ # D:\Dropbox\Projects\GEOGLAM\crop_condition\AMIS\argentina
88
+ plot.plots_ts_cur_yr(
89
+ obj.df_region,
90
+ obj.eo_plot,
91
+ closest=obj.closest,
92
+ dates_cal=dates_calendar,
93
+ frcast_yr=obj.plot_season,
94
+ logos=[obj.logo_harvest, obj.logo_geoglam],
95
+ dir_out=obj.dir_agmet / obj.scale,
96
+ sup_title=sup_title,
97
+ fname=f"{obj.region}.png",
98
+ )
99
+
100
+ ###############################################################
101
+ # Agmet plots for calendar regions
102
+ ###############################################################
103
+ columns = obj.eo_model + ["month", "day", "yield"]
104
+ if "chirps" in obj.df_region.columns:
105
+ bool_year_check, bool_date_check = obj.check_date(
106
+ obj.df_region, obj.plot_season
107
+ )
108
+
109
+ if bool_date_check and bool_year_check:
110
+ columns = obj.eo_model + [
111
+ "month",
112
+ "day",
113
+ "chirps_gefs",
114
+ "yield",
115
+ ]
116
+
117
+ df_calendar_region = (
118
+ obj.df_region.groupby(
119
+ [
120
+ "country",
121
+ "calendar_region",
122
+ "harvest_season",
123
+ "doy",
124
+ "datetime",
125
+ ]
126
+ )[columns]
127
+ .mean()
128
+ .reset_index()
129
+ )
130
+ df_calendar_region.loc[:, "average_temperature"] = (
131
+ df_calendar_region["cpc_tmax"] + df_calendar_region["cpc_tmin"]
132
+ ) / 2.0
133
+ df_calendar_region.set_index(
134
+ pd.DatetimeIndex(df_calendar_region["datetime"]),
135
+ inplace=True,
136
+ drop=True,
137
+ )
138
+ df_calendar_region.index.name = None
139
+ df_calendar_region.sort_values(by="datetime", inplace=True)
140
+
141
+ # TODO: Only plot if dates_calendar has valid dates
142
+ # Create title for plot
143
+ sup_title = create_title_for_plot(obj)
144
+
145
+ if not df_calendar_region.empty:
146
+ plot.plots_ts_cur_yr(
147
+ df_calendar_region,
148
+ obj.eo_plot,
149
+ closest=obj.closest,
150
+ dates_cal=dates_calendar,
151
+ frcast_yr=obj.plot_season,
152
+ logos=[obj.logo_harvest, obj.logo_geoglam],
153
+ dir_out=obj.dir_agmet / "district",
154
+ sup_title=sup_title,
155
+ fname=f"{obj.calendar_region}.png",
156
+ )
157
+
158
+
159
+ def run():
160
+ loop_agmet(
161
+ [
162
+ "D:/Users/ritvik/projects/geoprepare/geoprepare/geoprepare.txt",
163
+ "D:/Users/ritvik/projects/geoprepare/geoprepare/geoextract.txt",
164
+ "D:/Users/ritvik/projects/geocif/geocif/config/geocif.txt",
165
+ ]
166
+ )
167
+
168
+
169
+ if __name__ == "__main__":
170
+ run()