Skip to content

Commit

Permalink
fix: add warnings for run_inversion_workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanker committed Jun 26, 2024
1 parent f995f00 commit 54fc6b9
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/invert4geom/inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,10 +1138,18 @@ def run_inversion_workflow( # equivalent to monte_carlo_full_workflow

if run_damping_cv is True:
# resample to half spacing
data_spacing = kwargs.get("grav_spacing", None)
if data_spacing is None:
msg = "need to supply `grav_spacing` if `run_damping_cv` is True"
raise ValueError(msg)
inversion_region = kwargs.get("inversion_region", None)
if inversion_region is None:
msg = "need to supply `inversion_region` if `run_damping_cv` is True"
raise ValueError(msg)
grav_df = cross_validation.resample_with_test_points(
data_spacing=kwargs.get("grav_spacing", None),
data_spacing=data_spacing,
data=grav_df,
region=kwargs.get("inversion_region", None),
region=inversion_region,
)

# Starting Topography
Expand Down Expand Up @@ -1326,9 +1334,9 @@ def run_inversion_workflow( # equivalent to monte_carlo_full_workflow
"starting_topography",
"starting_topography_kwargs",
"starting_prisms",
"starting_prisms_kwargs",
"starting_grav_kwargs",
"regional_grav_kwargs",
"run",
"grav_spacing",
"damping_values",
"zref_values",
Expand Down Expand Up @@ -1382,6 +1390,12 @@ def run_inversion_workflow( # equivalent to monte_carlo_full_workflow
if run_zref_or_density_cv is False:
return inv_results

msg = (
f"Damping CV finished with best value found of {best_damping}. Using this "
"value with the zref/density CV."
)
logging.info(msg)

# drop the testing data
if "test" in grav_df.columns:
grav_df = grav_df[grav_df.test == False].copy() # noqa: E712 pylint: disable=singleton-comparison
Expand All @@ -1394,14 +1408,13 @@ def run_inversion_workflow( # equivalent to monte_carlo_full_workflow
raise ValueError(msg)
inv_results, _, _, _, _, _ = cross_validation.zref_density_optimal_parameter(
grav_df=grav_df,
grav_data_column=kwargs.get("grav_data_column"),
constraints_df=kwargs.get("constraints_df"),
zref_values=kwargs.get("zref_values"),
density_contrast_values=kwargs.get("density_contrast_values", None),
starting_topography=starting_topography,
regional_grav_kwargs={
"regional_method": regional_grav_kwargs.get("regional_method", None),
**regional_grav_kwargs.get("kwargs", None),
**regional_grav_kwargs,
},
plot_cv=plot_cv,
progressbar=True,
Expand Down

0 comments on commit 54fc6b9

Please sign in to comment.