Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Big-Data/simpleEnsemble.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
43 lines (37 sloc)
1.49 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%Function to calculate Simple Ensemble | |
function [simple_ensemble] = simpleEnsemble() | |
%load the 7 individual models | |
O3model1 = ncread('Individual Models\chimereModel.nc','unknown'); | |
O3model2 = ncread('Individual Models\emepModel.nc','unknown'); | |
O3model3 = ncread('Individual Models\ensembleModel.nc','unknown'); | |
O3model4 = ncread('Individual Models\euradModel.nc','unknown'); | |
O3model5 = ncread('Individual Models\matchModel.nc','unknown'); | |
O3model6 = ncread('Individual Models\mocageModel.nc','unknown'); | |
O3model7 = ncread('Individual Models\silamModel.nc','unknown'); | |
%Start parallel pool | |
NumWorkers = 6; | |
if isempty(gcp('nocreate')) | |
parpool(NumWorkers); | |
end | |
total = zeros(size(700,400,25)); %this will create and empty matrix with dimensions 700x400x25 for you to fill up with the result of your addition | |
tic | |
parfor i = 1:700 | |
for j = 1:400 | |
for k = 1:25 | |
total(i, j, k) = O3model1(i, j, k) + O3model2(i, j, k) + O3model3(i, j, k) + O3model4(i, j, k) + O3model5(i, j, k) + O3model6(i, j, k) + O3model7(i, j, k); | |
end | |
end | |
end | |
t2 = toc; | |
simple_ensemble = total/7; | |
%save result from total to a csv file | |
csvwrite('simpleEnsemble.csv', simple_ensemble) | |
fprintf('Parallel procesing time: %.3f\n', t2) | |
%remove first two rows and columns of the simple ensemble this is done so | |
%that it matches the CBE model | |
numRowsRemoved = 2; | |
for r = 1:numRowsRemoved | |
simple_ensemble(1,:,:) = []; | |
simple_ensemble(:,1,:) = []; | |
end | |
end | |