Skip to content

Commit

Permalink
regridding.ipynb: work-around for Jenkins (nbval/issues/204)
Browse files Browse the repository at this point in the history
Work-around for
computationalmodelling/nbval#204

Have to use NBVAL_IGNORE_OUTPUT because the sanitize file seems to not
be working in this case, see the issue above.

```
  _ pavics-sdi-fix_nbs_jupyter_alpha_refresh_output/docs/source/notebooks/regridding.ipynb::Cell 4 _
  Notebook cell execution failed
  Cell 4: Cell outputs differ

  Input:
  ds_tgt.cf.plot.scatter(x="longitude", y="latitude", s=0.1)
  plt.title("Target regular grid");

  Traceback:
  dissimilar number of outputs for key "text/plain"<<<<<<<<<<<< Reference outputs from ipynb file:
  <Figure size LENGTHxWIDTH with N Axes>
  ============ disagrees with newly computed (test) output:
  Text(0.5, 1.0, 'Target regular grid')
  <Figure size LENGTHxWIDTH with N Axes>
  >>>>>>>>>>>>

  _ pavics-sdi-fix_nbs_jupyter_alpha_refresh_output/docs/source/notebooks/regridding.ipynb::Cell 6 _
  Notebook cell execution failed
  Cell 6: Cell outputs differ

  Input:
  reg_bil = xe.Regridder(ds_in, ds_tgt, "bilinear")
  reg_bil  # Show information about the regridding

  Traceback:
  Missing output fields from running code: {'stderr'}

  _ pavics-sdi-fix_nbs_jupyter_alpha_refresh_output/docs/source/notebooks/regridding.ipynb::Cell 7 _
  Notebook cell execution failed
  Cell 7: Cell outputs differ

  Input:
  # xesmf/frontend.py:476: FutureWarning: ``output_sizes`` should be given in the ``dask_gufunc_kwargs`` parameter. It will be removed as direct parameter in a future version.
  warnings.filterwarnings("ignore", category=FutureWarning)

  # Apply the regridding weights to the input sea ice concentration data
  sic_bil = reg_bil(ds_in.siconc)

  # Plot the results
  sic_bil.isel(time=0).plot(cmap=cmap)
  plt.title("Regridded sic data (Jan 2020)");

  Traceback:
  dissimilar number of outputs for key "text/plain"<<<<<<<<<<<< Reference outputs from ipynb file:
  <Figure size LENGTHxWIDTH with N Axes>
  ============ disagrees with newly computed (test) output:
  Text(0.5, 1.0, 'Regridded sic data (Jan 2020)')
  <Figure size LENGTHxWIDTH with N Axes>
  >>>>>>>>>>>>

  _ pavics-sdi-fix_nbs_jupyter_alpha_refresh_output/docs/source/notebooks/regridding.ipynb::Cell 20 _
  Notebook cell execution failed
  Cell 20: Cell outputs differ

  Input:
  reg_mask_cons = xe.Regridder(ds_in_mask, ds_tgt_mask, "conservative")
  tasmin_mask_cons = reg_mask_cons(ds_in_mask.tasmin)

  fig, ax = plt.subplots(figsize=(6, 4))
  tasmin_mask_cons.plot(cmap=cmap, ax=ax)
  ax.set_xlim(210, 320)
  ax.set_ylim(38, 86)
  ax.set_title("Conservative regridding without normalization - zoom on Canada")
  ax.annotate(
      "Some values are close to 0 Kelvins.\nCanada can get cold, but not that cold!",
      (280, 40),
      xytext=(1.3, 0.3),
      xycoords="data",
      textcoords="axes fraction",
      fontsize="x-large",
      arrowprops=dict(arrowstyle="->", connectionstyle="arc3, rad=-0.3"),
  );

  Traceback:
  dissimilar number of outputs for key "text/plain"<<<<<<<<<<<< Reference outputs from ipynb file:
  <Figure size LENGTHxWIDTH with N Axes>
  ============ disagrees with newly computed (test) output:
  Text(1.3, 0.3, 'Some values are close to 0 Kelvins.\nCanada can get cold, but not that cold!')
  <Figure size LENGTHxWIDTH with N Axes>
  >>>>>>>>>>>>

  _ pavics-sdi-fix_nbs_jupyter_alpha_refresh_output/docs/source/notebooks/regridding.ipynb::Cell 27 _
  Notebook cell execution failed
  Cell 27: Cell outputs differ

  Input:
  # Now we can plot easily the results as a choropleth map!
  ax = shapes_data.plot(
      "tasmin", legend=True, legend_kwds={"label": "Minimal temperature 1993-05-20 [K]"}
  )
  ax.set_ylabel("Latitude")
  ax.set_xlabel("Longitude");

  Traceback:
  dissimilar number of outputs for key "text/plain"<<<<<<<<<<<< Reference outputs from ipynb file:
  <Figure size LENGTHxWIDTH with N Axes>
  ============ disagrees with newly computed (test) output:
  Text(0.5, 91.20243008191655, 'Longitude')
  <Figure size LENGTHxWIDTH with N Axes>
  >>>>>>>>>>>>
```
  • Loading branch information
tlvu committed Mar 26, 2024
1 parent fd53281 commit 5d2c528
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/source/notebooks/regridding.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,8 @@
}
],
"source": [
"# NBVAL_IGNORE_OUTPUT\n",
"\n",
"ds_tgt.cf.plot.scatter(x=\"longitude\", y=\"latitude\", s=0.1)\n",
"plt.title(\"Target regular grid\");"
]
Expand Down Expand Up @@ -1195,6 +1197,8 @@
}
],
"source": [
"# NBVAL_IGNORE_OUTPUT\n",
"\n",
"# xesmf/frontend.py:476: FutureWarning: ``output_sizes`` should be given in the ``dask_gufunc_kwargs`` parameter. It will be removed as direct parameter in a future version.\n",
"warnings.filterwarnings(\"ignore\", category=FutureWarning)\n",
"\n",
Expand Down Expand Up @@ -2617,6 +2621,8 @@
}
],
"source": [
"# NBVAL_IGNORE_OUTPUT\n",
"\n",
"reg_mask_cons = xe.Regridder(ds_in_mask, ds_tgt_mask, \"conservative\")\n",
"tasmin_mask_cons = reg_mask_cons(ds_in_mask.tasmin)\n",
"\n",
Expand Down Expand Up @@ -3808,6 +3814,8 @@
}
],
"source": [
"# NBVAL_IGNORE_OUTPUT\n",
"\n",
"# Now we can plot easily the results as a choropleth map!\n",
"ax = shapes_data.plot(\n",
" \"tasmin\", legend=True, legend_kwds={\"label\": \"Minimal temperature 1993-05-20 [K]\"}\n",
Expand Down

0 comments on commit 5d2c528

Please sign in to comment.