- 积分
- 9
- 注册时间
- 2006-12-24
- 仿真币
-
- 最后登录
- 1970-1-1
|
望版主加点辛苦分!
function main_program
clc;clear;
%----注意:以下两行需要修改具体数字---------
x=119.23;y=38.71;mag=7.2;
t='2009年12月2日13时41分(北京时间)';
%-----------------------------------------
x=num2str(x);
y=num2str(y);
mag=num2str(mag);
a=load('D:\tjpg\matlab_pg\earthq_intens.txt');
%=========control the corner interp nodes==============
d1=0.8*mean(a(:,3));
d2=[116.7 38.5 d1;
116.7 40.3 d1;
118.1 38.5 d1;
118.1 40.3 d1];
a=[a
d2];
%=========earthquake intensity interp==================
num=[];lon2=[];la2=[];PGA=[];
fp2=fopen('D:\tjpg\matlab_pg\cal_nodes.txt','r');
sr=fgetl(fp2);
while 1
sr=fgetl(fp2);
if ~ischar(sr), break, end
if isempty(sr),break,end
[token,rem]=strtok(sr,',');
%numb=str2num(token);
%num=[num
% numb];
[token,rem]=strtok(rem,',');
long=str2num(token); lat=str2num(rem);
lon2=[lon2;
long];
la2=[la2;
lat];
end
fclose(fp2);
PGA=griddata(a(:,1),a(:,2),a(:,3),lon2,la2,'linear');
%-=====================================================
%attention: The population density is people/(km^2).
%======================================================
b=load('D:\tjpg\matlab_pg\tianjin_caln_popu.txt');
peop=b(:,3);
%==========================================
PGAA=4*10^(-16)*(PGA.^(15)); %========
peop=PGAA.*peop; %========
men=round(sum(peop)); %========
%==========================================
[xx,yy]=meshgrid(116.7:0.02:118.1,38.5:0.02:40.3);
[s1,s2]=size(xx);
uu=NaN(s1,s2);
mm=length(lon2);
for i2=1:1:mm
j=round( 50*( lon2(i2) -116.7 ) +1);
i=round( 50*( la2(i2) -38.5 ) +1);
uu(i,j)=peop(i2);
end
s=shaperead('D:\tjpg\matlab_pg\tj_mp\tianjin.shp');
%===========
%figure;
zft1=figure('units','normalized','position',...
[0.15 0.15 0.75 0.92],'visible','off');
set(gca,'position',[0.20 0.05 0.70 0.90]);
pcolor(xx,yy,uu);
shading interp;
colorbar;
hold on
hh=mapshow(s,'color','g');
set(hh,'LineWidth',1);
axis([116.65 118.12 38.45 40.35]);
box on
view(0,90);
men=num2str(men);
c1='The totle dead are';
c2=[' ', men,' people'];
men2={c1, c2};
text(117.7,38.6,men2,'FontSize',10,'EdgeColor','b');
caxis([1 20]);
xlabel('Tianjian Earthquake Incited Dead Distribution');
%------------------------------------------------------
clear b;clear peop;clear uu;
%-=====================================================
%attention: The GDP of calculation nodes has not been divided by grid area
%======================================================
b=load('D:\tjpg\matlab_pg\tianjin_caln_eco.txt'); %============
peop=b(:,3); %============
PGAB=2*10^(-10)*(PGA.^(11.6)); %============
peop=PGAB.*peop; %============
gdp=round(sum(peop)); %============
peop=peop./(0.02*111.1949)^2;
gdp=num2str(gdp);
%=======================================================
[xx,yy]=meshgrid(116.7:0.02:118.1,38.5:0.02:40.3);
[s1,s2]=size(xx);
uu=NaN(s1,s2);
mm=length(lon2);
for i2=1:1:mm
j=round( 50*( lon2(i2) -116.7 ) +1);
i=round( 50*( la2(i2) -38.5 ) +1);
uu(i,j)=peop(i2);
end
%=====================================================
%=====================================================
%=====================================================
Fpath='D:\tjpg';
CurrentDate = datestr(now,30); %return date form is (ISO 8601) yyyymmddTHHMMSS
Fpath = [Fpath '\' CurrentDate(1:8)];
if ~exist(Fpath)
mkdir( Fpath );
end
Fname = CurrentDate(1:13); Fext = '.doc';
Filespec = fullfile(Fpath,[Fname,Fext]);
ReportDoc = actxserver('Word.Application');
if ~exist(Filespec,'file');
MS = invoke(ReportDoc.Documents,'Add');
else
MS = invoke(ReportDoc.Documents,'Open',Filespec);
end
set(ReportDoc,'Visible',1);
documents = ReportDoc.Documents;
if exist(Filespec,'file');
document = invoke(documents,'Open',Filespec);
else
document = invoke(documents, 'Add');
document.SaveAs(Filespec);
end
content = MS.Content;
selection = ReportDoc.Selection;
paragraphformat = selection.ParagraphFormat;
document.PageSetup.TopMargin = 60;
document.PageSetup.BottomMargin = 45;
document.PageSetup.LeftMargin = 45;
document.PageSetup.RightMargin = 45;
title='强震台网地震灾情快速评估简报';
set(ReportDoc.Selection,'Text',title);
set(paragraphformat, 'Alignment','wdAlignParagraphCenter');
rr=document.Range(0,14);%选择文本范围
rr.Font.Size=25;%设置文本字体大小
rr.Font.Bold=6;%设置文本字体粗细
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph'); %回车换行
tt1='年';tt2='月';tt3='日';tt4='(';tt5=')';
tt0=[tt4,CurrentDate(1:4),tt1,CurrentDate(5:6),tt2,CurrentDate(7:8),tt3,tt5];
set(ReportDoc.Selection,'Text',tt0);
set(paragraphformat, 'Alignment','wdAlignParagraphCenter');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
%men=num2str(men);
tex1='据地震台网中心测定,';
tex2='在东经';
tex3='度,北纬';
tex4='度发生的Ms';
tex5=' 级地震,造成天津地区总死亡人数约为';
tex6='人,GDP损失总数约为';
tex7='万元,具体灾情分布见图1、图2,地震引起的烈度场分布见图3:';
tex=[' ',tex1,t,tex2,x,tex3,y,tex4,mag,tex5,men,tex6,gdp,tex7];
set(ReportDoc.Selection,'Text',tex);
set(paragraphformat, 'Alignment','wdAlignParagraphLeft');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
print(gcf,'-dmeta');
invoke(ReportDoc.Selection,'Paste');
delete(zft1);
tex=' Fig 1. 地震造成的人员死亡分布图(单位:人/平方千米)';
set(ReportDoc.Selection,'Text',tex);
set(paragraphformat, 'Alignment','wdAlignParagraphCenter');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
%-----------------------------
zft2=figure('units','normalized','position',...
[0.15 0.15 0.75 0.92],'visible','off');
set(gca,'position',[0.20 0.05 0.70 0.90]);
pcolor(xx,yy,uu);
shading interp;
colorbar;
hold on
hh=mapshow(s,'color','g');
set(hh,'LineWidth',1);
axis([116.65 118.12 38.45 40.35]);
box on
view(0,90);
c1='The totle GDP lost is';
c2=[' ', gdp,'0000Yuan'];
gdp={c1, c2};
text(117.65,38.6,gdp,'FontSize',10,'EdgeColor','b');
caxis([100 20000]);
xlabel('Tianjian Earthquake GDP Lost');
print(gcf,'-dmeta');
invoke(ReportDoc.Selection,'Paste');
delete(zft2);
tex=' Fig 2. 地震造成的GDP损失分布图(单位:万元/平方千米)';
set(ReportDoc.Selection,'Text',tex);
set(paragraphformat, 'Alignment','wdAlignParagraphCenter');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
zft3=figure('units','normalized','position',...
[0.15 0.15 0.75 0.92],'visible','off');
set(gca,'position',[0.20 0.05 0.70 0.90]);
PGA_image2;
print(gcf,'-dmeta');
invoke(ReportDoc.Selection,'Paste');
delete(zft3);
tex=' Fig 3. 地震造成的地震烈度分布图';
set(ReportDoc.Selection,'Text',tex);
set(paragraphformat, 'Alignment','wdAlignParagraphCenter');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
tex=' 报:局领导';
set(ReportDoc.Selection,'Text',tex);
set(paragraphformat, 'Alignment','wdAlignParagraphLeft');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
tex=' 送:各有关处、室、部门';
set(ReportDoc.Selection,'Text',tex);
set(paragraphformat, 'Alignment','wdAlignParagraphLeft');
invoke(ReportDoc.Selection,'MoveDown');
invoke(ReportDoc.Selection, 'TypeParagraph');
% Close the presentation window:
invoke(MS,'Close');
% Quit MS Word
invoke(ReportDoc,'Quit');
delete(ReportDoc); |
评分
-
1
查看全部评分
-
|