-
Notifications
You must be signed in to change notification settings - Fork 0
/
LUCY_datasummary_v1cmd.m
69 lines (63 loc) · 1.91 KB
/
LUCY_datasummary_v1cmd.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function [YYYYclose,tabdata,tempmonth]=LUCY_datasummary_v1cmd(startdate,use_opt,WD)
% WD=pwd;
YYYY=datevec(startdate);
YYYY=YYYY(1);
datafolder='Data';
% Temperature
if use_opt==1
tempday=1;
tempmonth=0;
else
tempday=0;
if exist([WD,'\',datafolder,'\temperature\air_temp.',num2str(YYYY)],'file')>0
tempmonth=1;
else
tempmonth=0;
end
end
% Population
for i=1900:2099
pop(i)=exist([WD,'\',datafolder,'\population\popcell_',num2str(i),'.mat'],'file');
end
avail=find(pop>0);
clos=abs(avail-YYYY);
tmp=min(clos);
pos=clos==tmp;
if sum(pos)>1
postmp=find(pos==1,1);
pos(:,:)=0;
pos(postmp)=1;
end
YYYYclose=avail(pos);
% Energy
energytable=importdata([WD,'\',datafolder,'\','energy.txt']);
energytable=energytable.data;
datatable1=energytable(2:232,:);
energyyeartab=findclosestyear(datatable1,YYYY);
% energytab=energytable(2:232,YYYY-1900+1);
% Traffic
carstable=importdata([WD,'\',datafolder,'\','Cars.txt']);
carstable=carstable.data;
datatable2=carstable(2:232,:);
carsyeartab=findclosestyear(datatable2,YYYY);
% carstab=carstable(2:232,YYYY-1900+1);
freightstable=importdata([WD,'\',datafolder,'\','Freights.txt']);
freightstable=freightstable.data;
datatable3=freightstable(2:232,:);
freightsyeartab=findclosestyear(datatable3,YYYY);
% freightstab=freightstable(2:232,YYYY-1900+1);
mbikestable=importdata([WD,'\',datafolder,'\','Motorbikes.txt']);
mbikestable=mbikestable.data;
datatable4=mbikestable(2:232,:);
mbikesyeartab=findclosestyear(datatable4,YYYY);
% mbikestab=mbikestable(2:232,YYYY-1900+1);
tabdata=[energyyeartab carsyeartab freightsyeartab mbikesyeartab];
mbikestable=importdata([WD,'\',datafolder,'\','Motorbikes.txt']);
mbikestable.rowheaders=mbikestable.rowheaders(2:232);
save('tempday','tempday')
save('tempmonth','tempmonth')
save('YYYY','YYYY')
save('YYYYclose','YYYYclose')
save('mbikestable','mbikestable')
save('tabdata','tabdata')
% DataSummary()