def reporting_model_hourly(il_electricity_cdd_hdd_hourly): meter_data = il_electricity_cdd_hdd_hourly["meter_data"] temperature_data = il_electricity_cdd_hdd_hourly["temperature_data"] blackout_end_date = il_electricity_cdd_hdd_hourly["blackout_end_date"] reporting_meter_data, warnings = get_reporting_data( meter_data, start=blackout_end_date) preliminary_hourly_design_matrix = create_caltrack_hourly_preliminary_design_matrix( reporting_meter_data, temperature_data) segmentation = segment_time_series(preliminary_hourly_design_matrix.index, "three_month_weighted") occupancy_lookup = estimate_hour_of_week_occupancy( preliminary_hourly_design_matrix, segmentation=segmentation) occupied_temperature_bins, unoccupied_temperature_bins = fit_temperature_bins( preliminary_hourly_design_matrix, segmentation=segmentation, occupancy_lookup=occupancy_lookup, ) design_matrices = create_caltrack_hourly_segmented_design_matrices( preliminary_hourly_design_matrix, segmentation, occupancy_lookup, occupied_temperature_bins, unoccupied_temperature_bins, ) segmented_model = fit_caltrack_hourly_model( design_matrices, occupancy_lookup, occupied_temperature_bins, unoccupied_temperature_bins, ) return segmented_model
def test_create_caltrack_hourly_preliminary_design_matrix( il_electricity_cdd_hdd_hourly): meter_data = il_electricity_cdd_hdd_hourly["meter_data"] temperature_data = il_electricity_cdd_hdd_hourly["temperature_data"] design_matrix = create_caltrack_hourly_preliminary_design_matrix( meter_data[:1000], temperature_data) assert design_matrix.shape == (1000, 7) assert sorted(design_matrix.columns) == [ "cdd_65", "hdd_50", "hour_of_week", "meter_value", "n_hours_dropped", "n_hours_kept", "temperature_mean", ] assert round(design_matrix.sum().sum(), 2) == 136352.61
def preliminary_hourly_design_matrix(il_electricity_cdd_hdd_hourly): meter_data = il_electricity_cdd_hdd_hourly["meter_data"] temperature_data = il_electricity_cdd_hdd_hourly["temperature_data"] return create_caltrack_hourly_preliminary_design_matrix( meter_data[:1000], temperature_data)