<jupyter_start><jupyter_text>Texas Rate Inspector Overview- toc: true- branch: master- badges: false- comments: true- author: <NAME>- categories: [texas,rate]- hide: false<jupyter_code>#hide_input
import pandas as pd
import datetime
import calendar<jupyter_output><empty_output><jupyter_text>What's the Problem? Currently Texas' rate selection process is heavily driven by the lowest cost for a typical user.  However, this limits the imagination of Retail Electricity Providers (REP) and ends up hurting residential customers by creating a single variable rate plan that every REP optimizes for.  We at the Problem Solvers Guild have a different way of measuring plans that utilizes a customers' true historical usage.  Now the question is, which of the 159 plans currently available in almost any zip code in Texas is right for an individual? ![](notebook_images/2021-09-19-Texas-Rate-Inspector/powertochoose.png "159 Plans found on PowerToChoose for 77095")  What's the Solution? The Problem Solvers Guild has developed a method to take any electric `rate plan` and apply an individual's `usage` to calculate a more accurate price-per-kilowatt than what is typically provided by REPs.  With this solution, we help residential customers identify plans they would have previously overlooked.We grab usage by working with [Smart Meter Texas](https://www.smartmetertexas.com/aboutus).  A site that was created to allow residential customers to access their 15-minute usage data.  This site also allows customers to share this access with companies with just a few pieces of information.All of the rate plans that we currently use come from [Power to Choose](powertochoose.org) which is a site where REPs are able to advertise their available rates to residential customers.  Each plan has an electricity facts label (EFL) that describes the plan in detail.  We use these EFLs to model different rate plans that are offered.  Once we have all of this information, we combine the data and find the rate that would have given an individual the lowest price-per-kilowatt over the past year.  If this is something you are interested in knowing for yourself, [fill out our form](https://www.problemsolversguild.com/texas-power/tpwhearbcdgomrevxrxpjuuavqkoqwqxkeuh) and we will run an analysis for you.  If you are a company that would like to use our library to create better rate plans or to drive your rate engine, feel free to contact us and we can find a solution based on your needs as well.    How does it work? The Texas Rate Inspector was developed by The Problem Solvers Guild as a tool that allows an individual to quickly simulate any rate plan with their historical usage.  Let me take you on a quick tour of how this tool works.  Here are three rate plans to choose from.  1. **Plan 1 (Flat Rate)** charges $0.119 per kWh plus a $9.95 monthly charge if your usage for that month is less than 1000 kWh.1. **Plan 2 (Free Weekends)** charges $0.200 per kWh between 12:00 AM Monday to 7:00 PM Friday plus a $4.95 monthly charge.1. **Plan 3 (Tiered Rate)** charges $0.089 per kWh between 0 and 1200 kWh of usage and $0.145 per kWh past that.  This plan also has a $9.95 monthly charge and a $30 credit if you use more than 800 kWh.  Now that I've given you all the information you need, which of these plans is the best option for a residential customer in Texas?  You can close your Excel sheet.  I will walk you through each of these scenarios and at the end, I will tell you which of these is the best plan for the user.  Grabbing Historical Usage First, we grab a user's usage from Smart Meter Texas.  note: If you are interested in providing your usage information to us, [fill out our form](https://www.problemsolversguild.com/texas-power/tpwhearbcdgomrevxrxpjuuavqkoqwqxkeuh) and we will request access to your usage.<jupyter_code>from rate_inspector.usage import *
start_date = pd.to_datetime(datetime.date(2021, 7, 1))
end_date = pd.to_datetime(datetime.date(2021, 7,31))
data = pd.read_csv('../assets/example_usage.csv', parse_dates=['USAGE_DATE'])
data = get_data(data, start_date, end_date)
july_usage_data = UsageComponent.from_historical_df(data)<jupyter_output><empty_output><jupyter_text>Here is a single day of historical usage (96 15-minute intervals).<jupyter_code>july_usage_data.plot_usage(0,96)<jupyter_output><empty_output><jupyter_text>Now that we have historical usage, let's model each of the three plans.   Plan 1: Flat Rate> Plan 1 (Flat Rate) charges $0.119 per kWh plus a $9.95 monthly charge if your usage for that month is less than 1000 kWh<jupyter_code>from rate_inspector.rate import * 
from rate_inspector.plan import *<jupyter_output><empty_output><jupyter_text>First, we identify the rate components.  This first plan has a `FlatThreshold` component that has a flat charge up to a threshold.<jupyter_code>base_w_peak = FlatThreshold('Flat Charge', 9.95, max_thresh=1000)
kwh_charge = TimeOfUseRate('Energy Charge', 0.119)<jupyter_output><empty_output><jupyter_text>Once all of the rate components have been defined, we create a rate plan that contains all of the rate components.<jupyter_code>plan1 = RatePlan('Flat Rate', [base_w_peak, kwh_charge])<jupyter_output><empty_output><jupyter_text>Next, we create a statement which combines the plan and the usage.<jupyter_code>statement1 = Statement(plan1, july_usage_data)<jupyter_output><empty_output><jupyter_text>Since total_usage was under 1000 kWh in this case, the $9.95 base charge is applied.<jupyter_code>statement1.print_line_item()
statement1.total_usage<jupyter_output><empty_output><jupyter_text>So our total cost per kwh is $0.131/kWh for Plan 1<jupyter_code>statement1.price_per_kwh<jupyter_output><empty_output><jupyter_text>Plan 2: Free Weekends> Plan 2 (Free Weekends) charges $0.200 per kWh between 12:00 AM Monday to 7:00 PM Friday plus a $4.95 monthly charge<jupyter_code>energy_kwh_rest_of_week = TimeOfUseRate('RoW Energy Charge', 0.20, days_of_week=[calendar.MONDAY, calendar.TUESDAY, calendar.WEDNESDAY, calendar.THURSDAY])
energy_kwh_friday = TimeOfUseRate('Friday Energy Charge', 0.20, days_of_week=[calendar.FRIDAY], end_time=datetime.time(7))
base = Flat('Base Charge', 4.95)
plan2 = RatePlan('Free Weekends', [energy_kwh_rest_of_week, energy_kwh_friday, base])
statement2 = Statement(plan2, july_usage_data)
statement2.print_line_item()<jupyter_output>RoW Energy Charge: 82.3296
Friday Energy Charge: 1.7952
Base Charge: 4.9500<jupyter_text>So our total cost per kwh is $0.11/kWh for Plan 2 even though the advertised price on PowerToChoose shows the minimum price per kWh to be $0.132 (@ 2000 kWh)<jupyter_code>statement2.price_per_kwh<jupyter_output><empty_output><jupyter_text>Plan 3: Tiered Rate> Plan 3 (Tiered Rate) charges $0.089 per kWh between 0 and 1200 kWh of usage and $0.145 per kWh past that. This plan also has a $9.95 monthly charge and a $30 credit if you use more than 800 kWh.<jupyter_code>base = Flat('Base Charge', 9.95)
tier1 = Tier('0-1200 kWh', 0.089, max_kwh=1200)
tier2 = Tier('> 1200 kWh', 0.145, min_kwh=1200)
credit = FlatThreshold('800 kwh credit', -30, min_thresh=800)
plan3 = RatePlan('Tiered Rate', [base, tier1, tier2, credit])
statement3 = Statement(plan3, july_usage_data)
statement3.print_line_item()<jupyter_output>Base Charge: 9.9500
0-1200 kWh: 72.0042
> 1200 kWh: 0.0000
800 kwh credit: -30.0000<jupyter_text>Plan 3 ends up being a great option for the usage.  Our user would have paid just $0.064/kWh for plan number three.  One thing to keep in mind is that we are only simulating a single month at this point.<jupyter_code>statement3.price_per_kwh<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07372004713892889, 'fraction_numerical': 0.03941338221814849, 'mean_word_length': 5.489379779099405, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 57, 'https://': 3, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '525166', 'license': 'Apache-2.0', 'n_tokens_mistral': 2538, 'n_tokens_neox': 2286, 'n_words': 973, 'path': '_notebooks/2021-09-19-Texas-Rate-Inspector.ipynb', 'repo_name': 'ProblemSolversGuild/blog', 'size': '7641'}