Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use cartopy Library Code to draw Typhoon path in python

Shulou Source: shulou.com Published: 2022-06-01 18:20:47 10月04日 Update

This article mainly introduces the relevant knowledge of "how to use cartopy library code to draw typhoon path in python". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use cartopy library code to draw typhoon path in python" can help you solve the problem.

Using python to draw Typhoon tracks based on cartopy Library

Use python to draw the typhoon path of the western Pacific into China, the file is in .dat format, the content is as follows:

The code is as follows:

Import netCDF4 as nc4import matplotlib.pyplot as pltimport numpy as npimport datetimeimport osimport cartopy.crs as ccrspath='E://' # File path files= os.listdir (path) # get all the file names under the folder fig=plt.figure (figsize= (20jue 12)) # set the canvas size parallels = np.arange (0.mem90.Magne3.) Meridians = np.arange (0.0360.1) Ax = plt.axes (projection=ccrs.Robinson ()) # set projection mode # Set figure extent & ticksax.set_extent ([100,150,5,50]) # set latitude range # plt.grid (linestyle=':',color='y') # for file in files: # read the data name of each file in files in order to read f = open (path+file) 'r') # Open the first dat file records = f.readlines () # read all the data in this file f.close () # close the dat file date_t ='# # set a space btk_lat = [] # set an empty Latitude btk_lon = [] # set an empty longitude btk_vmax = [] # maximum wind speed Maximum sustained wind speed in knots: 0-300 kts. Btk_time = [] # time btk_rmw = [] # maximum wind speed radius radius of max winds, 0-999 n mi. Btk_name = [] # Typhoon name for rcd in records: # Loop every line of data that has been read in this dat file strs = rcd.split (',') # separate each', 'from if (len (strs))

Tags: File typhoon path latitude wind speed processing maximum name data longitude code time array knowledge drawing content radius folder space industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL Microsoft Shulou Technology Redmi