爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5577|回复: 0

[经验总结] 短期气候预测实习1

[复制链接]

新浪微博达人勋

发表于 2022-6-17 00:27:54 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 xiaoxiao啊 于 2022-6-18 19:29 编辑

基于jupyter notebook


# 导入所需库
import numpy as np
import pandas as pd
import xarray as xr
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter


# 更改字体
plt.rcParams['font.sans-serif'] = ['Times New Roman']
plt.rcParams['axes.unicode_minus'] = False


# 处理数据
f = xr.open_dataset('hgt.mon.mean.nc')  # 读取数据集
hgt48_07 = f.hgt.loc[f.time.dt.month.isin([1]), 500, 80:-20].loc['1948':'2007']
hgt08 = f.hgt.loc['2008-01', 500, 80:-20].squeeze()  # 2008年1月数据
x1 = hgt48_07.mean('time')  # 1月(1948-2007)平均
x2 = hgt08 - hgt48_07.mean('time')  # 2008年1月距平
x3 = hgt08 - hgt08.mean('lon')  # 2008年1月纬偏值


# 绘画气候态
def clim_plot():
    fig = plt.figure(figsize=(6, 3), facecolor='w')
    ax = fig.add_axes([0, 0.1, 0.95, 0.9], projection=ccrs.PlateCarree(180))
    ax.set_title(' Jan(1948-2007) Ave 500hPa height', loc='left', fontsize=13)
    ax.add_feature(cfeature.COASTLINE.with_scale('110m'), linewidth=0.6, edgecolor='k')
    ax.set_xticks(np.arange(0, 360, 60), crs=ccrs.PlateCarree())
    ax.set_yticks(np.arange(-20, 100, 20), crs=ccrs.PlateCarree())
    ax.xaxis.set_major_formatter(LongitudeFormatter())
    ax.yaxis.set_major_formatter(LatitudeFormatter())
    ax.tick_params(which='major', width=0.5, length=5)
    ax.set_aspect(1.5)
    ax.spines['geo'].set_linewidth(0.5)
    m = ax.contourf(f.lon, f.lat.loc[80:-20], x1, cmap='jet', levels=np.arange(5000, 6000, 100), transform=ccrs.PlateCarree())

    cax = fig.add_axes([0.1, -0.08, 0.75, 0.06])
    cb = fig.colorbar(m, cax=cax, orientation='horizontal', ticks=np.arange(5100, 5900, 100))
    cb.outline.set_linewidth(0.1)
    cb.ax.tick_params(length=0)

clim_plot()


# 绘画距平场
def ano_plot():
    levels = list(np.arange(-150, 180, 30))
    levels.remove(0)

    fig = plt.figure(figsize=(6, 3), facecolor='w')
    ax = fig.add_axes([0, 0.1, 0.95, 0.9], projection=ccrs.PlateCarree(180))
    ax.spines['geo'].set_linewidth(0.5)
    ax.set_title(' Jan2008 500hPa height Ano', loc='left', fontsize=13)
    ax.add_feature(cfeature.COASTLINE.with_scale('110m'), linewidth=0.6, edgecolor='k')
    ax.set_xticks(np.arange(0, 360, 60), crs=ccrs.PlateCarree())
    ax.set_yticks(np.arange(-20, 100, 20), crs=ccrs.PlateCarree())
    ax.xaxis.set_major_formatter(LongitudeFormatter())
    ax.yaxis.set_major_formatter(LatitudeFormatter())
    ax.tick_params(which='major', width=0.5, length=5)
    m = ax.contourf(f.lon, f.lat.loc[80:-20], x2, cmap='bwr', extend='both', levels=levels, transform=ccrs.PlateCarree())
    ax.set_aspect(1.5)

    cax = fig.add_axes([0.1, -0.05, 0.75, 0.04])
    cb = fig.colorbar(m, cax=cax, orientation='horizontal', ticks=levels)
    cb.outline.set_linewidth(0.1)
    cb.ax.tick_params(length=0)

ano_plot()


# 绘画纬偏场
def zonal_depart_plot():
    levels = list(np.arange(-250, 300, 50))
    levels.remove(0)

    fig = plt.figure(figsize=(6, 3), facecolor='w')
    ax = fig.add_axes([0, 0.1, 0.95, 0.9], projection=ccrs.PlateCarree(180))
    ax.set_title(' Jan2008 500hPa height zonal departure', loc='left', fontsize=13)
    ax.add_feature(cfeature.COASTLINE.with_scale('110m'), linewidth=0.6, edgecolor='k')
    ax.set_xticks(np.arange(0, 360, 60), crs=ccrs.PlateCarree())
    ax.set_yticks(np.arange(-20, 100, 20), crs=ccrs.PlateCarree())
    ax.xaxis.set_major_formatter(LongitudeFormatter())
    ax.yaxis.set_major_formatter(LatitudeFormatter())
    ax.tick_params(which='major', width=0.5, length=5)
    ax.spines['geo'].set_linewidth(0.5)
    ax.set_aspect(1.5)
    m = ax.contourf(f.lon, f.lat.loc[80:-20], x3, cmap='bwr', extend='both', levels=levels, transform=ccrs.PlateCarree())

    cax = fig.add_axes([0.1, -0.05, 0.75, 0.04])
    cb = fig.colorbar(m, cax=cax, orientation='horizontal', ticks=levels)
    cb.outline.set_linewidth(0.1)
    cb.ax.tick_params(length=0)

zonal_depart_plot()

1948-2007年1月平均高度场

1948-2007年1月平均高度场

2008年1月的高度距平图

2008年1月的高度距平图

2008年1月的高度场纬偏图

2008年1月的高度场纬偏图
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表