north_america_energy_system_catalog.py is completed and all the bugs have been resolved.

This commit is contained in:
Saeed Ranjbar 2023-08-24 15:09:17 -04:00
parent 3deb63b14a
commit fe0a2d3003
3 changed files with 21 additions and 11 deletions

View File

@ -110,7 +110,9 @@ class PvGenerationSystem(GenerationSystem):
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Photovoltaic Module': {
content = {'Energy Generation component': {
'id': self.id,
'name': self.name,
'model name': self.model_name,
'manufacturer': self.manufacturer,
'type': self.system_type,

View File

@ -33,13 +33,13 @@ class NorthAmericaEnergySystemCatalog(Catalog):
self._storage_components = self._load_storage_components()
self._systems = self._load_systems()
self._system_archetypes = self._load_archetypes()
print(self._system_archetypes)
self._content = Content(self._system_archetypes,
self._systems,
self._generation_components,
None,
None,
self._storage_components)
print(self._content)
def _load_generation_components(self):
generation_components = []
@ -381,11 +381,11 @@ class NorthAmericaEnergySystemCatalog(Catalog):
for system_cluster in system_clusters:
name = system_cluster['name']
systems = system_cluster['systems']['system_id']
integer_system_ids = [int(item) for item in systems]
_systems = []
for system in systems:
for system_archetype in self._systems:
if int(system_archetype.id) == int(system):
_systems.append(system_archetype)
for system_archetype in self._systems:
if int(system_archetype.id) in integer_system_ids:
_systems.append(system_archetype)
_system_archetypes.append(Archetype(None, name, _systems))
return _system_archetypes
@ -422,9 +422,17 @@ class NorthAmericaEnergySystemCatalog(Catalog):
@staticmethod
def _search_generation_equipment(generation_systems, generation_id):
_generation_systems = []
for generation in generation_systems:
if generation.id in generation_id:
_generation_systems.append(generation)
if type(generation_id) == list:
integer_ids = [int(item) for item in generation_id]
for generation in generation_systems:
if int(generation.id) in integer_ids:
_generation_systems.append(generation)
else:
integer_id = int(generation_id)
for generation in generation_systems:
if int(generation.id) == integer_id:
_generation_systems.append(generation)
if len(_generation_systems) == 0:
_generation_systems = None
raise ValueError(f'The system with the following id is not found in catalog [{generation_id}]')

View File

@ -38,5 +38,5 @@ class TestSystemsCatalog(TestCase):
def test_north_america_systems_catalog(self):
catalog = EnergySystemsCatalogFactory('north_america').catalog
def test_montreal_catalog(self):
catalog = EnergySystemsCatalogFactory('montreal_custom').catalog
# def test_montreal_catalog(self):
# catalog = EnergySystemsCatalogFactory('montreal_custom').catalog