You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/xarray.rst
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,18 +36,18 @@ Let's assume now we want to take a look at a specific value in the dataset at a
36
36
37
37
OK, we got a value, but how do we know whether this value corresponds to the correct height, latitude and longitude? Are we sure that latitude was the second dimension in the dataset? Was it the second or third index that corresponds to the correct position? In pure NumPy, we are mostly left in the dark and need to manually keep track of these things.
38
38
39
-
Unfortunately, Pandas isn't of much help either since it is not designed for data with more than 2 dimensions. Fortunately, some clever climate scientists have come up with a solution to this problem and created Xarray.
39
+
Unfortunately, Pandas isn't of much help either since it is not designed for data with more than 2 dimensions. Fortunately, `some clever climate scientists<https://github.com/pydata/xarray/graphs/contributors>`_ have come up with a solution to this problem and created Xarray.
40
40
41
41
What is Xarray?
42
42
----------------
43
43
44
44
Xarray is a powerful Python library that introduces labelled multidimensional arrays.
45
-
We will first download an 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.
45
+
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.
46
46
47
47
Let us open a python shell and download a public dataset: ::
We can now import xarray and open the dataset. Le'ts take a look at what it contains: ::
53
53
@@ -85,10 +85,10 @@ We can now import xarray and open the dataset. Le'ts take a look at what it cont
85
85
86
86
That was a lot of information at once, but let's break it down.
87
87
88
-
- Close to the top of the output we see the dimensions of the dataset: time1, isobaric1, y, and x.
89
-
- Below the dimensions, we see the coordinates of the dataset. These are the labels for the dimensions and give us the values of the dimension at each index.
90
-
- The data variables are the actual data stored in the dataset.
91
-
- At the bottom, we see the attributes of the dataset. This is a dictionary that stores metadata about the dataset.
88
+
- Close to the top of the output we see the ``Dimensions`` of the dataset: ``time1``, ``isobaric1``, ``y``, and ``x``.
89
+
- Below the dimensions, we see the ``Coordinates`` of the dataset. These are the labels for the dimensions and give us the values of the dimension at each index.
90
+
- The ``Data variables`` are the actual data stored in the dataset.
91
+
- At the bottom, we see the ``Attributes`` of the dataset. This is a dictionary that stores metadata about the dataset.
92
92
93
93
94
94
The following image shows the structure of this particular Xarray Dataset:
@@ -105,7 +105,7 @@ We can select a Data variable from the dataset using a dictionary-like syntax: :
105
105
106
106
The new variable ``temperature_data`` is a ``DataArray`` object. An xarray ``Dataset`` typically consists of multiple ``DataArrays``.
107
107
108
-
Xarray uses Numpy arrays under the hood, we can always access the raw data using the ``.values`` attribute: ::
108
+
Xarray uses Numpy(-like) arrays under the hood, we can always access the raw data using the ``.values`` attribute: ::
0 commit comments