Skip to content
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b13f884
Initialize PR
belle-storm Feb 12, 2026
7230c3b
create test file
belle-storm Feb 12, 2026
37d36d6
create test file for gtep_data
belle-storm Mar 5, 2026
b7eadbd
Merge branch 'IDAES:main' into unit_test_data-(#48)
belle-storm Mar 16, 2026
b7fa41d
Add initialization test
belle-storm Apr 6, 2026
3caa4c1
Add load_prescient unit tests
belle-storm Apr 6, 2026
8426aef
Add import_load_scaling tests
belle-storm Apr 6, 2026
96655e5
add import_outage_data tests
belle-storm Apr 6, 2026
7283093
add default data settings test
belle-storm Apr 6, 2026
a590f83
add load_storage_csv unit tests
belle-storm Apr 6, 2026
159ecbf
work on texas_case_study tests
belle-storm Apr 6, 2026
a40c9f2
replace actual load scaling file with fixture
belle-storm Apr 13, 2026
73dbc6b
fix texas unit test
belle-storm Apr 13, 2026
ddfeba7
add iloc to avoid deprecation warning
belle-storm Apr 13, 2026
ff52d49
Merge branch 'IDAES:main' into unit_test_data-(#48)
belle-storm Apr 28, 2026
4fc175c
Merge branch 'IDAES:main' into data_unit_tests
belle-storm Apr 28, 2026
8b6700f
Merge branch 'unit_test_data-(#48)' into data_unit_tests
belle-storm Apr 28, 2026
4c4e6a4
Merge pull request #2 from belle-storm/data_unit_tests
belle-storm Apr 28, 2026
5e727f4
enforce pathlib typing
belle-storm Apr 28, 2026
59dbc22
Merge branch 'main' into unit_test_data-(#48)
blnicho Apr 30, 2026
5b31e34
switch to unittest asserts and simplify mock
belle-storm Apr 30, 2026
eb334e7
add check for empty dataframe
belle-storm May 6, 2026
c9cd080
add directory call for outage data
belle-storm May 6, 2026
c7645ac
add resil week to texas check and base directory to csv path
belle-storm May 6, 2026
b82794c
convert to unittest assert and use real data files
belle-storm May 6, 2026
60b9c44
add testing guards
belle-storm May 11, 2026
8ed540c
Add missing dependency
blnicho May 11, 2026
11e9f8a
fix attribute failure for outage
belle-storm May 11, 2026
fd77c9f
remove print statement
belle-storm May 11, 2026
330d5a0
update based on PR notes
belle-storm May 21, 2026
a555dc8
Merge branch 'IDAES:main' into unit_test_data-(#48)
belle-storm May 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 40 additions & 21 deletions gtep/gtep_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ def load_prescient(
# create prescient config object with defaults
prescient_options = PrescientConfig()

# work around for prescient throwing an error with Path objects
if isinstance(data_path, Path):
data_path = str(data_path)

if options_dict is None:
# set basic configurations that do not match prescient defaults
options_dict = {
"data_path": data_path,
"data_path": str(
data_path
), # work around for prescient (error with Path objects)
"num_days": 365,
"ruc_horizon": 36,
}

else:
# ensure data path is included in options dictionary
options_dict["data_path"] = data_path
options_dict["data_path"] = str(
data_path
) # work around for prescient (error with Path objects)

# update configuration values based on options dictionary
prescient_options.set_value(options_dict)
Expand Down Expand Up @@ -154,14 +154,15 @@ def load_prescient(
"2020-10-14 00:00", ## Change the last date for whatever extreme day is needed based on the given run(s)
]
self.representative_dates = representative_dates
self.representative_weights = representative_weights

if not representative_weights:
# set the weight for each day to the total weight divided by number of days
total_weight = prescient_options.num_days * self.stages
weight_per_date = int(total_weight / (len(representative_dates)))
self.representative_weights = {
key: weight_per_date
for date, key in enumerate(self.representative_dates)
for key, date in enumerate(self.representative_dates)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did the order of key and date change here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our conversation on Monday, we talked about whether the key should be the index or the date itself.
The previous version of representative_weights that was hard coded in (prior to #61) , used the index as the key to call.

Screenshot 2026-05-21 140607

I'm not sure why it was swapped throughout the iterations, but it seems like it should be swapped back.

}

time_keys = self.md.data["system"]["time_keys"]
Expand Down Expand Up @@ -197,7 +198,7 @@ def import_load_scaling(self, load_file_name, forecast_years=None):

adjusted_forecast_by_period = adjusted_forecast[
adjusted_forecast["year"].isin(forecast_years)
]
].copy()

base_zones = [
"base_economic_coast",
Expand Down Expand Up @@ -263,12 +264,15 @@ def import_outage_data(self, load_file_name):
r" (\d+):"
)
filtered_outages = filtered_outages[["fips_code", "hour"]]
county_to_fips = pd.read_csv(
"./gtep/data/123_Bus_Resil_Week/county_fips_match.csv"
)
bus_to_county = pd.read_csv(
"./gtep/data/123_Bus_Resil_Week/Bus_data_gen_weights_mappings.csv"
)

base_dir = Path(load_file_name).parent

county_fips_path = base_dir / "county_fips_match.csv"
bus_to_county_path = base_dir / "Bus_data_gen_weights_mappings.csv"

county_to_fips = pd.read_csv(county_fips_path)
bus_to_county = pd.read_csv(bus_to_county_path)

county_to_fips = county_to_fips[["County", "FIPS"]]
bus_to_county = bus_to_county[["Bus Number", "County"]]
bus_to_county = bus_to_county.merge(county_to_fips, how="inner", on="County")
Expand All @@ -280,7 +284,8 @@ def import_outage_data(self, load_file_name):
how="left",
)
bus_hours = bus_hours[bus_hours["Bus Number"].notna()]
bus_hours.to_csv("./gtep/data/123_Bus_Resil_Week/not_right.csv")
csv_path = base_dir / "not_right.csv"
bus_hours.to_csv(csv_path)
self.bus_hours = bus_hours[["hour", "Bus Number"]]
self.bus_hours = self.bus_hours.astype(int)

Expand Down Expand Up @@ -346,8 +351,12 @@ def load_storage_csv(self, data_path):

:param data_path: filepath for storage data csv file
"""
# enforce pathlib object
if not isinstance(data_path, Path):
data_path = Path(data_path)

try:
storage_path = data_path + "/storage.csv"
storage_path = data_path / "storage.csv"
storage_df = pd.read_csv(storage_path)

storage_data = {}
Expand All @@ -368,10 +377,18 @@ def texas_case_study_updates(self, data_path):
:param data_path: filepath for generator data csv file
"""
# check that datapath is coming from a texas case study directory
if "Texas" or "Coal" not in data_path:
if (
("Texas" not in str(data_path))
and ("Coal" not in str(data_path))
and ("Resil_Week" not in str(data_path))
):
raise ValueError("The data path provided is not a Texas case study")

generator_update_path = data_path + "/gen.csv"
# enforce pathlib object
if not isinstance(data_path, Path):
data_path = Path(data_path)

generator_update_path = data_path / "gen.csv"
generator_df = pd.read_csv(generator_update_path)
bonus_feature_list = [
"capex1",
Expand All @@ -391,6 +408,8 @@ def texas_case_study_updates(self, data_path):
for col in bonus_feature_list:
for gen in data_point.data["elements"]["generator"]:
if not data_point.data["elements"]["generator"][gen].get(col):
data_point.data["elements"]["generator"][gen][col] = float(
generator_df[generator_df["GEN UID"] == gen][col]
)
matching_rows = generator_df[generator_df["GEN UID"] == gen]
if not matching_rows.empty:
data_point.data["elements"]["generator"][gen][col] = float(
matching_rows[col].iloc[0]
)
Loading
Loading