diff --git a/examples/nwm/nwm_swe_point_scale_evaluation.ipynb b/examples/nwm/nwm_swe_point_scale_evaluation.ipynb index e974054..c01c054 100644 --- a/examples/nwm/nwm_swe_point_scale_evaluation.ipynb +++ b/examples/nwm/nwm_swe_point_scale_evaluation.ipynb @@ -77,10 +77,6 @@ "import matplotlib.pyplot as plt\n", "import matplotlib.dates as mdates\n", "\n", - "# Import the Evaluation library from the project root.\n", - "repo_root = Path.cwd().resolve().parents[1]\n", - "sys.path.insert(0, str(repo_root / \"src\"))\n", - "\n", "from cssi_evaluation.models import nwm_utils\n", "from cssi_evaluation.variables import snow_utils\n", "from cssi_evaluation.utils import plot_utils, dataPrep_utils, evaluation_utils, metric_utils\n", @@ -283,7 +279,7 @@ "id": "35b1321e", "metadata": {}, "source": [ - "## 4. Retrieve Snow Model Outputs" + "## 3. Retrieve Snow Model Outputs" ] }, { @@ -304,10 +300,10 @@ "%%time \n", "ds = xr.open_zarr(\n", " store=conus_bucket_url,\n", - " consolidated=True,\n", - " storage_options={\n", - " \"anon\": True,\n", - " \"client_kwargs\": {\"region_name\": \"us-east-1\"}\n", + " consolidated=True, # Tells Xarray to use consolidated metadata (speeds up access)\n", + " storage_options={ \n", + " \"anon\": True, # Means anonymous access to the public S3 bucket without needing AWS credentials\n", + " \"client_kwargs\": {\"region_name\": \"us-east-1\"} # Specifies the AWS region where the bucket lives\n", " }\n", ")" ] @@ -496,7 +492,11 @@ "metadata": {}, "outputs": [], "source": [ - "plot_utils.comparison_plots(obs_df, model_df, f'{my_site_code}', f'{my_site_code}', site_label=None)" + "plot_utils.comparison_plots(obs_df, \n", + " model_df, \n", + " f'{my_site_code}', # Column name in df_obs\n", + " f'{my_site_code}', # Column name in df_model\n", + " site_label=None)" ] }, { @@ -594,7 +594,6 @@ "source": [ "# isolate the columns associated with observations and model predictions.\n", "# these will be inputs to our same-day comparison function.\n", - "combined_df = pd.concat([obs_df, model_df], axis=1)\n", "obs_swe_cols = obs_df.columns.tolist()\n", "mod_swe_cols = model_df.columns.tolist()" ] @@ -634,7 +633,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Rearrange the dataframe to long format for easier plotting\n", + "# Rearrange the dataframe to long format for easier plotting. The function `.melt({})` unpivots the DataFrame from wide to long format.\n", "df_long = (\n", " df_observed_peak\n", " .reset_index() \n", @@ -1205,6 +1204,16 @@ "The Condon diagram separates model performance into quadrants based on two metrics: **Spearman’s rho** (shape/time agreement) and **relative bias** (magnitude error). The horizontal line at 0.5 distinguishes whether the model captures the temporal pattern well (above 0.5 = good shape), while the vertical line is traditionally placed at a relative bias of 1.0, which represents a 100% error. This means the model’s total error is as large as the observed signal itself. This threshold has a clear physical interpretation and is used in the original Condon framework to distinguish acceptable vs. large bias. " ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "10a68672", + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/src/cssi_evaluation/utils/plot_utils.py b/src/cssi_evaluation/utils/plot_utils.py index 87caff4..12fd1c2 100644 --- a/src/cssi_evaluation/utils/plot_utils.py +++ b/src/cssi_evaluation/utils/plot_utils.py @@ -1059,7 +1059,7 @@ def plot_scatter_melt_metrics(df): lims = [min(x.min(), y.min()), max(x.max(), y.max())] axes[0].plot(lims, lims, 'k--') - axes[0].set_title("Melt Rate (Obs vs Model)") + axes[0].set_title("Melt Rate (Obs vs Model): m/day") axes[0].set_xlabel("Observed") axes[0].set_ylabel("Modeled") axes[0].grid(True) @@ -1073,7 +1073,7 @@ def plot_scatter_melt_metrics(df): lims = [min(x.min(), y.min()), max(x.max(), y.max())] axes[1].plot(lims, lims, 'k--') - axes[1].set_title("Melt Duration (Obs vs Model)") + axes[1].set_title("Melt Duration (Obs vs Model): days") axes[1].set_xlabel("Observed") axes[1].set_ylabel("Modeled") axes[1].grid(True)