{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "445b60dd-9f3c-4655-85f2-bcd0285c10c5", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "import huracanpy" ] }, { "cell_type": "markdown", "id": "58add8dc-7537-4512-b192-6594ba527eaf", "metadata": {}, "source": [ "## Loading IBTrACS\n", "IBTrACS can be loaded in two ways using HuracanPy's `load` function:\n", "* Online: You can load the latest version of any IBTrACS subset using the load function, provided you are connected to internet\n", "* Offline: Your installation of huracanpy embeds parts of the IBTrACS database which can be loaded even if you are not connected to internet.\n", "\n", "\n", "### Online\n", "With the arguments `source=\"ibtracs\"`, `ibtracs_online=True`, `load` will retrieve IBTrACS from the NCEI-NOAA (https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r00/access/csv/). \n", "Use the `ibtracs_subset` argument to specify the subset you want to download. See the webpage mentionned above for the list of existing subset. The following cells are not being run as it requires downloading the IBTrACS data" ] }, { "cell_type": "code", "execution_count": null, "id": "1a82335a-1b20-4f15-80b7-b35b88606225", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "# Example of 'last3years' subset\n", "# ib = huracanpy.load(source=\"ibtracs\", ibtracs_online=True, ibtracs_subset=\"last3years\")\n", "# huracanpy.plot.tracks(ib.lon, ib.lat, intensity_var=ib.wmo_wind)" ] }, { "cell_type": "code", "execution_count": null, "id": "ed26ac4d-bf5c-43d2-bc81-21dbb313699e", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "# Example of 'SI' subset\n", "# ib = huracanpy.load(source=\"ibtracs\", ibtracs_online=True, ibtracs_subset=\"SI\")\n", "# huracanpy.plot.tracks(ib.lon, ib.lat, intensity_var=ib.wmo_wind)" ] }, { "cell_type": "markdown", "id": "9b604429-4a29-462a-b86f-06cbd4b122df", "metadata": {}, "source": [ "### Offline\n", "Two subsets are currently available:\n", "* \"wmo\" contains the data provided in the \"wmo\" columns, which correspond to the data provided by the center\n", " responsible for the area of a given point. (see https://community.wmo.int/en/tropical-cyclone-regional-bodies)\n", " Note that within this dataset, wind units are not homogeneous: they are provided as collected from the\n", " meteorological agencies, which means that they have different time-averaging for wind extrema. (default)\n", "* \"usa\" contains the data provided in the \"wmo\" columns, which is provided by the NHC or the JTWC.\n", "\n", "Loading these will raise a warning to remind you that these datasets are offline versions with caveats and some post-treatment." ] }, { "cell_type": "code", "execution_count": null, "id": "219b4b1f-7224-4e22-bee0-0d0a04ac91f9", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "# WMO subset\n", "ib_wmo = huracanpy.load(source=\"ibtracs\", ibtracs_online=False, ibtracs_subset=\"wmo\")\n", "huracanpy.plot.tracks(ib_wmo.lon, ib_wmo.lat, intensity_var=ib_wmo.wind)" ] }, { "cell_type": "code", "execution_count": null, "id": "b449b6e9-8c66-4cf1-b3dd-0d7cfd55d169", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [ "nbsphinx-thumbnail" ] }, "outputs": [], "source": [ "# USA subset\n", "ib_usa = huracanpy.load(source=\"ibtracs\", ibtracs_online=False, ibtracs_subset=\"usa\")\n", "huracanpy.plot.tracks(ib_usa.lon, ib_usa.lat, intensity_var=ib_usa.wind)" ] }, { "cell_type": "markdown", "id": "5fd7eabc-df10-4e57-89fd-6e33f8f8a997", "metadata": {}, "source": [ "One of the main differences among these two subsets is the way winds are reported: In WMO, the maximum winds as reported by the WMO agencies are provided. This is inhomogeneous: the USA report 1-minute sustained winds, CMA reports 3-minutes sustained winds, and most other centers report 10-minutes sustained winds. " ] }, { "cell_type": "code", "execution_count": null, "id": "751d56de-1f2c-46ec-bdf9-451d8c0e7154", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "# Add basin data to ib_wmo\n", "ib_wmo = ib_wmo.hrcn.add_basin()\n", "# Match tracks between ib_wmo and ib_usa, then retrieve LMI\n", "m = huracanpy.assess.match([ib_wmo, ib_usa], names=[\"wmo\", \"usa\"])\n", "max_winds = m.join(\n", " ib_wmo[[\"wind\"]].groupby(ib_wmo.track_id).max().to_dataframe(), on=\"id_wmo\"\n", ").join(\n", " ib_usa[[\"wind\"]].groupby(ib_usa.track_id).max().to_dataframe(),\n", " on=\"id_usa\",\n", " lsuffix=\"_wmo\",\n", " rsuffix=\"_usa\",\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "bb31f486-51a4-4c49-b1ad-d67569ec9a6a", "metadata": {}, "outputs": [], "source": [ "# Add basin with separate groupby\n", "max_winds = max_winds.join(\n", " ib_wmo[[\"basin\"]].groupby(ib_wmo.track_id).first().to_dataframe(), on=\"id_wmo\"\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "8cebc0c0-e0b8-4aab-8059-74c0bb57e3a9", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "# Plot difference between WMO and USA winds in each basin\n", "import seaborn as sns\n", "\n", "p = sns.displot(\n", " data=max_winds,\n", " x=\"wind_wmo\",\n", " y=\"wind_usa\",\n", " col=\"basin\",\n", " col_wrap=3,\n", ")\n", "for ax in p.axes.flatten():\n", " ax.plot([0, 175], [0, 175], color=\"k\", linestyle=\"--\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.7" } }, "nbformat": 4, "nbformat_minor": 5 }