第八星系人气爱 发表于 2024-2-29 20:21:12

MATLAB—武汉市风场以及NO2空间分布


作者:第八星系-石头人
邮箱:2205455617@qq.com


读取数据
%% 武汉市风场以及NO2空间分布
clc;clear;close all

%% 导入数据
load nlon.mat    % 风场的经度数据
load nlat.mat    % 风场的纬度数据
load u.mat       % u分量空间分布数据
load v.mat       % v分量空间分布数据
load olon.mat    % NO2的经度数据
load olat.mat    % NO2的纬度数据
load NO2.mat   % NO2空间分布数据
loni = 113.45; lona = 115.3;% 武汉市范围
lati = 29.8; lata = 31.5;

%% 读取shp数据
cdL=shaperead('E:\武汉市\武汉市.shp');
cx=; cy=;画图
变量名解释见下表


% 风场利用m_vec函数,m_vec(s,lon,lat,u,u,Name1,Value1,Name2,Value2,...)
s = 6; % 设置风场箭头比例因子,可自行调节大小
figure('position',)   % 设置图片位置、大小
subplot(1,2,1)    % 多图
m_proj('miller','lon',,'lat',);   % 设置投影类型
m_contourf(olon,olat,W(:,:,1),'linestyle','none');      % NO2浓度填色
hold on
m_plot(cx,cy,'k','linewidth',1);% 绘制区域边界
hold on;
shading interp;
hold on
m_vec(s,nlon,nlat,U(:,:,1),V(:,:,1),'shaftwidth', 0.8, 'headlength', 4);
arr = m_vec(s,113.7,31.25,2,0,'shaftwidth',0.8,'headlength',4,'key','2 m/s');
% arr添加标注箭头
hold on;
m_grid('linestyle','none','xtick',(),'ytick',(),'FontSize',11);
caxis()
m_text(115,31.25,'(a)')
hold off

subplot(1,2,2)
m_proj('miller','lon',,'lat',);
m_contourf(olon,olat,W(:,:,2),'linestyle','none');
hold on
m_plot(cx,cy,'k','linewidth',1);
hold on;
shading interp;
hold on
m_vec(s,nlon,nlat,U(:,:,2),V(:,:,2),'shaftwidth', 0.8, 'headlength', 4);
hold on
m_grid('linestyle','none','xtick',(),'ytick',(),'FontSize',11);
m_text(115,31.25,'(b)')
caxis()
hold off

colormap(m_colmap('diverging'));% 设置色卡
level1 = {'10','20','30','40'};
axes('position',[.15,.001,.72,.2],'FontSize',10);
axis off

hh1 = colorbar('horizen');
hh1.Ticks = ;
hh1.TickLabels = level1;
caxis()
set(get(hh1,'title'),'string','\mug/m^{3}','FontName','Times New Roman','FontSize',11,'position',);图象

完整代码
%% 武汉市风场以及NO2空间分布
clc;clear;close all

%% 导入数据
load nlon.mat                                 % 风场的经度数据
load nlat.mat                                 % 风场的纬度数据
load olon.mat                                 % NO2的经度数据
load olat.mat                                 % NO2的纬度数据
load u.mat                                    % u分量空间分布数据
load v.mat                                    % v分量空间分布数据
load NO2.mat                                  % NO2空间分布数据
loni = 113.45; lona = 115.3;                  % 武汉市范围
lati = 29.8; lata = 31.5;

%% 读取shp数据
cdL=shaperead('E:\武汉市\武汉市.shp');
cx=; cy=;

%% 画图
% 风场利用m_vec函数,m_vec(s,lon,lat,u,u,Name1,Value1,Name2,Value2,...)
% 变量名解释见图
s = 6;                                                   % 设置风场箭头比例因子,可自行调节大小
figure('position',)                     % 设置图片位置、大小
subplot(1,2,1)                                           % 多图
m_proj('miller','lon',,'lat',);    % 设置投影类型
m_contourf(olon,olat,W(:,:,1),'linestyle','none');       % NO2浓度填色
hold on
m_plot(cx,cy,'k','linewidth',1);                         % 绘制区域边界
hold on;
shading interp;
hold on
m_vec(s,nlon,nlat,U(:,:,1),V(:,:,1),'shaftwidth', 0.8, 'headlength', 4);
arr = m_vec(s,113.7,31.25,2,0,'shaftwidth',0.8,'headlength',4,'key','2 m/s');
% arr添加标注箭头
hold on;
m_grid('linestyle','none','xtick',(),'ytick',(), ...
    'FontSize',11);
caxis()
m_text(115,31.25,'(a)')
hold off

subplot(1,2,2)
m_proj('miller','lon',,'lat',);
m_contourf(olon,olat,W(:,:,2),'linestyle','none');
hold on
m_plot(cx,cy,'k','linewidth',1);
hold on;
shading interp;
hold on
m_vec(s,nlon,nlat,U(:,:,2),V(:,:,2),'shaftwidth', 0.8, 'headlength', 4);
hold on
m_grid('linestyle','none','xtick',(),'ytick',(), ...
    'FontSize',11);
m_text(115,31.25,'(b)')
caxis()
hold off

colormap(m_colmap('diverging'));                        % 设置色卡
level1 = {'10','20','30','40'};
axes('position',[.15,.001,.72,.2],'FontSize',10);
axis off
hh1 = colorbar('horizen');
hh1.Ticks = ;
hh1.TickLabels = level1;
caxis()
set(get(hh1,'title'),'string','\mug/m^{3}','FontName','Times New Roman', ...
    'FontSize',11,'position',);微信搜索“第八星系人造大气理论爱好者”公众号,关注获取文章数据


页: [1]
查看完整版本: MATLAB—武汉市风场以及NO2空间分布