The hrcn accessor#
HuracanPy implements an xarray accessor. This means that when your tracks are loaded as an xarray.Dataset (e.g. when you have loaded tracks with huracanpy.load), you can call HuracanPy functions by typing:
tracks.hrcn.{{function name}}
This provides a useful shorthand for calling functions in HuracanPy. For example selecting an individual track by track_id
[1]:
import huracanpy
tracks = huracanpy.load(huracanpy.example_csv_file)
# Calling sel_id from the module
track = huracanpy.sel_id(tracks, tracks.track_id, 0)
# Shorthand with hrcn accessor
track = tracks.hrcn.sel_id(0)
Naming conventions#
For top-level functions in huracanpy, such as sel_id the accessor name matches the function name. Functions in other modules are named differently. For the full set of functions implemented by the accessor, see the accessor API
get_ and add_ functions#
The functions in huracanpy.info, huracanpy.calc, and huracanpy.tc are implemented as get_ and add_ functions separately e.g.
[2]:
# Getting is_land from the module
is_land = huracanpy.info.is_land(tracks.lon, tracks.lat)
# Shorthand with hrcn accessor
is_land = tracks.hrcn.get_is_land()
# Add is_land to the tracks using xarray syntax
# Note that this creates a new Dataset with the variable added
tracks_ = tracks.assign(is_land=huracanpy.info.is_land(tracks.lon, tracks.lat))
# Shorthand with hrcn accessor
# Note that this follows the xarray convention of returning a new dataset
tracks_ = tracks.hrcn.add_is_land()
Plot functions#
The functions from huracanpy.plot are named plot_. e.g.
[3]:
# Plot using the module function
huracanpy.plot.tracks(tracks.lon, tracks.lat, intensity_var=tracks.wind10)
# Shorthand with the hrcn accessor
tracks.hrcn.plot_tracks(intensity_var_name="wind10")
[3]:
(<Figure size 1000x1000 with 1 Axes>, <GeoAxes: xlabel='lon', ylabel='lat'>)
Not implemented functions#
Some functions are not included with the hrcn accessor following these naming conventions. These are:
loadadd_functions that would have output with a different shapeadd_apex_valsadd_gen_valsadd_densityadd_track_durationadd_aceandadd_pacewith thesum_bykeyword
plot_functions that are for multiple datasetsplot_doughnutplot_venn
Functions from
huracanpy.assessbecause it is for multiple datasets