爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2620|回复: 1

求助

[复制链接]
回帖奖励 10 金钱 回复本帖可获得 1 金钱奖励! 每人限 1 次

新浪微博达人勋

发表于 2022-8-22 22:19:25 | 显示全部楼层 |阅读模式
NCL
系统平台: 气象家园
问题截图:
问题概况: 想把正方形图变成圆形的
我看过提问的智慧: 看过
自己思考时长(天): 2

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

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

x
大佬们,我想把正方形图变成圆形图,纬度是40-90,经度0-360.

import matplotlib.pyplot as plt
import matplotlib as mpl
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
from netCDF4 import Dataset
import numpy as np
import xarray as xr
from cartopy.util import add_cyclic_point
plt.rcParams['font.sans-serif']=['Arial']#显示中文
plt.rcParams['axes.unicode_minus']=False
def make_map(ax):
    projection = ccrs.Orthographic(central_longitude=-90,central_latitude=90)
    ax.set_global()
    ax.coastlines(linewidth=0.5)
    '''标注坐标轴'''
    # ax.set_xticks(np.linspace(-180, 180, 1), crs=projection)
    # ax.set_yticks(np.linspace(-90, 90,5), crs=projection)
    '''zero_direction_label=True 有度的标识,False则去掉'''
    lon_formatter = LongitudeFormatter(zero_direction_label=True)
    lat_formatter = LatitudeFormatter()
    # ax.xaxis.set_major_formatter(lon_formatter)
    # ax.yaxis.set_major_formatter(lat_formatter)
    '''添加网格线'''
    #gl = ax.gridlines()
    #ax.grid()
    return ax
data=xr.open_dataset(r'Z:\shuju\o3\nc\OMI0401.nc')
lat = data['lat'].loc[:]
lon = data['lon'][:]
o3=data['ColumnAmountO3'].loc[:,:]
data_crs = ccrs.PlateCarree()
plt.figure(dpi=1200)
ax = plt.axes(projection=ccrs.NorthPolarStereo())#在这里必须设置相对应的经纬度的中心位置,如果不设置的话是无法出图的!
ax = make_map(ax)
ax.set_extent([-180, 180, 40, 90], crs=ccrs.PlateCarree())
ax.gridlines(color='black', linestyle=':', linewidth=0.5, xlocs = np.arange(-180,180,45), ylocs = np.linspace(0,90,6),draw_labels=True)
cf = ax.contourf(lon, lat, o3, cmap='Spectral_r',levels=np.arange(180,525,15),transform=data_crs)
ax.set_title('2020/04/01\nOMI',x=0.8,y=1,fontsize=10)
plt.colorbar(cf, pad=0.042, orientation='horizontal', shrink=0.87, aspect=35)
plt.tick_params(labelsize=10)
#plt.savefig('Z:\\shuju\\o3\\fig\\map\\OMI-0401-o3.png',dpi=1200, bbox_inches='tight')


密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2022-8-22 22:21:47 来自手机 | 显示全部楼层
正方形图

                               
登录/注册后可看大图
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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