fix: Fix syntax errors, wire config-driven simulation in run.py, and correct fault-rate/availability KPI bugs
This commit is contained in:
@@ -917,4 +917,49 @@ class WeatherModel:
|
||||
f"rain="
|
||||
f"{self.rain_enabled})"
|
||||
)
|
||||
```
|
||||
|
||||
@classmethod
|
||||
def from_config(
|
||||
cls,
|
||||
config: Dict,
|
||||
sun: SunModel
|
||||
) -> WeatherModel:
|
||||
"""
|
||||
Crea un'istanza di WeatherModel da un dizionario di configurazione.
|
||||
"""
|
||||
|
||||
weather_data = config['weather']
|
||||
|
||||
return cls(
|
||||
sun=sun,
|
||||
clear_sky_model=weather_data['clear_sky_model'],
|
||||
mean_annual_temperature_C=weather_data['temperature']['mean_annual_C'],
|
||||
daily_temperature_variation_C=weather_data['temperature']['daily_variation_C'],
|
||||
seasonal_temperature_variation_C=weather_data['temperature'].get('seasonal_variation_C', 12.0),
|
||||
cloud_enabled=weather_data['clouds']['enabled'],
|
||||
mean_cloud_factor=weather_data['clouds']['mean_cloud_factor'],
|
||||
cloud_variability=weather_data['clouds']['random_variability'],
|
||||
rain_enabled=weather_data['rain']['enabled'],
|
||||
rain_probability_daily=weather_data['rain']['probability_daily'],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_json(
|
||||
cls,
|
||||
json_path: str,
|
||||
sun: SunModel
|
||||
) -> WeatherModel:
|
||||
"""
|
||||
Crea un'istanza di WeatherModel da un file JSON.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
with open(json_path, 'r') as f:
|
||||
|
||||
config = json.load(f)
|
||||
|
||||
return cls.from_config(
|
||||
config=config,
|
||||
sun=sun
|
||||
)
|
||||
Reference in New Issue
Block a user