Skip to content

Commit

Permalink
rename xray into xarray
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Mar 12, 2016
1 parent 359b2d8 commit 35ae668
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
Expand Up @@ -109,7 +109,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"On lit les données puis on recrée un [DataSet](http://xray.readthedocs.org/en/stable/data-structures.html#dataset) :"
"On lit les données puis on recrée un [DataSet](http://xarray.pydata.org/en/stable/data-structures.html#dataset) :"
]
},
{
Expand All @@ -122,7 +122,7 @@
{
"data": {
"text/plain": [
"<xray.Dataset>\n",
"<xarray.Dataset>\n",
"Dimensions: (age_num: 84, annee: 54, genre: 3, pays: 54)\n",
"Coordinates:\n",
" * annee (annee) int64 1960 1961 1962 1963 1964 1965 1966 1967 1968 ...\n",
Expand Down Expand Up @@ -153,8 +153,8 @@
"piv = df2.pivot_table(index=[\"annee\", \"age_num\",\"pays\",\"genre\"],\n",
" columns=[\"indicateur\"],\n",
" values=\"valeur\")\n",
"import xray\n",
"ds = xray.Dataset.from_dataframe(piv)\n",
"import xarray\n",
"ds = xarray.Dataset.from_dataframe(piv)\n",
"ds"
]
},
Expand All @@ -164,7 +164,7 @@
"source": [
"### Exercice 1 : que font les lignes suivantes ?\n",
"\n",
"Le programme suivant uilise les fonctions [align nad reindex](http://xray.readthedocs.org/en/stable/indexing.html#align-and-reindex), [transforming datasets](http://xray.readthedocs.org/en/stable/data-structures.html?highlight=assign#transforming-datasets) pour faire une moyenne sur une des dimensions du DataSet (le pays) puis à ajouter une variable *meanp* contenant le résultat."
"Le programme suivant uilise les fonctions [align nad reindex](http://xarray.pydata.org/en/stable/data-structures.html?highlight=assign#transforming-datasets) pour faire une moyenne sur une des dimensions du DataSet (le pays) puis à ajouter une variable *meanp* contenant le résultat."
]
},
{
Expand All @@ -177,7 +177,7 @@
{
"data": {
"text/plain": [
"<xray.Dataset>\n",
"<xarray.Dataset>\n",
"Dimensions: (age_num: 84, annee: 54, genre: 3, pays: 54)\n",
"Coordinates:\n",
" * annee (annee) int64 1960 1961 1962 1963 1964 1965 1966 1967 1968 ...\n",
Expand Down Expand Up @@ -213,7 +213,7 @@
"outputs": [],
"source": [
"meanp = ds.mean(dim=\"pays\")\n",
"ds1, ds2 = xray.align(ds, meanp, join='outer')"
"ds1, ds2 = xarray.align(ds, meanp, join='outer')"
]
},
{
Expand Down Expand Up @@ -376,7 +376,7 @@
{
"data": {
"text/plain": [
"<xray.DataArray 'meanp' ()>\n",
"<xarray.DataArray 'meanp' ()>\n",
"array(23.83243243243243)\n",
"Coordinates:\n",
" annee int64 2000\n",
Expand Down
Expand Up @@ -373,7 +373,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cubes de données avec xray"
"### Cubes de données avec xarray"
]
},
{
Expand All @@ -382,7 +382,7 @@
"source": [
"#### création\n",
"\n",
"Cette réprésentation sous forme de table n'est pas toujours très lisible. Les informations sont souvent répétées et les données sont vraiment multidimensionnelles. Le module [xray](http://xray.readthedocs.org/en/stable/) propose de distinguer les coordonnées des valeurs pour proposer des manipulations plus intuitives. Le module propose un DataFrame multidimensionnelle [DataSet](http://xray.readthedocs.org/en/stable/data-structures.html#dataset)."
"Cette réprésentation sous forme de table n'est pas toujours très lisible. Les informations sont souvent répétées et les données sont vraiment multidimensionnelles. Le module [xarray](http://xarray.pydata.org/en/stable/) propose de distinguer les coordonnées des valeurs pour proposer des manipulations plus intuitives. Le module propose un DataFrame multidimensionnelle [DataSet](http://xarray.pydata.org/en/stable/data-structures.html#dataset)."
]
},
{
Expand Down Expand Up @@ -415,12 +415,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Dans ce cas-ci, pour reprendre la temrinologie du module [xray](http://xray.readthedocs.org/en/stable/), nous avons :\n",
"Dans ce cas-ci, pour reprendre la temrinologie du module [xarray](http://xarray.pydata.org/en/stable/), nous avons :\n",
"\n",
"* les **dimensions** : annee, age_num, pays, genre\n",
"* les **valeurs** : une valeur par indicateur\n",
"\n",
"On peut passer d'un [DataFrame](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html) à un [DataSet](http://xray.readthedocs.org/en/stable/data-structures.html#dataset) de la façon suivante :\n",
"On peut passer d'un [DataFrame](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html) à un [DataSet](http://xarray.pydata.org/en/stable/data-structures.html#dataset) de la façon suivante :\n",
"\n",
"* les colonnes indéxées représentent les dimensions\n",
"* les colonnes non indéxées sont les valeurs\n",
Expand Down Expand Up @@ -754,7 +754,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Les données sont maintenant prêtes à passer sous *xray* :"
"Les données sont maintenant prêtes à passer sous *xarray* :"
]
},
{
Expand All @@ -767,7 +767,7 @@
{
"data": {
"text/plain": [
"<xray.Dataset>\n",
"<xarray.Dataset>\n",
"Dimensions: (age_num: 84, annee: 54, genre: 3, pays: 54)\n",
"Coordinates:\n",
" * annee (annee) int64 1960 1961 1962 1963 1964 1965 1966 1967 1968 ...\n",
Expand All @@ -790,8 +790,8 @@
}
],
"source": [
"import xray\n",
"ds = xray.Dataset.from_dataframe(piv)\n",
"import xarray\n",
"ds = xarray.Dataset.from_dataframe(piv)\n",
"ds"
]
},
Expand All @@ -801,7 +801,7 @@
"source": [
"#### sélection\n",
"\n",
"Il est facile ensuite d'extraire les données d'un pays avec la méthode [sel](http://xray.readthedocs.org/en/stable/indexing.html#indexing-and-selecting-data) :"
"Il est facile ensuite d'extraire les données d'un pays avec la méthode [sel](http://xarray.pydata.org/en/stable/indexing.html#indexing-and-selecting-data) :"
]
},
{
Expand All @@ -814,7 +814,7 @@
{
"data": {
"text/plain": [
"<xray.Dataset>\n",
"<xarray.Dataset>\n",
"Dimensions: (age_num: 84, annee: 54, genre: 3, pays: 1)\n",
"Coordinates:\n",
" * annee (annee) int64 1960 1961 1962 1963 1964 1965 1966 1967 1968 ...\n",
Expand Down Expand Up @@ -857,7 +857,7 @@
{
"data": {
"text/plain": [
"<xray.Dataset>\n",
"<xarray.Dataset>\n",
"Dimensions: (age_num: 84, annee: 54, genre: 3, pays: 2)\n",
"Coordinates:\n",
" * annee (annee) int64 1960 1961 1962 1963 1964 1965 1966 1967 1968 ...\n",
Expand Down Expand Up @@ -900,7 +900,7 @@
{
"data": {
"text/plain": [
"<xray.Dataset>\n",
"<xarray.Dataset>\n",
"Dimensions: (age_num: 84, genre: 3)\n",
"Coordinates:\n",
" annee int64 2000\n",
Expand Down Expand Up @@ -1181,8 +1181,8 @@
"\n",
"On pourra s'aider des pages :\n",
"\n",
"* [align nad reindex](http://xray.readthedocs.org/en/stable/indexing.html#align-and-reindex)\n",
"* [transforming datasets](http://xray.readthedocs.org/en/stable/data-structures.html?highlight=assign#transforming-datasets)"
"* [align nad reindex](http://xarray.pydata.org/en/stable/indexing.html#align-and-reindex)\n",
"* [transforming datasets](http://xarray.pydata.org/en/stable/data-structures.html?highlight=assign#transforming-datasets)"
]
},
{
Expand All @@ -1195,7 +1195,7 @@
{
"data": {
"text/plain": [
"<xray.Dataset>\n",
"<xarray.Dataset>\n",
"Dimensions: (age_num: 84, annee: 54, genre: 3, pays: 54)\n",
"Coordinates:\n",
" * annee (annee) int64 1960 1961 1962 1963 1964 1965 1966 1967 1968 ...\n",
Expand Down Expand Up @@ -1231,7 +1231,7 @@
"outputs": [],
"source": [
"meanp = ds.mean(dim=\"pays\")\n",
"ds1, ds2 = xray.align(ds, meanp, join='outer')"
"ds1, ds2 = xarray.align(ds, meanp, join='outer')"
]
},
{
Expand Down Expand Up @@ -1388,7 +1388,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Le module [xray](http://xray.readthedocs.org/) s'appuie sur le module [netCDF4](https://github.com/Unidata/netcdf4-python) qui lui-même est un [wrapper](https://fr.wikipedia.org/wiki/Adaptateur_(patron_de_conception)) poython de la libraire [netCDF-c](https://github.com/Unidata/netcdf-c). Celle-ci est spécialisée dans la lecture et l'écriture de données scientifiques. Concrètement, ce n'est pas [xray](http://xray.readthedocs.org/) qui s'en occupe mais [netCDF4](https://github.com/Unidata/netcdf4-python). Cela explique la syntaxe décrite par [Serialization and IO](http://xray.readthedocs.org/en/stable/io.html#serialization-and-io) :"
"Le module [xarray](http://xarray.pydata.org/en/stable/) s'appuie sur le module [netCDF4](https://github.com/Unidata/netcdf4-python) qui lui-même est un [wrapper](https://fr.wikipedia.org/wiki/Adaptateur_(patron_de_conception)) poython de la libraire [netCDF-c](https://github.com/Unidata/netcdf-c). Celle-ci est spécialisée dans la lecture et l'écriture de données scientifiques. Concrètement, ce n'est pas [xarray](http://xarray.pydata.org/en/stable/) qui s'en occupe mais [netCDF4](https://github.com/Unidata/netcdf4-python). Cela explique la syntaxe décrite par [Serialization and IO](http://xarray.pydata.org/en/stable/io.html#serialization-and-io) :"
]
},
{
Expand Down Expand Up @@ -1440,7 +1440,7 @@
" ds.to_netcdf('mortalite.nc')\n",
"except ValueError as e:\n",
" # it breaks with pandas 0.17\n",
" # xray has to be updated\n",
" # xarray has to be updated\n",
" print(\"l'écriture a échoué\")\n",
" pass"
]
Expand Down Expand Up @@ -1481,15 +1481,15 @@
"outputs": [],
"source": [
"if os.path.exists(\"mortalite.nc\"):\n",
" ds_lu = xray.open_dataset('mortalite.nc')\n",
" ds_lu = xarray.open_dataset('mortalite.nc')\n",
" ds_lu"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Le module [xray](http://xray.readthedocs.org/) propose également de lire des données de plusieurs fichiers pour ne former qu'un seul dataset (voir [Combining multiple files](http://xray.readthedocs.org/en/stable/io.html#combining-multiple-files)) :"
"Le module [xarray](http://xarray.pydata.org/en/stable/) propose également de lire des données de plusieurs fichiers pour ne former qu'un seul dataset (voir [Combining multiple files](http://xarray.pydata.org/en/stable/io.html#combining-multiple-files)) :"
]
},
{
Expand Down Expand Up @@ -1566,7 +1566,7 @@
"source": [
"import os\n",
"if os.path.exists(\"mortalite_pays_AM.nc\"):\n",
" ds_lu2 = xray.open_mfdataset('mortalite_pays*.nc')\n",
" ds_lu2 = xarray.open_mfdataset('mortalite_pays*.nc')\n",
" ds_lu2"
]
},
Expand All @@ -1576,7 +1576,7 @@
"source": [
"A quoi ça sert ?\n",
"\n",
"Lorsqu'on travaille avec des gros fichiers de données, on cherche à retarder le plus possible l'exécution d'un calcul, on manipule les données sans les charger en mémoire. On appelle ceci [évaluation paresseuse](https://fr.wikipedia.org/wiki/%C3%89valuation_paresseuse) ou [lazy evaluation](https://en.wikipedia.org/wiki/Lazy_evaluation) en anglais. [xray](http://xray.readthedocs.org/en/stable/) et [dask](http://dask.pydata.org/en/latest/) permettent de faire cela (voir [Using dask with xray](http://xray.readthedocs.org/en/stable/dask.html#dask-io)). La logique qu'on suit est alors assez proche de la [programmation fonctionnelle](https://fr.wikipedia.org/wiki/Programmation_fonctionnelle)."
"Lorsqu'on travaille avec des gros fichiers de données, on cherche à retarder le plus possible l'exécution d'un calcul, on manipule les données sans les charger en mémoire. On appelle ceci [évaluation paresseuse](https://fr.wikipedia.org/wiki/%C3%89valuation_paresseuse) ou [lazy evaluation](https://en.wikipedia.org/wiki/Lazy_evaluation) en anglais. [xarray](http://xarray.pydata.org/en/stable/) et [dask](http://dask.pydata.org/en/latest/) permettent de faire cela (voir [Using dask with xarray](http://xarray.pydata.org/en/stable/dask.html#dask-io)). La logique qu'on suit est alors assez proche de la [programmation fonctionnelle](https://fr.wikipedia.org/wiki/Programmation_fonctionnelle)."
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion _doc/sphinxdoc/source/seances_base.rst
Expand Up @@ -59,7 +59,8 @@ Bibliographie
**articles, blogs**


* `Xray + Dask: Out-of-Core, Labeled Arrays in Python <http://continuum.io/blog/xray-dask>`_
* `Xray + Dask: Out-of-Core, Labeled Arrays in Python <http://continuum.io/blog/xray-dask>`_
(now `array <http://xarray.pydata.org/en/stable/>`_)
* `A thorough guide to SQLite database operations in Python <http://sebastianraschka.com/Articles/2014_sqlite_in_python_tutorial.html>`_

Examens
Expand Down

0 comments on commit 35ae668

Please sign in to comment.