Coverage for pybeepop/engine_interface.py: 58%
26 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-19 20:58 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-19 20:58 +0000
1"""
2Engine interface protocol for PyBeePop.
4This module defines the BeepopEngineInterface protocol that a BeePop+ simulation
5engine must implement to be compatible with the PyBeePop wrapper.
6"""
8from typing import Protocol, Dict, Optional
9import pandas as pd
12class BeepopEngineInterface(Protocol):
13 """
14 Protocol defining the interface that a BeePop simulation engine must implement.
16 Implemented by PythonEngineAdapter, which wraps the pure Python engine
17 (beepop.BeePop).
19 Note: Initialization happens in __init__(), not via a separate initialize_model() method.
20 """
22 engine_type: str
24 def set_parameters(self, parameters: Dict[str, str]) -> Dict[str, str]:
25 """
26 Set simulation parameters from a dictionary.
28 Args:
29 parameters: Dictionary of parameter name -> value pairs.
30 Example: {"ICWorkerAdults": "10000", "SimStart": "04/01/2023"}
32 Returns:
33 Dict[str, str]: Dictionary of parameters that were successfully set.
34 """
35 ...
37 def get_parameters(self) -> Dict[str, str]:
38 """
39 Get currently set parameters.
41 Returns:
42 Dict[str, str]: Dictionary of current parameter values.
43 """
44 ...
46 def load_parameter_file(self, file_path: str) -> bool:
47 """
48 Load parameters from a text file.
50 Args:
51 file_path: Path to parameter file (format: parameter=value per line).
53 Returns:
54 bool: True if file loaded successfully, False otherwise.
55 """
56 ...
58 def load_weather_file(self, file_path: str) -> bool:
59 """
60 Load weather data from a CSV or text file.
62 Args:
63 file_path: Path to weather file.
65 Returns:
66 bool: True if file loaded successfully, False otherwise.
67 """
68 ...
70 def load_residue_file(self, file_path: str) -> bool:
71 """
72 Load pesticide residue/contamination data from a file.
74 Args:
75 file_path: Path to residue file.
77 Returns:
78 bool: True if file loaded successfully, False otherwise.
79 """
80 ...
82 def set_latitude(self, latitude: float) -> bool:
83 """
84 Set geographic latitude for daylight calculations.
86 Args:
87 latitude: Latitude in decimal degrees (-90 to 90).
89 Returns:
90 bool: True if latitude set successfully, False otherwise.
91 """
92 ...
94 def run_simulation(self) -> Optional[pd.DataFrame]:
95 """
96 Execute the simulation and return results.
98 Returns:
99 pd.DataFrame: DataFrame with simulation results (44 columns), or None if failed.
100 """
101 ...
103 def get_error_log(self) -> str:
104 """
105 Get error messages from the simulation session.
107 Returns:
108 str: Error log as newline-separated string.
109 """
110 ...
112 def get_info_log(self) -> str:
113 """
114 Get informational messages from the simulation session.
116 Returns:
117 str: Info log as newline-separated string.
118 """
119 ...
121 def get_version(self) -> str:
122 """
123 Get the engine version string.
125 Returns:
126 str: Version string (e.g., "1.15.25").
127 """
128 ...
130 def cleanup(self) -> None:
131 """
132 Clean up resources and close connections.
134 This method should be idempotent and safe to call multiple times.
135 """
136 ...