2021-09-14

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);
  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值