def assign_data_to_year(carbon_trust_data, base_yr): """Fill every base year day with correct data Arguments ---------- carbon_trust_data : data Raw data base_yr : int Base Year """ shape_non_peak_y_dh = np.zeros((365, 24), dtype="float") # Create list with all dates of a whole year list_dates = date_prop.fullyear_dates( start=date(base_yr, 1, 1), end=date(base_yr, 12, 31)) # Assign every date to the place in the array of the year for yearday in list_dates: month_python = yearday.timetuple().tm_mon - 1 # - 1 because in _info: Month 1 = Jan yearday_python = yearday.timetuple().tm_yday - 1 # - 1 because in _info: 1.Jan = 1 daytype = date_prop.get_weekday_type(yearday) # Get day from HES raw data array _data = carbon_trust_data[daytype][month_python] # Add values to yearly _data = np.array(list(_data.items())) shape_non_peak_y_dh[yearday_python] = np.array(_data[:, 1], dtype="float") return shape_non_peak_y_dh
def test_fullyear_dates(): """Testing """ start_date = date(2015, 1, 1) end_date = date(2015, 1, 4) expected = [ date(2015, 1, 1), date(2015, 1, 2), date(2015, 1, 3), date(2015, 1, 4) ] # call function out_value = date_prop.fullyear_dates(start_date, end_date) assert out_value == expected
def assign_hes_data_to_year(nr_of_appliances, hes_data, base_yr): """Fill every base year day with correct data Arguments ---------- nr_of_appliances : dict Defines how many appliance types are stored (max 10 provided in original hes file) hes_data : array HES raw data for every month and daytype and appliance base_yr : float Base year to generate shapes Returns ------- year_raw_values : array Energy data for every day in the base year for every appliances """ year_raw_values = np.zeros((365, 24, nr_of_appliances), dtype=float) #yeardays, houry, appliances # Create list with all dates of a whole year list_dates = date_prop.fullyear_dates( start=date(base_yr, 1, 1), end=date(base_yr, 12, 31)) # Assign every date to the place in the array of the year for yearday_date in list_dates: month_python = date_prop.get_month_from_yeraday( yearday_date.timetuple().tm_year, yearday_date.timetuple().tm_yday) yearday_python = date_prop.date_to_yearday( yearday_date.timetuple().tm_year, yearday_date.timetuple().tm_mon, yearday_date.timetuple().tm_mday) daytype_str = date_prop.get_weekday_type(yearday_date) # Get day from HES raw data array year_raw_values[yearday_python] = hes_data[daytype_str][month_python] return year_raw_values