architecture-building-systems / CityEnergyAnalyst

The City Energy Analyst (CEA)
https://www.cityenergyanalyst.com/
MIT License
196 stars 66 forks source link

Archetypes Mapper + Database Editor - Unable to map schedules #2655

Closed AlexJew closed 4 years ago

AlexJew commented 4 years ago

Describe the bug The Archetype mapper is not able to map a Schedule from the database USE-TYPES and from the input file typology.dbf . The Archetype Mapper ran properly for the other mappings. The error kept on arising even after changing all the 1ST_USE field to 'MULTI_RES' and assigning the archetype database from the default database CH in Database Editor > Assign Database. The error shown is :

City Energy Analyst version 2.32.0
Running `cea archetypes-mapper` with the following parameters:
- general:scenario = C:\Users\jewell\Desktop\CEA\VSA\All_WithUses_1
  (default: {general:project}\{general:scenario-name})
- archetypes-mapper:input-databases = ['schedules']
  (default: ['comfort', 'architecture', 'air-conditioning', 'internal-loads', 'supply', 'schedules'])
- archetypes-mapper:buildings = []
  (default: [])
Running archetypes-mapper with scenario = C:\Users\jewell\Desktop\CEA\VSA\All_WithUses_1
Traceback (most recent call last):
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\cea\worker.py", line 146, in worker
    run_job(config, job, server)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\cea\worker.py", line 108, in run_job
    script(config=config, **parameters)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\cea\api.py", line 53, in __call__
    self._runner.__call__(*args, **kwargs)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\cea\api.py", line 33, in script_runner
    script_module.main(config)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\cea\datamanagement\archetypes_mapper.py", line 452, in main
    buildings=buildings)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\cea\datamanagement\archetypes_mapper.py", line 109, in archetypes_mapper
    calc_mixed_schedule(locator, building_typology_df, buildings)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\cea\datamanagement\schedule_helper.py", line 66, in calc_mixed_schedule
    list_uses = get_list_of_uses_in_case_study(building_typology_df)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\cea\datamanagement\schedule_helper.py", line 221, in get_list_of_uses_in_case_study
    if building_typology_df.loc[row, var_value] > 0.0:
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\pandas\core\indexing.py", line 1472, in __getitem__
    return self._getitem_tuple(key)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\pandas\core\indexing.py", line 870, in _getitem_tuple
    return self._getitem_lowerdim(tup)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\pandas\core\indexing.py", line 998, in _getitem_lowerdim
    section = self._getitem_axis(key, axis=i)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\pandas\core\indexing.py", line 1911, in _getitem_axis
    self._validate_key(key, axis)
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\pandas\core\indexing.py", line 1798, in _validate_key
    error()
  File "C:\Users\jewell\Documents\CityEnergyAnalyst\Dependencies\Python\lib\site-packages\pandas\core\indexing.py", line 1785, in error
    axis=self.obj._get_axis_name(axis)))
KeyError: u'the label [11] is not in the [index]'

To Reproduce Steps to reproduce the behavior:

  1. New scenario in CEA
  2. Run Archetypes Mapper

Expected behaviour The proper mapping from of 1ST_USE attribute values from typology.dbf to schedules.csv

Screenshots If applicable, add screenshots to help explain your problem.

Hardware (please complete the following information):

reyery commented 4 years ago

@AlexJew, I believe this bug is fixed in commit https://github.com/architecture-building-systems/CityEnergyAnalyst/commit/763771e8554b3c336aaf0f7d90dfe4a20d27d3c8 upstream. We will be releasing the next version really soon, which would include this fix.

AlexJew commented 4 years ago

@reyery ok thanks. I do not understand why are all the other mappings working then? The Archetypes Mapper is able to select values from typology.dbf when building achitecture.dbf (from STANDARD field) or when building indoor-comfort.dbf (from 1ST_USE field).

reyery commented 4 years ago

The function that was causing the bug is only used when calculating mixed schedules (I guess it was an attempt to optimize not recalculating the same use type multiple types). So it does not affect the other mappings.

AlexJew commented 4 years ago

@reyery I was able to run the Archetypes Mapper after loading a database I had previously created which included some use-types I had created.

shanshanhsieh commented 4 years ago

this issue should be fixed in v3.0.2, please update your CEA and let us know if the issue persists.