{ "cells": [ { "cell_type": "markdown", "id": "02a608e9-0fb1-4532-980e-ce860b421d58", "metadata": {}, "source": [ "# Additional information with the `info` module\n", "The `info` allows for the computation of individual attributes." ] }, { "cell_type": "code", "execution_count": null, "id": "eb505975-abb8-48dd-ac4b-4307f6f7a050", "metadata": {}, "outputs": [], "source": [ "import seaborn as sns\n", "\n", "import huracanpy\n", "\n", "# Load tracks\n", "filename = huracanpy.example_year_file\n", "data = huracanpy.load(filename)\n", "\n", "list(data.keys()) # Available attributes" ] }, { "cell_type": "markdown", "id": "64456089-dc90-4551-8b2b-dadcf6745424", "metadata": {}, "source": [ "## Geographical attributes" ] }, { "cell_type": "code", "execution_count": null, "id": "0877b6dd-065d-4a9a-8c98-e3b38e3ac03d", "metadata": {}, "outputs": [], "source": [ "# hemisphere, can also be obtained with huracanpy.info.hemisphere\n", "data = data.hrcn.add_hemisphere()\n", "huracanpy.plot.tracks(\n", " data.lon, data.lat, intensity_var=data.hemisphere, scatter_kws=dict(s=10)\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "f9212e59-973e-4cb6-b890-8fcb36e25be4", "metadata": {}, "outputs": [], "source": [ "# basin, can also be obtained with huracanpy.info.basin (NB: Several convention available)\n", "data = data.hrcn.add_basin()\n", "huracanpy.plot.tracks(\n", " data.lon, data.lat, intensity_var=data.basin, scatter_kws=dict(s=10)\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "6a34f956-d4ff-4cfa-9091-7f4f31ef96b2", "metadata": {}, "outputs": [], "source": [ "# is_ocean, can also be obtained with huracanpy.info.is_ocean\n", "data = data.hrcn.add_is_ocean()\n", "huracanpy.plot.tracks(\n", " data.lon, data.lat, intensity_var=data.is_ocean, scatter_kws=dict(s=10)\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "e75bd875-f7d5-43a9-8b61-54791f986db6", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "# country, can also be obtained with huracanpy.info.country\n", "data = data.hrcn.add_country()\n", "data_ = data.isel(record=slice(0, 60))\n", "huracanpy.plot.tracks(\n", " data_.lon, data_.lat, intensity_var=data_.country, scatter_kws=dict(s=10)\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "c309d5ab-6054-436f-a0be-03ea8fbd353d", "metadata": {}, "outputs": [], "source": [ "# continent, can also be obtained with huracanpy.info.continent\n", "data = data.hrcn.add_continent()\n", "huracanpy.plot.tracks(\n", " data.lon, data.lat, intensity_var=data.continent, scatter_kws=dict(s=10)\n", ")" ] }, { "cell_type": "markdown", "id": "aca8f284-d15e-4f11-a0d2-323029d705e9", "metadata": {}, "source": [ "# Time attributes" ] }, { "cell_type": "code", "execution_count": null, "id": "d643aa60-3d1f-40f6-8ed5-7c000763762d", "metadata": {}, "outputs": [], "source": [ "# Season. Can also be obtained with huracanpy.info.season\n", "data = data.hrcn.add_season()\n", "data = data.hrcn.add_hemisphere()\n", "sns.scatterplot(data=data, x=\"time\", y=\"hemisphere\", hue=\"season\")" ] }, { "cell_type": "markdown", "id": "e2753aa6-1e8a-478f-bef5-08701ec29ad0", "metadata": {}, "source": [ "# Categories\n", "\n", "Categories are specific to tropical cyclones and can be found in the `huracanpy.tc` module\n", "A more generic function is available in `huracanpy.info.get_category`" ] }, { "cell_type": "code", "execution_count": null, "id": "b723da8f-0fcd-4cd9-8243-b7d7caaaeea4", "metadata": {}, "outputs": [], "source": [ "# sshs\n", "sshs = huracanpy.tc.saffir_simpson_category(data.wind10)\n", "huracanpy.plot.tracks(\n", " data.lon,\n", " data.lat,\n", " intensity_var=sshs,\n", " scatter_kws=dict(s=5, palette=\"Spectral\"),\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "98501092-fc50-4b9f-97c7-643aa79e6b20", "metadata": {}, "outputs": [], "source": [ "# pressure category\n", "pres_cat = huracanpy.tc.pressure_category(data.slp)\n", "huracanpy.plot.tracks(\n", " data.lon,\n", " data.lat,\n", " intensity_var=pres_cat,\n", " scatter_kws=dict(s=5, palette=\"Spectral\"),\n", ")" ] } ], "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 }