Esempio n. 1
0
def add_predictor_columns(data):
    """
    Will return predictive variables given a data-set with the 'TimeHour' column.
    'TimeHour' can be created by applying the .replace() method on the 'TimeStamp'
    column. The following variables will be added:

    NAME ~~~~~~~~~~~~~~~ COLUMN ~~~~~~~ FORMAT
    Hour of the day      hour_XX        Dummy, binary
    Month of the year    month_XX       Dummy, binary
    Holiday              is_holiday     Binary

    Holiday is based on all holidays in the Netherlands in 2018, 2019.
    """
    # Fetch holidays of given period
    NL_holidays = [i[0] for i in holidays.Netherlands(years = [2018, 2019]).items()]

    # Create dummies for hour of day and month of year
    hour_dummies = pd.get_dummies(data["TimeHour"].apply(lambda i: i.hour), prefix="hour")
    month_dummies = pd.get_dummies(data["TimeHour"].apply(lambda i: i.month), prefix="month")

    # Check each date whether in holidays
    is_holiday = data["TimeHour"].apply(lambda i: i.date() in NL_holidays).astype(int)

    # Concatenate and add constant/intercept
    X = pd.concat([hour_dummies, month_dummies, is_holiday], axis=1)
    X["Constant"] = 1

    return X
Esempio n. 2
0
def SP_profile(SP_weekday,SP_dayoff):
    
    """ Define Temperature SP for 1 days (24 hours).

    Args:
        SP_weekday:          week day temperature profile
        SP_dayoff:           holiday or weekend temperature profile
      

    Returns:
        
        SP:                 Temperature SP profile for 8760 hours(year) 

    """
    
        
    base = datetime.datetime(2020, 1, 1)
    date = np.array([base + datetime.timedelta(days=i) for i in range(365)])
    nl_holidays = holidays.Netherlands(years = 2020) 
  
    temp2 = np.zeros((0,1))
    
    # A years profile loop
    for i in range(len(date)):
        
        temp  = SP_weekday[0:24]
        
        if date[i].strftime("%A") == 'Saturday' or date[i].strftime("%A") == 'Sunday':
            #print(i)
            temp  = SP_dayoff[0:24]
            #print('------------------weekend------------------')

        if nl_holidays.get(date[i]) != None:
            #print(i)
            temp  = SP_dayoff[0:24]
            
        #if i == 359:
            #plt.plot(SP_weekday[0:23])
         #   plt.plot(temp[7:24])

        temp2 = np.concatenate((temp2, temp))
 
    SP = temp2[0:8760].flatten()
    
    return SP
Esempio n. 3
0
def is_holiday(date):
    try:
        import holidays
        return date in holidays.Netherlands()
    except:
        return False
    'FR': 64.610,
    'LU': 0.502,
    'NL': 16.570,
    'PL': 38.53,
    'SE': 9.341
}
holiday_op = [
    ('AT', holidays.Austria()),  # holidays for each country
    ('BE', holidays.Belgium()),  # implented this way because of bug in library
    ('CH', holidays.Switzerland()),
    ('CZ', holidays.Czech()),
    ('DE', holidays.Germany()),
    ('DK', holidays.Denmark()),
    ('FR', holidays.France()),
    ('LU', holidays.Luxembourg()),
    ('NL', holidays.Netherlands()),
    ('PL', holidays.Poland()),
    ('SE', holidays.Sweden())
]


def timedata(dt):
    # create time data extra information for influxDB (makes sorting easier)
    timestamp = datetime.fromtimestamp(dt)
    year = timestamp.year
    month = timestamp.month
    hour = timestamp.hour
    minute = timestamp.minute
    weekday = timestamp.weekday()

    # determine the holiday export weight
Esempio n. 5
0
### STATIC VARIABLES

today = date.today()

australia_holidays = holidays.Australia()
austria_holidays = holidays.Austria()
canada_holidays = holidays.Canada()
colombia_holidays = holidays.Colombia()
czech_holidays = holidays.Czech()
denmark_holidays = holidays.Denmark()
england_holidays = holidays.England()
europeancentralbank_holidays = holidays.EuropeanCentralBank()
germany_holidays = holidays.Germany()
ireland_holidays = holidays.Ireland()
mexico_holidays = holidays.Mexico()
netherlands_holidays = holidays.Netherlands()
newzealand_holidays = holidays.NewZealand()
northernireland_holidays = holidays.NorthernIreland()
norway_holidays = holidays.Norway()
portugal_holidays = holidays.Portugal()
portugalext_holidays = holidays.PortugalExt()
scotland_holidays = holidays.Scotland()
spain_holidays = holidays.Spain()
unitedkingdom_holidays = holidays.UnitedKingdom()
unitedstates_holidays = holidays.UnitedStates()
wales_holidays = holidays.Wales()

def isDateHoliday(date, countryHolidays):
	return date in country

def isTodayHoliday(countryHolidays):