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'>)
../_images/user_guide_accessor_5_1.png
../_images/user_guide_accessor_5_2.png

Not implemented functions#

Some functions are not included with the hrcn accessor following these naming conventions. These are:

  • load

  • add_ functions that would have output with a different shape

    • add_apex_vals

    • add_gen_vals

    • add_density

    • add_track_duration

    • add_ace and add_pace with the sum_by keyword

  • plot_ functions that are for multiple datasets

    • plot_doughnut

    • plot_venn

  • Functions from huracanpy.assess because it is for multiple datasets