Xray + Dask: Out-of-Core, Labeled Arrays in Python

From https://www.continuum.io/content/xray-dask-out-core-labeled-arrays-python


In [47]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
import pandas as pd
import seaborn as sns # pandas aware plotting library
 
ds = xr.open_mfdataset('C:\\Users\\Norman\\EOData\\Ozone-CCI\\*.nc', concat_dim='time')

In [40]:
u = ds.mean(['latitude', 'longitude'])
ozone = u['atmosphere_mole_content_of_ozone']
error = u['atmosphere_mole_content_of_ozone_standard_error']

In [41]:
ozone.plot()


Out[41]:
[<matplotlib.lines.Line2D at 0x2569ae09fd0>]

In [42]:
error.plot()


Out[42]:
[<matplotlib.lines.Line2D at 0x2569adf5a90>]

In [60]:
sns.pairplot(u.to_dataframe().reset_index(), vars=('atmosphere_mole_content_of_ozone', 'atmosphere_mole_content_of_ozone_standard_error'))


Out[60]:
<seaborn.axisgrid.PairGrid at 0x256a4459c88>

In [46]:
ozone.to_pandas().corr(error.to_pandas())


Out[46]:
0.48088987063648286

In [63]:
error.to_series()


Out[63]:
time
0    -0.813978
1    -0.076256
2     0.034037
3    -0.222029
4    -0.515819
5    -0.791572
6    -0.915771
7    -0.614480
8    -0.064331
9     0.230168
10    0.382513
11   -0.609076
12   -0.793726
13    0.079238
14    0.126370
15   -0.119606
16   -0.573135
17   -0.732674
18   -0.890230
19   -0.584892
20   -0.264095
21    0.081200
22   -0.105007
23   -0.111974
24   -0.830809
25    0.005321
26    0.096775
27    0.154626
28   -0.496374
29   -0.876270
Name: atmosphere_mole_content_of_ozone_standard_error, dtype: float64

In [50]:
ds.to_dataframe()


Out[50]:
atmosphere_mole_content_of_ozone_number_of_observations atmosphere_mole_content_of_ozone_standard_deviation atmosphere_mole_content_of_ozone_standard_error atmosphere_mole_content_of_ozone
latitude longitude time
-89.5 0.5 0 807.0 5.43322 1.544573 278.04576
1 568.0 7.23138 2.061854 260.15539
2 -9.9 -9.90000 -9.900000 -9.90000
3 -9.9 -9.90000 -9.900000 -9.90000
4 -9.9 -9.90000 -9.900000 -9.90000
5 -9.9 -9.90000 -9.900000 -9.90000
6 -9.9 -9.90000 -9.900000 -9.90000
7 -9.9 -9.90000 -9.900000 -9.90000
8 -9.9 -9.90000 -9.900000 -9.90000
9 -9.9 -9.90000 -9.900000 -9.90000
10 814.0 47.83293 13.597272 204.83961
11 870.0 20.17617 5.732814 285.22081
12 860.0 7.53958 2.142444 280.85473
13 574.0 6.81371 1.942563 259.76818
14 -9.9 -9.90000 -9.900000 -9.90000
15 -9.9 -9.90000 -9.900000 -9.90000
16 -9.9 -9.90000 -9.900000 -9.90000
17 -9.9 -9.90000 -9.900000 -9.90000
18 -9.9 -9.90000 -9.900000 -9.90000
19 -9.9 -9.90000 -9.900000 -9.90000
20 -9.9 -9.90000 -9.900000 -9.90000
21 -9.9 -9.90000 -9.900000 -9.90000
22 768.0 11.75056 3.341683 168.15475
23 805.0 49.30903 14.017974 241.89029
24 868.0 9.91608 2.817577 266.91766
25 729.0 8.06666 2.294946 247.68081
26 -9.9 -9.90000 -9.900000 -9.90000
27 -9.9 -9.90000 -9.900000 -9.90000
28 -9.9 -9.90000 -9.900000 -9.90000
29 -9.9 -9.90000 -9.900000 -9.90000
... ... ... ... ... ... ...
89.5 359.5 0 -9.9 -9.90000 -9.900000 -9.90000
1 -9.9 -9.90000 -9.900000 -9.90000
2 -9.9 -9.90000 -9.900000 -9.90000
3 610.0 16.14759 3.311279 429.99610
4 658.0 22.12441 4.530712 397.26639
5 608.0 18.79907 3.855238 334.70840
6 602.0 14.68393 3.011885 291.48224
7 633.0 13.18551 2.702027 284.19670
8 -9.9 -9.90000 -9.900000 -9.90000
9 -9.9 -9.90000 -9.900000 -9.90000
10 -9.9 -9.90000 -9.900000 -9.90000
11 -9.9 -9.90000 -9.900000 -9.90000
12 -9.9 -9.90000 -9.900000 -9.90000
13 -9.9 -9.90000 -9.900000 -9.90000
14 -9.9 -9.90000 -9.900000 -9.90000
15 614.0 18.58430 3.810495 449.62803
16 650.0 21.30227 4.363285 419.05275
17 609.0 25.74521 5.279562 357.49545
18 598.0 13.49845 2.769076 337.08187
19 613.0 16.95427 3.476382 302.12367
20 -9.9 -9.90000 -9.900000 -9.90000
21 -9.9 -9.90000 -9.900000 -9.90000
22 -9.9 -9.90000 -9.900000 -9.90000
23 -9.9 -9.90000 -9.900000 -9.90000
24 -9.9 -9.90000 -9.900000 -9.90000
25 -9.9 -9.90000 -9.900000 -9.90000
26 -9.9 -9.90000 -9.900000 -9.90000
27 595.0 58.63596 12.029756 402.79381
28 568.0 29.54374 6.066712 374.02702
29 611.0 18.26396 3.745155 340.63038

1944000 rows × 4 columns


In [ ]: