beyarkay / eskom-calendar

Get your loadshedding schedule in your calendar and never be left in the dark! Open-source, up-to-date, and developer friendly.
https://eskomcalendar.co.za
GNU General Public License v3.0
190 stars 35 forks source link

Buffalo City stages >4 not done properly #406

Closed beyarkay closed 1 year ago

beyarkay commented 1 year ago

(thanks Rory on ZATech for raising the issue!)

Buffalo city defines their loadshedding in this 33 page document, and I didn't read it properly. It's a simple fix, basically stages 1-4 have a certain schedule, and stages 5-8 have a certain schedule. BUT, stages 5-8 also implement the stage 4 schedule, so the project currently under-reports the loadshedding of buffalo city.

Fixing this will involve writing a script to go through the buffalo city CSV files and for each day of the month, adding the stage 4 loadshedding schedule to the stage 5,6,7,8 schedules.

beyarkay commented 1 year ago

Busy working with this snippet to fix the files:

import pandas as pd
import glob

# Read in the buffalo city paths
bc_paths = sorted(glob.glob('generated/buffalo-city-block-*.csv'))

# Iterate over each buffalo city block
for bc_path in bc_paths:
    # Read in the schedule
    df = pd.read_csv(bc_path)

    # We're gonna change stages 5, 6, 7, 8
    for stage in (5,6,7,8):
        # Copy all the loadshedding for stage 4 in this block
        to_concat = df[df.stage == 4].copy()
        # Set the stage to actually be `stage`
        to_concat.stage = stage

        # Append the newly staged data to the original data
        df = pd.concat(
            (df, to_concat),
            ignore_index=True
        ).sort_values(['stage', 'date_of_month', 'start_time'])
    # Save the result to disk
    df.to_csv(bc_path, index=False)
beyarkay commented 1 year ago

This should be fixed by 2ae289e, but I'll wait a bit to double check.

beyarkay commented 1 year ago

LGTM