Ejemplo n.º 1
0
def setup_energy_system_handler_from_args(args):
    '''
    Returns an EnergySystemHandler based on a passed energy_system if there was one given,
    or else on the energy system that was attached to the ETM scenario.
    If there is no ESDL to be found, fails the whole request
    '''
    if args['energy_system']:
        return EnergySystemHandler.from_string(urllib.parse.unquote(args['energy_system']))

    result = FetchEsdlFromEtengine.execute(args['session_id'])
    if result.successful:
        return EnergySystemHandler.from_string(result.value)

    fail_with(result)
Ejemplo n.º 2
0
    def post(self):
        """
        Transform ESDL energy system description into an ETM scenario
        """
        args = import_parser.parse_args()
        energy_system_title = args['energy_system_title'] or 'original.esdl'

        self.energy_system_handler = EnergySystemHandler.from_string(
            urllib.parse.unquote(args['energy_system']))

        converter = EsdlToScenarioConverter(self.energy_system_handler)
        self.__create_new_scenario_id(converter.area)
        self.__set_sliders_in_etm(self.__filter_on_hold(converter.calculate()))

        self.__attach_esdl_to_etm(energy_system_title)

        return {'scenario_id': self.scenario_id}
Ejemplo n.º 3
0
def energy_system_handler_with_kpis():
    '''ESH based on the valid Hengelo fixture'''
    with open('tests/fixtures/valid_Hengelo_with_kpis.esdl') as file:
        esdl_string = file.read()
    return EnergySystemHandler.from_string(esdl_string)
Ejemplo n.º 4
0
def hic_handler():
    with open('tests/fixtures/2021_hic_description.esdl') as file:
        data = file.read()
    return EnergySystemHandler.from_string(data)
Ejemplo n.º 5
0
def energy_system_handler(esdl_file_name):
    '''ESH based on a valid ESDL'''
    with open(f'tests/fixtures/{esdl_file_name}.esdl') as file:
        esdl_string = file.read()
    return EnergySystemHandler.from_string(esdl_string)
Ejemplo n.º 6
0
def hic_2050():
    '''ESH based on a valid HIC ESDL with power plants'''
    with open('tests/fixtures/2050_hic_description_fake.esdl') as file:
        esdl_string = file.read()
    return EnergySystemHandler.from_string(esdl_string)
Ejemplo n.º 7
0
def energy_system_handler_without_heating_demand():
    '''ESH based on the valid Hengelo ESDL'''
    with open('tests/fixtures/valid_Hengelo.esdl') as file:
        esdl_string = file.read()
    return EnergySystemHandler.from_string(esdl_string)
Ejemplo n.º 8
0
 def __get_as_situation(self, energy_system):
     return EsdlToScenarioConverter(
         EnergySystemHandler.from_string(
             urllib.parse.unquote(energy_system))).as_situation()