From 6cd324153f38886ea0266a32b80d57c05ec4e0ec Mon Sep 17 00:00:00 2001 From: Gregor Decristoforo Date: Mon, 4 Nov 2024 15:50:51 +0100 Subject: [PATCH 1/3] Add note for installation of missing packages --- content/xarray.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/content/xarray.rst b/content/xarray.rst index d76ad416..b4e2226e 100644 --- a/content/xarray.rst +++ b/content/xarray.rst @@ -45,6 +45,13 @@ Xarray is a powerful Python library that introduces labelled multidimensional ar We will first download a dataset similar to the example above to illustrate the advantages of Xarray. We will cover how to transform your own data into an Xarray Dataset later in this lecture. +.. Note:: + + If you have set up your ``python-for-scicomp`` environment yesterday or earlier, you need to install the packages ``netcdf4`` and ``pythia_datasets`` manually. You can do this by running the following commands in your (JupyterLab) terminal: :: + + conda install netcdf4 + pip install pythia_datasets + Let us open a python shell and download a public dataset: :: >>> from pythia_datasets import DATASETS @@ -328,7 +335,7 @@ Creating your own Xarray Dataset is quite simple. We can create a Dataset from s # Put everything together to create the Dataset ds = xr.Dataset( - { + data_vars = { "pressure": (["time", "location"], pressure_data), "humidity": (["time", "location"], humidity_data) }, @@ -338,10 +345,6 @@ Creating your own Xarray Dataset is quite simple. We can create a Dataset from s }, attrs={ "description": "Weather data", - "units": { - "pressure": "hPa", - "humidity": "%" - }, "creation_date": "2023-01-01", "author": "Data Scientist" } @@ -403,7 +406,7 @@ Exercises 2 stock_prices = np.random.normal(loc=[100, 1500, 200], scale=[10, 50, 20], size=(10, 3)) trading_volumes = np.random.randint(1000, 10000, size=(10, 3)) ds = xr.Dataset( - { + data_vars = { "stock_price": (["time", "company"], stock_prices), "trading_volume": (["time", "company"], trading_volumes), }, From 90b58cf4d294f50b157b86ab3710c81eb85e8bf1 Mon Sep 17 00:00:00 2001 From: Gregor Decristoforo Date: Mon, 4 Nov 2024 16:26:58 +0100 Subject: [PATCH 2/3] Add conda install for all packages --- content/xarray.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/content/xarray.rst b/content/xarray.rst index b4e2226e..335b14ff 100644 --- a/content/xarray.rst +++ b/content/xarray.rst @@ -47,10 +47,9 @@ We will first download a dataset similar to the example above to illustrate the .. Note:: - If you have set up your ``python-for-scicomp`` environment yesterday or earlier, you need to install the packages ``netcdf4`` and ``pythia_datasets`` manually. You can do this by running the following commands in your (JupyterLab) terminal: :: + If you have set up your ``python-for-scicomp`` environment yesterday or earlier, you need to install the packages ``netcdf4`` and ``pythia_datasets`` manually. You can do this by running the following command in your (JupyterLab) terminal: :: - conda install netcdf4 - pip install pythia_datasets + conda install netcdf4 pythia-datasets Let us open a python shell and download a public dataset: :: From c3234ab6980a886155c10d169132a1f0c3fe9343 Mon Sep 17 00:00:00 2001 From: Enrico Glerean Date: Mon, 4 Nov 2024 23:14:59 +0200 Subject: [PATCH 3/3] explicitly using conda-forge channel to help Windows installation --- content/xarray.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/xarray.rst b/content/xarray.rst index 335b14ff..07b33984 100644 --- a/content/xarray.rst +++ b/content/xarray.rst @@ -49,7 +49,7 @@ We will first download a dataset similar to the example above to illustrate the If you have set up your ``python-for-scicomp`` environment yesterday or earlier, you need to install the packages ``netcdf4`` and ``pythia_datasets`` manually. You can do this by running the following command in your (JupyterLab) terminal: :: - conda install netcdf4 pythia-datasets + conda install netcdf4 pythia-datasets -c conda-forge Let us open a python shell and download a public dataset: ::