|
5 | 5 | "id": "978b8621-e050-47c3-8e66-807cbac823e6",
|
6 | 6 | "metadata": {},
|
7 | 7 | "source": [
|
8 |
| - "# `huracanpy` basic use for assessing storm climatology in a dataset\n", |
| 8 | + "# Assessing storm climatology in a dataset\n", |
9 | 9 | "Here, we examplify usage of `huracanpy` with the dataset of TC in ERA-20C detected by the TRACK algorithm.\n",
|
10 | 10 | "This is meant to show an example of workflow. Please refer to specific parts of the documentation to learn about each part (e.g. loading, plotting, etc.) in more detail."
|
11 | 11 | ]
|
|
87 | 87 | "outputs": [],
|
88 | 88 | "source": [
|
89 | 89 | "# Apply add_all_info to add a number of useful attributes.\n",
|
90 |
| - "data = huracanpy.utils.add_all_info(\n", |
| 90 | + "data = huracanpy.info.add_all_info(\n", |
91 | 91 | " data,\n",
|
92 | 92 | " lat_name=\"latitude\",\n",
|
93 | 93 | " lon_name=\"longitude\",\n",
|
94 |
| - " wind_name=\"wind_speed_10m\",\n", |
95 |
| - " slp_name=\"psl\",\n", |
96 |
| - " slp_units=\"hPa\",\n", |
97 | 94 | ")\n",
|
98 |
| - "# If you want to add individually the one you need instead, have a look at the functionning of the utils module itself." |
| 95 | + "# If you want to add individually the one you need instead, have a look at the functionning of the info module itself.\n", |
| 96 | + "\n", |
| 97 | + "# TC specific\n", |
| 98 | + "data[\"sshs\"] = huracanpy.tc.get_sshs_cat(data.wind_speed_10m)\n", |
| 99 | + "data[\"pres_cat\"] = huracanpy.tc.get_sshs_cat(data.psl)" |
99 | 100 | ]
|
100 | 101 | },
|
101 | 102 | {
|
|
172 | 173 | ],
|
173 | 174 | "source": [
|
174 | 175 | "# Basic plot of the data points\n",
|
175 |
| - "huracanpy.plot.tracks.plot_tracks_basic(\n", |
| 176 | + "huracanpy.plot.tracks(\n", |
176 | 177 | " data.longitude,\n",
|
177 | 178 | " data.latitude,\n",
|
178 | 179 | " data.wind_speed_10m,\n",
|
|
575 | 576 | ],
|
576 | 577 | "source": [
|
577 | 578 | "# Frequency (Number of track per year)\n",
|
578 |
| - "huracanpy.diags.climato.freq(data, by=\"season\")" |
| 579 | + "huracanpy.calc.freq(data, by=\"season\")" |
579 | 580 | ]
|
580 | 581 | },
|
581 | 582 | {
|
|
965 | 966 | ],
|
966 | 967 | "source": [
|
967 | 968 | "# TCD (Accumulated duration of storms per year)\n",
|
968 |
| - "huracanpy.diags.climato.TC_days(data, by=\"season\")" |
| 969 | + "huracanpy.calc.get_track_duration(data.time, data.track_ids).groupby(data.season).sum()" |
969 | 970 | ]
|
970 | 971 | },
|
971 | 972 | {
|
|
1355 | 1356 | ],
|
1356 | 1357 | "source": [
|
1357 | 1358 | "# ACE (aggregated per year)\n",
|
1358 |
| - "huracanpy.utils.ace.ace_by_point(\n", |
1359 |
| - " data.wind_speed_10m, threshold=0, wind_units=\"m s**-1\"\n", |
1360 |
| - ").groupby(data.season).sum().mean()" |
| 1359 | + "huracanpy.tc.ace(\n", |
| 1360 | + " data.wind_speed_10m,\n", |
| 1361 | + " sum_by=data.time.dt.year,\n", |
| 1362 | + " threshold=0,\n", |
| 1363 | + ").mean()" |
1361 | 1364 | ]
|
1362 | 1365 | },
|
1363 | 1366 | {
|
|
1391 | 1394 | "\n",
|
1392 | 1395 | "fig, axs = plt.subplots(3, sharex=True)\n",
|
1393 | 1396 | "# Frequency\n",
|
1394 |
| - "data.groupby(\"season\").apply(huracanpy.diags.climato.freq).plot(ax=axs[0])\n", |
| 1397 | + "data.groupby(\"season\").apply(huracanpy.calc.freq).plot(ax=axs[0])\n", |
1395 | 1398 | "axs[0].set_ylabel(\"Number of tracks\")\n",
|
1396 | 1399 | "# TCD\n",
|
1397 |
| - "data.groupby(\"season\").apply(huracanpy.diags.climato.TC_days).plot(ax=axs[1])\n", |
| 1400 | + "data.groupby(\"season\").apply(huracanpy.calc.duration).plot(ax=axs[1])\n", |
1398 | 1401 | "axs[1].set_ylabel(\"TC days\")\n",
|
1399 | 1402 | "# ACE\n",
|
1400 |
| - "data.groupby(\"season\").apply(\n", |
1401 |
| - " lambda x: huracanpy.diags.climato.ACE(x, wind_name=\"wind_speed_10m\")\n", |
1402 |
| - ").plot(ax=axs[2])\n", |
| 1403 | + "data.groupby(\"season\").apply(lambda x: huracanpy.tc.ace(x.wind_speed_10m).sum()).plot(\n", |
| 1404 | + " ax=axs[2]\n", |
| 1405 | + ")\n", |
1403 | 1406 | "axs[2].set_ylabel(\"ACE\")\n",
|
1404 | 1407 | "\n",
|
1405 | 1408 | "for ax in axs:\n",
|
|
1437 | 1440 | "source": [
|
1438 | 1441 | "## Seasonal\n",
|
1439 | 1442 | "\n",
|
1440 |
| - "gen = huracanpy.diags.track_stats.gen_vals(\n", |
| 1443 | + "gen = huracanpy.calc.gen_vals(\n", |
1441 | 1444 | " data,\n",
|
1442 | 1445 | ") # Extract the point of genesis for each track\n",
|
1443 | 1446 | "(\n",
|
|
1491 | 1494 | "fig, axs = plt.subplots(1, 3, sharey=True, figsize=[15, 5])\n",
|
1492 | 1495 | "\n",
|
1493 | 1496 | "# Duration\n",
|
1494 |
| - "huracanpy.diags.track_stats.duration(data.time, data.track_id).plot.hist(ax=axs[0])\n", |
| 1497 | + "huracanpy.calc.get_duration(data.time, data.track_id).plot.hist(ax=axs[0])\n", |
1495 | 1498 | "\n",
|
1496 | 1499 | "# Maximum wind speed\n",
|
1497 |
| - "huracanpy.diags.track_stats.extremum_vals(\n", |
| 1500 | + "huracanpy.calc.get_extremum_vals(\n", |
1498 | 1501 | " data, varname=\"wind_speed_10m\", stat=\"max\"\n",
|
1499 | 1502 | ").wind_speed_10m.plot.hist(ax=axs[1])\n",
|
1500 | 1503 | "\n",
|
|
1945 | 1948 | ],
|
1946 | 1949 | "metadata": {
|
1947 | 1950 | "kernelspec": {
|
1948 |
| - "display_name": "Python 3 (Spyder)", |
1949 |
| - "language": "python3", |
| 1951 | + "display_name": "Python 3 (ipykernel)", |
| 1952 | + "language": "python", |
1950 | 1953 | "name": "python3"
|
1951 | 1954 | },
|
1952 | 1955 | "language_info": {
|
|
1959 | 1962 | "name": "python",
|
1960 | 1963 | "nbconvert_exporter": "python",
|
1961 | 1964 | "pygments_lexer": "ipython3",
|
1962 |
| - "version": "3.11.9" |
| 1965 | + "version": "3.12.4" |
1963 | 1966 | }
|
1964 | 1967 | },
|
1965 | 1968 | "nbformat": 4,
|
|
0 commit comments