Animations with xmovie
This tutorial demonstrates how to make an animation with Cartopy and xmovie. See https://github.com/jbusecke/xmovie for more details on xmovie package.
Client
Client-2f1b04dc-68cb-11ef-8403-000007dafe80
Connection method: Cluster object
Cluster type: distributed.LocalCluster
Dashboard: /proxy/8787/status
Launch dashboard in JupyterLab
Cluster Info
LocalCluster
1c89d2af
Dashboard: /proxy/8787/status
Workers: 28
Total threads: 28
Total memory: 126.00 GiB
Status: running
Using processes: True
Scheduler Info
Scheduler
Scheduler-d7bc8e05-81c9-4fca-9a18-eb034cbcb2a8
Comm: tcp://127.0.0.1:41139
Workers: 28
Dashboard: /proxy/8787/status
Total threads: 28
Started: Just now
Total memory: 126.00 GiB
Workers
Worker: 0
Comm: tcp://127.0.0.1:44487
Total threads: 1
Dashboard: /proxy/36877/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:38013
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-hxome659
Worker: 1
Comm: tcp://127.0.0.1:43131
Total threads: 1
Dashboard: /proxy/35339/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:37807
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-17hyu7l5
Worker: 2
Comm: tcp://127.0.0.1:44687
Total threads: 1
Dashboard: /proxy/35271/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:43913
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-79huix9l
Worker: 3
Comm: tcp://127.0.0.1:33759
Total threads: 1
Dashboard: /proxy/44399/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:43425
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-jfkdgzf7
Worker: 4
Comm: tcp://127.0.0.1:36003
Total threads: 1
Dashboard: /proxy/36361/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:42815
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-xjzueoik
Worker: 5
Comm: tcp://127.0.0.1:45431
Total threads: 1
Dashboard: /proxy/42957/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:35553
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-7vjes_yg
Worker: 6
Comm: tcp://127.0.0.1:42453
Total threads: 1
Dashboard: /proxy/34661/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:37295
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-tfp9joh1
Worker: 7
Comm: tcp://127.0.0.1:40459
Total threads: 1
Dashboard: /proxy/43767/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:33855
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-z30gyan4
Worker: 8
Comm: tcp://127.0.0.1:34115
Total threads: 1
Dashboard: /proxy/45659/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:35293
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-42e2sh54
Worker: 9
Comm: tcp://127.0.0.1:41705
Total threads: 1
Dashboard: /proxy/41443/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:36521
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-905u_o53
Worker: 10
Comm: tcp://127.0.0.1:38259
Total threads: 1
Dashboard: /proxy/33067/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:44029
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-d8tryfq4
Worker: 11
Comm: tcp://127.0.0.1:36493
Total threads: 1
Dashboard: /proxy/34567/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:39367
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-2s4v9rx_
Worker: 12
Comm: tcp://127.0.0.1:43987
Total threads: 1
Dashboard: /proxy/34459/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:36941
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-xwmcoasx
Worker: 13
Comm: tcp://127.0.0.1:39487
Total threads: 1
Dashboard: /proxy/44063/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:35937
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-ummrm92q
Worker: 14
Comm: tcp://127.0.0.1:44875
Total threads: 1
Dashboard: /proxy/40033/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:42055
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-aspb5s9z
Worker: 15
Comm: tcp://127.0.0.1:39813
Total threads: 1
Dashboard: /proxy/45959/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:37421
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-xo55qcwz
Worker: 16
Comm: tcp://127.0.0.1:46257
Total threads: 1
Dashboard: /proxy/38365/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:45005
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-hefpst0m
Worker: 17
Comm: tcp://127.0.0.1:45923
Total threads: 1
Dashboard: /proxy/35157/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:37637
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-_0xnjp88
Worker: 18
Comm: tcp://127.0.0.1:37619
Total threads: 1
Dashboard: /proxy/42767/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:42487
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-am502_9c
Worker: 19
Comm: tcp://127.0.0.1:41151
Total threads: 1
Dashboard: /proxy/38953/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:43229
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-bg170j06
Worker: 20
Comm: tcp://127.0.0.1:35245
Total threads: 1
Dashboard: /proxy/36229/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:33451
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-tbv5dly_
Worker: 21
Comm: tcp://127.0.0.1:43493
Total threads: 1
Dashboard: /proxy/45437/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:41985
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-q9gse74y
Worker: 22
Comm: tcp://127.0.0.1:43277
Total threads: 1
Dashboard: /proxy/43021/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:41371
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-75ldo2aj
Worker: 23
Comm: tcp://127.0.0.1:36491
Total threads: 1
Dashboard: /proxy/41905/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:37233
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-rswguhse
Worker: 24
Comm: tcp://127.0.0.1:46201
Total threads: 1
Dashboard: /proxy/33139/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:39041
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-64zadbk6
Worker: 25
Comm: tcp://127.0.0.1:42687
Total threads: 1
Dashboard: /proxy/46431/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:35375
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-e5zue84c
Worker: 26
Comm: tcp://127.0.0.1:33899
Total threads: 1
Dashboard: /proxy/34591/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:34525
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-a8y_wk3l
Worker: 27
Comm: tcp://127.0.0.1:45121
Total threads: 1
Dashboard: /proxy/38877/status
Memory: 4.50 GiB
Nanny: tcp://127.0.0.1:38901
Local directory: /jobfs/124011001.gadi-pbs/dask-scratch-space/worker-eg_fjolt
Load the ACCESS-NRI catalog
We use the sea-surface temperature (SST) from a 0.25°-resolution experiment as our sample data. These maps should work with any 2D data.
<xarray.DataArray 'sst' (time: 11, yt_ocean: 1080, xt_ocean: 1440)> Size: 68MB
dask.array<getitem, shape=(11, 1080, 1440), dtype=float32, chunksize=(1, 216, 240), chunktype=numpy.ndarray>
Coordinates:
* xt_ocean (xt_ocean) float64 12kB -279.9 -279.6 -279.4 ... 79.38 79.62 79.88
* yt_ocean (yt_ocean) float64 9kB -81.08 -80.97 -80.87 ... 89.74 89.84 89.95
* time (time) datetime64[ns] 88B 1958-01-14T12:00:00 ... 1958-11-14 Coordinates: (3)
xt_ocean
(xt_ocean)
float64
-279.9 -279.6 ... 79.62 79.88
long_name : tcell longitude units : degrees_E cartesian_axis : X array([-279.875, -279.625, -279.375, ..., 79.375, 79.625, 79.875]) yt_ocean
(yt_ocean)
float64
-81.08 -80.97 ... 89.84 89.95
long_name : tcell latitude units : degrees_N cartesian_axis : Y array([-81.077001, -80.971402, -80.865804, ..., 89.736085, 89.841684,
89.947282]) time
(time)
datetime64[ns]
1958-01-14T12:00:00 ... 1958-11-14
long_name : time cartesian_axis : T calendar_type : GREGORIAN bounds : time_bounds array(['1958-01-14T12:00:00.000000000', '1958-02-13T00:00:00.000000000',
'1958-03-14T12:00:00.000000000', '1958-04-14T00:00:00.000000000',
'1958-05-14T12:00:00.000000000', '1958-06-14T00:00:00.000000000',
'1958-07-14T12:00:00.000000000', '1958-08-14T12:00:00.000000000',
'1958-09-14T00:00:00.000000000', '1958-10-14T12:00:00.000000000',
'1958-11-14T00:00:00.000000000'], dtype='datetime64[ns]') Indexes: (3)
PandasIndex
PandasIndex(Index([-279.875, -279.625, -279.375, -279.125, -278.875, -278.625, -278.375,
-278.125, -277.875, -277.625,
...
77.625, 77.875, 78.125, 78.375, 78.625, 78.875, 79.125,
79.375, 79.625, 79.875],
dtype='float64', name='xt_ocean', length=1440)) PandasIndex
PandasIndex(Index([ -81.0770008338366, -80.9714022446317, -80.8658036554268,
-80.7602050662219, -80.654606477017, -80.5490078878121,
-80.4434092986072, -80.33781070940229, -80.23221212019739,
-80.12661353099249,
...
88.9968950242055, 89.10249361341039, 89.20809220261533,
89.31369079182024, 89.41928938102512, 89.52488797023008,
89.630486559435, 89.73608514863992, 89.84168373784476,
89.94728232704986],
dtype='float64', name='yt_ocean', length=1080)) PandasIndex
PandasIndex(DatetimeIndex(['1958-01-14 12:00:00', '1958-02-13 00:00:00',
'1958-03-14 12:00:00', '1958-04-14 00:00:00',
'1958-05-14 12:00:00', '1958-06-14 00:00:00',
'1958-07-14 12:00:00', '1958-08-14 12:00:00',
'1958-09-14 00:00:00', '1958-10-14 12:00:00',
'1958-11-14 00:00:00'],
dtype='datetime64[ns]', name='time', freq=None)) Attributes: (0)
We load the unmasked coordinates and assign them to the dataset; see the tutorial on maps with Cartopy for more details.
We create a custom function that plots every frame. See https://xmovie.readthedocs.io/en/latest/examples/quickstart.html#Modifying-plots for more details on the argument structure requirements of this plotting function that we will provide to xmovie.Movie
method.
Now we create a figure and the movie using xmovie.Movie
method.
<Figure size 800x600 with 0 Axes>
Let’s preview how one of the frames look; choose here frame 2.
And now make the movie. We can save as .gif
or .mp4
.
Movie created at movie_sst.mp4
GIF created at movie_sst.gif