Skip to content

Commit

Permalink
fix it in adv too
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal committed May 2, 2024
1 parent c47a664 commit f6cb0e3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/notebooks/sdba-advanced.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,11 @@
"from xclim import sdba\n",
"\n",
"group = sdba.Grouper(\"time.dayofyear\", window=31)\n",
"sim_ad, pth, dP0 = sdba.processing.adapt_freq(\n",
" pr_ref, pr_sim, thresh=\"0.05 mm d-1\", group=group\n",
"hist_ad, pth, dP0 = sdba.processing.adapt_freq(\n",
" pr_ref, pr_hist, thresh=\"0.05 mm d-1\", group=group\n",
")\n",
"QM_ad = sdba.EmpiricalQuantileMapping.train(\n",
" pr_ref, sim_ad, nquantiles=15, kind=\"*\", group=group\n",
" pr_ref, hist_ad, nquantiles=15, kind=\"*\", group=group\n",
")\n",
"scen_ad = QM_ad.adjust(pr_sim)\n",
"\n",
Expand All @@ -698,7 +698,7 @@
"source": [
"In the figure above, `scen` occasionally has small peaks where `sim` is 0, indicating that there are more \"dry days\" (days with almost no precipitation) in `hist` than in `ref`. The frequency-adaptation [Themeßl et al. (2010)](https://doi.org/10.1007/s10584-011-0224-4) performed in the step above only worked partially. \n",
"\n",
"The reason for this is the following. The first step above combines precipitations in 365 overlapping blocks of 31 days * Y years, one block for each day of the year. Each block is adapted, and the 16th day-of-year slice (at the center of the block) is assigned to the corresponding day-of-year in the adapted dataset `sim_ad`. As we proceed to the training, we re-form those 31 days * Y years blocks, but this step does not invert the last one: There can still be more zeroes in the simulation than in the reference. \n",
"The reason for this is the following. The first step above combines precipitations in 365 overlapping blocks of 31 days * Y years, one block for each day of the year. Each block is adapted, and the 16th day-of-year slice (at the center of the block) is assigned to the corresponding day-of-year in the adapted dataset `hist_ad`. As we proceed to the training, we re-form those 31 days * Y years blocks, but this step does not invert the last one: There can still be more zeroes in the simulation than in the reference. \n",
"\n",
"To alleviate this issue, another way of proceeding is to perform a frequency adaptation on the blocks, and then use the same blocks in the training step, as we show below.\n"
]
Expand All @@ -714,7 +714,7 @@
"\n",
"QM_ad = sdba.EmpiricalQuantileMapping.train(\n",
" pr_ref,\n",
" sim_ad,\n",
" pr_hist,\n",
" nquantiles=15,\n",
" kind=\"*\",\n",
" group=group,\n",
Expand Down

0 comments on commit f6cb0e3

Please sign in to comment.