|
5 | 5 | "id": "978b8621-e050-47c3-8e66-807cbac823e6",
|
6 | 6 | "metadata": {},
|
7 | 7 | "source": [
|
8 |
| - "# Assessing storm climatology in a dataset\n", |
| 8 | + "# `huracanpy` basic use for 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.info.add_all_info(\n", |
| 90 | + "data = huracanpy.utils.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", |
94 | 97 | ")\n",
|
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)" |
| 98 | + "# If you want to add individually the one you need instead, have a look at the functionning of the utils module itself." |
100 | 99 | ]
|
101 | 100 | },
|
102 | 101 | {
|
|
173 | 172 | ],
|
174 | 173 | "source": [
|
175 | 174 | "# Basic plot of the data points\n",
|
176 |
| - "huracanpy.plot.tracks(\n", |
| 175 | + "huracanpy.plot.tracks.plot_tracks_basic(\n", |
177 | 176 | " data.longitude,\n",
|
178 | 177 | " data.latitude,\n",
|
179 | 178 | " data.wind_speed_10m,\n",
|
|
576 | 575 | ],
|
577 | 576 | "source": [
|
578 | 577 | "# Frequency (Number of track per year)\n",
|
579 |
| - "huracanpy.calc.freq(data, by=\"season\")" |
| 578 | + "huracanpy.diags.climato.freq(data, by=\"season\")" |
580 | 579 | ]
|
581 | 580 | },
|
582 | 581 | {
|
|
966 | 965 | ],
|
967 | 966 | "source": [
|
968 | 967 | "# TCD (Accumulated duration of storms per year)\n",
|
969 |
| - "huracanpy.calc.get_track_duration(data.time, data.track_ids).groupby(data.season).sum()" |
| 968 | + "huracanpy.diags.climato.TC_days(data, by=\"season\")" |
970 | 969 | ]
|
971 | 970 | },
|
972 | 971 | {
|
|
1356 | 1355 | ],
|
1357 | 1356 | "source": [
|
1358 | 1357 | "# ACE (aggregated per year)\n",
|
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()" |
| 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()" |
1364 | 1361 | ]
|
1365 | 1362 | },
|
1366 | 1363 | {
|
|
1394 | 1391 | "\n",
|
1395 | 1392 | "fig, axs = plt.subplots(3, sharex=True)\n",
|
1396 | 1393 | "# Frequency\n",
|
1397 |
| - "data.groupby(\"season\").apply(huracanpy.calc.freq).plot(ax=axs[0])\n", |
| 1394 | + "data.groupby(\"season\").apply(huracanpy.diags.climato.freq).plot(ax=axs[0])\n", |
1398 | 1395 | "axs[0].set_ylabel(\"Number of tracks\")\n",
|
1399 | 1396 | "# TCD\n",
|
1400 |
| - "data.groupby(\"season\").apply(huracanpy.calc.duration).plot(ax=axs[1])\n", |
| 1397 | + "data.groupby(\"season\").apply(huracanpy.diags.climato.TC_days).plot(ax=axs[1])\n", |
1401 | 1398 | "axs[1].set_ylabel(\"TC days\")\n",
|
1402 | 1399 | "# ACE\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", |
| 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", |
1406 | 1403 | "axs[2].set_ylabel(\"ACE\")\n",
|
1407 | 1404 | "\n",
|
1408 | 1405 | "for ax in axs:\n",
|
|
1440 | 1437 | "source": [
|
1441 | 1438 | "## Seasonal\n",
|
1442 | 1439 | "\n",
|
1443 |
| - "gen = huracanpy.calc.gen_vals(\n", |
| 1440 | + "gen = huracanpy.diags.track_stats.gen_vals(\n", |
1444 | 1441 | " data,\n",
|
1445 | 1442 | ") # Extract the point of genesis for each track\n",
|
1446 | 1443 | "(\n",
|
|
1494 | 1491 | "fig, axs = plt.subplots(1, 3, sharey=True, figsize=[15, 5])\n",
|
1495 | 1492 | "\n",
|
1496 | 1493 | "# Duration\n",
|
1497 |
| - "huracanpy.calc.get_duration(data.time, data.track_id).plot.hist(ax=axs[0])\n", |
| 1494 | + "huracanpy.diags.track_stats.duration(data.time, data.track_id).plot.hist(ax=axs[0])\n", |
1498 | 1495 | "\n",
|
1499 | 1496 | "# Maximum wind speed\n",
|
1500 |
| - "huracanpy.calc.get_extremum_vals(\n", |
| 1497 | + "huracanpy.diags.track_stats.extremum_vals(\n", |
1501 | 1498 | " data, varname=\"wind_speed_10m\", stat=\"max\"\n",
|
1502 | 1499 | ").wind_speed_10m.plot.hist(ax=axs[1])\n",
|
1503 | 1500 | "\n",
|
|
1948 | 1945 | ],
|
1949 | 1946 | "metadata": {
|
1950 | 1947 | "kernelspec": {
|
1951 |
| - "display_name": "Python 3 (ipykernel)", |
1952 |
| - "language": "python", |
| 1948 | + "display_name": "Python 3 (Spyder)", |
| 1949 | + "language": "python3", |
1953 | 1950 | "name": "python3"
|
1954 | 1951 | },
|
1955 | 1952 | "language_info": {
|
|
1962 | 1959 | "name": "python",
|
1963 | 1960 | "nbconvert_exporter": "python",
|
1964 | 1961 | "pygments_lexer": "ipython3",
|
1965 |
| - "version": "3.12.4" |
| 1962 | + "version": "3.11.9" |
1966 | 1963 | }
|
1967 | 1964 | },
|
1968 | 1965 | "nbformat": 4,
|
|
0 commit comments