Getting Started#
HuracanPy provides a standard way for working with cyclone track data from different sources. HuracanPy can load track data from various sources as an xarray Dataset with a minimal number of assumed variables (track_id, lon, lat, time). e.g.
[1]:
import huracanpy
tracks = huracanpy.load(huracanpy.example_csv_file)
print(tracks)
<xarray.Dataset> Size: 7kB
Dimensions: (record: 99)
Dimensions without coordinates: record
Data variables:
track_id (record) int64 792B 0 0 0 0 0 0 0 0 0 0 0 ... 2 2 2 2 2 2 2 2 2 2
i (record) int64 792B 482 476 476 477 478 ... 229 230 234 241 249
j (record) int64 792B 417 419 420 420 422 ... 501 509 517 528 542
lon (record) float64 792B 120.5 119.0 119.0 119.2 ... 58.5 60.25 62.25
lat (record) float64 792B -14.25 -14.75 -15.0 ... -39.25 -42.0 -45.5
slp (record) float64 792B 9.988e+04 9.981e+04 ... 9.747e+04 9.754e+04
zs (record) float64 792B -10.71 -16.11 -40.21 ... -218.5 -211.5
wind10 (record) float64 792B 14.65 13.99 13.7 17.98 ... 23.69 23.96 23.4
time (record) datetime64[ns] 792B 1980-01-06T06:00:00 ... 1980-01-30...
Each “record” corresponds to a TC point (time, lon, lat).
Note that the data is one dimensional but represents multiple tracks. This is done rather than having track_id as an additional dimension to avoid having to add blank data to each track when they are not the same length. The groupby function, built in to xarray, allows us to easily loop over or index tracks in this format.
[2]:
import huracanpy
tracks = huracanpy.load(huracanpy.example_csv_file)
track_groups = tracks.groupby("track_id")
# Selecting track by ID
# The track_id is not necessarily an integer, it follows whatever you have loaded
# e.g. could be a string for IBTrACS
track_id1 = track_groups[1]
# Iterating over all tracks
# Each track will be a subset of the xarray Dataset with a unique track_id
for n, track in track_groups:
# Do something with the track
print(track)
<xarray.Dataset> Size: 2kB
Dimensions: (record: 31)
Dimensions without coordinates: record
Data variables:
track_id (record) int64 248B 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
i (record) int64 248B 482 476 476 477 478 ... 484 494 510 521 525
j (record) int64 248B 417 419 420 420 422 ... 483 486 487 486 487
lon (record) float64 248B 120.5 119.0 119.0 ... 127.5 130.2 131.2
lat (record) float64 248B -14.25 -14.75 -15.0 ... -31.75 -31.5 -31.75
slp (record) float64 248B 9.988e+04 9.981e+04 ... 1.004e+05 1.005e+05
zs (record) float64 248B -10.71 -16.11 -40.21 ... 15.29 33.08 41.33
wind10 (record) float64 248B 14.65 13.99 13.7 17.98 ... 13.12 11.48 10.23
time (record) datetime64[ns] 248B 1980-01-06T06:00:00 ... 1980-01-13...
<xarray.Dataset> Size: 1kB
Dimensions: (record: 20)
Dimensions without coordinates: record
Data variables:
track_id (record) int64 160B 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
i (record) int64 160B 598 606 616 625 634 ... 610 612 615 619 624
j (record) int64 160B 446 453 458 464 471 ... 538 542 545 546 547
lon (record) float64 160B 149.5 151.5 154.0 ... 153.8 154.8 156.0
lat (record) float64 160B -21.5 -23.25 -24.5 ... -46.25 -46.5 -46.75
slp (record) float64 160B 9.963e+04 9.912e+04 ... 9.934e+04 9.962e+04
zs (record) float64 160B -32.96 -76.44 -60.96 ... -55.82 -31.82
wind10 (record) float64 160B 12.68 18.66 20.71 ... 13.14 11.39 10.46
time (record) datetime64[ns] 160B 1980-01-07 ... 1980-01-12T06:00:00
<xarray.Dataset> Size: 3kB
Dimensions: (record: 48)
Dimensions without coordinates: record
Data variables:
track_id (record) int64 384B 2 2 2 2 2 2 2 2 2 2 2 ... 2 2 2 2 2 2 2 2 2 2
i (record) int64 384B 221 217 211 216 220 ... 229 230 234 241 249
j (record) int64 384B 435 433 433 422 425 ... 501 509 517 528 542
lon (record) float64 384B 55.25 54.25 52.75 54.0 ... 58.5 60.25 62.25
lat (record) float64 384B -18.75 -18.25 -18.25 ... -39.25 -42.0 -45.5
slp (record) float64 384B 1.006e+05 1.006e+05 ... 9.747e+04 9.754e+04
zs (record) float64 384B 48.7 49.59 54.99 ... -225.5 -218.5 -211.5
wind10 (record) float64 384B 11.51 12.95 14.91 15.37 ... 23.69 23.96 23.4
time (record) datetime64[ns] 384B 1980-01-17T06:00:00 ... 1980-01-30...