Additional information with the info module#
The info allows for the computation of individual attributes.
[1]:
import matplotlib.pyplot as plt
import seaborn as sns
import huracanpy
# Load tracks
filename = huracanpy.example_year_file
data = huracanpy.load(filename)
list(data.keys()) # Available attributes
[1]:
['track_id',
'year',
'month',
'day',
'hour',
'i',
'j',
'lon',
'lat',
'slp',
'zs',
'wind10',
'time']
Geographical attributes#
[2]:
# hemisphere, can also be obtained with huracanpy.info.hemisphere
data = data.hrcn.add_hemisphere()
huracanpy.plot.tracks(
data.lon, data.lat, intensity_var=data.hemisphere, scatter_kws=dict(s=10)
)
plt.show()
[3]:
# basin, can also be obtained with huracanpy.info.basin
# (NB: Several convention available)
data = data.hrcn.add_basin()
huracanpy.plot.tracks(
data.lon, data.lat, intensity_var=data.basin, scatter_kws=dict(s=10)
)
plt.show()
[4]:
# is_ocean, can also be obtained with huracanpy.info.is_ocean
data = data.hrcn.add_is_ocean()
huracanpy.plot.tracks(
data.lon, data.lat, intensity_var=data.is_ocean, scatter_kws=dict(s=10)
)
plt.show()
/home/docs/checkouts/readthedocs.org/user_builds/huracanpy/envs/latest/lib/python3.14/site-packages/cartopy/io/__init__.py:242: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_physical/ne_10m_ocean.zip
warnings.warn(f'Downloading: {url}', DownloadWarning)
[5]:
# country, can also be obtained with huracanpy.info.country
data = data.hrcn.add_country()
data_ = data.isel(record=slice(0, 60))
huracanpy.plot.tracks(
data_.lon, data_.lat, intensity_var=data_.country, scatter_kws=dict(s=10)
)
plt.show()
/home/docs/checkouts/readthedocs.org/user_builds/huracanpy/envs/latest/lib/python3.14/site-packages/cartopy/io/__init__.py:242: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_cultural/ne_10m_admin_0_countries.zip
warnings.warn(f'Downloading: {url}', DownloadWarning)
/home/docs/checkouts/readthedocs.org/user_builds/huracanpy/envs/latest/lib/python3.14/site-packages/cartopy/io/__init__.py:242: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_physical/ne_10m_coastline.zip
warnings.warn(f'Downloading: {url}', DownloadWarning)
[6]:
# continent, can also be obtained with huracanpy.info.continent
data = data.hrcn.add_continent()
huracanpy.plot.tracks(
data.lon, data.lat, intensity_var=data.continent, scatter_kws=dict(s=10)
)
plt.show()
Time attributes#
[7]:
# Season. Can also be obtained with huracanpy.info.season
data = data.hrcn.add_season()
data = data.hrcn.add_hemisphere()
sns.scatterplot(data=data, x="time", y="hemisphere", hue="season")
plt.show()
Categories#
Categories are specific to tropical cyclones and can be found in the huracanpy.tc module A more generic function is available in huracanpy.info.get_category
[8]:
# sshs
sshs = huracanpy.tc.saffir_simpson_category(data.wind10)
huracanpy.plot.tracks(
data.lon,
data.lat,
intensity_var=sshs,
scatter_kws=dict(s=5, palette="Spectral"),
)
plt.show()
[9]:
# pressure category
pres_cat = huracanpy.tc.pressure_category(data.slp)
huracanpy.plot.tracks(
data.lon,
data.lat,
intensity_var=pres_cat,
scatter_kws=dict(s=5, palette="Spectral"),
)
plt.show()
/home/docs/checkouts/readthedocs.org/user_builds/huracanpy/envs/latest/lib/python3.14/site-packages/metpy/xarray.py:1330: UserWarning: Caution, pressure are likely in Pa, they are being converted to hPa for categorization. In future specify the units explicitly by passing slp_units="Pa" to this function or setting slp.attrs["units"] = "Pa"
result = func(*bound_args.args, **bound_args.kwargs)