暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Python气象数据处理与绘图:热带气旋轨迹数据的分析与可视化之Individual Storm

气海无涯 2021-09-03
2042

1、introduction

This sample script illustrates how to retrieve a single storm from the HURDAT2 dataset, and make plots and analyses of this storm.

For documentation generation purposes, return_ax must be set True for plotting functions. You don't need to have this extra argument in every plotting function call (e.g., "storm.plot(return_ax=True)" will produce the same output as "storm.plot()").

2、import packets

1import tropycal.tracks as tracks
2import datetime as dt
3import warnings
4warnings.filterwarnings('ignore')

3、HURTDAT2 Dataset

Let's start by creating an instance of a TrackDataset object. By default, this reads in the HURDAT2 dataset from the National Hurricane Center (NHC) website. For this example we'll be using the HURDAT2 dataset over the North Atlantic basin.

HURDAT data is not available for the most recent hurricane seasons. To include the latest data up through today, the "include_btk" flag would need to be set to True, which reads in preliminary best track data from the NHC website.

1hurdat_atl = tracks.TrackDataset(basin='north_atlantic',source='hurdat',include_btk=False)

4、Individual storm analysis

Individual storms can be retrieved from the dataset by calling the get_storm() function, which returns an instance of a Storm object. This can be done by either entering a tuple containing the storm name and year, or by the standard tropical cyclone ID (e.g., "AL012019").

Let's retrieve an instance of Hurricane Michael from 2018:

1storm = hurdat_atl.get_storm(('michael',2018))

This instance of Storm contains several methods that return the storm data back in different data types. The following examples will show # how to retrieve 3 different data types.

Retrieve a dictionary of Michael's data:

1print(storm.to_dict())
2
3output:
4{'id''AL142018''operational_id''AL142018''name''MICHAEL''year'2018'season'2018'basin''north_atlantic''source_info''NHC Hurricane Database''source''hurdat''date': [datetime.datetime(2018106180), datetime.datetime(201810700), datetime.datetime(201810760), datetime.datetime(2018107120), datetime.datetime(2018107180), datetime.datetime(201810800), datetime.datetime(201810860), datetime.datetime(2018108120), datetime.datetime(2018108180), datetime.datetime(201810900), datetime.datetime(201810960), datetime.datetime(2018109120), datetime.datetime(2018109180), datetime.datetime(2018101000), datetime.datetime(2018101060), datetime.datetime(20181010120), datetime.datetime(201810101730), datetime.datetime(20181010180), datetime.datetime(2018101100), datetime.datetime(2018101160), datetime.datetime(20181011120), datetime.datetime(20181011180), datetime.datetime(2018101200), datetime.datetime(2018101260), datetime.datetime(20181012120), datetime.datetime(20181012180), datetime.datetime(2018101300), datetime.datetime(2018101360), datetime.datetime(20181013120), datetime.datetime(20181013180), datetime.datetime(2018101400), datetime.datetime(2018101460), datetime.datetime(20181014120), datetime.datetime(20181014180), datetime.datetime(2018101500), datetime.datetime(2018101560), datetime.datetime(20181015120), datetime.datetime(20181015180)], 'extra_obs': [00000000000000001000000000000000000000], 'special': ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'L', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], 'type': ['LO', 'LO', 'TD', 'TS', 'TS', 'TS', 'TS', 'HU', 'HU', 'HU', 'HU', 'HU', 'HU', 'HU', 'HU', 'HU', 'HU', 'HU', 'HU', 'TS', 'TS', 'TS', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX', 'EX'], 'lat': [17.8, 18.1, 18.4, 18.8, 19.1, 19.7, 20.2, 20.9, 21.7, 22.7, 23.7, 24.6, 25.6, 26.6, 27.7, 29.0, 30.0, 30.2, 31.5, 32.8, 34.1, 35.6, 36.5, 37.3, 39.1, 41.1, 43.1, 44.8, 46.4, 47.6, 48.4, 48.8, 48.6, 47.5, 45.9, 44.4, 42.8, 41.2], 'lon': [-86.6, -86.9, -86.8, -86.4, -85.7, -85.5, -85.4, -85.1, -85.1, -85.2, -85.8, -86.2, -86.4, -86.5, -86.6, -86.3, -85.5, -85.4, -84.5, -83.2, -81.7, -80.0, -77.7, -75.0, -70.6, -66.1, -61.5, -55.7, -48.2, -40.7, -33.1, -26.1, -20.7, -16.4, -13.5, -11.4, -10.3, -10.0], 'vmax': [25, 25, 30, 35, 45, 50, 60, 65, 75, 85, 85, 90, 100, 110, 120, 125, 140, 135, 80, 50, 45, 45, 50, 60, 60, 60, 65, 65, 65, 65, 65, 65, 60, 55, 55, 50, 35, 35], 'mslp': [1006, 1004, 1004, 1003, 999, 996, 984, 982, 977, 971, 973, 968, 961, 952, 945, 934, 919, 920, 957, 979, 987, 991, 988, 983, 980, 977, 975, 975, 975, 975, 975, 975, 975, 978, 982, 989, 996, 1001], 'wmo_basin': ['north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic', 'north_atlantic'], 'ace': 12.505000000000003}
5Retrieve xarray Dataset object with Michael'
s data:

Retrieve xarray Dataset object with Michael's data:

 1print(storm.to_xarray())
2
3output:
4<xarray.Dataset>
5Dimensions:    (time38)
6Coordinates:
7  * time       (time) datetime64[ns] 2018-10-06T18:00:00 ... 2018-10-15T18:00:00
8Data variables:
9    extra_obs  (time) int64 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 0
10    special    (time) <U1 '' '' '' '' '' '' '' '' '' ... '' '' '' '' '' '' '' ''
11    type       (time) <U2 'LO' 'LO' 'TD' 'TS' 'TS' ... 'EX' 'EX' 'EX' 'EX' 'EX'
12    lat        (time) float64 17.8 18.1 18.4 18.8 19.1 ... 45.9 44.4 42.8 41.2
13    lon        (time) float64 -86.6 -86.9 -86.8 -86.4 ... -11.4 -10.3 -10.0
14    vmax       (time) int64 25 25 30 35 45 50 60 65 ... 65 65 60 55 55 50 35 35
15    mslp       (time) int64 1006 1004 1004 1003 999 996 ... 978 982 989 996 1001
16    wmo_basin  (time) <U14 'north_atlantic' ... 'north_atlantic'
17Attributes:
18    id:              AL142018
19    operational_id:  AL142018
20    name:            MICHAEL
21    year:            2018
22    season:          2018
23    basin:           north_atlantic
24    source_info:     NHC Hurricane Database
25    source:          hurdat
26    ace:             12.505000000000003

Retrieve pandas DataFrame object with Michael's data:

 1print(storm.to_dataframe())
2                  date  extra_obs special type   lat   lon  vmax  mslp  \
30  2018-10-06 18:00:00          0           LO  17.8 -86.6    25  1006   
41  2018-10-07 00:00:00          0           LO  18.1 -86.9    25  1004   
52  2018-10-07 06:00:00          0           TD  18.4 -86.8    30  1004   
63  2018-10-07 12:00:00          0           TS  18.8 -86.4    35  1003   
74  2018-10-07 18:00:00          0           TS  19.1 -85.7    45   999   
85  2018-10-08 00:00:00          0           TS  19.7 -85.5    50   996   
96  2018-10-08 06:00:00          0           TS  20.2 -85.4    60   984   
107  2018-10-08 12:00:00          0           HU  20.9 -85.1    65   982   
118  2018-10-08 18:00:00          0           HU  21.7 -85.1    75   977   
129  2018-10-09 00:00:00          0           HU  22.7 -85.2    85   971   
1310 2018-10-09 06:00:00          0           HU  23.7 -85.8    85   973   
1411 2018-10-09 12:00:00          0           HU  24.6 -86.2    90   968   
1512 2018-10-09 18:00:00          0           HU  25.6 -86.4   100   961   
1613 2018-10-10 00:00:00          0           HU  26.6 -86.5   110   952   
1714 2018-10-10 06:00:00          0           HU  27.7 -86.6   120   945   
1815 2018-10-10 12:00:00          0           HU  29.0 -86.3   125   934   
1916 2018-10-10 17:30:00          1       L   HU  30.0 -85.5   140   919   
2017 2018-10-10 18:00:00          0           HU  30.2 -85.4   135   920   
2118 2018-10-11 00:00:00          0           HU  31.5 -84.5    80   957   
2219 2018-10-11 06:00:00          0           TS  32.8 -83.2    50   979   
2320 2018-10-11 12:00:00          0           TS  34.1 -81.7    45   987   
2421 2018-10-11 18:00:00          0           TS  35.6 -80.0    45   991   
2522 2018-10-12 00:00:00          0           EX  36.5 -77.7    50   988   
2623 2018-10-12 06:00:00          0           EX  37.3 -75.0    60   983   
2724 2018-10-12 12:00:00          0           EX  39.1 -70.6    60   980   
2825 2018-10-12 18:00:00          0           EX  41.1 -66.1    60   977   
2926 2018-10-13 00:00:00          0           EX  43.1 -61.5    65   975   
3027 2018-10-13 06:00:00          0           EX  44.8 -55.7    65   975   
3128 2018-10-13 12:00:00          0           EX  46.4 -48.2    65   975   
3229 2018-10-13 18:00:00          0           EX  47.6 -40.7    65   975   
3330 2018-10-14 00:00:00          0           EX  48.4 -33.1    65   975   
3431 2018-10-14 06:00:00          0           EX  48.8 -26.1    65   975   
3532 2018-10-14 12:00:00          0           EX  48.6 -20.7    60   975   
3633 2018-10-14 18:00:00          0           EX  47.5 -16.4    55   978   
3734 2018-10-15 00:00:00          0           EX  45.9 -13.5    55   982   
3835 2018-10-15 06:00:00          0           EX  44.4 -11.4    50   989   
3936 2018-10-15 12:00:00          0           EX  42.8 -10.3    35   996   
4037 2018-10-15 18:00:00          0           EX  41.2 -10.0    35  1001   
41
42         wmo_basin  
430   north_atlantic  
441   north_atlantic  
452   north_atlantic  
463   north_atlantic  
474   north_atlantic  
485   north_atlantic  
496   north_atlantic  
507   north_atlantic  
518   north_atlantic  
529   north_atlantic  
5310  north_atlantic  
5411  north_atlantic  
5512  north_atlantic  
5613  north_atlantic  
5714  north_atlantic  
5815  north_atlantic  
5916  north_atlantic  
6017  north_atlantic  
6118  north_atlantic  
6219  north_atlantic  
6320  north_atlantic  
6421  north_atlantic  
6522  north_atlantic  
6623  north_atlantic  
6724  north_atlantic  
6825  north_atlantic  
6926  north_atlantic  
7027  north_atlantic  
7128  north_atlantic  
7229  north_atlantic  
7330  north_atlantic  
7431  north_atlantic  
7532  north_atlantic  
7633  north_atlantic  
7734  north_atlantic  
7835  north_atlantic  
7936  north_atlantic  
8037  north_atlantic  

Visualize Michael's observed track with the "plot" function:
Note that you can pass various arguments to the plot function, such as customizing the map and track aspects. The only cartopy projection # currently offered is PlateCarree. Read through the documentation for more customization options.
1storm.plot(return_ax=True)


Plot the tornado tracks associated with Michael, along with the accompanying daily practically perfect forecast (PPH):
Note: There is currently a bug with this function that outputs 2 axes, a filled one and a blank one. This will be fixed in future updates.
1storm.plot_tors(plotPPH=True)

If this storm was ever in NHC's area of responsibility, you can retrieve operational NHC forecast data for this event provided it is available. Forecast discussions date back to 1992, and forecast tracks date back to 1954.
Retrieve a single forecast discussion for Michael:
1#Method 1: Specify date closest to desired discussion
2disco = storm.get_nhc_discussion(forecast=dt.datetime(2018,10,7,0))
3print(disco['text'])
4
5#Method 2: Specify forecast discussion ID
6disco = storm.get_nhc_discussion(forecast=2)
7#print(disco['text']) printing this would show the same output

output:
 1ZCZC MIATCDAT4 ALL
2TTAA00 KNHC DDHHMM
3
4Potential Tropical Cyclone Fourteen Discussion Number   2
5NWS National Hurricane Center Miami FL       AL142018
61000 PM CDT Sat Oct 06 2018
7
8The cloud pattern has improved in organization and surface pressures
9are gradually falling, but there is no evidence that the system is
10a tropical cyclone at this time.  All indications are, however, that
11a tropical depression will likely form at any time soon. Strong wind
12shear is expected to affect the disturbance, and the SHIPS model
13only show a modest strengthening. This is in contrast to some global
14models and the HWRF, which are more aggressive in developing this
15system.  Since the environment is marginally favorable, the NHC
16forecast only gradually strengthens the system at the rate of the
17intensity consensus IVCN.  However, the forecast is highly uncertain
18given the solution of the global models.
19
20Since the system does not have a well-defined center, the initial
21motion is also uncertain. The best estimate is toward the north or
22360 degrees at 6 kt. Over the next 2 or 3 days, the cyclone will be
23embedded within the deep southerly flow between a strong subtropical
24ridge over the western Atlantic and a sharp mid-latitude trough
25advancing eastward over the United States.  This flow pattern will
26force the system to move northward at 5 to 10 kt across the
27eastern Gulf of Mexico for the next 2 to 3 days. By day 4, the
28system should have moved inland and be weakening. It should
29then race northeastward farther inland across the eastern U.S.  The
30track guidance envelope is remarkably quite tight. This increases
31the confidence in the track forecast primarily after the cyclone
32forms.
33
34Key Messages for Potential Tropical Cyclone Fourteen:
35
361.  This system is producing heavy rainfall and flash flooding over
37portions of Central America, and these rains will spread over
38western Cuba and the northeastern Yucatan Peninsula of Mexico during
39the next couple of days.
40
412.  The system is forecast to become a tropical storm by late
42Sunday, and tropical storm conditions are expected over portions of
43western Cuba, where a Tropical Storm Warning is in effect.
44
453.  The system could bring storm surge, rainfall, and wind impacts
46to portions of the northern Gulf Coast by mid-week, although it is
47too soon to specify the exact location and magnitude of these
48impacts.  Residents in these areas should monitor the progress of
49this system.
50
51
52FORECAST POSITIONS AND MAX WINDS
53
54INIT  07/030018.8N  86.6W   25 KT  30 MPH...POTENTIAL TROP CYCLONE
55 12H  07/120019.5N  86.5W   30 KT  35 MPH...TROPICAL CYCLONE
56 24H  08/000021.0N  86.2W   35 KT  40 MPH
57 36H  08/120022.3N  86.1W   40 KT  45 MPH
58 48H  09/000023.8N  86.3W   45 KT  50 MPH
59 72H  10/000027.4N  87.2W   55 KT  65 MPH
60 96H  11/000032.0N  85.0W   30 KT  35 MPH...INLAND
61120H  12/000038.5N  77.5W   30 KT  35 MPH...INLAND
62
63$$
64Forecaster Avila
65
66NNNN

NHC also archives forecast tracks, albeit in a different format than the official advisory data, so the operational forecast IDs here differ from the discussion IDs. As such, the forecast cone is not directly retrieved from NHC, but is generated using an algorithm that yields a cone closely resembling the official NHC cone.

Let's plot Michael's second forecast cone:

1storm.plot_nhc_forecast(forecast=2,return_ax=True)

Now let's look at the 12th forecast for Michael.

Note that the observed track here differs from the HURDAT2 track plotted previously! This is because this plot displays the operationally analyzed location and intensity, rather than the post-storm analysis data. This is done to account for differences between HURDAT2 and operational data.

1storm.plot_nhc_forecast(forecast=12,return_ax=True)

5、IBTrACS Dataset

We can also read in IBTrACS data and use it the same way as we would use HURDAT2 data. There are caveats to using IBTrACS data, however, which are described more in depth in the :doc:../data page. We'll retrieve the global IBTrACS dataset, using the Joint Typhoon Warning Center (JTWC) data, modified with the Neumann reanalysis for southern hemisphere storms, and including a special reanalysis for Cyclone Catarina (2004) in Brazil.

Warning: By default, IBTrACS data is read in from an online source. If you're reading in the global IBTrACS dataset, this could be quite slow. For global IBTrACS, it is recommended to have the CSV file saved locally (`link to data`_), then set the flag ``ibtracs_url="local_path"``.

1ibtracs = tracks.TrackDataset(basin='all',source='ibtracs',ibtracs_mode='jtwc_neumann',catarina=True)

The functionality for handling storms in IBTrACS is the same as with using HURDAT2, the only limitation being no NHC and operational model data can be accessed when using IBTrACS as the data source.

Super Typhoon Haiyan_ (2013) was a catastrophic storm in the West Pacific basin, having made landfall in the Philippines. With estimated sustained winds of 195 mph (170 kt), it is among one of the most powerful tropical cyclones in recorded history. We can illustrate this by making a plot of Haiyan's observed track and intensity, from JTWC data:

1storm = ibtracs.get_storm(('haiyan',2013))
2storm.plot(return_ax=True)

Cyclone Catarina_ (2004) was an extremely rare hurricane-force tropical cyclone that developed in the South Atlantic basin, which normally doesn't see tropical cyclone activity, and subsequently made landfall in Brazil. The "Catarina" name is unofficial; it was not assigned a name in real time, and JTWC assigned it the ID "AL502004". Recall that when reading in the IBTrACS dataset previously, we set Catarina=True. This read in data for Cyclone Catarina from a special post-storm reanalysis from McTaggart-Cowan et al. (2006). Let's make a plot of Catarina's observed track and intensity per this reanalysis:

1storm = ibtracs.get_storm(('catarina',2004))
2storm.plot(return_ax=True)

If we were to read in IBTrACS without setting Catarina=True (which sets it to False by default) and plot the track for "AL502004", we would get a noticeably different (shorter) and weaker track.



有问题可以到QQ群里进行讨论,我们在那边等大家。

QQ群号:854684131

文章转载自气海无涯,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论