Skip to content

Commit

Permalink
Fixed bug in sensitivity plot
Browse files Browse the repository at this point in the history
  • Loading branch information
aaschwanden committed Dec 19, 2024
1 parent 174ddcb commit 7a02d2a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![DOI](https://zenodo.org/badge/562988605.svg)](https://zenodo.org/badge/latestdoi/562988605)
[![License: GPL-3.0](https://img.shields.io:/github/license/pism/pypac)](https://opensource.org/licenses/GPL-3.0)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![flake8](https://img.shields.io/badge/flake8-enabled-green)](https://github.com/PyCQA/flake8)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint)

# pism-ragis: A Reanalysis for the Greenland Ice Sheet (RAGIS)

Expand Down
11 changes: 7 additions & 4 deletions analysis/analyze_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def run_sampling(
return prior_posterior


def filter_config(ds: xr.Dataset, params: List[str]) -> xr.DataArray:
def filter_config(ds: xr.Dataset, params: list[str]) -> xr.DataArray:
"""
Filter the configuration parameters from the dataset.
Expand Down Expand Up @@ -927,7 +927,7 @@ def run_sensitivity_analysis(
[intersection_grace, intersection_mankoff],
[["mass_balance"], ["mass_balance", "grounding_line_flux"]],
):
sobol_response_ds = basin_group.sel(time=slice("1980-01-01", "1990-01-01"))
sobol_response_ds = basin_group
sobol_input_df = params_df[params_df["basin"].isin(intersection)]

sensitivity_indices_list.append(
Expand Down Expand Up @@ -969,10 +969,13 @@ def run_sensitivity_analysis(
for basin in aggregated_ds.basin.values:
for filter_var in aggregated_ds.filtered_by.values:
plot_sensitivity_indices(
aggregated_ds.sel(filtered_by=filter_var)
aggregated_ds.sel(basin=basin, filtered_by=filter_var)
.rolling({"time": 13})
.mean(),
.mean()
.sel(time=slice("1980-01-01", "2020-01-01")),
indices_var=indices_var,
indices_conf_var=indices_conf_var,
basin=basin,
filter_var=filter_var,
fig_dir=fig_dir,
)
2 changes: 1 addition & 1 deletion pism_ragis/data/ragis_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"atmosphere" = "Climate"
"ocean" = "Ocean"
"calving" = "Frontal Ablation"
"geometry" = "Frontal Ablation"
"geometry" = "Retreat"
"frontal_melt" = "Frontal Ablation"
"basal_resistance" = "Flow"
"basal_yield_stress" = "Flow"
Expand Down
2 changes: 1 addition & 1 deletion pism_ragis/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from pism_ragis.logger import get_logger

logger: logging.Logger = get_logger(__name__)
logger: logging.Logger = get_logger("pism_ragis")


def timeit(func):
Expand Down
10 changes: 8 additions & 2 deletions pism_ragis/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def plot_sensitivity_indices(
ds: xr.Dataset,
indices_var: str = "S1",
indices_conf_var: str = "S1_conf",
basin: str = "",
filter_var: str = "",
fig_dir: Union[str, Path] = "figures",
fontsize: float = 6,
):
Expand All @@ -214,6 +216,10 @@ def plot_sensitivity_indices(
The variable name for sensitivity indices in the dataset, by default "S1".
indices_conf_var : str, optional
The variable name for confidence intervals of sensitivity indices in the dataset, by default "S1_conf".
basin : str, optional
The basin for which the sensitivity indices are plotted, by default None.
filter_var : str, optional
The variable used for filtering, by default "".
fig_dir : Union[str, Path], optional
The directory where the figures will be saved, by default "figures".
fontsize : float, optional
Expand Down Expand Up @@ -242,8 +248,8 @@ def plot_sensitivity_indices(
legend = ax.legend(loc="upper left")
legend.get_frame().set_linewidth(0.0)
legend.get_frame().set_alpha(0.0)
ax.set_title(f"{indices_var} filtered by sensitivity_indices_group")
fn = pdf_dir / f"{indices_var}_filtered_by_sensitivity_indices_group.pdf"
ax.set_title(f"{indices_var} for basin {basin} for {filter_var}")
fn = pdf_dir / f"basin_{basin}_{indices_var}_for_{filter_var}.pdf"
fig.savefig(fn)
plt.close()

Expand Down

0 comments on commit 7a02d2a

Please sign in to comment.