Commit 221e1608 authored by Henrik Grythe's avatar Henrik Grythe
Browse files

Tentative update on the temporary file mess

parent 0dc1e629
......@@ -24,7 +24,7 @@ fprintf('---------------------------------------------------------------\n')
fprintf('in Emission_Factors_OnRoadAllCond *\n')
fprintf('---------------------------------------------------------------\n')
end
TM = readtable(SSB_Vehicle_dist,'Sheet','MODEL');
LightVehiclesIdx = TM.ClassNum==1|TM.ClassNum==2;
......
......@@ -36,7 +36,7 @@ fprintf('\t---- Subtracting biofuel share from CO2 Emission Factors \n')
sheet = 'Biofuels';
BioInnblanding = readtable(input.files.Bio_mix_file,'Sheet',sheet,'ReadVariableNames',true);
fprintf('\tRead Biofuels from %s\nSheet ::: %s\n',input.files.Bio_mix_file,sheet)
fprintf('\tRead Biofuels from %s\n\tSheet ::: %s\n',input.files.Bio_mix_file,sheet)
pos = find(ismember(BioInnblanding.Properties.VariableNames,sprintf('x%i',Tyear)));
Bio = table2array(BioInnblanding(:,pos));
fprintf('\t-----------\n')
......@@ -133,7 +133,7 @@ EFnew = nanmean(EFs);
fprintf('\tAdjusted Petrol by -%4.1f%% of %4.1f%%\n',100*(1-nanmean(EFnew(Petrol))/nanmean(EFold(Petrol))),100*Bio(2))
fprintf('\tAdjusted Diesel by -%4.1f%% of %4.1f%%\n',100*(1-nanmean(EFnew(Diesel))/nanmean(EFold(Diesel))),100*Bio(3))
fprintf('\tAdjusted Gas by -%4.1f%% of %4.1f%%\n',100*(1-nanmean(EFnew(Gas))/nanmean(EFold(Gas))),100*Bio(4))
fprintf('\t CONTINUING-----------------------------\n')
fprintf('\t CONTINUING\n-----------------------------\n')
TFout(:,8:end) = array2table(EFs);
TMout = TFout;
end
......
......@@ -33,24 +33,25 @@ for com = 1:length(comps)
% files that must be read per species
R_EF_File = sprintf('Temp/EFA_Table_MODEL_%s.mat',char(comps(com)));
load(R_EF_File,'TFout'); % TFout
fprintf('%s\n',char(comps(com)))
for Tyear = 2018:2019
fprintf('%i\n',Tyear)
for Tyear = 2009:2019
fprintf('%i\n',Tyear)
% files that must be read per year
munFile = sprintf('Temp/Municipal_Traffic_Exchange_%i.mat',Tyear);
load(munFile)
RdDistFile = sprintf('Output/RoadTypeDistanceMunicipal%i.mat',Tyear);
load(munFile)
load(RdDistFile) % KDD
% files that must be read for each year and component!
EF_File = sprintf('Temp/EF_On_AllRoadCond_Municipality_%i_%s.mat',Tyear,char(comps(com)));
load(EF_File)
DaysInYear = datenum([Tyear+1 1 1 0 0 0])-datenum([Tyear 1 1 0 0 0]);
RLinks = shaperead(sprintf('Output/Traffic_Emissions_%i',Tyear));
DaysInYear = datenum([Tyear+1 1 1 0 0 0])-datenum([Tyear 1 1 0 0 0]);
KOMM = extractfield(RLinks,'KOMMS');
KOMMe = extractfield(RLinks,'KOMME');
......@@ -92,7 +93,6 @@ for com = 1:length(comps)
end
% Vehicle_dist
%------------------------------------------------------------------
% find *NV(kom,veh)* from:: SSB data
% find *TD(kom,veh)* from:: SSB data
......@@ -100,8 +100,8 @@ for com = 1:length(comps)
% find *FrdComp(kom,veh)* from:: SSB data
NV = Vehicle_dist.modelNV;
TD = Vehicle_dist.modelTD;
OrdComp = Vehicle_dist.Vdist;
FrdComp = Vehicle_dist.VdistFROM;
ORdComp = Vehicle_dist.Vdist;
FRdComp = Vehicle_dist.VdistFROM;
%------------------------------------------------------------------
% Estimate *EF_IN(kom,Veh) * based on:::: EF_IN and exchange
......@@ -138,11 +138,11 @@ for com = 1:length(comps)
for veh = 1:length(vehicles)
type = TM.Model_Class(veh);
if type <= 2
EM_IN(k,veh) = L_IN(k)*OrdComp(k,veh)*EF_IN(k,veh);
EM_IN(k,veh) = L_IN(k)*ORdComp(k,veh)*EF_IN(k,veh);
elseif (type == 5 || type == 6 || type == 7)
EM_IN(k,veh) = H_IN(k)*OrdComp(k,veh)*EF_IN(k,veh);
EM_IN(k,veh) = H_IN(k)*ORdComp(k,veh)*EF_IN(k,veh);
elseif (type == 3 || type == 4)
EM_IN(k,veh) = B_IN(k)*OrdComp(k,veh)*EF_IN(k,veh);
EM_IN(k,veh) = B_IN(k)*ORdComp(k,veh)*EF_IN(k,veh);
end
end
end
......@@ -173,11 +173,11 @@ for com = 1:length(comps)
for veh = 1:length(vehicles)
type = TM.Model_Class(veh);
if type <= 2
EM_FROM(k,veh) = L_FROM(k)*OrdComp(k,veh)*EF_FROM(k,veh);
EM_FROM(k,veh) = L_FROM(k)*FRdComp(k,veh)*EF_FROM(k,veh);
elseif (type == 5 || type == 6 || type == 7)
EM_FROM(k,veh) = H_FROM(k)*OrdComp(k,veh)*EF_FROM(k,veh);
EM_FROM(k,veh) = H_FROM(k)*FRdComp(k,veh)*EF_FROM(k,veh);
elseif (type == 3 || type == 4)
EM_FROM(k,veh) = B_FROM(k)*OrdComp(k,veh)*EF_FROM(k,veh);
EM_FROM(k,veh) = B_FROM(k)*FRdComp(k,veh)*EF_FROM(k,veh);
end
end
end
......@@ -187,7 +187,7 @@ for com = 1:length(comps)
fileout = sprintf('Output/NERVE_output_%s_%04i.mat',char(comps(com)),Tyear);
fprintf('Processed Emissions for %s year %i\n',Tyears,char(comps(com)))
fprintf('Processed Emissions for %s year %i\n',char(comps(com)),Tyear)
save(fileout,'NV','TD','L_IN','H_IN','B_IN','L_FROM','H_FROM','B_FROM','ORdComp','FRdComp','EF_IN','EF_FROM','EM_IN','EM_FROM')
end
end
......
%--------------------------------------------------------------------------
% 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 [kmne,TrafficIN,TrafficFROM] = Vehicle_Distribution_Municipal_Traffic_Exchange()
%--------------------------------------------------------------------------
% Miljodirektoratet Traffic emission model NERVE:
%
% FUNCTION :: mix_in_biofuels_NERVE ::
% Function to adjust emission factor for biofuels. Only applied if comp == CO2.
%
% -INPUT : .xlsx Exchange matrix file (RTMpexch) sheet='Biofuels'. Emssion
% factors per municipality (KEF).
% -OUTPUT : KEF adjusted for biofuels.
......@@ -17,7 +27,8 @@ global tfold Tyear KmneNr KmneNavn debug_mode text_div
global traff_exchange traff_exchange_sh
fprintf('%s\n',text_div)
fprintf('* call Municipal_Traffic_Exchange_NERVE *\n')
fprintf('in Vehicle_Distribution_Municipal_Traffic_Exchange *\n')
fprintf('%s\n',text_div)
fprintf('--- Finding Origin of Traffic in each municipality \n')
%RTMsheet = '2020_Utveksling';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment