diff --git a/parsers/ERP_PGCB.py b/parsers/ERP_PGCB.py index 4e44a8315e..70a3709dc5 100644 --- a/parsers/ERP_PGCB.py +++ b/parsers/ERP_PGCB.py @@ -42,6 +42,7 @@ "Wind", "Bheramara HVDC", "Tripura", + "Adani", "Remarks", ] PARSER = "ERP_PGCB.py" @@ -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], } ) @@ -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: @@ -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 ) @@ -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, diff --git a/parsers/test/mocks/ERP_PGCB/latest.html b/parsers/test/mocks/ERP_PGCB/latest.html index 5479afebb5..ae9be5f124 100644 --- a/parsers/test/mocks/ERP_PGCB/latest.html +++ b/parsers/test/mocks/ERP_PGCB/latest.html @@ -8,16 +8,43 @@ - + + + + + + + + + + + +