经度范围
lon_beg = 127.875 ;
lon_end = 130 ;
lon0 = lon1d(1) ;
%经纬度始末坐标序号
lat_beg_p = fix((lat_beg +35.125)/0.25) + 1;
lat_end_p = fix((lat_end +35.125)/0.25) +1 ;
lon_beg_p = fix((lon_beg -lon0)/0.25) + 1;
lon_end_p = fix((lon_end -lon0)/0.25) +1;
hhx = (hh(1:end-1)+hh(2:end))*0.5;
hhxp1 = [0 hhx'] ;
delth = hhxp1(2:end)-hhxp1(1:end-1);
deltx = a_earth*cos(lat_beg*deg2rad)*0.25*deg2rad ;
lon=lon1d(lon_beg_p:lon_end_p);
for ix=1:length(lon)
for iz = 1:length(delth)
dxdh(iz,ix)= delth(iz)*deltx;
end
end
vv = squeeze(vmean(1:c21, lat_beg_p:lat_end_p, lon_beg_p:lon_end_p));
vvarea = vv .* dxdh ;
tspt_lon = sum(vvarea, 1)*cons1m6 ;
tot_tspt = sum(vvarea(:))*cons1m6 ;
第二部分
此部分为东西向输送,红色字体为根据第一部分做的相应改动
更改的最关键地方是将第一部分的代码
deltx = a_earth*cos(lat_beg*deg2rad)*0.25*deg2rad ;
更改为
delty = a_earth*cos(lon_beg*deg2rad)*0.25*deg2rad ;
完整代码如下:
%东西走向的输送
clc;clear all;
cd('J:\transport2')
%load('J:\transport2\u_mean_3d_ecco2_2004.mat')
c21 = 21 ;
matin = ['J:\transport2\u_mean_3d_ecco2_2004.mat'] ; %载入平均场
load(matin) ;
%经纬度范围 东经127.85,南纬0.875到1.875
lon_beg =127.875;
lon_end =127.875;
lat_beg = -0.875;
lat_end = -1.875;
lon0 = lon1d(1) ;
% Compute the arrays needs for transport
lat_beg_p = fix((lat_beg +35.125)/0.25) + 1;
lat_end_p = fix((lat_end +35.125)/0.25) +1 ;
lon_beg_p = fix((lon_beg -lon0)/0.25) + 1;
lon_end_p = fix((lon_end -lon0)/0.25) +1 ;
deg2rad = pi/180;
a_earth = 6.371e6;
cons1m6 = 1.e-6 ;
hhy = (hh(1:end-1)+hh(2:end))*0.5;
hhyp1 = [0 hhy'] ;
delth = hhyp1(2:end)-hhyp1(1:end-1);
%以前是lat_beg乘以deg2rad
delty = a_earth*cos(lon_beg*deg2rad)*0.25*deg2rad ;
lat2d=lat1d(134:138);
%lat2d=1at1d(lat_beg_p:lat_end_p)%-5 to 0
for iy=1:length(lat2d)
for iz = 1:length(delth)
dydh(iz,iy)= delth(iz)*delty;
end
end
vv = squeeze(vmean(1:c21, 134:138, lon_beg_p:lon_end_p));
vvarea = vv .* dydh ;
tspt_lat = sum(vvarea, 1)*cons1m6 ; %每列之和
tot_tspt = sum(vvarea(:))*cons1m6 ; %所有元素之和