Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to perform Radial basis function interpolation Visualization of site data

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces how to use Python to implement radial basis function interpolation visualization of site data, the content is very detailed, interested friends can refer to, hope to be helpful to you.

The data of 29 meteorological stations in Yunnan Province in June 2015 are taken as an example to carry out radial basis function (Rbf) interpolation. The data format is as follows:

Today, you need to use the cartopy library to draw, so you need to install it first. It is said that the installation is very annoying. You can go to uci to download the .whl file to install it. After installation, you can test whether it can be run. Here is a simple test:

First of all, it was an unsuccessful attempt because the shp layer failed to load so that the final interpolation did not fall within a specific geographical range. If any partner knows the solution to this problem, please do not hesitate to give us advice. I believe that as long as it is a problem, there must be a solution.

So let's start today's test, first of all, import the required libraries or modules in the old routine, as follows:

Import numpy as np

Import pandas as pd

From scipy.interpolate import Rbf

Import cartopy.crs as ccrs

Import cartopy.feature as cfeat

From cartopy.io.shapereader import Reader

From cartopy.mpl.gridliner import LONGITUDE_FORMATTER,LATITUDE_FORMATTER

Import matplotlib.pyplot as plt

Then set it to display Chinese and minus signs normally.

Plt.rcParams ['font.sans-serif'] = [' SimHei'] # display Chinese normally

Plt.rcParams ['axes.unicode_minus'] = False# shows a negative sign normally

Next, we use pandas to read the sorted data, using the precipitation data and temperature data of Yunnan Province in June 2015. only the Rbf interpolation of precipitation is tested in this paper.

Climate = pd.read_excel ('yunnanclimate.xlsx',header=None,sep='\ lon','lat',' precipitation, temperature]) # print (climate) then extract specific elements from the loaded xlsx data, such as latitude and longitude, precipitation, etc.

# read the specific data in climate

Lon = climate ['lon']

Lat = climate ['lat']

Rain_data = climate ['precipitation'] then set the range and gridding

# set longitude and latitude range

Slon = np.linspace (97.85105.21 and 36)

Slat = np.linspace (21.45, 28.50, 36)

Slon,slat = np.meshgrid (slon,slat) then start interpolation, function, I tested three kinds of linear+cubic+gaussian here, what's the difference between them, , at the end, I'm going to show what these three functions look like.

# start interpolation, using radial basis function Rbf

Func = Rbf (lon,lat,rain_data,function='cubic')

RainX = func (slon,slat) next load Yunnan Province's shp layer and modify latitude and longitude information, this is where I made a mistake, if you know the solution, please do not hesitate to let me know.

Shp_path = rudder:\ GeoCAS\ Python\ yunnan.shp'# set the absolute path

Proj = ccrs.PlateCarree () # set projection

Fig = plt.figure (figsize= (5), dpi=300)

Ax = fig.subplots (1,1, subplot_kw= {'projection': proj})

Extent = [97.85105.21] # limit the range of longitude and latitude

Reader = Reader (shp_path) # read shp vector

Yunnan = cfeat.ShapelyFeature (reader.geometries (), proj,edgecolor='k',facecolor='none') # set shp feature

Ax.add_feature (yunnan,linewidth=0.5)

Ax.set_extent (extent,crs=proj)

Gl = ax.gridlines (crs=ccrs.PlateCarree (), draw_labels=True,linestyle='-')

Gl.xlabels_top=False

Gl.ylabels_right=False

Gl.xformatter = LONGITUDE_FORMATTER# displays the xy axis in latitude and longitude format

Gl.yformatter = LATITUDE_FORMATTER

Gl.xlabel_style= {'size':6} # sets the xy font size

Gl.ylabel_style= {'size':6}

H = ax.contourf (slon,slat,rainX,cmap='viridis',extend='both')

Plt.colorbar (hre orientationally ordered vertical`)

Plt.show ()

The final result is like this, and here is the linear result:

Here is the cubic result:

Finally, there is the result of Gaussian, as follows:

On how to use Python to perform radial basis function interpolation visualization of site data is shared here, I hope the above content can be of some help to you, you can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report