Created
January 15, 2020 20:47
-
-
Save swnesbitt/68d6b558ead2949bc4f8aed77cd2d6e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Adapted from SatPy Examples [https://github.com/pytroll/pytroll-examples/blob/master/satpy/GOES-16%20ABI%20-%20True%20Color%20Animation%20-%20Hurricane%20Florence.ipynb]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import os\n", | |
"from satpy import Scene\n", | |
"from glob import glob\n", | |
"os.environ['PYTROLL_CHUNK_SIZE']='2048'\n", | |
"from satpy.multiscene import MultiScene" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<table style=\"border: 2px solid white;\">\n", | |
"<tr>\n", | |
"<td style=\"vertical-align: top; border: 0px solid white\">\n", | |
"<h3>Client</h3>\n", | |
"<ul>\n", | |
" <li><b>Scheduler: </b>tcp://127.0.0.1:42338\n", | |
" <li><b>Dashboard: </b><a href='http://127.0.0.1:8787/status' target='_blank'>http://127.0.0.1:8787/status</a>\n", | |
"</ul>\n", | |
"</td>\n", | |
"<td style=\"vertical-align: top; border: 0px solid white\">\n", | |
"<h3>Cluster</h3>\n", | |
"<ul>\n", | |
" <li><b>Workers: </b>5</li>\n", | |
" <li><b>Cores: </b>20</li>\n", | |
" <li><b>Memory: </b>270.75 GB</li>\n", | |
"</ul>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"<Client: scheduler='tcp://127.0.0.1:42338' processes=5 cores=20>" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"#Only if you want to use Dask\n", | |
"from distributed import Client\n", | |
"client = Client(n_workers=5,threads_per_worker=4)\n", | |
"client" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Number of Scenes: 120\n", | |
"CPU times: user 28.6 s, sys: 1.38 s, total: 30 s\n", | |
"Wall time: 31.6 s\n" | |
] | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"BASE_DIR = '/data/gpm/a/snesbitt/nov10-2'\n", | |
"all_filenames = [glob(fn.replace('C01', 'C0[123]*')[:len(BASE_DIR) + 50] + '*.nc') for fn in sorted(glob(os.path.join(BASE_DIR, 'OR*-RadM2-*C01*.nc')))]\n", | |
"scenes = [Scene(reader='abi_l1b', filenames=filenames) for filenames in all_filenames]\n", | |
"print(\"Number of Scenes: \", len(scenes))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"%%time\n", | |
"mscn = MultiScene(scenes)\n", | |
"mscn.load(['true_color'])\n", | |
"new_mscn = mscn.resample(resampler='native')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#remove client keyword if you don't want to use dask\n", | |
"\n", | |
"#new_mscn.save_animation('/data/accp/a/snesbitt/{name}_{start_time:%Y%m%d_%H%M%S}.mp4', fps=5, client=client)\n", | |
"new_mscn.save_datasets(writer='simple_image',filename='{name}_{start_time:%Y%m%d_%H%M%S}.png',base_dir='/data/accp/a/snesbitt/goes-imgs',client=client) " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Could not import writer config from: ['/data/keeling/a/snesbitt/anaconda3/envs/satpy/lib/python3.7/site-packages/satpy/etc/writers/ninjotiff.yaml']\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"['geotiff', 'mitiff', 'scmi', 'simple_image', 'cf']" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from satpy import available_writers\n", | |
"available_writers()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"client.close()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "satpy", | |
"language": "python", | |
"name": "satpy" | |
}, | |
"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.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment