Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
EmissionModels
NERVE
Commits
6bfe87b7
Commit
6bfe87b7
authored
Nov 13, 2020
by
Henrik Grythe
Browse files
added slope calculations which had fallen out
parent
b1f7b3b8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Emission_Factor_Model_group_HBEFA.m
View file @
6bfe87b7
...
...
@@ -174,24 +174,71 @@ for com =1:length(comps)
end
end
%__________________________________________________________________________
if
input
.
options
.
Subtract_bio_from_CO2
switch
char
(
comps
(
com
))
case
'CO2'
fprintf
(
'### ADD CALL TO: Emission_Factor_mix_in_biofuels()\n'
)
TFout
=
Emissions_Factor_Mix_in_biofuels
(
TFout
)
end
end
%__________________________________________________________________________
switch
char
(
comps
(
com
))
case
'CO2'
MunicpalHBEFA_RoadsEF_
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_'
,
'roads'
,
'-append'
);
case
'FC'
MunicpalHBEFA_RoadsEF_FC
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_FC'
,
'roads'
,
'-append'
);
case
'FC_MJ'
MunicpalHBEFA_RoadsEF_FC_MJ
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_FC_MJ'
,
'roads'
,
'-append'
);
case
'CH4'
MunicpalHBEFA_RoadsEF_CH4
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_CH4'
,
'roads'
,
'-append'
);
case
'BC'
MunicpalHBEFA_RoadsEF_BC
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_BC'
,
'roads'
,
'-append'
);
case
'PM'
MunicpalHBEFA_RoadsEF_PM
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_PM'
,
'roads'
,
'-append'
);
case
'HC'
MunicpalHBEFA_RoadsEF_HC
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_HC'
,
'roads'
,
'-append'
);
case
'CO'
MunicpalHBEFA_RoadsEF_CO
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_CO'
,
'roads'
,
'-append'
);
case
'NOx'
MunicpalHBEFA_RoadsEF_NOx
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_NOx'
,
'roads'
,
'-append'
);
case
'Be'
MunicpalHBEFA_RoadsEF_Be
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_Be'
,
'roads'
,
'-append'
);
case
'NMHC'
MunicpalHBEFA_RoadsEF_NMHC
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_NMHC'
,
'roads'
,
'-append'
);
case
'NO2'
MunicpalHBEFA_RoadsEF_NO2
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_NO2'
,
'roads'
,
'-append'
);
case
'NO'
MunicpalHBEFA_RoadsEF_NO
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_NO'
,
'roads'
,
'-append'
);
case
'PN'
MunicpalHBEFA_RoadsEF_PN
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_PN'
,
'roads'
,
'-append'
);
case
'CO2'
case
'CO2'
case
'CO2'
MunicpalHBEFA_RoadsEF_CO2
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_CO2'
,
'roads'
,
'-append'
);
case
'N2O'
MunicpalHBEFA_RoadsEF_N2O
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_N2O'
,
'roads'
,
'-append'
);
case
'NH3'
MunicpalHBEFA_RoadsEF_NH3
=
TFout
;
save
(
ofiles
.
MatlabOutput
,
'MunicpalHBEFA_RoadsEF_NH3'
,
'roads'
,
'-append'
);
end
writetable
(
TFout
,
'modelHBEFA.xlsx'
,
'Sheet'
,
sprintf
(
'%s_%s_Weight'
,
char
(
comps
(
com
)),
Vehicle_weight
)
)
fprintf
(
'Saved a temp-file for Emission Factors Model:\n%s\n'
,
oEFfile
)
end
% OLD METHOD
...
...
Emission_Factors_OnRoadAllCond.m
View file @
6bfe87b7
...
...
@@ -4,6 +4,7 @@ global debug_mode ofile
%--------------------------------------------------------------
% COMBINE Municipal VEHICLE DISTRIBUTION & EMISSION FACTORS
%--------------------------------------------------------------
fprintf
(
'in Emission_Factors_OnRoadAllCond *\n'
)
TM
=
readtable
(
SSB_Vehicle_dist
,
'Sheet'
,
'MODEL'
);
LightVehiclesIdx
=
TM
.
ClassNum
==
1
|
TM
.
ClassNum
==
2
;
...
...
@@ -31,8 +32,8 @@ for com = 1:length(comps)
sum
(
VD
(
komm
,
HeavyVehiclesIdx
)),
...
sum
(
VD
(
komm
,
BusesVehiclesIdx
)))
else
fprintf
(
'Komm:%04i;'
,
Vehicle_dist
.
D1_KommNr
(
komm
))
if
rem
(
komm
,
15
)
==
0
;
fprintf
(
'\n'
);
end
fprintf
(
'Komm:%04i;'
,
Vehicle_dist
.
D1_KommNr
(
komm
))
if
rem
(
komm
,
15
)
==
0
;
fprintf
(
'\n'
);
end
end
if
abs
(
sum
(
VD
(
komm
,:))
-
3
)
>
1e-5
...
...
@@ -56,23 +57,66 @@ for com = 1:length(comps)
end
Trout
.
Light
=
EFLight
;
Trout
.
Heavy
=
EFHeavy
;
Trout
.
Buses
=
EFBuses
;
Trout
.
Buses
=
EFBuses
;
Trout
.
Properties
.
VariableNames
(
find
(
ismember
(
Trout
.
Properties
.
VariableNames
,
'Light'
)))
=
{
sprintf
(
'EF_Light_%04i'
,
Vehicle_dist
.
D1_KommNr
(
komm
))};
Trout
.
Properties
.
VariableNames
(
find
(
ismember
(
Trout
.
Properties
.
VariableNames
,
'Heavy'
)))
=
{
sprintf
(
'EF_Heavy_%04i'
,
Vehicle_dist
.
D1_KommNr
(
komm
))};
Trout
.
Properties
.
VariableNames
(
find
(
ismember
(
Trout
.
Properties
.
VariableNames
,
'Buses'
)))
=
{
sprintf
(
'EF_Buses_%04i'
,
Vehicle_dist
.
D1_KommNr
(
komm
))};
end
switch
char
(
comps
(
com
))
case
'FC'
OnRoadEF_RoadClasses_FC
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_FC'
,
'-append'
);
case
'FC_MJ'
OnRoadEF_RoadClasses_FC_MJ
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_FC_MJ'
,
'-append'
);
case
'CH4'
OnRoadEF_RoadClasses_CH4
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_CH4'
,
'-append'
);
case
'BC'
OnRoadEF_RoadClasses_BC
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_BC'
,
'-append'
);
case
'PM'
OnRoadEF_RoadClasses_PM
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_PM'
,
'-append'
);
case
'HC'
OnRoadEF_RoadClasses_HC
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_HC'
,
'-append'
);
case
'CO'
OnRoadEF_RoadClasses_CO
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_CO'
,
'-append'
);
case
'NOx'
OnRoadEF_RoadClasses_NOx
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_NOx'
,
'-append'
);
case
'Be'
OnRoadEF_RoadClasses_Be
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_Be'
,
'-append'
);
case
'NMHC'
OnRoadEF_RoadClasses_NMHC
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_NMHC'
,
'-append'
);
case
'NO2'
OnRoadEF_RoadClasses_NO2
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_NO2'
,
'-append'
);
case
'NO'
OnRoadEF_RoadClasses_NO
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_NO'
,
'-append'
);
case
'PN'
OnRoadEF_RoadClasses_PN
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_PN'
,
'-append'
);
case
'CO2'
fprintf
(
'### ADD CALL TO: Emission_Factor_mix_in_biofuels()\n'
)
OnRoadEF_RoadClasses_CO2
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_CO2'
,
'-append'
);
case
'N2O'
OnRoadEF_RoadClasses_N2O
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_N2O'
,
'-append'
);
case
'NH3'
OnRoadEF_RoadClasses_NH3
=
Trout
;
save
(
ofiles
.
MatlabOutput
,
'OnRoadEF_RoadClasses_NH3'
,
'-append'
);
end
ofile
=
'OnRoadEF_RoadClasses.xlsx'
;
OnRoadEF_RoadClasses
=
Trout
;
save
(
ofile
.
MatlabOutput
,
'OnRoadEF_RoadClasses'
,
'-append'
)
writetable
(
Trout
,
ofile
,
'Sheet'
,
sprintf
(
'%s_%i'
,
char
(
comps
(
com
)),
Tyear
))
fprintf
(
'%s--- >\n'
,
char
(
comps
(
com
)))
end
...
...
Emission_Factors_Road_DrivingDistance_IN_Municipalities.m
View file @
6bfe87b7
...
...
@@ -11,7 +11,6 @@ HeavyVehiclesIdx = TM.ClassNum==5|TM.ClassNum==6|TM.ClassNum==7;
T
=
readtable
(
'modelHBEFA.xlsx'
,
'Sheet'
,
'Roads'
);
file
=
sprintf
(
'%s%s'
,
tfold
,
'roads'
);
fprintf
(
'### Warning,using roads file not produced by NERVE model\n%s\n'
,
file
)
load
(
file
)
...
...
Emissions_Calculations_SSB.m
View file @
6bfe87b7
...
...
@@ -180,7 +180,6 @@ for com = 1:length(comps)
end
save
(
ofiles
.
MatlabOutput
,
'RLinks'
,
'-append'
)
fprintf
(
'Added RLinks to output\n'
)
Sn
=
RLinks
;
end
PreProcess_Emission_Factors_HBEFA.m
View file @
6bfe87b7
...
...
@@ -28,7 +28,7 @@ if use_temporary_files && ~do_preProcessing_HBEFA
error
(
sprintf
(
'### file not found\n%s\n will make new'
,
ifile
))
end
end
fprintf
(
'Temporary files found\n
CONTINUE\n'
)
fprintf
(
'Temporary files found\n
\t\t
CONTINUE\n
\n\n
'
)
return
catch
end
...
...
PreProcess_Roads_Input_Traffic.m
View file @
6bfe87b7
...
...
@@ -45,22 +45,11 @@ function [RLinks] = PreProcess_Roads_Input_Traffic()
% 20.09.2020 -Henrik Grythe
% Kjeller NILU
%--------------------------------------------------------------------------
global
use_temporary_files
tfiles
global
use_temporary_files
tfiles
Tyear
global
traffile
Listfields
Inputfields
fprintf
(
'in PreProcess_Input_Traffic.\n'
)
% List of input fields used
Inputfields
=
[{
'Geometry'
},{
'X'
},{
'Y'
},{
'KOLL_ADT'
},{
'LETTE_BILE'
},
...
{
'GODS_ADT'
},{
'SUM_ADT'
},{
'FM_TIME'
},{
'KO_MORGEN'
},{
'KO_ETTERM'
},
...
{
'FM_SPEED'
},{
'SHAPE_LENG'
},{
'VK'
},{
'STIGNING_P'
},{
'SPEED'
},{
'HP_ID'
},{
'LANES'
}];
% List of output fields a finished file has:
Listfields
=
[{
'Geometry'
},{
'X'
},{
'Y'
},{
'BoundingBox'
},{
'DISTANCE'
},{
'KOMMS'
},{
'KOMME'
},{
'KOMM'
},{
'SPEED'
},{
'SLOPE'
},
...
{
'URBAN'
},{
'RUSH_DELAY'
},{
'HBEFA_EQIV'
},{
'WIDTH'
},{
'CAPACITY'
},{
'N_LANES'
},{
'L_ADT'
},{
'H_ADT'
},{
'B_ADT'
},{
'IDO'
}];
if
use_temporary_files
try
% First do tests if there is a temporary file saved:
...
...
@@ -74,7 +63,13 @@ if use_temporary_files
end
return
catch
fprintf
(
'### No temporary file found ###\n'
)
fprintf
(
'### Temporary file Scaled to Year %i NOT found ###\n'
,
Tyear
)
try
RLinks
=
shaperead
(
tfiles
.
CleanRoads
);
RLinks
=
Roads_Scale_Traffic_to_Year
(
RLinks
);
fprintf
(
'### Temporary file found ###\n'
,
Tyear
)
return
end
prj
=
read_projection
(
traffile
);
fprintf
(
'Reading large file: \n\t %s ...'
,
traffile
)
RLinks
=
shaperead
(
traffile
);
...
...
@@ -100,6 +95,18 @@ else
end
fprintf
(
'\n'
)
end
% List of input fields used
Inputfields
=
[{
'Geometry'
},{
'X'
},{
'Y'
},{
'KOLL_ADT'
},{
'LETTE_BILE'
},
...
{
'GODS_ADT'
},{
'SUM_ADT'
},{
'FM_TIME'
},{
'KO_MORGEN'
},{
'KO_ETTERM'
},
...
{
'FM_SPEED'
},{
'SHAPE_LENG'
},{
'VK'
},{
'STIGNING_P'
},{
'SPEED'
},{
'HP_ID'
},{
'LANES'
}];
% List of output fields a finished file has:
Listfields
=
[{
'Geometry'
},{
'X'
},{
'Y'
},{
'BoundingBox'
},{
'DISTANCE'
},{
'KOMMS'
},{
'KOMME'
},{
'KOMM'
},{
'SPEED'
},{
'SLOPE'
},
...
{
'URBAN'
},{
'RUSH_DELAY'
},{
'HBEFA_EQIV'
},{
'WIDTH'
},{
'CAPACITY'
},{
'N_LANES'
},{
'L_ADT'
},{
'H_ADT'
},{
'B_ADT'
},{
'IDO'
}];
%--------------------------------------------------------------------------
RLinks
=
Roads_clean_Input
(
RLinks
);
%--------------------------------------------------------------------------
...
...
@@ -115,15 +122,16 @@ RLinks = Roads_Fix_Roadfields(RLinks);
%--------------------------------------------------------------------------
RLinks
=
Roads_Congestion_Parameters
(
RLinks
);
%--------------------------------------------------------------------------
RLinks
=
Roads_Calc_HBEFA_Slope
(
RLinks
);
%--------------------------------------------------------------------------
RLinks
=
Roads_Add_Urban
(
RLinks
);
save
(
'RLinks.mat'
,
'RLinks'
)
%--------------------------------------------------------------------------
RLinks
=
Roads_Add_HBEFA_Parameters
(
RLinks
);
%--------------------------------------------------------------------------
RLinks
=
Roads_Congestion_Parameters
(
RLinks
);
%--------------------------------------------------------------------------
if
use_temporary_files
Save_shape
(
RLinks
,
tfiles
.
RL
)
Save_shape
(
RLinks
,
tfiles
.
CleanRoads
)
end
RLinks
=
Roads_Scale_Traffic_to_Year
(
RLinks
);
%--------------------------------------------------------------------------
...
...
PreProcess_Vehicle_Distribution.m
View file @
6bfe87b7
...
...
@@ -39,6 +39,6 @@ if ismember(Vehicle_source,{'Scenario'})
fprintf
(
'Using Costum-made file for:\nVehcile_distribution\n\n'
)
[
Vehicle_dist
]
=
Vehcile_Distribution_National_Scenario
();
end
save
(
ofiles
.
MatlabOutput
,
'Vehicle_dist'
,
'-append'
)
end
Roads_Calc_HBEFA_Slope.m
0 → 100644
View file @
6bfe87b7
%--------------------------------------------------------------------------
% This file is part of NERVE
%
% NERVE is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation version 3.
%
% NERVE is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NERVE. If not, see <https://www.gnu.org/licenses/>.
%--------------------------------------------------------------------------
function
[
Sn
]
=
Roads_Calc_HBEFA_Slope
(
RLinks
)
% Convert Precentage into HBEAF interpretable 0,2,4,6 pct slopes
st
=
min
(
abs
(
round
(
50
*
extractfield
(
RLinks
,
'STIGNING_P'
))
*
2
),
6
);
T
=
struct2table
(
RLinks
);
T
.
SLOPE
=
st
'
;
Sn
=
table2struct
(
T
);
fprintf
(
'Setfields\n -- SLOPE ...on all links \n'
)
end
\ No newline at end of file
Vehicle_Distribution_per_Municipality_SSB.m
View file @
6bfe87b7
...
...
@@ -17,7 +17,7 @@ function [Vehicle_dist] = Vehicle_Distribution_per_Municipality_SSB()
% Module for processing SSB DD.
global
Tyear
SSB_Vehicle_dist
fprintf
(
'
\t
in Vehicle_Distribution_per_Municipality_SSB\n'
)
fprintf
(
'in Vehicle_Distribution_per_Municipality_SSB
*
\n'
)
% OPT TODO: ADD a test to check for data from municipality and year
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment