Skip to content

Commit

Permalink
Merge pull request #2968 from SEED-platform/refactor/bsync-scenarios
Browse files Browse the repository at this point in the history
refactor: only import AT scenarios with measures or meters
  • Loading branch information
macintoshpie committed Oct 29, 2021
2 parents 701e208 + 71c7a50 commit adf4609
Show file tree
Hide file tree
Showing 5 changed files with 389 additions and 376 deletions.
40 changes: 39 additions & 1 deletion seed/building_sync/building_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,21 @@ def restructure_mapped_result(self, result, messages):
# End Audit Template weirdness
#

# clean up the meters so that we only include ones with readings
meters_with_readings = []
for meter_id, meter in meters.items():
if meter['readings']:
meters_with_readings.append(meter)
else:
messages['warnings'].append(
f'Skipping meter {meter_id} because it had no valid readings.'
)

# create scenario
seed_scenario = {
'id': scenario['id'],
'name': scenario['name'],
'temporal_status': scenario['temporal_status'],
'reference_case': scenario['reference_case'],
'annual_site_energy_savings': scenario['annual_site_energy_savings'],
'annual_source_energy_savings': scenario['annual_source_energy_savings'],
Expand All @@ -302,9 +313,36 @@ def restructure_mapped_result(self, result, messages):
'annual_peak_electricity_reduction': scenario['annual_peak_electricity_reduction'],
'annual_natural_gas_energy': scenario['annual_natural_gas_energy'],
'measures': [id['id'] for id in scenario['measure_ids']],
'meters': meters_with_readings,
}

seed_scenario['meters'] = list(meters.values())
#
# Begin Audit Template weirdness
#
# Audit Template (AT) BuildingSync files include scenarios we don't want
# in SEED. For example, "Audit Template Annual Summary - Electricity"
# which doesn't contain measures or meter data so we want to skip it.
# Note that it's OK to skip scenarios without measures b/c AT does not
# have Baseline scenarios (the type of scenario where it's OK to not
# have measures.
#

if (
self._is_from_audit_template_tool()
and not seed_scenario['measures']
and not seed_scenario['meters']
):
# Skip this scenario!
messages['warnings'].append(
f'Skipping Scenario {scenario["id"]} because it doesn\'t include '
'measures or meter data.'
)
continue

#
# End Audit Template weirdness
#

scenarios.append(seed_scenario)

property_ = result['property']
Expand Down
5 changes: 5 additions & 0 deletions seed/building_sync/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,11 @@ def update_tree(schema, tree, xpath, target, value, namespaces):
'type': 'value',
'value': 'text'
},
'temporal_status': {
'xpath': './auc:TemporalStatus',
'type': 'value',
'value': 'text'
},
'reference_case': {
'xpath': './auc:ScenarioType/auc:PackageOfMeasures/auc:ReferenceCase',
'type': 'value',
Expand Down

0 comments on commit adf4609

Please sign in to comment.