fix: Fix syntax errors, wire config-driven simulation in run.py, and correct fault-rate/availability KPI bugs
This commit is contained in:
49
pvsim/sun.py
49
pvsim/sun.py
@@ -675,4 +675,51 @@ class SunModel:
|
||||
f"timezone='{self.timezone}', "
|
||||
f"altitude={self.altitude}m)"
|
||||
)
|
||||
```
|
||||
|
||||
@classmethod
|
||||
def from_config(cls, config: Dict) -> SunModel:
|
||||
"""
|
||||
Crea un'istanza di SunModel da un dizionario di configurazione.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
config : Dict
|
||||
Dizionario contenente i parametri di configurazione.
|
||||
|
||||
Returns
|
||||
-------
|
||||
SunModel
|
||||
Istanza di SunModel.
|
||||
"""
|
||||
|
||||
location = config['plant']['location']
|
||||
|
||||
return cls(
|
||||
latitude=location['latitude'],
|
||||
longitude=location['longitude'],
|
||||
timezone=location['timezone'],
|
||||
altitude=location['altitude']
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_path: str) -> SunModel:
|
||||
"""
|
||||
Crea un'istanza di SunModel da un file JSON.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
json_path : str
|
||||
Percorso del file JSON contenente i parametri di configurazione.
|
||||
|
||||
Returns
|
||||
-------
|
||||
SunModel
|
||||
Istanza di SunModel.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
with open(json_path, 'r') as f:
|
||||
config = json.load(f)
|
||||
|
||||
return cls.from_config(config)
|
||||
Reference in New Issue
Block a user