{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Quantitative Precipitation Forecast (QPF)\nThis example demonstrates how to perform QPF using radar data\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import xarray as xr\nimport swirlspy.qpf.qpfrover as rov\nimport numpy as np\nimport os\nfrom swirlspy.rad.cinrad import read_cinrad\nfrom swirlspy.rad.xrnd import xrnd\n\nimport os.path\n\ntry:\n THIS_DIR = os.path.dirname(os.path.abspath(__file__))\nexcept NameError:\n import sys\n THIS_DIR = os.path.dirname(os.path.abspath(sys.argv[0]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Initialising\n\nRead data from files (in this example, the files are\nin cinrad format) and storing data as xarrays.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "file_type = 'cinrad-cband'\nvalid_time = '201805150624'\nxllcenter = 113.35\nyllcenter = 23.0\nsteps = 6\ntime_step_size = 5\n# radar_radius = 256\n\nos.chdir(THIS_DIR + \"/../tests/test_qpf\")\nfile_name1 = \"Z_RADR_I_Z9290_20180515062400_O_DOR_CB_CAP.bin\"\nfile_name2 = \"Z_RADR_I_Z9290_20180515062900_O_DOR_CB_CAP.bin\"\n\n# Reading file data, storing as xarray\nxarray1 = read_cinrad(file_name1, 113.35, 23.0,\n 480, 480, '201805150624', 5, 'aeqd', 256, 'c-band')\nxarray2 = read_cinrad(file_name2, 113.35, 23.0,\n 480, 480, '201805150629', 5, 'aeqd', 256, 'c-band')\nqpf_xarray = xrnd(xarray1, xarray2)\nos.chdir(THIS_DIR)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Extrapolation\nPerform rover extrapolation\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Calling rover\nmotion_u, motion_v, reflectivity = rov.rover_qpf(qpf_xarray, xllcenter,\n yllcenter, valid_time, steps,\n time_step_size, THIS_DIR)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generating radar plots\n\nHere we generate radar colour-images based on forecasted\ndata over the next six timesteps.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "rov.rover_map(reflectivity, THIS_DIR)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.6.15" } }, "nbformat": 4, "nbformat_minor": 0 }