geocif 0.0.1__tar.gz → 0.1.21__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.
- geocif-0.1.21/PKG-INFO +80 -0
- {geocif-0.0.1 → geocif-0.1.21}/README.md +21 -21
- geocif-0.1.21/geocif/__init__.py +7 -0
- geocif-0.1.21/geocif/agmet/geoagmet.py +170 -0
- geocif-0.1.21/geocif/agmet/plot.py +773 -0
- geocif-0.1.21/geocif/agmet/utils.py +255 -0
- geocif-0.1.21/geocif/backup/__init__.py +0 -0
- {geocif-0.0.1/geocif → geocif-0.1.21/geocif/backup}/constants.py +1 -1
- geocif-0.1.21/geocif/backup/features.py +306 -0
- geocif-0.1.21/geocif/backup/geo.py +291 -0
- geocif-0.1.21/geocif/backup/geocif.py +496 -0
- geocif-0.1.21/geocif/backup/metadata.py +39 -0
- geocif-0.1.21/geocif/backup/models.py +6 -0
- geocif-0.1.21/geocif/cei/__init__.py +4 -0
- geocif-0.1.21/geocif/cei/definitions.py +111 -0
- geocif-0.1.21/geocif/cei/indices.py +873 -0
- geocif-0.1.21/geocif/geocif.py +1016 -0
- geocif-0.1.21/geocif/indices_runner.py +193 -0
- geocif-0.1.21/geocif/logger.py +75 -0
- geocif-0.1.21/geocif/ml/__init__.py +0 -0
- geocif-0.1.21/geocif/ml/analysis.py +744 -0
- geocif-0.1.21/geocif/ml/correlations.py +343 -0
- geocif-0.1.21/geocif/ml/embedding.py +153 -0
- geocif-0.1.21/geocif/ml/feature_engineering.py +322 -0
- geocif-0.1.21/geocif/ml/feature_selection.py +192 -0
- geocif-0.1.21/geocif/ml/misc.py +365 -0
- geocif-0.1.21/geocif/ml/outliers.py +239 -0
- geocif-0.1.21/geocif/ml/outlook.py +22 -0
- geocif-0.1.21/geocif/ml/output.py +121 -0
- geocif-0.1.21/geocif/ml/stages.py +282 -0
- geocif-0.1.21/geocif/ml/stats.py +151 -0
- geocif-0.1.21/geocif/ml/trainers.py +311 -0
- geocif-0.1.21/geocif/ml/trend.py +88 -0
- geocif-0.1.21/geocif/ml/xai.py +81 -0
- geocif-0.1.21/geocif/utils.py +723 -0
- geocif-0.1.21/geocif.egg-info/PKG-INFO +80 -0
- geocif-0.1.21/geocif.egg-info/SOURCES.txt +47 -0
- geocif-0.1.21/geocif.egg-info/dependency_links.txt +41 -0
- geocif-0.1.21/geocif.egg-info/requires.txt +40 -0
- geocif-0.1.21/requirements.txt +40 -0
- {geocif-0.0.1 → geocif-0.1.21}/setup.py +55 -57
- {geocif-0.0.1 → geocif-0.1.21}/tests/test_geocif.py +19 -21
- geocif-0.0.1/.editorconfig +0 -21
- geocif-0.0.1/.github/ISSUE_TEMPLATE/bug_report.md +0 -25
- geocif-0.0.1/.github/ISSUE_TEMPLATE/config.yml +0 -10
- geocif-0.0.1/.github/ISSUE_TEMPLATE/feature_request.md +0 -18
- geocif-0.0.1/.github/workflows/build.yml +0 -41
- geocif-0.0.1/.github/workflows/docs.yml +0 -24
- geocif-0.0.1/.github/workflows/pypi.yml +0 -31
- geocif-0.0.1/.gitignore +0 -106
- geocif-0.0.1/PKG-INFO +0 -45
- geocif-0.0.1/docs/changelog.md +0 -11
- geocif-0.0.1/docs/contributing.md +0 -108
- geocif-0.0.1/docs/faq.md +0 -1
- geocif-0.0.1/docs/geocif.md +0 -4
- geocif-0.0.1/docs/index.md +0 -20
- geocif-0.0.1/docs/installation.md +0 -23
- geocif-0.0.1/docs/overrides/main.html +0 -11
- geocif-0.0.1/docs/usage.md +0 -7
- geocif-0.0.1/geocif/__init__.py +0 -9
- geocif-0.0.1/geocif/base.py +0 -4
- geocif-0.0.1/geocif/config/geocif.txt +0 -29
- geocif-0.0.1/geocif/features.py +0 -6
- geocif-0.0.1/geocif/geoagmet.py +0 -168
- geocif-0.0.1/geocif/geocif.py +0 -205
- geocif-0.0.1/geocif/models.py +0 -6
- geocif-0.0.1/geocif/plot.py +0 -468
- geocif-0.0.1/geocif/utils.py +0 -73
- geocif-0.0.1/geocif.egg-info/PKG-INFO +0 -45
- geocif-0.0.1/geocif.egg-info/SOURCES.txt +0 -41
- geocif-0.0.1/geocif.egg-info/dependency_links.txt +0 -1
- geocif-0.0.1/mkdocs.yml +0 -52
- geocif-0.0.1/requirements_dev.txt +0 -11
- geocif-0.0.1/tests/__init__.py +0 -1
- {geocif-0.0.1 → geocif-0.1.21}/LICENSE +0 -0
- {geocif-0.0.1 → geocif-0.1.21}/MANIFEST.in +0 -0
- /geocif-0.0.1/requirements.txt → /geocif-0.1.21/geocif/agmet/__init__.py +0 -0
- {geocif-0.0.1 → geocif-0.1.21}/geocif.egg-info/not-zip-safe +0 -0
- {geocif-0.0.1 → geocif-0.1.21}/geocif.egg-info/top_level.txt +0 -0
- {geocif-0.0.1 → geocif-0.1.21}/setup.cfg +0 -0
geocif-0.1.21/PKG-INFO
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: geocif
|
3
|
+
Version: 0.1.21
|
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.5.6
|
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
|
+
[](https://pypi.python.org/pypi/geocif)
|
64
|
+
[](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/yield_forecasting/
|
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.
|
@@ -1,21 +1,21 @@
|
|
1
|
-
# geocif
|
2
|
-
|
3
|
-
|
4
|
-
[](https://pypi.python.org/pypi/geocif)
|
5
|
-
[](https://anaconda.org/conda-forge/geocif)
|
6
|
-
|
7
|
-
|
8
|
-
**Models to visualize and forecast crop conditions and yields**
|
9
|
-
|
10
|
-
|
11
|
-
- Free software: MIT license
|
12
|
-
- Documentation: https://ritviksahajpal.github.io/
|
13
|
-
|
14
|
-
|
15
|
-
## Features
|
16
|
-
|
17
|
-
- TODO
|
18
|
-
|
19
|
-
## Credits
|
20
|
-
|
21
|
-
This package was created with [Cookiecutter](https://github.com/cookiecutter/cookiecutter) and the [giswqs/pypackage](https://github.com/giswqs/pypackage) project template.
|
1
|
+
# geocif
|
2
|
+
|
3
|
+
|
4
|
+
[](https://pypi.python.org/pypi/geocif)
|
5
|
+
[](https://anaconda.org/conda-forge/geocif)
|
6
|
+
|
7
|
+
|
8
|
+
**Models to visualize and forecast crop conditions and yields**
|
9
|
+
|
10
|
+
|
11
|
+
- Free software: MIT license
|
12
|
+
- Documentation: https://ritviksahajpal.github.io/yield_forecasting/
|
13
|
+
|
14
|
+
|
15
|
+
## Features
|
16
|
+
|
17
|
+
- TODO
|
18
|
+
|
19
|
+
## Credits
|
20
|
+
|
21
|
+
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,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()
|