{ "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": [ "# Embedded IBTrACS Subsets\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", "Two offline 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": "a96453f3-9ea4-493f-b421-215d8f0bb201", "metadata": {}, "source": [ "Both subsets currently cover the 1980-2022. The WMO subset contains more tracks, because\n", "the JTWC columns does not always contain data for all tracks" ] }, { "cell_type": "code", "execution_count": null, "id": "b9bb2fb8-cfce-4dd9-b1b0-2edfdcabf3ce", "metadata": {}, "outputs": [], "source": [ "print(\"WMO\")\n", "print(ib_wmo.time.values.min(), ib_wmo.time.values.max())\n", "print(ib_wmo.track_id.hrcn.nunique(), \"tracks\", len(ib_wmo.record), \"points\\n\")\n", "\n", "print(\"JTWC\")\n", "print(ib_usa.time.values.min(), ib_usa.time.values.max())\n", "print(ib_usa.track_id.hrcn.nunique(), \"tracks\", len(ib_usa.record), \"points\")" ] }, { "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.12.4" } }, "nbformat": 4, "nbformat_minor": 5 }