Skip to content

Instantly share code, notes, and snippets.

@jbusecke
Created March 10, 2021 15:44
Show Gist options
  • Save jbusecke/04f9c0aa4e3888ec0574a2b9bef1e131 to your computer and use it in GitHub Desktop.
Save jbusecke/04f9c0aa4e3888ec0574a2b9bef1e131 to your computer and use it in GitHub Desktop.
Testing tomchors PR for xmovie
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "scenic-segment",
"metadata": {},
"source": [
"# Testing Toms PR with the weird case..."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "clear-broad",
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"from xmovie import Movie\n",
"from xmovie.presets import rotating_globe_dark\n",
"\n",
"ds = xr.tutorial.open_dataset('air_temperature').isel(time=slice(0,150))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "inappropriate-school",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/juliusbusecke/code/xmovie/xmovie/core.py:51: UserWarning: No `vmin` provided. Data limits are calculated from input. Depending on the input this can take long. Pass `vmin` to avoid this step\n",
" UserWarning,\n",
"/Users/juliusbusecke/code/xmovie/xmovie/core.py:58: UserWarning: No `vmax` provided. Data limits are calculated from input. Depending on the input this can take long. Pass `vmax` to avoid this step\n",
" UserWarning,\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Movie created at movie_rotating.mp4\n",
"GIF created at movie_rotating.gif\n"
]
}
],
"source": [
"from xmovie.presets import rotating_globe\n",
"# specify custom plotfunctions (here a preset from xmovie)\n",
"mov = Movie(ds.air, plotfunc=rotating_globe)\n",
"\n",
"# run one save without timing, because cartopy might cache the coastline data\n",
"mov.save('movie_rotating.gif', progress=False, overwrite_existing=True)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "alike-stylus",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Movie created at movie.mp4\n",
"GIF created at movie.gif\n",
"CPU times: user 39.4 s, sys: 528 ms, total: 40 s\n",
"Wall time: 51.2 s\n"
]
}
],
"source": [
"%%time\n",
"mov.save('movie.gif', progress=False, parallel=False, overwrite_existing=True, )"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "tracked-zoning",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Movie created at movie_parallel.mp4\n",
"GIF created at movie_parallel.gif\n",
"CPU times: user 39.6 s, sys: 478 ms, total: 40.1 s\n",
"Wall time: 51.1 s\n"
]
}
],
"source": [
"%%time\n",
"mov.save('movie_parallel.gif',progress=False, parallel=True, overwrite_existing=True)"
]
},
{
"cell_type": "markdown",
"id": "resistant-microwave",
"metadata": {},
"source": [
"This does not seem to speed things up?\n",
"\n",
"Can we improve with a Local Cluster?"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "liquid-charlotte",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/juliusbusecke/miniconda/envs/test_env_xmovie/lib/python3.7/site-packages/distributed/node.py:155: UserWarning: Port 8787 is already in use.\n",
"Perhaps you already have a cluster running?\n",
"Hosting the HTTP server on port 53522 instead\n",
" http_address[\"port\"], self.http_server.port\n"
]
}
],
"source": [
"from dask.distributed import Client, LocalCluster\n",
"cluster = LocalCluster(n_workers=4)\n",
"# explicitly connect to the cluster we just created\n",
"client = Client(cluster)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "sitting-municipality",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"distributed.utils_perf - WARNING - full garbage collections took 11% CPU time recently (threshold: 10%)\n",
"distributed.utils_perf - WARNING - full garbage collections took 11% CPU time recently (threshold: 10%)\n",
"distributed.utils_perf - WARNING - full garbage collections took 11% CPU time recently (threshold: 10%)\n",
"distributed.utils_perf - WARNING - full garbage collections took 11% CPU time recently (threshold: 10%)\n",
"distributed.utils_perf - WARNING - full garbage collections took 11% CPU time recently (threshold: 10%)\n",
"distributed.utils_perf - WARNING - full garbage collections took 11% CPU time recently (threshold: 10%)\n",
"distributed.utils_perf - WARNING - full garbage collections took 11% CPU time recently (threshold: 10%)\n",
"distributed.utils_perf - WARNING - full garbage collections took 11% CPU time recently (threshold: 10%)\n"
]
}
],
"source": [
"%%time\n",
"mov.save('movie_parallel.gif',progress=False, parallel=True, overwrite_existing=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "insured-joshua",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:test_env_xmovie]",
"language": "python",
"name": "conda-env-test_env_xmovie-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment