亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

利用Python繪制多種風(fēng)玫瑰圖

 更新時(shí)間:2022年05月08日 10:04:14   作者:螞蟻ailing  
這篇文章主要介紹了利用Python繪制多種風(fēng)玫瑰圖,風(fēng)玫瑰是由氣象學(xué)家用于給出如何風(fēng)速和風(fēng)向在特定位置通常分布的簡(jiǎn)明視圖的圖形工具,下文繪制實(shí)現(xiàn)詳情,需要的小伙伴可以參考一下

前言

風(fēng)玫瑰是由氣象學(xué)家用于給出如何風(fēng)速和風(fēng)向在特定位置通常分布的簡(jiǎn)明視圖的圖形工具。它也可以用來描述空氣質(zhì)量污染源。風(fēng)玫瑰工具使用Matplotlib作為后端。

安裝方式直接使用:

pip install windrose

導(dǎo)入模塊

import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import matplotlib.cm as cm
from math import pi
import windrose
from windrose import WindroseAxes, WindAxes, plot_windrose
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import cartopy.crs as ccrs
import cartopy.io.img_tiles as cimgt

讀取數(shù)據(jù)

df = pd.read_csv("./sample_wind_poitiers.csv", parse_dates=['Timestamp'])
df = df.set_index('Timestamp')

計(jì)算風(fēng)速的u、v分量

df['speed_x'] = df['speed'] * np.sin(df['direction'] * pi / 180.0)
df['speed_y'] = df['speed'] * np.cos(df['direction'] * pi / 180.0)

uv風(fēng)速散點(diǎn)圖(含透明度)

fig, ax = plt.subplots(figsize=(8, 8), dpi=80)
x0, x1 = ax.get_xlim()
y0, y1 = ax.get_ylim()
ax.set_aspect(abs(x1-x0)/abs(y1-y0))
ax.set_aspect('equal')
ax.scatter(df['speed_x'], df['speed_y'], alpha=0.25)
df.plot(kind='scatter', x='speed_x', y='speed_y', alpha=0.05, ax=ax)
Vw = 80
ax.set_xlim([-Vw, Vw])
ax.set_ylim([-Vw, Vw])

風(fēng)玫瑰圖(多種形式)

ax = WindroseAxes.from_ax()
ax.bar(df.direction.values, df.speed.values, bins=np.arange(0.01,10,1), cmap=cm.hot, lw=3)
ax.set_legend()

ax = WindroseAxes.from_ax()
ax.box(df.direction.values, df.speed.values, bins=np.arange(0.01,10,1), cmap=cm.hot, lw=3)
ax.set_legend()

plot_windrose(df, kind='contour', bins=np.arange(0.01,8,1), cmap=cm.hot, lw=3)

繪制特定月份風(fēng)玫瑰圖

def plot_month(df, t_year_month, *args, **kwargs):
    by = 'year_month'
    df[by] = df.index.map(lambda dt: (dt.year, dt.month))
    df_month = df[df[by] == t_year_month]
    ax = plot_windrose(df_month, *args, **kwargs)
    return ax
plot_month(df, (2014, 7), kind='contour', bins=np.arange(0, 10, 1), cmap=cm.hot)

plot_month(df, (2014, 8), kind='contour', bins=np.arange(0, 10, 1), cmap=cm.hot)

plot_month(df, (2014, 9), kind='contour', bins=np.arange(0, 10, 1), cmap=cm.hot)

繪制風(fēng)速頻率直方圖

bins = np.arange(0,30+1,1)
bins = bins[1:]
plot_windrose(df, kind='pdf', bins=np.arange(0.01,30,1),normed=True)

在地圖上繪制風(fēng)玫瑰圖

proj = ccrs.PlateCarree()
fig = plt.figure(figsize=(12, 6))
minlon, maxlon, minlat, maxlat = (6.5, 7.0, 45.85, 46.05)
main_ax = fig.add_subplot(1, 1, 1, projection=proj)
main_ax.set_extent([minlon, maxlon, minlat, maxlat], crs=proj)
main_ax.gridlines(draw_labels=True)
main_ax.add_wms(wms='http://vmap0.tiles.osgeo.org/wms/vmap0',layers=['basic'])
cham_lon, cham_lat = (6.8599, 45.9259)
passy_lon, passy_lat = (6.7, 45.9159)
wrax_cham = inset_axes(main_ax,
        width=1,
        height=1,
        loc='center',
        bbox_to_anchor=(cham_lon, cham_lat),
        bbox_transform=main_ax.transData,
        axes_class=windrose.WindroseAxes,

height_deg = 0.1
wrax_passy = inset_axes(main_ax,
        width="100%",
        height="100%",
        bbox_to_anchor=(passy_lon-height_deg/2, passy_lat-height_deg/2, height_deg, height_deg),
        bbox_transform=main_ax.transData,
        axes_class=windrose.WindroseAxes,
        )
wrax_cham.bar(df.direction.values, df.speed.values,bins=np.arange(0.01,10,1), lw=3)
wrax_passy.bar(df.direction.values, df.speed.values,bins=np.arange(0.01,10,1), lw=3)

for ax in [wrax_cham, wrax_passy]:
        ax.tick_params(labelleft=False, labelbottom=False)

最后:

這樣繪制出來的風(fēng)玫瑰看起來還是很漂亮的,并且也能夠大大提高工作效率,對(duì)于那些科研人員是很有幫助的。代碼以及圖片效果就放在上面了。

相關(guān)文章

  • Python?數(shù)據(jù)篩選功能實(shí)現(xiàn)

    Python?數(shù)據(jù)篩選功能實(shí)現(xiàn)

    這篇文章主要介紹了Python?數(shù)據(jù)篩選,無論是在數(shù)據(jù)分析還是數(shù)據(jù)挖掘的時(shí)候,數(shù)據(jù)篩選總會(huì)涉及到,這里我總結(jié)了一下python中列表,字典,數(shù)據(jù)框中一些常用的數(shù)據(jù)篩選的方法,需要的朋友可以參考下
    2023-04-04
  • Python獲取時(shí)間戳的幾種方法詳細(xì)示例

    Python獲取時(shí)間戳的幾種方法詳細(xì)示例

    這篇文章主要給大家介紹了關(guān)于Python獲取時(shí)間戳的幾種方法,時(shí)間戳通常是一個(gè)字符序列,唯一地標(biāo)識(shí)某一刻的時(shí)間,文中通過代碼示例介紹的非常詳細(xì),需要的朋友可以參考下
    2023-10-10
  • 利用Python開發(fā)微信支付的注意事項(xiàng)

    利用Python開發(fā)微信支付的注意事項(xiàng)

    如今支付的引入是很多互聯(lián)網(wǎng)產(chǎn)品都需要的。為了讓用戶用著更方便快捷,集成像支付寶、微信支付這樣的第三方支付也就成了常有的事。今天跟著小編就來看看微信支付開發(fā)中幾個(gè)值得注意的地方,涉及代碼之處均用 Python 編寫。
    2016-08-08
  • PyQt5 窗口切換與自定義對(duì)話框的實(shí)例

    PyQt5 窗口切換與自定義對(duì)話框的實(shí)例

    今天小編就為大家分享一篇PyQt5 窗口切換與自定義對(duì)話框的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-06-06
  • python數(shù)字轉(zhuǎn)對(duì)應(yīng)中文的方法總結(jié)

    python數(shù)字轉(zhuǎn)對(duì)應(yīng)中文的方法總結(jié)

    在本篇文章里小編給大家分享的是一篇關(guān)于python數(shù)字轉(zhuǎn)對(duì)應(yīng)中文的方法總結(jié)內(nèi)容,有興趣的朋友們可以跟著猜嘗試測(cè)試下。
    2021-08-08
  • Python小波變換去噪的原理解析

    Python小波變換去噪的原理解析

    這篇文章主要介紹了Python小波變換去噪,對(duì)于去噪效果好壞的評(píng)價(jià),常用信號(hào)的信噪比(SNR)與估計(jì)信號(hào)同原始信號(hào)的均方根誤差(RMSE)來判斷,需要的朋友可以參考下
    2021-12-12
  • python中的對(duì)數(shù)log函數(shù)表示及用法

    python中的對(duì)數(shù)log函數(shù)表示及用法

    在本篇文章里小編給大家整理了一篇關(guān)于python中的對(duì)數(shù)log函數(shù)表示及用法,有需要的朋友們可以學(xué)習(xí)下。
    2020-12-12
  • Pytest使用fixture實(shí)現(xiàn)token共享的方法

    Pytest使用fixture實(shí)現(xiàn)token共享的方法

    同學(xué)們?cè)谧鰌ytest接口自動(dòng)化時(shí),會(huì)遇到一個(gè)場(chǎng)景就是不同的測(cè)試用例需要有一個(gè)登錄的前置步驟,登錄完成后會(huì)獲取到token,用于之后的代碼中,本文給大家介紹Pytest使用fixture實(shí)現(xiàn)token共享的方法,感興趣的朋友一起看看吧
    2023-11-11
  • python實(shí)現(xiàn)可變變量名方法詳解

    python實(shí)現(xiàn)可變變量名方法詳解

    在本篇文章里小編給大家整理了關(guān)于python實(shí)現(xiàn)可變變量名的相關(guān)知識(shí)點(diǎn)內(nèi)容以及實(shí)例代碼,需要的朋友們參考下。
    2019-07-07
  • Python yield生成器和return對(duì)比代碼實(shí)例

    Python yield生成器和return對(duì)比代碼實(shí)例

    這篇文章主要介紹了Python yield生成器和return對(duì)比代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04

最新評(píng)論