ECMWF风场制作dfs2 matlab程序,可以类比做dfs2
info = ncinfo('00.nc');
name=['00.nc']; %%%nc路径
lat=ncread(name,'latitude');
lon=ncread(name,'longitude');
time=ncread(name,'time');
wind_u =ncread(name,'u10'); %%%10m u-component of wind
wind_v =ncread(name,'v10'); %%%10m v-component of wind
wind_sp =ncread(name,'sp'); %%%%the surface pressure
latcount = size(lat,1);
loncount = size(lon,1);
t = size(time,1);
wind_end =[];
for k=1:t
i = k-1; %%%0开始排
str = """tstep"" " + i + " ""item"" " +1 + " ""layer"" " + 0;
A = wind_u(:,:,k);
A = num2str(A);
A = [str;A];
A = [A;''];
str = """tstep"" " + i + " ""item"" " +2 + " ""layer"" " + 0;
B = wind_v(:,:,k);
B = num2str(B);
B = [str;B];
B = [B;''];
str = """tstep"" " + i + " ""item"" " +3 + " ""layer"" " + 0;
C = wind_sp(:,:,k);
C = num2str(C);
C = [str;C];
C = [C;''];
wind_and =[A;B;C];
wind_end = [wind_end;wind_and];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%仅需要更改title4%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
title1= """Title"" "+"""File Title""";%这行不用更改
title2 = """Dim"" "+2;%2代表·2维
title3 = """Geo"" "+"""LONG/LAT"" "+lon(1)+" "+ lat(latcount) + " " + 0;
%title3 = """Geo"" "+"""LONG/LAT"" "+lon[loncount]+" "+ lat[latcount] + " " +
%0;只需要改lon和lat注意空格分别对应经度开始和维度开始,不用更改,自动读取
w = t-1;
title4 = """Time"" "+"""EqudistantTimeAxis"" "+"""2020-04-16"" "+"""00:00:00"" "+w+ " "+ 7200;
% title4 = """Time"" "+"""EqudistantTimeAxis"" "+"""2020-04-16"" "+"""00:00:00"" "+w+ " "+ 7200;
%%%%%2020-04-16开始日期 需要更改
%%%%%00:00:00 开始时间 需要更改
%%%%%7200时间间隔秒 需要更改
dy = lon(2)-lon(1);
dx = lat(1)-lat(2);
title5 = """NoGridPoints"" "+latcount+" "+loncount;
title6 = """Spacing"" " +dx+" "+dy;
title7 = """NoStaticItems"" "+0;
title8 = """NoDynamicItems"" "+3;
title9 = """Item"" "+"""wx"" "+"""Wind speed"" "+"""m/s""";
title10 = """Item"" "+"""wy"" "+"""Wind speed"" "+"""m/s""";
title11 = """Item"" "+"""p"" " + """Pressure"" "+"""Pascal""";
title12 = "NoCustomBlocks "+1;
title13 = """M21_Misc"" "+1+" "+7+" "+0+" "+"-1E-030"+" "+-900+" "+10+" "+"-1E-030"+" "+"-1E-030"+" "+"-1E-030";
title14 = """Delete"" "+"-1E-030";
title15 = """DataType"" "+0;
title =[title1;title2;title3;title4;title5;title6;title7;title8;title9;title10;title11;title12;title13;title14;title15;' '];
wind_end = [title;wind_end];
fid = fopen('0.txt','wt');
fprintf(fid,'%s\n',wind_end);
fclose(fid);