Skip to content

Commit fa358da

Browse files
Merge branch 'project-red-2026-update_2026-04-24'
2 parents 7c81288 + 262742c commit fa358da

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/geophires_docs/generate_fervo_project_red_2026_docs.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
_PRODUCTION_CSV_FILENAME = 'project_red_2026_production_data.csv'
3333
_MODEL_CSV_FILENAME = 'project_red_2026_model_data.csv'
34-
_STEADY_STATE_CSV_FILENAME = 'project_red_2026_variance_analysis.csv'
34+
_VARIANCE_ANALYSIS_CSV_FILENAME = 'project_red_2026_variance_analysis.csv'
3535
_GENERATED_GRAPH_FILENAME_STEM = 'fervo_project_red-2026_production-temperature-data-vs-modeling'
3636

3737
_STEADY_STATE_START_YEARS = 0.041625
@@ -268,7 +268,6 @@ def _get_steady_state_mask(df_prod: pd.DataFrame, steady_state_start_years: floa
268268
def _generate_production_temperature_comparison_graph(
269269
production_csv_path: Path,
270270
model_csv_path: Path,
271-
steady_state_csv_path: Path,
272271
output_path_stem: Path,
273272
steady_state_start_years: float = _STEADY_STATE_START_YEARS,
274273
geophires_data: pd.Series | None = None,
@@ -471,7 +470,6 @@ def get_project_red_production_temperature_profile_series(
471470
pd.Series,
472471
Any, # interpolator
473472
]:
474-
475473
input_and_result = get_project_red_input_params_and_result()
476474
input_params: GeophiresInputParameters = input_and_result[0]
477475

@@ -528,6 +526,7 @@ def _generate_fracture_sensitivity_graph(
528526
sensitivity_graph_path: Path,
529527
power_graph_path: Path,
530528
power_csv_path: Path,
529+
df_variance: pd.DataFrame | None = None,
531530
show_excluded_measured_temperatures: bool = False,
532531
calculate_stats: bool = True,
533532
) -> pd.DataFrame:
@@ -634,13 +633,20 @@ def _generate_fracture_sensitivity_graph(
634633
geo_interp = interp1d(geophires_x, geophires_y, kind='linear', fill_value='extrapolate')
635634
y_geo = geo_interp(df_included['Time_Years'])
636635

636+
if df_variance is not None:
637+
df_variance[f'GEOPHIRES_Modeled_Temperature_C_{frac_count}_Fractures'] = geo_interp(
638+
df_variance['Time_Years']
639+
)
640+
637641
ss_res_g = float(np.sum((y_true - y_geo) ** 2))
638642

639643
calculated_stats = _StatsAlignmentResult(
640644
rmse_degc=float(np.sqrt(((y_true - y_geo) ** 2).mean())),
641645
bias_degc=float((y_geo - y_true).mean()),
642646
r2=1.0 - (ss_res_g / ss_tot) if ss_tot != 0.0 else 0.0,
643647
)
648+
if df_variance is not None:
649+
df_variance.loc[0, f'GEOPHIRES_R2_{frac_count}_Fractures'] = calculated_stats.r2
644650

645651
_log.info(f'{frac_count} Fractures: {calculated_stats.as_caption}')
646652

@@ -743,7 +749,6 @@ def generate_fervo_project_red_2026_md(
743749
geophires_stats_alignment: _StatsAlignmentResult,
744750
project_root: Path = _PROJECT_ROOT,
745751
) -> None:
746-
747752
result_values: dict[str, Any] = {} # get_result_values(result)
748753

749754
def _get_input_params_dict_with_nbsp() -> dict[str, Any]:
@@ -803,7 +808,7 @@ def generate_fervo_project_red_2026_docs():
803808
_BUILD_DIR.mkdir(parents=True, exist_ok=True)
804809
production_csv_path_ = _BUILD_DIR / _PRODUCTION_CSV_FILENAME
805810
model_csv_path_ = _BUILD_DIR / _MODEL_CSV_FILENAME
806-
steady_state_csv_path = _BUILD_DIR / _STEADY_STATE_CSV_FILENAME
811+
variance_analysis_csv_path = _BUILD_DIR / _VARIANCE_ANALYSIS_CSV_FILENAME
807812
generated_graph_path_stem = _get_file_path(f'../../docs/_images/{_GENERATED_GRAPH_FILENAME_STEM}')
808813

809814
_log.info('Extracting data from image...')
@@ -865,16 +870,16 @@ def generate_fervo_project_red_2026_docs():
865870
df_model_['Time_Years'], df_model_['Temperature_C'], kind='linear', fill_value='extrapolate'
866871
)
867872
df_variance['Fervo_Modeled_Temperature_C'] = model_interpolator(df_variance['Time_Years'])
868-
df_variance['GEOPHIRES_Modeled_Temperature_C'] = geo_interp(df_variance['Time_Years'])
873+
df_variance.loc[0, 'Fervo_R2'] = fervo_stat_result.r2
869874

870-
df_variance.to_csv(steady_state_csv_path, index=False)
875+
df_variance['GEOPHIRES_Modeled_Temperature_C'] = geo_interp(df_variance['Time_Years'])
876+
df_variance.loc[0, 'GEOPHIRES_R2'] = geophires_stat_result.r2
871877

872878
_tab = ' '
873879

874880
_generate_production_temperature_comparison_graph(
875881
production_csv_path_,
876882
model_csv_path_,
877-
steady_state_csv_path,
878883
generated_graph_path_stem,
879884
geophires_data=geophires_series,
880885
fervo_modeled_stats_caption=f'\n{_tab}{fervo_modeled_stats_caption}\n',
@@ -901,9 +906,13 @@ def generate_fervo_project_red_2026_docs():
901906
_get_file_path(f'../../docs/_images/{_GENERATED_GRAPH_FILENAME_STEM}-fracture-sensitivity.png'),
902907
_get_file_path(f'../../docs/_images/{_GENERATED_GRAPH_FILENAME_STEM}-power-sensitivity.png'),
903908
_BUILD_DIR / 'project_red_2026_power_sensitivity.csv',
909+
df_variance=df_variance,
904910
)
905911
_log.info('Wrote sensitivity graphs and power data')
906912

913+
df_variance.to_csv(variance_analysis_csv_path, index=False)
914+
_log.info(f'Wrote variance analysis CSV: {variance_analysis_csv_path}')
915+
907916
generate_fervo_project_red_2026_md(
908917
*get_project_red_input_params_and_result(), fervo_stat_result, geophires_stat_result
909918
)

0 commit comments

Comments
 (0)