示例#1
0
    def setUp(self):
        '''Setup for each test.
        
        '''

        resources_dir = os.path.join(testing_root_dir, 'models', 'Resources')
        self.gen = Data_Generator(resources_dir)
示例#2
0
class DataGeneratorTest(unittest.TestCase, utilities.partialTimeseries):
    '''Tests the data generator class
    
    '''
    def setUp(self):
        '''Setup for each test.
        
        '''

        resources_dir = os.path.join(testing_root_dir, 'models', 'Resources')
        self.gen = Data_Generator(resources_dir)

    def test_generate_weather(self):
        '''Runs the generate weather data method and compares
        trajectories with references.
           
        '''

        # Generate weather file
        self.gen.generate_weather()
        os.chdir(testing_root_dir)
        # Set generated file path
        gen_filepath = os.path.join(self.gen.resources_dir, 'weather.csv')

        # Set reference file path
        ref_filepath = os.path.join(testing_root_dir, 'references', 'data',
                                    'default_weather.csv')

        # Check the data file has been created
        self.assertTrue(os.path.exists(gen_filepath))

        # Read data into data frame
        df_gen = pd.read_csv(gen_filepath).set_index('time')

        # Check trajectories
        self.compare_ref_timeseries_df(df_gen, ref_filepath)

    def test_generate_prices(self):
        '''Runs the generate prices method and compares trajectories 
        with references.
        
        '''

        # Generate weather file
        self.gen.generate_prices()

        # Set generated file path
        gen_filepath = os.path.join(self.gen.resources_dir, 'prices.csv')

        # Set reference file path
        ref_filepath = os.path.join(testing_root_dir, 'references', 'data',
                                    'default_prices.csv')

        # Check the data file has been created
        self.assertTrue(os.path.exists(gen_filepath))

        # Read data into data frame
        df_gen = pd.read_csv(gen_filepath).set_index('time')

        # Check trajectories
        self.compare_ref_timeseries_df(df_gen, ref_filepath)

    def test_generate_emissions(self):
        '''Runs the generate emissions method and compares 
        trajectories with references.
        
        '''

        # Generate weather file
        self.gen.generate_emissions()

        # Set generated file path
        gen_filepath = os.path.join(self.gen.resources_dir, 'emissions.csv')

        # Set reference file path
        ref_filepath = os.path.join(testing_root_dir, 'references', 'data',
                                    'default_emissions.csv')

        # Check the data file has been created
        self.assertTrue(os.path.exists(gen_filepath))

        # Read data into data frame
        df_gen = pd.read_csv(gen_filepath).set_index('time')

        # Check trajectories
        self.compare_ref_timeseries_df(df_gen, ref_filepath)

    def test_generate_occupancy(self):
        '''Runs the generate occupancy method and compares 
        trajectories with references.
        
        '''

        # Generate weather file
        self.gen.generate_occupancy(occ_num=10)

        # Set generated file path
        gen_filepath = os.path.join(self.gen.resources_dir, 'occupancy.csv')

        # Set reference file path
        ref_filepath = os.path.join(testing_root_dir, 'references', 'data',
                                    'default_occupancy.csv')

        # Check the data file has been created
        self.assertTrue(os.path.exists(gen_filepath))

        # Read data into data frame
        df_gen = pd.read_csv(gen_filepath).set_index('time')

        # Check trajectories
        self.compare_ref_timeseries_df(df_gen, ref_filepath)

    def test_generate_internalGains(self):
        '''Runs the generate internal gains method and compares 
        trajectories with references.
        
        '''

        # Generate weather file
        self.gen.generate_internalGains()

        # Set generated file path
        gen_filepath = os.path.join(self.gen.resources_dir,
                                    'internalGains.csv')

        # Set reference file path
        ref_filepath = os.path.join(testing_root_dir, 'references', 'data',
                                    'default_internalGains.csv')

        # Check the data file has been created
        self.assertTrue(os.path.exists(gen_filepath))

        # Read data into data frame
        df_gen = pd.read_csv(gen_filepath).set_index('time')

        # Check trajectories
        self.compare_ref_timeseries_df(df_gen, ref_filepath)

    def test_generate_setpoints(self):
        '''Runs the generate setpoints method for testcase 2 and 
        compares trajectories with references.
        
        '''

        # Generate weather file
        self.gen.generate_setpoints()

        # Set generated file path
        gen_filepath = os.path.join(self.gen.resources_dir, 'setpoints.csv')

        # Set reference file path
        ref_filepath = os.path.join(testing_root_dir, 'references', 'data',
                                    'default_setpoints.csv')

        # Check the data file has been created
        self.assertTrue(os.path.exists(gen_filepath))

        # Read data into data frame
        df_gen = pd.read_csv(gen_filepath).set_index('time')

        # Check trajectories
        self.compare_ref_timeseries_df(df_gen, ref_filepath)
示例#3
0
@author: Javier Arroyo
'''

from data.data_generator import Data_Generator
import os
import pandas as pd
from pymodelica import compile_fmu
from pyfmi import load_fmu
from scipy import interpolate

# Set the location of the Resource directory relative to this file location
file_dir = os.path.dirname(os.path.realpath(__file__))
resources_dir = os.path.join(file_dir, 'Resources')
# Create data generator object with time interval to 15 minutes
gen = Data_Generator(resources_dir, period=900)

# Generate weather data from .mos in Resources folder with default values
gen.generate_weather()

#=====================================================================
# Generate prices
#=====================================================================
# Electricity prices obtained from: https://www.energyprice.be/products-list/Engie
# for the "Easy Indexed" deal for electricity, on June 2020
# More info in https://www.energyprice.be/blog/2017/11/06/electricity-price-belgium/
# and in https://www.energyprice.be/blog/2017/10/23/electricity-off-peak-hours/
# For the highly dynamic scenario, the Belgian day-ahead prices of 2019 are used.
# Obtained from:
# https://my.elexys.be/MarketInformation/SpotBelpex.aspx
# And stored as downloaded in /Resources/BelpexFilter.xlsx
示例#4
0
@author: Javier Arroyo
'''

from data.data_generator import Data_Generator
import os
import pandas as pd
from pymodelica import compile_fmu
from pyfmi import load_fmu
from scipy import interpolate
import numpy as np

# Set the location of the Resource directory relative to this file location
file_dir = os.path.dirname(os.path.realpath(__file__))
resources_dir = os.path.join(file_dir, 'Resources')
# Create data generator object with time interval of 5 minutes
gen = Data_Generator(resources_dir, period=300)

# Generate weather data from .mos in Resources folder with default values
gen.generate_weather()

#=====================================================================
# Generate prices
#=====================================================================
# Electricity prices obtained from:
# https://particuliers.engie.fr/electricite/contrat-electricite/contrat-elec-ajust.html
# for the Engie's "Elec Ajust" deal before taxes (HTT = 'hors taxes', TTC = 'taxes compris')
# for electricity the price before taxes is chosen to allow comparison against
# the highly dynamic price scenario that uses spot prices.
# The tariff used is the one for households with contracted power installations
# higher than 6 kVA.
# For the highly dynamic scenario, the French day-ahead prices of 2019 are used.
示例#5
0
from data.data_generator import Data_Generator
import os
# Set the location of the Resource directory relative to this file location
file_dir = os.path.dirname(os.path.realpath(__file__))
resources_dir = os.path.join(file_dir, 'Resources')
# Create data generator object with time interval to 15 minutes
gen = Data_Generator(resources_dir, period=900)
# Generate weather data from .mos in Resources folder with default values
gen.generate_weather()

# Generate emission factors data in Denmark
gen.generate_emissions(
    emissions_district_heating_power=0.1163,
    #kg CO2e/kWh
    #obtained from https://www.banktrack.org/download/carbon_accounting_report_2018/dnb_asa_carbon_footprint_report_2018.pdf
    emissions_electric_power=0.2090
    #kg CO2e/kWh
    # obtained from https://www.carbonfootprint.com/docs/2019_06_emissions_factors_sources_for_2019_electricity.pdf
)

#=====================================================================
# Generate prices
#=====================================================================
# Electricity prices obtained from Nordpool DK2: average for Feb, 2019
# https://www.nordpoolgroup.com/Market-data1/Dayahead/Area-Prices/DK/Yearly/?view=table
#
# Dynamic price obtained from Nordpool DK 1: 12 Feb, 2019, peak and off peak price of the selected day
# https://www.nordpoolgroup.com/Market-data1/Dayahead/Area-Prices/DK/Hourly/?view=table

# highly dynamic price obtained from Nord pool DK1: day-ahead price, hourly price on 12 Feb, 2019, repeat electricity price of the selected day
# https://www.nordpoolgroup.com/Market-data1/Dayahead/Area-Prices/DK/Hourly/?view=chart
示例#6
0
'''
Created on Sep 18, 2019

@author: Javier Arroyo
'''

from data.data_generator import Data_Generator
import os
# Set the location of the Resource directory relative to this file location
file_dir = os.path.dirname(os.path.realpath(__file__))
resources_dir = os.path.join(file_dir, 'Resources')
# Create data generator object with time interval to 15 minutes
gen = Data_Generator(resources_dir, period=900)
# Generate weather data from .mos in Resources folder with default values
gen.generate_weather()