Makefile
5.29 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
all: subregion
D = $$0
S = $
O = $$1
T = $$2
R = $$3
subregion: xy
sed s/$(S)/,NorthEast/ subregions/i_fulleast > i.csv
sed s/$(S)/,NorthWest/ subregions/i_fullwest > ii.csv
sed s/$(S)/,PaivaWest/ subregions/ip_continent > iii.csv
sed s/$(S)/,PaivaIslands/ subregions/ip_notmideast > iiii.csv
sed s/$(S)/,PaivaEast/ subregions/ip_mideast > iiiii.csv
sqlite3 database_modfire.db < imp/import_subregion_ext.sql
xy: region
cut -f1 input/UG_Vertice_Concelho.txt > i.csv
cut -f3 input/UG_Vertice_Concelho.txt > x.csv
cut -f4 input/UG_Vertice_Concelho.txt > y.csv
paste --delimiter=',' x.csv y.csv > ii.csv
paste --delimiter=',' i.csv ii.csv > iii.csv
sed '1d' iii.csv > ii.csv
awk '!/1551,-/' ii.csv | awk '!/1552,-/' | awk '!/1553,-/' | awk '!/1591,-/' | awk '!/1592,-/' | awk '!/1607,-/' | awk '!/1549,-/' | awk '!/1550,-/' > iii.csv
sqlite3 database_modfire.db < imp/import_xy_ext.sql
sqlite3 database_modfire.db < imp/import_xy_ext.sql
cut -d, -f1 iii.csv > i.csv
cut -d, -f2 iii.csv > x.csv
cut -d, -f3 iii.csv > y.csv
paste --delimiter=',' x.csv y.csv > ii.csv
python3 convert_u.py > ids.csv
paste --delimiter='' ids.csv ii.csv > iii.csv
sqlite3 database_modfire.db < imp/import_xy_int.sql
region: conditions
cut -f1 input/UG_Vertice_Concelho.txt > i.csv
cut -f5 input/UG_Vertice_Concelho.txt > ii.csv
paste --delimiter=',' i.csv ii.csv > iii.csv
awk '!seen[$(D)]++' iii.csv > ii.csv
sed -i '1d' ii.csv
awk '!/1551/' ii.csv | awk '!/1552/' | awk '!/1553/' | awk '!/1591/' | awk '!/1592/' | awk '!/1607/' | awk '!/1549/' | awk '!/1550/' > iii.csv
sqlite3 database_modfire.db < imp/import_reg_ext.sql
cut -d, -f1 iii.csv > i.csv
cut -d, -f2 iii.csv > ii.csv
python3 convert_u.py > ids.csv
paste --delimiter='' ids.csv ii.csv > iii.csv
sqlite3 database_modfire.db < imp/import_reg_int.sql
conditions: adj_int_gt
sqlite3 database_modfire.db 'insert into wood_rewards (ug,presc,wood) select Id, Presc,sum(V_harv+V_thin) from action_internal group by Id,Presc;'
sqlite3 database_modfire.db 'insert into soilloss (ug,presc,soilloss) select Id, Presc,sum(Soilloss) from action_internal group by Id,Presc;'
sqlite3 database_modfire.db 'insert into perc_r0 (ug,presc,perc_r0_total) select Id, Presc, sum(Perc_r0 * area)/50 from action_internal group by Id,Presc;'
sqlite3 database_modfire.db 'insert into perc_r5 (ug,presc,perc_r5_total) select Id, Presc, sum(Perc_r5 * area)/50 from action_internal group by Id,Presc;'
sqlite3 database_modfire.db 'insert into perc_r10 (ug,presc,perc_r10_total) select Id, Presc, sum(Perc_r10 * area)/50 from action_internal group by Id,Presc;'
adj_int_gt: adj
sed -i '1s/^/UG1,UG2,BORDER\n/' ii.csv
python3 remove_adj_below.py 50
sed -i '1d' i.csv
cut -d, -f2,3,4 i.csv > iii.csv
sqlite3 database_modfire.db < imp/import_adj_int_gt50.sql
adj: area
cut -f1,2,3 input/Adjacencias_VS22.txt > i.csv
sed -i '1d' i.csv
sed -i '/-1/d' i.csv
awk '! a[$(D)]++' i.csv | sed "s/\t/,/g" > ii.csv
awk -F "," '$(O) != 1551' ii.csv | awk -F "," '$(O) != 1552' | awk -F "," '$(O) != 1553' | awk -F "," '$(O) != 1591' | awk -F "," '$(O) != 1592' | awk -F "," '$(O) != 1607' > iii.csv
awk -F "," '$(T) != 1551' iii.csv | awk -F "," '$(T) != 1552' | awk -F "," '$(T) != 1553' | awk -F "," '$(T) != 1591' | awk -F "," '$(T) != 1592' | awk -F "," '$(T) != 1607' > ii.csv
sqlite3 database_modfire.db < imp/import_adj_ext.sql
cut -d, -f1 ii.csv > i.csv
python3 convert_u.py > ids.csv
cut -d, -f2 ii.csv > i.csv
python3 convert_u.py > iii.csv
paste --delimiter='' ids.csv iii.csv > i.csv
cut -d, -f3 ii.csv > iii.csv
paste --delimiter='' i.csv iii.csv > ii.csv
sqlite3 database_modfire.db < imp/import_adj_int.sql
area: action_internal
cut -f1,5 input/Adjacencias_VS22.txt > i.csv
sed -i '1d' i.csv
sed -i '/-1/d' i.csv
awk '! a[$(D)]++' i.csv | sed "s/\t/,/g" > ii.csv
sed -i '/1551,4.23199781869/d' ii.csv
sed -i '/1552,14.5795859997/d' ii.csv
sed -i '/1553,11.3507636964/d' ii.csv
sed -i '/1591,0.372829596169/d' ii.csv
sed -i '/1592,2.11169189261/d' ii.csv
sed -i '/1607,17.4850819576/d' ii.csv
echo | cat missings >> ii.csv
sqlite3 database_modfire.db < imp/import_area_ext.sql
cut -d, -f1 ii.csv > i.csv
cut -d, -f2 ii.csv > iii.csv
python3 convert_u.py > ids.csv
paste --delimiter='' ids.csv iii.csv > ii.csv
sqlite3 database_modfire.db < imp/import_area_int.sql
action_internal: action_external
cut -f2,3,4,5,6,7,8,11,24,25,26,27,28,29,33,40 input/Prescricoes_VS22.txt | sed "s/\t/,/g" > ii.csv
sed -i '1d' ii.csv
cut -f1 input/Prescricoes_VS22.txt > i.csv
sed -i '1d' i.csv
python3 convert_u.py > ids.csv
paste --delimiter='' ids.csv ii.csv > i.csv
awk '!seen[$D]++' i.csv > iii.csv
sqlite3 database_modfire.db < imp/import_action_internal.sql
action_external: ug_ids
cut -f1,2,3,4,5,6,7,8,11,24,25,26,27,28,29,33,40 input/Prescricoes_VS22.txt | sed "s/\t/,/g" > ii.csv
sed -i '1d' ii.csv
awk '!seen[$D]++' ii.csv > i.csv
sqlite3 database_modfire.db < imp/import_action_external.sql
ug_ids: create_tables
cut -f1 input/Prescricoes_VS22.txt > i.csv
sed -i '1d' i.csv
awk '!seen[$(D)]++' i.csv > ii.csv
sqlite3 database_modfire.db < imp/import_ug.sql
create_tables:
rm -rf *.db
rm -rf i.csv
rm -rf ii.csv
rm -rf iii.csv
rm -rf ids.csv
sqlite3 database_modfire.db < create.sql
clean:
rm -rf *.db
rm -rf *.csv
rm -rf i.csv
rm -rf ii.csv
rm -rf iii.csv