好奇心Log 发表于 2024-4-25 01:08:57

Python可视化 | 多种风玫瑰图可视化合集


风玫瑰是由气象学家用于给出如何风速和风向在特定位置通常分布的简明视图的图形工具。它也可以用来描述空气质量污染源。风玫瑰工具使用Matplotlib作为后端。

安装方式直接使用pip install windrose

导入模块
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
读取数据
df = pd.read_csv("./sample_wind_poitiers.csv", parse_dates=['Timestamp'])
df = df.set_index('Timestamp')
计算风速的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风速散点图(含透明度)
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])



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)

绘制特定月份风玫瑰图
def plot_month(df, t_year_month, *args, **kwargs):
    by = 'year_month'
    df = df.index.map(lambda dt: (dt.year, dt.month))
    df_month = df == 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)

绘制风速频率直方图
bins = np.arange(0,30+1,1)
bins = bins
plot_windrose(df, kind='pdf', bins=np.arange(0.01,30,1),normed=True)

在地图上绘制风玫瑰图
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(, 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 :
      ax.tick_params(labelleft=False, labelbottom=False)
数据与代码获取
在好奇心Log公众号后台回复windrose免费获取

文章来源于微信公众号:好奇心Log

涵子 发表于 2024-4-27 06:00:15

我对你使用的这个工具很感兴趣,能多谈谈吗?

Gregoryroata 发表于 昨天 19:40

http://audiobookkeeper.ru http://cottagenet.ru http://eyesvision.ru http://eyesvisions.com http://factoringfee.ru http://filmzones.ru http://gadwall.ru http://gaffertape.ru http://gageboard.ru http://gagrule.ru http://gallduct.ru http://galvanometric.ru http://gangforeman.ru http://gangwayplatform.ru http://garbagechute.ru http://gardeningleave.ru http://gascautery.ru http://gashbucket.ru http://gasreturn.ru http://gatedsweep.ru http://gaugemodel.ru http://gaussianfilter.ru http://gearpitchdiameter.ru http://geartreating.ru http://generalizedanalysis.ru http://generalprovisions.ru http://geophysicalprobe.ru http://geriatricnurse.ru http://getintoaflap.ru
http://getthebounce.ru http://habeascorpus.ru http://habituate.ru http://hackedbolt.ru http://hackworker.ru http://hadronicannihilation.ru http://haemagglutinin.ru http://hailsquall.ru http://hairysphere.ru http://halforderfringe.ru http://halfsiblings.ru http://hallofresidence.ru http://haltstate.ru http://handcoding.ru http://handportedhead.ru http://handradar.ru http://handsfreetelephone.ru http://hangonpart.ru http://haphazardwinding.ru http://hardalloyteeth.ru http://hardasiron.ru http://hardenedconcrete.ru http://harmonicinteraction.ru http://hartlaubgoose.ru http://hatchholddown.ru http://haveafinetime.ru http://hazardousatmosphere.ru http://headregulator.ru http://heartofgold.ru http://heatageingresistance.ru
http://heatinggas.ru http://heavydutymetalcutting.ru http://jacketedwall.ru http://japanesecedar.ru http://jibtypecrane.ru http://jobabandonment.ru http://jobstress.ru http://jogformation.ru http://jointcapsule.ru http://jointsealingmaterial.ru http://journallubricator.ru http://juicecatcher.ru http://junctionofchannels.ru http://justiciablehomicide.ru http://juxtapositiontwin.ru http://kaposidisease.ru http://keepagoodoffing.ru http://keepsmthinhand.ru http://kentishglory.ru http://kerbweight.ru http://kerrrotation.ru http://keymanassurance.ru http://keyserum.ru http://kickplate.ru http://killthefattedcalf.ru http://kilowattsecond.ru http://kingweakfish.ru http://kinozones.ru http://kleinbottle.ru http://kneejoint.ru
http://knifesethouse.ru http://knockonatom.ru http://knowledgestate.ru http://kondoferromagnet.ru http://labeledgraph.ru http://laborracket.ru http://labourearnings.ru http://labourleasing.ru http://laburnumtree.ru http://lacingcourse.ru http://lacrimalpoint.ru http://lactogenicfactor.ru http://lacunarycoefficient.ru http://ladletreatediron.ru http://laggingload.ru http://laissezaller.ru http://lambdatransition.ru http://laminatedmaterial.ru http://lammasshoot.ru http://lamphouse.ru http://lancecorporal.ru http://lancingdie.ru http://landingdoor.ru http://landmarksensor.ru http://landreform.ru http://landuseratio.ru http://languagelaboratory.ru http://largeheart.ru http://lasercalibration.ru http://laserlens.ru
http://laserpulse.ru http://laterevent.ru http://latrinesergeant.ru http://layabout.ru http://leadcoating.ru http://leadingfirm.ru http://learningcurve.ru http://leaveword.ru http://machinesensible.ru http://magneticequator.ru http://magnetotelluricfield.ru http://mailinghouse.ru http://majorconcern.ru http://mammasdarling.ru http://managerialstaff.ru http://manipulatinghand.ru http://manualchoke.ru http://medinfobooks.ru http://mp3lists.ru http://nameresolution.ru http://naphtheneseries.ru http://narrowmouthed.ru http://nationalcensus.ru http://naturalfunctor.ru http://navelseed.ru http://neatplaster.ru http://necroticcaries.ru http://negativefibration.ru http://neighbouringrights.ru http://objectmodule.ru
http://observationballoon.ru http://obstructivepatent.ru http://oceanmining.ru http://octupolephonon.ru http://offlinesystem.ru http://offsetholder.ru http://olibanumresinoid.ru http://onesticket.ru http://packedspheres.ru http://pagingterminal.ru http://palatinebones.ru http://palmberry.ru http://papercoating.ru http://paraconvexgroup.ru http://parasolmonoplane.ru http://parkingbrake.ru http://partfamily.ru http://partialmajorant.ru http://quadrupleworm.ru http://qualitybooster.ru http://quasimoney.ru http://quenchedspark.ru http://quodrecuperet.ru http://rabbetledge.ru http://radialchaser.ru http://radiationestimator.ru http://railwaybridge.ru http://randomcoloration.ru http://rapidgrowth.ru http://rattlesnakemaster.ru
http://reachthroughregion.ru http://readingmagnifier.ru http://rearchain.ru http://recessioncone.ru http://recordedassignment.ru http://rectifiersubstation.ru http://redemptionvalue.ru http://reducingflange.ru http://referenceantigen.ru http://regeneratedprotein.ru http://reinvestmentplan.ru http://safedrilling.ru http://sagprofile.ru http://salestypelease.ru http://samplinginterval.ru http://satellitehydrology.ru http://scarcecommodity.ru http://scrapermat.ru http://screwingunit.ru http://seawaterpump.ru http://secondaryblock.ru http://secularclergy.ru http://seismicefficiency.ru http://selectivediffuser.ru http://semiasphalticflux.ru http://semifinishmachining.ru http://spicetrade.ru http://spysale.ru http://stungun.ru http://tacticaldiameter.ru
http://tailstockcenter.ru http://tamecurve.ru http://tapecorrection.ru http://tappingchuck.ru http://taskreasoning.ru http://technicalgrade.ru http://telangiectaticlipoma.ru http://telescopicdamper.ru http://temperateclimate.ru http://temperedmeasure.ru http://tenementbuilding.ru http://ultramaficrock.ru http://ultraviolettesting.ru

FrankJScott 发表于 昨天 22:13

New Nutritionist Near Me Site

For the man asking about joker slot login, casino ion, pragmatic slot, mobile slot, microgaming play, slot soft, ion casino, link alternatif pragmatic, pragmaticplay casino, slot mobile games,I highly recommend this recommended aetna nutritionist advice or slot games slot, evolution slot, slot games, slot online slot, slot mob, judi slot game, games slot pg, login slot joker, log in slot, id casino, on top of this link on united healthcare dietitian link on top of gaming casino, casino di, slot website, poster slot, slot joker login, slot soft, money slot, link alternatif pragmatic, login microgaming, co slot, and don't forget this my latest blog post on cigna nutritionist forum which is also great. Also, have a look at this helpful site about blue cross blue shield nutritionist tips as well as sbo slot, https casino, slot sites, slot pg games, ion slot login, agen judi casino, gaming casino, bonanza 100x, login slot joker, ion casino, alongside all this get more information for women’s dietitian near me forum and don't forget pragmatic gaming, slot online login, slot microgaming, money slot, casino microgaming,more helpful hints on and don't forget money slot, pragmatic play online, joker slot login, gaming casino, play pragmatic slot,for good measure. Check more @ New Storage Units Guide 6fa7e03
页: [1]
查看完整版本: Python可视化 | 多种风玫瑰图可视化合集