日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

python气象可视化第二弹-黄河流域白化

發(fā)布時(shí)間:2024/3/24 python 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python气象可视化第二弹-黄河流域白化 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

提示:文章寫(xiě)完后,目錄可以自動(dòng)生成,如何生成可參考右邊的幫助文檔

文章目錄

  • 前言
    • 在學(xué)習(xí)了氣象家園平流層的蘿卜首發(fā)、晉陵小生優(yōu)化的 maskout 模塊白化功能之后。利用九大流域的shp文件,我對(duì)九大流域中黃河流域的降水分布進(jìn)行了繪制。
  • 一、使用maskout程序包的要點(diǎn)?
  • 二、使用步驟
    • 1.引入庫(kù)
    • 2.繪制黃河流域降水分布圖
  • 總結(jié)


前言

在學(xué)習(xí)了氣象家園平流層的蘿卜首發(fā)、晉陵小生優(yōu)化的 maskout 模塊白化功能之后。利用九大流域的shp文件,我對(duì)九大流域中黃河流域的降水分布進(jìn)行了繪制。

一、使用maskout程序包的要點(diǎn)?

maskout是比較python+cartopy實(shí)現(xiàn)白化功能的一個(gè)比較好用的子程序。(1)在應(yīng)用的過(guò)程中要注意相關(guān)的shp文件應(yīng)該是地理坐標(biāo)系,如果不是的話要轉(zhuǎn)化坐標(biāo)系。(詳情參考:如何使用arcmap轉(zhuǎn)換shp文件坐標(biāo)系)(2)注意選擇合適的region,盡量選擇具有代表性的record。
相應(yīng)的maskout_hhriver里應(yīng)該修改為下圖所示:

二、使用步驟

1.引入庫(kù)

代碼如下(示例):

import os import shapefile as shp SHP = r'F:\mapshp\china_shp' import numpy as np import matplotlib import matplotlib.pyplot as plt import matplotlib.ticker as mticker import xarray as xr import cartopy.crs as ccrs import cartopy.feature as cfeature from cartopy.io.shapereader import Reader from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter import numpy import pandas as pd import mask_hhriver #設(shè)定新字體

2.繪制黃河流域降水分布圖

代碼如下(示例):

#設(shè)定新字體 from matplotlib.font_manager import FontProperties lpfont = matplotlib.font_manager.FontProperties(fname='F:\python可視化\font\SimSun.ttf') plt.rcParams.update({'font.size':16})region=[95,120,32,42] df=xr.open_dataset(r'E:\testdataset\precip.mon.mean.nc') lat = df.lat lon = df.lon # lat = df['lat'] # lon = df['lon'] pre0 = df['precip'] #含缺測(cè)值 pre1 = np.array(pre0) pre_clim=np.nanmean(pre1,axis=0) fig=plt.figure(dpi=600,figsize=(12,6)) proj=ccrs.PlateCarree() ax = plt.axes(projection = proj) ax.set_extent(region, crs = proj) ax.set_xticks(np.arange(region[0], region[1] + 1, 5), crs = proj) ax.set_yticks(np.arange(region[-2], region[-1] + 1, 2), crs = proj) ax.xaxis.set_major_formatter(LongitudeFormatter(zero_direction_label=False)) ax.yaxis.set_major_formatter(LatitudeFormatter()) # Add 黃河流域&干流shp c11=ax.contourf(lon,lat,pre_clim,np.arange(0,3,0.01),extend='both',transform=ccrs.PlateCarree(),cmap='gist_rainbow') ax.add_geometries(Reader(r'F:/mapshp/hhriver/jichu/黃河干流epsg4324.shp').geometries(),ccrs.PlateCarree(),facecolor='none',edgecolor='k',linewidth=0.5) clip=mask_hhriver.shp2clip(c11,ax,shpfile=os.path.join(SHP, 'China_nine_basinepsg4324.shp'),region=['Yellow River Basin'],proj= proj) cbar=plt.colorbar(c11,shrink=0.75,aspect=20,fraction=.03,pad=0.02) #aspect控制bar寬度,fraction控制大小比例,pad控制與圖的距離 cbar.set_ticks(np.arange(0,3,0.3)) #設(shè)置colorbar范圍和刻度標(biāo)記間隔 cbar.ax.tick_params(labelsize=12, direction='in', right=False) #出圖 plt.savefig('prehh.png',dpi=600) plt.show()


總結(jié)

最后還可以對(duì)圖片進(jìn)行潤(rùn)色,例如添加標(biāo)題等等。參考?xì)庀笏目蒲胸埌l(fā)布的Python可視化中國(guó)區(qū)域地面氣象要素驅(qū)動(dòng)數(shù)據(jù)集—以黃河流域?yàn)槔??;緦?shí)現(xiàn)了黃河流域的白化功能。

j

總結(jié)

以上是生活随笔為你收集整理的python气象可视化第二弹-黄河流域白化的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。