Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh notebook outputs for new Jupyter env #86

Closed
wants to merge 3 commits into from
Closed

Conversation

tlvu
Copy link
Collaborator

@tlvu tlvu commented May 10, 2024

tlvu added 2 commits May 9, 2024 22:42
```
  _ PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-1DataAccess.ipynb::Cell 2 _
  Notebook cell execution failed
  Cell 2: Cell outputs differ

  Input:
  # Extract a subset of the file

  # Again, this only creates an in-memory representation of the data
  sub = ds.pr.sel(time="2050").sel(lon=-80, lat=46, method="nearest")

  # The data is only downloaded when we actuall need it for a computation.
  sub.mean(keep_attrs=True).compute()

  Traceback:
   mismatch 'text/plain'

   assert reference_output == test_output failed:

    '<xarray.Data...[256  16  16]' == '<xarray.Data...[256  16  16]'

    - <xarray.DataArray 'pr' ()> Size: 4B
    ?                           ---------
    + <xarray.DataArray 'pr' ()>
      array(3.975487e-05, dtype=float32)
      Coordinates:
    -     lat      float32 4B 46.04
    ?                      ---
    +     lat      float32 46.04
    -     lon      float32 4B -79.96
    ?                      ---
    +     lon      float32 -79.96
      Attributes:
          long_name:      lwe_precipitation_rate
          standard_name:  lwe_precipitation_rate
          units:          mm s-1
          _ChunkSizes:    [256  16  16]
```
```
  _ PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-2Subsetting.ipynb::Cell 0 _
  Notebook cell execution failed
  Cell 0: Cell outputs differ

  Input:
  import warnings

  import xarray as xr
  from IPython.display import display  # Fancy representation of xarray objects
  from siphon.catalog import TDSCatalog

  warnings.simplefilter("ignore")
  url = "https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/catalog/datasets/simulations/bias_adjusted/cmip5/ouranos/cb-oura-1.0/catalog.xml"  # TEST_USE_PROD_DATA

  # Create Catalog
  cat = TDSCatalog(url)

  # DAP link for this demo
  ds_url = cat.datasets[0].access_urls["OPENDAP"]

  # xarray.Dataset
  ds = xr.open_dataset(ds_url, chunks=dict(time=256 * 2, lon=32, lat=32))
  display(ds)
  a = ds.tasmin.isel(time=0).plot(figsize=(10, 4))

  Traceback:
   mismatch 'text/plain'

   assert reference_output == test_output failed:

    '<xarray.Data...id:       NCC' == '<xarray.Data...id:       NCC'

    - <xarray.Dataset> Size: 169GB
    + <xarray.Dataset>
      Dimensions:  (lat: 320, lon: 797, time: 55115)
      Coordinates:
    -   * lat      (lat) float32 1kB 66.62 66.54 66.46 66.37 ... 40.21 40.12 40.04
    ?                            ----
    +   * lat      (lat) float32 66.62 66.54 66.46 66.37 ... 40.29 40.21 40.12 40.04
    ?                                                       ++++++
    -   * lon      (lon) float32 3kB -120.8 -120.7 -120.6 ... -54.63 -54.55 -54.46
    ?                            ----
    +   * lon      (lon) float32 -120.8 -120.7 -120.6 -120.5 ... -54.63 -54.55 -54.46
    ?                                                 +++++++
    -   * time     (time) object 441kB/DATE/TIME/.../DATE/00:00:00
    ?                           ------
    +   * time     (time) object/DATE/TIME/.../DATE/00:00:00
      Data variables:
    -     tasmin   (time, lat, lon) float32 56GB dask.array<chunksize=(512, 32, 32), meta=np.ndarray>
    ?                                      -----
    +     tasmin   (time, lat, lon) float32 dask.array<chunksize=(512, 32, 32), meta=np.ndarray>
    -     tasmax   (time, lat, lon) float32 56GB dask.array<chunksize=(512, 32, 32), meta=np.ndarray>
    ?                                      -----
    +     tasmax   (time, lat, lon) float32 dask.array<chunksize=(512, 32, 32), meta=np.ndarray>
    -     pr       (time, lat, lon) float32 56GB dask.array<chunksize=(512, 32, 32), meta=np.ndarray>
    ?                                      -----
    +     pr       (time, lat, lon) float32 dask.array<chunksize=(512, 32, 32), meta=np.ndarray>
      Attributes: (12/26)
          Conventions:                CF-1.5
          title:                      Ouranos standard ensemble of bias-adjusted cl...
          history:                    DATE_TIME_TZ CMOR rewrote data to com...
          institution:                Ouranos Consortium on Regional Climatology an...
          source:                     NorESM1-M 2011  atmosphere: CAM-Oslo (CAM4-Os...
          driving_experiment:         historical,rcp85
          ...                         ...
          frequency:                  day
          modeling_realm:             atmos
          target_dataset:             CANADA : ANUSPLIN interpolated Canada daily 3...
          target_dataset_references:  CANADA : https://doi.org/10.1175/2011BAMS3132...
          driving_institution:        Norwegian Climate Centre
          driving_institute_id:       NCC

  _ PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-2Subsetting.ipynb::Cell 1 _
  Notebook cell execution failed
  Cell 1: Cell outputs differ

  Input:
  from clisops.core import subset

  lon = [-75.4, -85, -65.5]  # Longitude
  lat = [46.67, 41, 55.3]  # Latitude

  ds_gridpoint = subset.subset_gridpoint(ds, lon=lon, lat=lat)
  display(ds_gridpoint)

  # Plot first year of tasmax data
  a = ds_gridpoint.tasmax.isel(time=slice(0, 365)).plot.line(x="time", figsize=(10, 4))

  Traceback:
   mismatch 'text/plain'

   assert reference_output == test_output failed:

    '<xarray.Data...id:       NCC' == '<xarray.Data...id:       NCC'

    - <xarray.Dataset> Size: 2MB
    ?                 ----------
    + <xarray.Dataset>
      Dimensions:  (site: 3, time: 55115)
      Coordinates:
    -     lat      (site) float32 12B 46.71 41.04 55.29
    ?                             ----
    +     lat      (site) float32 46.71 41.04 55.29
    -     lon      (site) float32 12B -75.38 -84.96 -65.46
    ?                             ----
    +     lon      (site) float32 -75.38 -84.96 -65.46
    -   * time     (time) object 441kB/DATE/TIME/.../DATE/00:00:00
    ?                           ------
    +   * time     (time) object/DATE/TIME/.../DATE/00:00:00
      Dimensions without coordinates: site
      Data variables:
    -     tasmin   (time, site) float32 661kB dask.array<chunksize=(512, 3), meta=np.ndarray>
    ?                                  ------
    +     tasmin   (time, site) float32 dask.array<chunksize=(512, 3), meta=np.ndarray>
    -     tasmax   (time, site) float32 661kB dask.array<chunksize=(512, 3), meta=np.ndarray>
    ?                                  ------
    +     tasmax   (time, site) float32 dask.array<chunksize=(512, 3), meta=np.ndarray>
    -     pr       (time, site) float32 661kB dask.array<chunksize=(512, 3), meta=np.ndarray>
    ?                                  ------
    +     pr       (time, site) float32 dask.array<chunksize=(512, 3), meta=np.ndarray>
      Attributes: (12/26)
          Conventions:                CF-1.5
          title:                      Ouranos standard ensemble of bias-adjusted cl...
          history:                    DATE_TIME_TZ CMOR rewrote data to com...
          institution:                Ouranos Consortium on Regional Climatology an...
          source:                     NorESM1-M 2011  atmosphere: CAM-Oslo (CAM4-Os...
          driving_experiment:         historical,rcp85
          ...                         ...
          frequency:                  day
          modeling_realm:             atmos
          target_dataset:             CANADA : ANUSPLIN interpolated Canada daily 3...
          target_dataset_references:  CANADA : https://doi.org/10.1175/2011BAMS3132...
          driving_institution:        Norwegian Climate Centre
          driving_institute_id:       NCC

  _ PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-2Subsetting.ipynb::Cell 2 _
  Notebook cell execution failed
  Cell 2: Cell outputs differ

  Input:
  subset.subset_gridpoint(ds, lon=lon, lat=lat, add_distance=True).distance

  Traceback:
   mismatch 'text/plain'

   assert reference_output == test_output failed:

    '<xarray.Data...  units:    m' == '<xarray.Data...  units:    m'

    - <xarray.DataArray 'distance' (site: 3)> Size: 24B
    ?                                        ----------
    + <xarray.DataArray 'distance' (site: 3)>
      array([4458.75328944, 5560.94197182, 2590.95839354])
      Coordinates:
    -     lat       (site) float32 12B 46.71 41.04 55.29
    ?                              ----
    +     lat       (site) float32 46.71 41.04 55.29
    -     lon       (site) float32 12B -75.38 -84.96 -65.46
    ?                              ----
    +     lon       (site) float32 -75.38 -84.96 -65.46
    -     distance  (site) float64 24B 4.459e+03 5.561e+03 2.591e+03
    ?                             ----
    +     distance  (site) float64 4.459e+03 5.561e+03 2.591e+03
      Dimensions without coordinates: site
      Attributes:
          units:    m

  _ PAVICS-landing-master/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-2Subsetting.ipynb::Cell 3 _
  Notebook cell execution failed
  Cell 3: Cell outputs differ

  Input:
  # Specify the longitude and latitude boundaries
  lon_bnds = [-80.5, -60.2]
  lat_bnds = [44, 55]

  ds1 = subset.subset_bbox(ds, lon_bnds=lon_bnds, lat_bnds=lat_bnds)
  display(ds1)

  # Plot a map of first timestep
  a = ds1.tasmax.isel(time=0).plot()

  Traceback:
   mismatch 'text/plain'

   assert reference_output == test_output failed:

    '<xarray.Data...id:       NCC' == '<xarray.Data...id:       NCC'

    - <xarray.Dataset> Size: 21GB
    ?                 -----------
    + <xarray.Dataset>
      Dimensions:  (lat: 132, lon: 244, time: 55115)
      Coordinates:
    -   * lat      (lat) float32 528B 54.96 54.87 54.79 54.71 ... 44.21 44.12 44.04
    ?                            -----
    +   * lat      (lat) float32 54.96 54.87 54.79 54.71 ... 44.29 44.21 44.12 44.04
    ?                                                       ++++++
    -   * lon      (lon) float32 976B -80.46 -80.38 -80.3 ... -60.38 -60.3 -60.21
    ?                            -----
    +   * lon      (lon) float32 -80.46 -80.38 -80.3 -80.21 ... -60.38 -60.3 -60.21
    ?                                                +++++++
    -   * time     (time) object 441kB/DATE/TIME/.../DATE/00:00:00
    ?                           ------
    +   * time     (time) object/DATE/TIME/.../DATE/00:00:00
      Data variables:
    -     tasmin   (time, lat, lon) float32 7GB dask.array<chunksize=(512, 20, 28), meta=np.ndarray>
    ?                                      ----
    +     tasmin   (time, lat, lon) float32 dask.array<chunksize=(512, 20, 28), meta=np.ndarray>
    -     tasmax   (time, lat, lon) float32 7GB dask.array<chunksize=(512, 20, 28), meta=np.ndarray>
    ?                                      ----
    +     tasmax   (time, lat, lon) float32 dask.array<chunksize=(512, 20, 28), meta=np.ndarray>
    -     pr       (time, lat, lon) float32 7GB dask.array<chunksize=(512, 20, 28), meta=np.ndarray>
    ?                                      ----
    +     pr       (time, lat, lon) float32 dask.array<chunksize=(512, 20, 28), meta=np.ndarray>
      Attributes: (12/26)
          Conventions:                CF-1.5
          title:                      Ouranos standard ensemble of bias-adjusted cl...
          history:                    DATE_TIME_TZ CMOR rewrote data to com...
          institution:                Ouranos Consortium on Regional Climatology an...
          source:                     NorESM1-M 2011  atmosphere: CAM-Oslo (CAM4-Os...
          driving_experiment:         historical,rcp85
          ...                         ...
          frequency:                  day
          modeling_realm:             atmos
          target_dataset:             CANADA : ANUSPLIN interpolated Canada daily 3...
          target_dataset_references:  CANADA : https://doi.org/10.1175/2011BAMS3132...
          driving_institution:        Norwegian Climate Centre
          driving_institute_id:       NCC
```
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

```
  _ PAVICS-landing-new-jupyter-env/content/notebooks/climate_indicators/PAVICStutorial_ClimateDataAnalysis-3Climate-Indicators.ipynb::Cell 0 _
  Notebook cell execution failed
  Cell 0: Cell outputs differ

  Input:
  import os

  os.environ["USE_PYGEOS"] = "0"  # force use Shapely with GeoPandas

  import warnings

  import numba

  warnings.simplefilter("ignore", category=numba.core.errors.NumbaDeprecationWarning)

  import geopandas as gpd
  import matplotlib.pyplot as plt
  import xarray as xr
  from clisops.core import subset
  from dask.diagnostics import ProgressBar
  from siphon.catalog import TDSCatalog
  from xclim import atmos

  warnings.simplefilter("ignore")
  # TODO change address
  url = "https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/catalog/datasets/simulations/bias_adjusted/cmip5/ouranos/cb-oura-1.0/catalog.xml"  # TEST_USE_PROD_DATA

  # Create Catalog
  cat = TDSCatalog(url)

  # Subset over the Gasp�� peninsula in eastern Quebec
  gaspe = gpd.GeoDataFrame.from_file(
      "/notebook_dir/pavics-homepage/tutorial_data/gaspesie_mrc.geojson"
  )
  ds = subset.subset_shape(
      xr.open_dataset(cat.datasets[0].access_urls["OPENDAP"], chunks=dict(time=256)),
      shape=gpd.GeoDataFrame(geometry=gaspe.buffer(0.05)),
  )

  # What we see here is only a representation of the full content, the entire data set hasn't been loaded.
  display(ds)

  # plot of single day tasmin
  a = ds.tasmin.isel(time=0).plot(figsize=(10, 4))

  Traceback:
   mismatch 'text/plain'

   assert reference_output == test_output failed:

    '<xarray.Data...    EPSG:4326' == '<xarray.Data...    EPSG:4326'

    - <xarray.Dataset> Size: 524MB
    + <xarray.Dataset>
      Dimensions:  (lat: 18, lon: 44, time: 55115)
      Coordinates:
    -   * lat      (lat) float32 72B 49.29 49.21 49.12 49.04 ... 48.04 47.96 47.87
    ?                            ----
    +   * lat      (lat) float32 49.29 49.21 49.12 49.04 ... 48.12 48.04 47.96 47.87
    ?                                                       ++++++
    -   * lon      (lon) float32 176B -67.71 -67.63 -67.55 ... -64.3 -64.21 -64.13
    ?                            -----
    +   * lon      (lon) float32 -67.71 -67.63 -67.55 -67.46 ... -64.3 -64.21 -64.13
    ?                                                 +++++++
    -   * time     (time) object 441kB/DATE/TIME/.../DATE/00:00:00
    ?                           ------
    +   * time     (time) object/DATE/TIME/.../DATE/00:00:00
      Data variables:
    -     tasmin   (time, lat, lon) float32 175MB dask.array<chunksize=(256, 18, 44), meta=np.ndarray>
    ?                                      ------
    +     tasmin   (time, lat, lon) float32 dask.array<chunksize=(256, 18, 44), meta=np.ndarray>
    -     tasmax   (time, lat, lon) float32 175MB dask.array<chunksize=(256, 18, 44), meta=np.ndarray>
    ?                                      ------
    +     tasmax   (time, lat, lon) float32 dask.array<chunksize=(256, 18, 44), meta=np.ndarray>
    -     pr       (time, lat, lon) float32 175MB dask.array<chunksize=(256, 18, 44), meta=np.ndarray>
    ?                                      ------
    +     pr       (time, lat, lon) float32 dask.array<chunksize=(256, 18, 44), meta=np.ndarray>
    -     crs      int64 8B 1
    ?                    ---
    +     crs      int64 1
      Attributes: (12/27)
          Conventions:                CF-1.5
          title:                      Ouranos standard ensemble of bias-adjusted cl...
          history:                    DATE_TIME_TZ CMOR rewrote data to com...
          institution:                Ouranos Consortium on Regional Climatology an...
          source:                     NorESM1-M 2011  atmosphere: CAM-Oslo (CAM4-Os...
          driving_experiment:         historical,rcp85
          ...                         ...
          modeling_realm:             atmos
          target_dataset:             CANADA : ANUSPLIN interpolated Canada daily 3...
          target_dataset_references:  CANADA : https://doi.org/10.1175/2011BAMS3132...
          driving_institution:        Norwegian Climate Centre
          driving_institute_id:       NCC
          crs:                        EPSG:4326
```
@tlvu
Copy link
Collaborator Author

tlvu commented Nov 13, 2024

Replaced by #98

@tlvu tlvu closed this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant