-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec3e2f1
commit 22006a2
Showing
8 changed files
with
188 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from . import aggregate, constants, geo, io, plotting, settings | ||
from . import agro, crop, site, soil, weather | ||
from .model import run_pcse_single, run_pcse_ensemble | ||
from .model import run_pcse_single | ||
from .settings import DEFAULT_DATA, DEFAULT_OUTPUT, DEFAULT_RESULTS | ||
from .tools import RUNNING_IN_IPYTHON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
Legacy code for bundling parameters. | ||
Probably won't be re-used. | ||
""" | ||
from datetime import date, datetime | ||
from itertools import product | ||
from multiprocessing import Pool | ||
from pathlib import Path | ||
|
||
import geopandas as gpd | ||
gpd.options.io_engine = "pyogrio" | ||
from pyogrio import read_dataframe as read_geodataframe, write_dataframe as write_geodataframe | ||
import pandas as pd | ||
import shapely | ||
from tqdm import tqdm | ||
|
||
from pcse.base import MultiCropDataProvider, ParameterProvider, WeatherDataProvider | ||
from pcse.exceptions import WeatherDataProviderError | ||
from pcse.fileinput import CABOFileReader | ||
from pcse.models import Engine, Wofost72_WLP_FD | ||
from pcse.util import _GenericSiteDataProvider as PCSESiteDataProvider | ||
|
||
from ._typing import Callable, Coordinates, Iterable, Optional, PathOrStr | ||
from .agro import AgromanagementData | ||
from .constants import CRS_AMERSFOORT | ||
from .model import RunData, RunDataBRP | ||
from .soil import SoilType | ||
from .tools import make_iterable | ||
|
||
|
||
def bundle_parameters(sitedata: PCSESiteDataProvider | Iterable[PCSESiteDataProvider], | ||
soildata: CABOFileReader | Iterable[CABOFileReader], | ||
cropdata: MultiCropDataProvider | Iterable[MultiCropDataProvider], | ||
weatherdata: WeatherDataProvider | Iterable[WeatherDataProvider], | ||
agromanagementdata: AgromanagementData | Iterable[AgromanagementData]) -> tuple[Iterable[RunData], int | None]: | ||
""" | ||
Bundle the site, soil, and crop parameters into PCSE ParameterProvider objects. | ||
For the main parameters, a Cartesian product is used to get all their combinations. | ||
""" | ||
# Make sure the data are iterable | ||
sitedata_iter = make_iterable(sitedata, exclude=[PCSESiteDataProvider]) | ||
soildata_iter = make_iterable(soildata, exclude=[CABOFileReader]) | ||
cropdata_iter = make_iterable(cropdata, exclude=[MultiCropDataProvider]) | ||
weatherdata_iter = make_iterable(weatherdata, exclude=[WeatherDataProvider]) | ||
agromanagementdata_iter = make_iterable(agromanagementdata, exclude=[AgromanagementData]) | ||
|
||
# Determine the total number of parameter combinations, if possible | ||
try: | ||
n = len(sitedata_iter) * len(soildata_iter) * len(cropdata_iter) * len(weatherdata_iter) * len(agromanagementdata_iter) | ||
except TypeError: | ||
n = None | ||
|
||
# Combine everything | ||
combined_parameters = product(sitedata_iter, soildata_iter, cropdata_iter, weatherdata_iter, agromanagementdata_iter) | ||
rundata = (RunData(*params) for params in combined_parameters) | ||
|
||
return rundata, n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.