Skip to content

Commit 70863ce

Browse files
Tweak graph title/legend labels. mark WIP/TODO to add GEOPHIRES profile data to graph
1 parent e17fca2 commit 70863ce

3 files changed

Lines changed: 46 additions & 27 deletions

File tree

src/geophires_docs/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
from __future__ import annotations
22

3+
import json
34
import os
45
from pathlib import Path
56
from typing import Any
67

8+
from pint.facets.plain import PlainQuantity
9+
710
from geophires_x_client import GeophiresInputParameters
11+
from geophires_x_client import GeophiresXClient
12+
from geophires_x_client import GeophiresXResult
813

914

1015
def _get_file_path(file_name) -> Path:
@@ -75,3 +80,20 @@ def _get_input_parameters_dict( # TODO consolidate with FervoProjectCape5TestCa
7580
# TODO preserve newlines
7681

7782
return ret
83+
84+
85+
def _get_full_profile(input_and_result: tuple[GeophiresInputParameters, GeophiresXResult], profile_key: str):
86+
input_params: GeophiresInputParameters = input_and_result[0]
87+
result = GeophiresXClient().get_geophires_result(input_params)
88+
89+
with open(result.json_output_file_path, encoding='utf-8') as f:
90+
full_result_obj = json.load(f)
91+
92+
net_gen_obj = full_result_obj[profile_key]
93+
net_gen_obj_unit = net_gen_obj['CurrentUnits'].replace('CELSIUS', 'degC')
94+
profile = [PlainQuantity(it, net_gen_obj_unit) for it in net_gen_obj['value']]
95+
return profile
96+
97+
98+
def _get_full_production_temperature_profile(input_and_result: tuple[GeophiresInputParameters, GeophiresXResult]):
99+
return _get_full_profile(input_and_result, 'Produced Temperature')

src/geophires_docs/generate_fervo_project_cape_5_graphs.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
from __future__ import annotations
22

3-
import json
43
from math import ceil
54
from pathlib import Path
65
from typing import Any
76

87
import numpy as np
98
from matplotlib import pyplot as plt
10-
from pint.facets.plain import PlainQuantity
119

1210
from geophires_docs import _FPC5_INPUT_FILE_PATH
1311
from geophires_docs import _FPC5_RESULT_FILE_PATH
1412
from geophires_docs import _PROJECT_ROOT
13+
from geophires_docs import _get_full_production_temperature_profile
14+
from geophires_docs import _get_full_profile
1515
from geophires_docs import _get_input_parameters_dict
1616
from geophires_docs import _get_logger
1717
from geophires_x_client import GeophiresInputParameters
18-
from geophires_x_client import GeophiresXClient
1918
from geophires_x_client import GeophiresXResult
2019
from geophires_x_client import ImmutableGeophiresInputParameters
2120

@@ -32,27 +31,10 @@ def _get_full_total_electricity_generation_profile(input_and_result: tuple[Geoph
3231
return _get_full_profile(input_and_result, 'Total Electricity Production')
3332

3433

35-
def _get_full_production_temperature_profile(input_and_result: tuple[GeophiresInputParameters, GeophiresXResult]):
36-
return _get_full_profile(input_and_result, 'Produced Temperature')
37-
38-
3934
def _get_full_thermal_drawdown_profile(input_and_result: tuple[GeophiresInputParameters, GeophiresXResult]):
4035
return _get_full_profile(input_and_result, 'Thermal Drawdown')
4136

4237

43-
def _get_full_profile(input_and_result: tuple[GeophiresInputParameters, GeophiresXResult], profile_key: str):
44-
input_params: GeophiresInputParameters = input_and_result[0]
45-
result = GeophiresXClient().get_geophires_result(input_params)
46-
47-
with open(result.json_output_file_path, encoding='utf-8') as f:
48-
full_result_obj = json.load(f)
49-
50-
net_gen_obj = full_result_obj[profile_key]
51-
net_gen_obj_unit = net_gen_obj['CurrentUnits'].replace('CELSIUS', 'degC')
52-
profile = [PlainQuantity(it, net_gen_obj_unit) for it in net_gen_obj['value']]
53-
return profile
54-
55-
5638
def _get_redrilling_event_indexes(
5739
input_and_result: tuple[GeophiresInputParameters, GeophiresXResult], threshold_degc: float = 0.5
5840
) -> list[float]:

src/geophires_docs/generate_fervo_project_red_2026_docs.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,13 @@ def _get_steady_state_mask(df_prod: pd.DataFrame, steady_state_start_years: floa
227227
return is_steady
228228

229229

230-
def _regenerate_graph_from_csv(
230+
def _generate_production_temperature_graph_from_fervo_graph_data_csv_and_project_red_geophires_result_data(
231231
production_csv_path: Path,
232232
model_csv_path: Path,
233233
steady_state_csv_path: Path,
234234
output_path: Path,
235235
steady_state_start_years: float = _STEADY_STATE_START_YEARS,
236+
# TODO/WIP pass GEOPHIRES production profile data
236237
) -> None:
237238
df_prod = pd.read_csv(production_csv_path)
238239
df_model = pd.read_csv(model_csv_path)
@@ -253,7 +254,10 @@ def _regenerate_graph_from_csv(
253254
s=22,
254255
linewidths=1.0,
255256
alpha=0.85,
256-
label=f'Measured flowing temperature (Included), n={len(df_included)}',
257+
label='Measured '
258+
# f'Flowing '
259+
'Temperature (Thermal Conditioning and Steady State)',
260+
# f', n={len(df_included)}',
257261
)
258262

259263
if not df_excluded.empty:
@@ -265,7 +269,10 @@ def _regenerate_graph_from_csv(
265269
s=22,
266270
linewidths=1.0,
267271
alpha=0.5,
268-
label=f'Measured flowing temperature (Excluded), n={len(df_excluded)}',
272+
label='Measured '
273+
# f'Flowing '
274+
'Temperature (Excluded Operational Periods)',
275+
# f', n={len(df_excluded)}',
269276
)
270277

271278
ax.plot(
@@ -274,12 +281,18 @@ def _regenerate_graph_from_csv(
274281
color='black',
275282
linestyle='--',
276283
linewidth=1.5,
277-
label='Modeled output',
284+
label='Fervo-Modeled Temperature',
278285
)
279286

280287
ax.set_xlabel('Time (Years)', fontsize=12)
281-
ax.set_ylabel('Flowing Temperature (°C)', fontsize=12)
282-
ax.set_title('Fervo Project Red: Measured vs. Modeled Flowing Temperature (Regenerated)', fontsize=13)
288+
ax.set_ylabel('Temperature (°C)', fontsize=12)
289+
ax.set_title(
290+
'Project Red Temperature: Measured vs. Fervo-Modeled'
291+
# ' vs. GEOPHIRES-Modeled' # WIP/TODO
292+
'',
293+
fontsize=13,
294+
)
295+
283296
ax.set_xlim(0.0, 2.0)
284297
ax.set_ylim(0.0, 200.0)
285298
ax.grid(True, linestyle='--', alpha=0.5)
@@ -330,5 +343,7 @@ def _regenerate_graph_from_csv(
330343
df_steady_state.to_csv(steady_state_csv_path, index=False)
331344
_log.info(f'Wrote variance analysis CSV: {steady_state_csv_path}')
332345

333-
_regenerate_graph_from_csv(production_csv_path, model_csv_path, steady_state_csv_path, regenerated_graph_path)
346+
_generate_production_temperature_graph_from_fervo_graph_data_csv_and_project_red_geophires_result_data(
347+
production_csv_path, model_csv_path, steady_state_csv_path, regenerated_graph_path
348+
)
334349
_log.info(f'Wrote regenerated graph: {regenerated_graph_path}')

0 commit comments

Comments
 (0)