%本脚本用于提取Micaps各类型数据至Matlab,并以结构变量方式储存
%若程序返回“找不到文件”,或者等意的英文表述并非错误。会自动跳过相应的内容
tic
clc;clear;
Rootdire='E:\sci\data\ksf';
Location=cell(3,1);
p=1;
Location{1}='\surface';Location{2}='\high';Location{3}='\physics';
address=[Rootdire,Location{p}];
title=cell(30,1);lev=cell(11,1);
title{1,1}='p0';title{2,1}='p0-p';title{3,1}='p3';title{4,1}='p3-p';
title{5,1}='p24';title{6,1}='p24-p';title{7,1}='plot';title{8,1}='pressure';
title{9,1}='r1-p';title{10,1}='r3-p';title{11,1}='r6';title{12,1}='r6-p';
title{13,1}='r12-p';title{14,1}='r24-5-p';title{15,1}='r24-8-p';
title{16,1}='special';title{17,1}='t0';title{18,1}='t0-p';title{19,1}='t24';
title{20,1}='t24-p';title{21,1}='td';title{22,1}='tg-p';title{23,1}='td-p';
title{24,1}='tmax';title{25,1}='tmax-p';title{26,1}='tmin';
title{27,1}='tmin-p';title{28,1}='uv';title{29,1}='vv-p';
title{30,1}='vv';title{31,1}='r24-5';title{32,1}='r24-8';
title{33,1}='detail';title{34,1}='plot';title{35,1}='height-p';
title{36,1}='height';title{37,1}='temper-p';title{38,1}='temper';
title{39,1}='t-td-p';title{40,1}='t-td';title{41,1}='vv-p';title{42,1}='vv';
title{43,1}='uv';title{44,1}='tlogp';title{45,1}='dh-p';title{46,1}='dt-p';
title{47,1}='qq';title{48,1}='rh';title{49,1}='thetse';title{50,1}='tt';
title{51,1}='ttadv';title{52,1}='qflux';title{53,1}='qfdiv';
title{54,1}='qadv';title{55,1}='ki';title{56,1}='ky';title{57,1}='si';
title{58,1}='vor';title{59,1}='voradv';title{60,1}='div';title{61,1}='omega';
title{62,1}='tadv';
lev{1,1}='1000';lev{2,1}='925';lev{3,1}='850';lev{4,1}='700';lev{5,1}='500';
lev{6,1}='400';lev{7,1}='300';lev{8,1}='250';lev{9,1}='200';lev{10,1}='150';
lev{11,1}='100';
if p==1
ll=1;ul=33;
elseif p==2
ll=34;ul=46;
elseif p==3
ll=47;ul=62;
end
while ll<=ul
if p==1
eval(['x=dos(''dir ' address '\' title{ll} ' /on /b /s > ' address '\' title{ll} '.txt'');']);
if x==1 %判断路径是否存在,若否则进入下一个路径读取
ll=ll+1;
continue
end
title1=title{ll};
title11=strrep(title1,'-','_');
if strcmp(title11,'plot')
title11='plot1';
end
eval(['global ' title11]);
eval([title11 '=struct([]);']);
eval([title11 '=data(address,title1);']);
ll=ll+1;
elseif p==2|p==3
eval(['x=dos(''dir ' address '\' title{ll} ' /on /b /s > ' address '\' title{ll} '.txt'');']);
if x==1
ll=ll+1;
continue
end
n=1;
while n<=11
eval(['x=dos(''dir ' address '\' title{ll} '\' lev{n} ' /on /b /s > ' address '\' title{ll} '.txt'');']);
if x==1 %判断路径是否存在,若否则进入下一个路径读取
n=n+1;
continue
end
title1=[title{ll},lev{n}];
title11=strrep(title1,'-','_');
if strcmp(title11,'plot')
title11='plot1';
end
eval(['global ' title11]);
eval([title11 '=struct([]);']);
eval([title11 '=data(address,title1);']);
n=n+1;
end
ll=ll+1;
end
end
toc