cafe package

Submodules

cafe.fakeData module

cafe.farm module

class cafe.farm.Config(species: str, name: str = '', output_per_crop: float = 1.0, unit: str = 'cuerdas')[source]

Bases: object

Stores information about crop yields per species / varietal name

name: str = ''
output_per_crop: float = 1.0
species: str
unit: str = 'cuerdas'
class cafe.farm.Event(name: str, impact: Optional[Union[float, Callable]] = 1.0, scope: Optional[Union[bool, Dict]] = <factory>, start: Optional[datetime.datetime] = None, end: Optional[datetime.datetime] = None)[source]

Bases: cafe.farm.Event

Stores information about events which impact harvest expectations.

age(current_time=datetime.datetime(2021, 8, 16, 6, 25, 2, 277660)) datetime.timedelta
days(current_time=datetime.datetime(2021, 8, 16, 6, 25, 2, 277666)) int
end = None
mins(current_time=datetime.datetime(2021, 8, 16, 6, 25, 2, 277668)) int
name: str
scope: Optional[Union[bool, Dict]]
start = None
property year_planted
years(current_time=datetime.datetime(2021, 8, 16, 6, 25, 2, 277664)) int
class cafe.farm.Farm(plot_list: List[cafe.farm.Plot] = <factory>)[source]

Bases: object

Container class for a collection of Plot objects.

contains(species: str = '') bool[source]
classmethod from_csv(csv_file)[source]
property ids: List[str]
plot_list: List[cafe.farm.Plot]
property plots: List[cafe.farm.Plot]
property size: float
class cafe.farm.Plot(num: int = 1, area: float = 1.0, plot_id: int = 0, species: str = <factory>, unit: str = 'cuerdas', start: Optional[datetime.datetime] = None, end: Optional[datetime.datetime] = None)[source]

Bases: cafe.farm.Plot

Stores information about a farmer’s plot.

What is planted, how much, where, to whom does it belong? etc.

age(current_time=datetime.datetime(2021, 8, 16, 6, 25, 2, 276423)) datetime.timedelta
days(current_time=datetime.datetime(2021, 8, 16, 6, 25, 2, 276437)) int
end = None
mins(current_time=datetime.datetime(2021, 8, 16, 6, 25, 2, 276439)) int
species: str
start = None
property year_planted
years(current_time=datetime.datetime(2021, 8, 16, 6, 25, 2, 276434)) int
cafe.farm.find_config(name: str, configs: Tuple[cafe.farm.Config]) cafe.farm.Config[source]

Looks up a varietal by name in a collection of Configs. If name not found, will return config for the species instead, but throw an error if missing.

Parameters
  • name (str) – Name of varietal or species to look up

  • configs (Tuple[Config]) – registry of configs

Returns

relevant config entry

Return type

config (Config)

Raises

KeyErrorname could not be found in configs

cafe.farm.guate_harvest_function(lifespan: float = 30, mature: float = 5, retire: Optional[float] = None) Callable[source]

Defines piecewise-linear function which approximates the growth patterns of coffee trees according to the coffee cooperative for which this simulation was first written.

cafe.farm.maybe_time_like(cls)[source]

Wrapper to add temporal properties and methods to a class.

cafe.farm.predict_yield_for_farm(farm: cafe.farm.Farm, configs: List[cafe.farm.Config], events: Optional[List[cafe.farm.Event]] = None, time: datetime.datetime = datetime.datetime(2020, 1, 1, 0, 0)) List[float][source]
cafe.farm.predict_yield_for_plot(plot: cafe.farm.Plot, config: cafe.farm.Config, events: Optional[List[cafe.farm.Event]] = None, time: datetime.datetime = datetime.datetime(2020, 1, 1, 0, 0)) float[source]

Predicts yields for a given plot, set of events, and collection of configs at a specified time.

cafe.farm.total_impact(plot: cafe.farm.Plot, time: datetime.datetime, events: List[cafe.farm.Event]) float[source]

Determines which events are relevant and multiplies all the associated impacts together in order to define the “total impact” of these events on a particular plot.

Module contents