Skip to content

Commit

Permalink
fix(parsers): Fix to include new Adani import column in BD data (#7154)
Browse files Browse the repository at this point in the history
* fix(parsers):Fix to include new Adani import column in BD data

* fix(parsers):Fix to include new Adani import column in BD data

* fix(parsers):Nicer code for including Adani

* update mock

* Add snapshot

---------

Co-authored-by: Electricity Maps <electricitymaps@Electricitys-MacBook-Pro.local>
  • Loading branch information
annaib00 and Electricity Maps authored Sep 6, 2024
1 parent 0b4cfe6 commit c4f9047
Show file tree
Hide file tree
Showing 3 changed files with 1,438 additions and 1,297 deletions.
19 changes: 15 additions & 4 deletions parsers/ERP_PGCB.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"Wind",
"Bheramara HVDC",
"Tripura",
"Adani",
"Remarks",
]
PARSER = "ERP_PGCB.py"
Expand Down Expand Up @@ -99,7 +100,8 @@ def parse_table_body(table_body: Tag) -> list[dict]:
"wind": table_entry_to_float(row_items[10]),
"bd_import_bheramara": table_entry_to_float(row_items[11]),
"bd_import_tripura": table_entry_to_float(row_items[12]),
"remarks": row_items[13],
"bd_import_adani": table_entry_to_float(row_items[13]),
"remarks": row_items[14],
}
)

Expand Down Expand Up @@ -197,13 +199,12 @@ def fetch_production(
session = session or Session()

row_data = query(session, target_datetime, logger)

production_data_list = ProductionBreakdownList(logger)
for row in row_data:
# Create data with empty production
production = ProductionMix()

# And add sources if they are present in the table
# And add sources if they are present in the table z
known_sources_sum_mw = 0.0
for source_type in ["coal", "gas", "hydro", "oil", "solar", "wind"]:
if row[source_type] is not None:
Expand All @@ -214,12 +215,18 @@ def fetch_production(
# infer 'unknown'
if row["total_generation"] is not None:
# Total generation includes all sources, including imports so we need to subtract them to get the unknown source
# Before this date Adani import in NoneType

unknown_source_mw = (
row["total_generation"]
- known_sources_sum_mw
- row["bd_import_bheramara"]
- row["bd_import_tripura"]
)
# Adani import was added after this date
if target_datetime is None or target_datetime > datetime(2024, 8, 27):
unknown_source_mw -= row["bd_import_adani"]

production.add_value(
"unknown", unknown_source_mw, correct_negative_with_zero=True
)
Expand Down Expand Up @@ -291,8 +298,12 @@ def fetch_exchange(
# Export to India NorthEast via Tripura
bd_import = row["bd_import_tripura"]
elif zone_key2 == "IN-EA":
# Export to India East via Bheramara
# Export to India East via Bheramara and Adani (Jharkhand plant)
bd_import = row["bd_import_bheramara"]

if target_datetime is None or target_datetime > datetime(2024, 8, 27):
bd_import += row["bd_import_adani"]

else:
raise ParserException(
parser=PARSER,
Expand Down
Loading

0 comments on commit c4f9047

Please sign in to comment.