Skip to content

Commit 3891928

Browse files
Parse S_DAC_GT PROFILE
1 parent 18a0cbd commit 3891928

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/geophires_x_client/geophires_x_result.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ def __init__(self, output_file_path, logger_name=None):
371371
if ccus_profile is not None:
372372
self.result['CCUS PROFILE'] = ccus_profile
373373

374+
sdacgt_profile = self._get_sdacgt_profile()
375+
if sdacgt_profile is not None:
376+
self.result['S_DAC_GT PROFILE'] = sdacgt_profile
377+
374378
self.result['metadata'] = {'output_file_path': self.output_file_path}
375379
for metadata_field in GeophiresXResult._METADATA_FIELDS:
376380
self.result['metadata'][metadata_field] = self._get_equal_sign_delimited_field(metadata_field)
@@ -595,6 +599,27 @@ def extract_table_header(lines: list) -> list:
595599
self._logger.debug(f'Failed to get extended economic profile: {e}')
596600
return None
597601

602+
def _get_sdacgt_profile(self):
603+
def extract_table_header(lines: list) -> list:
604+
# Tried various regexy approaches to extract this programmatically but landed on hard-coding.
605+
return [
606+
'Year Since Start',
607+
'Carbon Captured (tonne/yr)',
608+
'Cumm. Carbon Captured (tonne)',
609+
'S_DAC_GT Annual Cost (USD/yr)',
610+
'S_DAC_GT Cumm. Cash Flow (USD)',
611+
'Cumm. Cost Per Tonne (USD/tonne)',
612+
]
613+
614+
try:
615+
lines = self._get_profile_lines('S_DAC_GT PROFILE')
616+
profile = [extract_table_header(lines)]
617+
profile.extend(self._extract_addons_style_table_data(lines))
618+
return profile
619+
except BaseException as e:
620+
self._logger.debug(f'Failed to get S-DAC-GT profile: {e}')
621+
return None
622+
598623
def _get_ccus_profile(self):
599624
"""
600625
FIXME TODO - transform from revenue & cashflow if present (CCUS profile replaced by revenue & cashflow

tests/test_geophires_x_client.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,3 +532,29 @@ def test_parse_annualized_capital_costs(self):
532532
def test_parse_number_with_commas(self):
533533
result = GeophiresXResult(self._get_test_file_path('examples/S-DAC-GT.out'))
534534
self.assertEqual(result.result['S_DAC_GT ECONOMICS']['Total Cost of Capture']['value'], 499_311_405.59)
535+
536+
def test_parse_sdacgt_profile(self):
537+
result = GeophiresXResult(self._get_test_file_path('examples/S-DAC-GT.out'))
538+
sdacgt_profile = result.result['S_DAC_GT PROFILE']
539+
self.assertIsNotNone(sdacgt_profile)
540+
self.assertEqual(
541+
sdacgt_profile[0],
542+
[
543+
'Year Since Start',
544+
'Carbon Captured (tonne/yr)',
545+
'Cumm. Carbon Captured (tonne)',
546+
'S_DAC_GT Annual Cost (USD/yr)',
547+
'S_DAC_GT Cumm. Cash Flow (USD)',
548+
'Cumm. Cost Per Tonne (USD/tonne)',
549+
],
550+
)
551+
552+
# Values below need to be synchronized if S-DAC-GT example output values change.
553+
self.assertEqual(sdacgt_profile[1], [1, 78330.8, 78330.8, 17411627.98, 17411627.98, 222.28])
554+
555+
self.assertEqual(
556+
sdacgt_profile[15],
557+
[15, 76263.89, 1167207.48, 16952186.81, 259450710.33, 222.28],
558+
)
559+
560+
self.assertEqual(sdacgt_profile[30], [30, 61974.61, 2246284.1, 13775920.11, 499311405.59, 222.28])

0 commit comments

Comments
 (0)