Skip to content

Commit 10a26fa

Browse files
WIP - prepare to change 'CCUS PROFILE' to 'CARBON REVENUE PROFILE'
1 parent 657a8af commit 10a26fa

File tree

2 files changed

+50
-34
lines changed

2 files changed

+50
-34
lines changed

src/geophires_x_client/geophires_x_result.py

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,28 @@ class GeophiresXResult:
323323
'Reservoir Model',
324324
)
325325

326+
_REVENUE_AND_CASHFLOW_PROFILE_HEADERS: ClassVar[list[str]] = [
327+
'Year Since Start',
328+
'Electricity Price (cents/kWh)',
329+
'Electricity Ann. Rev. (MUSD/yr)',
330+
'Electricity Cumm. Rev. (MUSD)',
331+
'Heat Price (cents/kWh)',
332+
'Heat Ann. Rev. (MUSD/yr)',
333+
'Heat Cumm. Rev. (MUSD)',
334+
'Cooling Price (cents/kWh)',
335+
'Cooling Ann. Rev. (MUSD/yr)',
336+
'Cooling Cumm. Rev. (MUSD)',
337+
'Carbon Price (USD/tonne)',
338+
'Carbon Ann. Rev. (MUSD/yr)',
339+
'Carbon Cumm. Rev. (MUSD)',
340+
'Project OPEX (MUSD/yr)',
341+
'Project Net Rev. (MUSD/yr)',
342+
'Project Net Cashflow (MUSD)',
343+
]
344+
345+
CCUS_PROFILE_LEGACY_NAME: ClassVar[str] = 'CCUS PROFILE'
346+
CARBON_REVENUE_PROFILE_NAME: ClassVar[str] = 'CCUS PROFILE' # FIXME WIP change to 'CARBON REVENUE PROFILE'
347+
326348
def __init__(self, output_file_path, logger_name=None):
327349
if logger_name is None:
328350
logger_name = __name__
@@ -369,9 +391,11 @@ def __init__(self, output_file_path, logger_name=None):
369391
if revenue_and_cashflow_profile is not None:
370392
self.result['REVENUE & CASHFLOW PROFILE'] = revenue_and_cashflow_profile
371393

372-
ccus_profile = self._get_ccus_profile()
373-
if ccus_profile is not None:
374-
self.result['CCUS PROFILE'] = ccus_profile
394+
carbon_revenue_or_ccus_profile_key, carbon_revenue_or_ccus_profile = (
395+
self._get_carbon_revenue_or_ccus_legacy_profile()
396+
)
397+
if carbon_revenue_or_ccus_profile is not None:
398+
self.result[carbon_revenue_or_ccus_profile_key] = carbon_revenue_or_ccus_profile
375399

376400
sdacgt_profile = self._get_sdacgt_profile()
377401
if sdacgt_profile is not None:
@@ -428,8 +452,10 @@ def __init__(self, v_u):
428452
'POWER GENERATION PROFILE',
429453
'HEAT AND/OR ELECTRICITY EXTRACTION AND GENERATION PROFILE',
430454
'EXTENDED ECONOMIC PROFILE',
431-
'CCUS PROFILE',
432455
'REVENUE & CASHFLOW PROFILE',
456+
GeophiresXResult.CARBON_REVENUE_PROFILE_NAME,
457+
GeophiresXResult.CCUS_PROFILE_LEGACY_NAME,
458+
'S-DAC-GT PROFILE',
433459
):
434460
raise RuntimeError('unexpected category')
435461

@@ -543,25 +569,6 @@ def _get_heat_electricity_extraction_generation_profile(self):
543569
profile_lines = self._get_profile_lines('HEAT AND/OR ELECTRICITY EXTRACTION AND GENERATION PROFILE')
544570
return self._get_data_from_profile_lines(profile_lines)
545571

546-
_REVENUE_AND_CASHFLOW_PROFILE_HEADERS: ClassVar[list[str]] = [
547-
'Year Since Start',
548-
'Electricity Price (cents/kWh)',
549-
'Electricity Ann. Rev. (MUSD/yr)',
550-
'Electricity Cumm. Rev. (MUSD)',
551-
'Heat Price (cents/kWh)',
552-
'Heat Ann. Rev. (MUSD/yr)',
553-
'Heat Cumm. Rev. (MUSD)',
554-
'Cooling Price (cents/kWh)',
555-
'Cooling Ann. Rev. (MUSD/yr)',
556-
'Cooling Cumm. Rev. (MUSD)',
557-
'Carbon Price (USD/tonne)',
558-
'Carbon Ann. Rev. (MUSD/yr)',
559-
'Carbon Cumm. Rev. (MUSD)',
560-
'Project OPEX (MUSD/yr)',
561-
'Project Net Rev. (MUSD/yr)',
562-
'Project Net Cashflow (MUSD)',
563-
]
564-
565572
def _get_revenue_and_cashflow_profile(self):
566573
def extract_table_header(lines: list) -> list:
567574
# Tried various regexy approaches to extract this programmatically but landed on hard-coding.
@@ -624,14 +631,23 @@ def extract_table_header(lines: list) -> list:
624631
self._logger.debug(f'Failed to get S-DAC-GT profile: {e}')
625632
return None
626633

627-
def _get_ccus_profile(self):
634+
def _get_carbon_revenue_or_ccus_legacy_profile(self) -> tuple:
635+
"""
636+
:return: tuple[profile key name, profile]
637+
"""
638+
628639
profile_legacy = self._get_ccus_profile_legacy()
629640
if profile_legacy is not None:
630-
return profile_legacy
641+
# Earlier versions of GEOPHIRES referred to the profile containing carbon revenue as the 'CCUS PROFILE';
642+
# the name was changed to 'CARBON REVENUE PROFILE' for technical accuracy, as it does not include data
643+
# for capture or storage, only revenue according to carbon avoided given a carbon price. However, we still
644+
# check for and parse CCUS profile if it is present in order to retain backwards compatibility in terms
645+
# of the client being able to read results from previous GEOPHIRES versions.
646+
return GeophiresXResult.CCUS_PROFILE_LEGACY_NAME, profile_legacy
631647

632648
revenue_and_cashflow_profile = self._get_revenue_and_cashflow_profile()
633649
if revenue_and_cashflow_profile is None:
634-
return None
650+
return None, None
635651

636652
carbon_price_field_name = 'Carbon Price (USD/tonne)'
637653
headers = [
@@ -654,7 +670,7 @@ def _get_ccus_profile(self):
654670
)
655671

656672
if not has_ccus_profile_in_revenue_and_cashflow:
657-
return None
673+
return None, None
658674

659675
try:
660676
profile = [headers]
@@ -670,10 +686,10 @@ def _get_ccus_profile(self):
670686
ccus_entry.append(revenue_and_cashflow_profile[i][rcp_index])
671687
profile.append(ccus_entry)
672688

673-
return profile
689+
return GeophiresXResult.CARBON_REVENUE_PROFILE_NAME, profile
674690
except BaseException as e:
675-
self._logger.debug(f'Failed to get CCUS profile: {e}')
676-
return None
691+
self._logger.debug(f'Failed to get {GeophiresXResult.CARBON_REVENUE_PROFILE_NAME}: {e}')
692+
return None, None
677693

678694
def _get_ccus_profile_legacy(self):
679695
def extract_table_header(lines: list) -> list:
@@ -690,12 +706,12 @@ def extract_table_header(lines: list) -> list:
690706
]
691707

692708
try:
693-
lines = self._get_profile_lines('CCUS PROFILE')
709+
lines = self._get_profile_lines(GeophiresXResult.CCUS_PROFILE_LEGACY_NAME)
694710
profile = [extract_table_header(lines)]
695711
profile.extend(self._extract_addons_style_table_data(lines))
696712
return profile
697713
except BaseException as e:
698-
self._logger.debug(f'Failed to get legacy CCUS profile: {e}')
714+
self._logger.debug(f'Failed to get legacy {GeophiresXResult.CCUS_PROFILE_LEGACY_NAME}: {e}')
699715
return None
700716

701717
def _extract_addons_style_table_data(self, lines: list):

tests/test_geophires_x_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ def test_revenue_and_cashflow_profile(self):
345345
rcf_profile,
346346
)
347347

348-
def test_ccus_profile(self):
348+
def test_carbon_revenue_profile(self):
349349
result_example1 = GeophiresXResult(self._get_test_file_path('examples/example1.out'))
350-
self.assertTrue('CCUS PROFILE' not in result_example1.result)
350+
self.assertTrue(GeophiresXResult.CARBON_REVENUE_PROFILE_NAME not in result_example1.result)
351351

352352
result_addons = GeophiresXResult(self._get_test_file_path('examples/example1_addons.out'))
353353
ccus_profile = result_addons.result['CCUS PROFILE']

0 commit comments

Comments
 (0)