|
本帖最后由 45005TY 于 2024-6-13 13:18 编辑
教學部分:最好使用anaconda navigator 的jupyter notebook
在cmd 打conda install numpy,matplotlib,pandas,pint,pooch,pyproj,scipy,traitlets,xarray,
還有最重要conda install metpy
開jupyter notebook copy and paste以下的code
便會出鎮樓圖
- from datetime import datetime, timedelta
- import matplotlib.pyplot as plt
- import xarray as xr
- from metpy.calc import wind_components
- import metpy.calc as mpcalc
- from metpy.cbook import get_test_data
- from metpy.io import metar
- from metpy.plots.declarative import (BarbPlot, ContourPlot, FilledContourPlot, MapPanel,
- PanelContainer, PlotObs)
- from metpy.units import units
- import numpy as np
复制代码- run_date="20180907"
- init="18"
- forecast="174"
- url = f"https://thredds.rda.ucar.edu/thredds/dodsC/files/g/ds084.1/2018/{run_date}/gfs.0p25.{run_date}{init}.f{forecast}.grib2"
- data = xr.open_dataset(url)
复制代码- ds = data.metpy.sel(lat=slice(25,19), lon=slice(122,128))
复制代码 cfill 即是底色
- cfill = FilledContourPlot()
- cfill.data = ds
- cfill.field = 'Temperature_height_above_ground'
- cfill.level = 0*units.m
- cfill.colormap = 'gist_ncar'
- cfill.time=None
- cfill.colorbar = 'horizontal'
- cfill.plot_units='K'
- cfill.contours = list((range(233,313,2)))
复制代码 cntr2即是plot isobar
- cntr2 = ContourPlot()
- cntr2.data = ds
- cntr2.field = 'MSLP_Eta_model_reduction_msl'
- cntr2.linecolor = 'black'
- cntr2.linestyle = 'solid'
- cntr2.time=None
- cntr2.clabels = True
- cntr2.plot_units='hPa'
- cntr2.contours = list(range(870,1014,4))
复制代码 barbs即是barbs
- barbs = BarbPlot()
- barbs.data = ds
- barbs.time = None
- barbs.field = ['u-component_of_wind_isobaric', 'v-component_of_wind_isobaric']
- barbs.level = 1000* units.hPa
- barbs.skip = (5, 5)
- barbs.plot_units = 'knots'
- barbs.color='green'
复制代码- panel = MapPanel()
- panel.area = [122,128,19,25]
- panel.projection = 'mer'
- panel.layers = ['states', 'coastline', 'borders']
- panel.layers_edgecolor='black'
- panel.title = f'MSLP isobar at 2018091500Z ,{run_date}{init}Z run, Minimum pressure:{float(np.min(cfill.data.MSLP_Eta_model_reduction_msl))/100}hPa,Maximum Temperature:{int(np.max(cfill.data.Temperature_height_above_ground))}K'
- panel.plots = [cfill,cntr2,barbs]
复制代码- pc = PanelContainer()
- pc.size = (15,15)
- pc.panels=[panel]
复制代码 最後就是出圖
--------------------------------------------------------------------
2015年至今GFS及GEFS圖存檔
以下所有圖都是用python plot 的
鎮樓圖:山竹
(底色是溫度,以K為單位)
2016年1月極端寒潮
之後是重要過程前每日00Z的GFS圖存檔
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
评分
-
查看全部评分
|