12
12
def ace (
13
13
wind ,
14
14
aggregate_by = None ,
15
- average_by = None ,
16
15
threshold = 34 * units ("knots" ),
17
16
wind_units = "m s-1" ,
18
17
):
19
- r"""Calculate accumulate cyclone energy (ACE) for each track
18
+ r"""Calculate accumulate cyclone energy (ACE)
20
19
21
20
.. math:: \mathrm{ACE} = 10^{-4} \sum v_\mathrm{max}^2 \quad (v_\mathrm{max} \ge 34 \mathrm{kn})
22
21
22
+ By default, this function will return the "ACE" for each individual point in `wind`.
23
+ To calculate more useful quantities of ACE, use the `aggregate_by` keyword.
24
+
25
+ For example, to calculate the ACE of each individual track, doing
26
+
27
+ >>> ace_by_track = huracanpy.tc.ace(tracks.wind, aggregate_by=tracks.track_id)
28
+
29
+ will return a DataArray with track_id as a coordinate and the sum of ACE for each
30
+ track as the data. Note that this is equivalent to using groupby:
31
+
32
+ >>> ace_by_point = huracanpy.tc.ace(tracks.wind)
33
+ >>> ace_by_track = ace_by_point.groupby(tracks.track_id).sum()
34
+
35
+ To calculate the average ACE by track, you can do
36
+
37
+ >>> ace_by_track_mean = ace_by_track.mean()
38
+
39
+ Similarly to calculate a climatological mean ACE by year, run
40
+
41
+ >>> climatological_ace = huracanpy.tc.ace(tracks.wind, aggregate_by=tracks.time.dt.year).mean()
42
+
23
43
Parameters
24
44
----------
25
45
wind : array_like
26
46
Maximum velocity of a tropical cyclone associated with the tracks dataset
47
+ aggregate_by : array_like
48
+ Variable to take the sum of ACE values across. Must have the same length as wind
27
49
threshold : scalar, default=34 knots
28
50
ACE is set to zero below this threshold wind speed. The default argument is in
29
51
knots. To pass an argument with units, use :py:mod:`metpy.units`, otherwise any
@@ -45,9 +67,6 @@ def ace(
45
67
if aggregate_by is not None :
46
68
ace_values = ace_values .groupby (aggregate_by ).sum ()
47
69
48
- if average_by is not None :
49
- ace_values = ace_values .groupby (average_by ).sum ().mean ()
50
-
51
70
return ace_values
52
71
53
72
@@ -56,7 +75,6 @@ def pace(
56
75
wind = None ,
57
76
model = None ,
58
77
aggregate_by = None ,
59
- average_by = None ,
60
78
threshold_wind = None ,
61
79
threshold_pressure = None ,
62
80
wind_units = "m s-1" ,
@@ -90,6 +108,9 @@ def pace(
90
108
pressure : array_like
91
109
wind : array_like, optional
92
110
model : str, class, or object, optional
111
+ aggregate_by : array_like
112
+ Variable to take the sum of PACE values across. Must have the same length as
113
+ pressure/wind. For examples, see the documentation for `huracanpy.tc.ace`
93
114
threshold_wind : scalar, optional
94
115
threshold_pressure : scalar, optional
95
116
wind_units : str, default="m s-1"
@@ -115,9 +136,6 @@ def pace(
115
136
if aggregate_by is not None :
116
137
pace_values = pace_values .groupby (aggregate_by ).sum ()
117
138
118
- if average_by is not None :
119
- pace_values = pace_values .groupby (average_by ).sum ().mean ()
120
-
121
139
return pace_values , model
122
140
123
141
0 commit comments