竈門炭治郎712 2022-06-24 13:01 采纳率: 0%
浏览 15

海洋遥感第8题第888888题

m.drawparallels(np.arange(-1., 45., 9.), labels=[1,0,0,0], fontsize=10) #纬线
#为地图添加上海岸线和经纬网格
m.drawmeridians(np.arange(102., 134., 6.), labels=[0,0,0,1], fontsize=10) #经线
m.drawcoastlines()
m.fillcontinents(color='gray')#为陆地填色

cs=m.pcolor(lon,lat,chl,cmap="jet") #绘制浓度分布
cbar = m.colorbar(cs ,ticks=[-4,-3,-2,-1, 0, 1, 2, 3, 4, 5],location='right', label='Log Chla(\mug/L)',pad = '10%')
#显示颜色图例
plt.title('Global distribution of chlorophyll concentration ',fontsize='10')
#添加标题
plt.savefig('C:\Auseful/china.png',dpi=300,bbox_inches='tight') #保存图片,去掉图片周围空白

plt.show()

  • 写回答

1条回答 默认 最新

  • WisdomDevil 2022-06-24 16:26
    关注

    import netCDF4 as nc
    import numpy as np
    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    import datetime
    file=nc.Dataset("sst.wkmean.1990-present.nc")
    lon = file.variables['lon'][:] #经度
    lat = file.variables['lat'][:] #纬度
    sst = file.variables['sst'][:] #海表温度
    time = file.variables['time'][:] #时间
    time_bnds = file.variables['time_bnds'][:] #时间段
    stdate = [1800,1,1]#days since 1800-1-1 00:00:00,起始时间
    time1 = datetime.date(1998,1,1) - datetime.date(1800,1,1) #1998.1.1 距起始时间的天数
    time2 = datetime.date(1998,1,31) - datetime.date(1800,1,1) #1998.1.31 距起始时间的天数
    trange = np.where((time >= time1.days)&(time <= time2.days),1,0)#找出所有一月的数据
    time9019 = time[trange==1]
    sstmean9019 = np.mean(sst[trange==1,:,:],0)#90到19的平均值
    lons, lats = np.meshgrid(lon, lat)
    m=Basemap()
    m=Basemap(lat_0=21,lon_0=117,llcrnrlon=102,llcrnrlat=0,urcrnrlon=132,urcrnrlat=42,projection='lcc',resolution='l')
    m.drawparallels(np.arange(-90.,91.,9.),labels=[1,0,0,0],fontsize=10)
    m.drawmeridians(np.arange(-180.,181.,6.),labels=[0,0,0,1],fontsize=10)
    m.drawcoastlines()
    m.fillcontinents(color='grey')
    lons,lats=m(lons,lats)
    cs=m.contourf(lons,lats,sstmean9019,range(0,35,1),cmap='jet')
    cbar = m.colorbar(cs,pad="10%",label='Sea Surface Temperature(degC)') #显示颜色图例
    plt.title('Distribution of SST near China',fontsize=10)
    plt.show()
    plt.close()

    time1 = datetime.date(1998,7,1) - datetime.date(1800,1,1) #1998.1.1 距起始时间的天数
    time2 = datetime.date(1998,7,31) - datetime.date(1800,1,1) #1998.1.31 距起始时间的天数
    trange = np.where((time >= time1.days)&(time <= time2.days),1,0)#找出所有一月的数据
    time9019 = time[trange==1]
    sstmean9019 = np.mean(sst[trange==1,:,:],0)#90到19的平均值
    lons, lats = np.meshgrid(lon, lat)
    m=Basemap()
    m=Basemap(lat_0=21,lon_0=117,llcrnrlon=102,llcrnrlat=0,urcrnrlon=132,urcrnrlat=42,projection='lcc',resolution='l')
    m.drawparallels(np.arange(-90.,91.,9.),labels=[1,0,0,0],fontsize=10)
    m.drawmeridians(np.arange(-180.,181.,6.),labels=[0,0,0,1],fontsize=10)
    m.drawcoastlines()
    m.fillcontinents(color='grey')
    lons,lats=m(lons,lats)
    cs=m.contourf(lons,lats,sstmean9019,range(0,35,1),cmap='jet')
    cbar = m.colorbar(cs,pad="10%",label='Sea Surface Temperature(degC)') #显示颜色图例
    plt.title('Distribution of SST near China',fontsize=10)
    plt.show()
    plt.close()

    评论

报告相同问题?

问题事件

  • 创建了问题 6月24日