水深地形图

水深地形图

1. 转置

1.1 代码示例

Filename='filename.nc'; 
lon=ncread(Filename,'LON');  % 115-140
lat=ncread(Filename,'LAT');    % 15-40
dep=ncread(Filename,'BATHY'); 
dep=dep';

重点注意,水深数据dep需要进行转置

1.2 解释说明

A = [ a 11 a 12 . . . a 14 a 15 a 21 a 22 . . . a 14 a 25 . . a 41 a 42 . . . a 14 a 45 ] A=\begin{bmatrix}a_{11} &a_{12}&...&a_{14}&a_{15} \\ a_{21} &a_{22}&...&a_{14}&a_{25} \\ ..\\ a_{41} &a_{42}&...&a_{14}&a_{45} \\ \end{bmatrix} A=a11a21..a41a12a22a42.........a14a14a14a15a25a45 对4×5型 A A A矩阵进行转置得到 A T A^{T} AT为5×4型矩阵 A T = [ a 11 a 21 . . . a 41 a 12 a 22 . . . a 42 a 13 a 23 . . . a 43 . . . a 15 a 25 . . . a 45 ] A^{T}=\begin{bmatrix} a_{11} & a_{21} &...& a_{41} \\ a_{12} & a_{22} &...& a_{42}\\ a_{13} & a_{23} &...& a_{43}\\ ...\\ a_{15} & a_{25} &...& a_{45}\\ \end{bmatrix} AT=a11a12a13...a15a21a22a23a25............a41a42a43a45
对于nc文件中的水深数据,其维度:

Dimensions: LON17701_19201,LAT6301_7801,TIME

重构网格点meshgrid后得到的网格同为(lon,lat),但区别如下:
\qquad 在这里插入图片描述 \qquad\quad 在这里插入图片描述
如左图,假设标记处 a 34 a_{34} a34表示其lon=30,lat=40的水深,但发现若在地图中标记处应为lon=40,lat=30,因此对 A A A进行转置得到 A T A^{T} AT后,标记处变为 a 43 a_{43} a43,恰好与lon=40,lat=30与其对应。
故:在进行一般绘图时需要考虑是否进行转置!

2. plot水深地形图

2.1 代码示例

f=figure(id);
m_proj('mercator','lon',[115,140],'lat',[15,40]); 
m_contourf(lon,lat,dep,50,'linestyle','none');     
m_gshhs_f('Color','g','LineWidth',0.6,'LineStyle','-.');    
m_grid('linestyle',':','box','fancy','tickdir','out','linecolor','w','alpah','0.5');

设置投影和,等值线填充,海岸线,格点

2.2 部分参数详解

m_proj('投影方式','long',[lonmin lonmax],'lat',[latmin latmax]);

2.2.1 等值线

m_contourf(x,y,z,level,LineSpec,'ShowText','LineWidth','LabelSpacing');

   1 o 1^o 1o. x,y,z的维度size应该一致,若x,y分别为 1 × n , m × 1 1×n,m×1 1×n,m×1,则可以通过meshgrid进行重构网格,最终得到相同大小的x,y,z;

% reshap size
[X,Y]=meshgrid(x,y) % produce the coordinates of a rectangular grid (X, Y).
cat(DIM,A,B)        % cat(2,A,B) is the same as [A,B].
                    % cat(1,A,B) is the same as [A;B].

   2 o 2^o 2o. level表示层级,可以为层级数也可以是一个或几个特定的层级;

contourf(X,Y,Z,10)
contourf(X,Y,Z,[2 3])
contourf(X,Y,Z,[2 2])

level=10level=[2 3]level=[2 2]
上述三幅图来自于mathworks,分别表示level=50,[2 3],[2 2]的结果;
   3 o 3^o 3o. LineSpec表示线性

contourf(X,Y,Z,50'b--');
contourf(X,Y,Z,50,'linestyle','--','color','blue'

两种呈现结果相同,均显示蓝色虚线的线条格式
   4 o 4^o 4o. ShowText表示等高线标签

2.2.2 海岸线

m_gshhs(RES,'patch' ( ,standard patch options,...,...) )

在这里插入图片描述

2.2.3 网格相关参数

在这里插入图片描述

3. colormap

hh=colorbar;                           
set(hh,'position',[0.78 0.1 0.02 0.8]);
caxis([-7000 3000]);
set(hh,'ytick',-7000:1000:3000,'yticklabel',-7000:1000:3000);
colormap([ m_colmap('blues(1)',70); m_colmap('greens',30)]);

3.1 常见的colormap/m_colmap

在这里插入图片描述
在这里插入图片描述

3.2 特殊拼接用法

   1 o 1^o 1o. flipud翻转colormap

colormap(m_colmap('blues'));

正常

colormap(flipud(m_colmap('blues')));

翻转

   2 o 2^o 2o. colormap拼接

colormap([ m_colmap('blues',70); m_colmap('greens',30)]);

拼接
表示blues与greens两个colmap的比例为7:3

  • 8
    点赞
  • 58
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值