-
Notifications
You must be signed in to change notification settings - Fork 170
Use Case: Modifying Utility Agent Mapping
Although dGen is overall accurate with mapping counties to appropriate utilities, sometimes it is necessary to readjust the mapping. For instance, there are cases where counties are mapped to only one utility in dGen, even though in reality the area is split between two different utilities. Depending on the scenario the user is interested in, this might require manual adjustment of utility mappings within the model. It is also common for utility territories to change, adding or losing counties. Since the dGen model does not get updated with the latest utility territory maps on a regular basis, the user might need to adjust the underlying utility mapping to account for such changes. This section describes the process for making these updates. You will need to use Jupyter Notebook. For the purpose of illustration, we will update county mappings for a Wisconsin Utility.
A pre-populated jupyter notebook detailing these steps can be found here.
Step 1: Obtain the most recent list of county names within a given utility territory. This information can usually be found on utility websites.
import pandas as pd
import numpy as np
Step 3: Create a list of county names for a given utility territory by loading the utility territory table and saving all county names to a list
alliant_cnty_df = pd.read_csv(“utility_counties.csv”)
cnty_list = alliant_cnty_df['County'].tolist()
cfp = 'dgen_county_fips_mapping.csv'
cfm_df = pd.read_csv(cfp)
Step 5: Download and load the appropriate agent file. In this example we will use WI’s residential agent file
Residential:
rp='agent_df_base_res_wi_revised.pkl'
res_agents = pd.read_pickle(rp)
Commercial:
cp='agent_df_base_com_wi_revised.pkl'
com_agents = pd.read_pickle(cp)
cfm_wi_df = cfm_df.loc[cfm_df['state_abbr']=='WI']
cfm_wi_df = cfm_wi_df.loc[cfm_wi_df['county'].isin(cnty_lst)]
ids = cfm_wi_df['county_id'].tolist()
You can find the EIA id for a given utility by looking for look for “Entity ID” here.
Step 8: Look up tariff information for your utility by eia_id (in this example, we are using ‘20856’) and save tariff name, tariff id, and tariff dictionary to respective variables
tn = res_agents[res_agents.eia_id == '20856'].iloc[0]['tariff_name']
td = res_agents[res_agents.eia_id == '20856'].iloc[0]['tariff_dict']
t_id = res_agents[res_agents.eia_id == '20856'].iloc[0]['tariff_id']
Step 9: Assign the correct tariff name, tariff id and tariff dictionary to all agents in your utilities counties by using the most updated county list
for _id in ids:
for i, r in res_agents.iterrows():
if r['county_id'] == _id:
res_agents.at[i,'tariff_name'] = tn
res_agents.at[i,'tariff_dict'] = td
res_agents.at[i,'tariff_id'] = t_id
res_agents.at[i,'eia_id'] = '20856'
rsp='agent_df_base_res_wi_revised_v2.pkl'
res_agents.to_pickle(rsp)
Repeat Steps 8 through 10 for the commercial agent file. After you are finished with the updates, you can run the dGen model for Commercial and/or Residential. You will need to update the input sheet to reflect the revised agent file name like so:
