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?
5011CEM-Resit/main.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
122 lines (114 sloc)
5.32 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
%% Definining the choices of each menu. The function will loop over these and create a menu | |
menuChoices = {'Ensemble Ozone', 'Chimere Ozone', 'Emep Ozone', 'Match Ozone', 'Eurad Ozone' , 'Change Color Mode'} | |
colourchoices = {'Normal', 'Protanopia', 'Deuteranopia', 'Tritanopia'} | |
filename = "Combined.nc" %% This is o3_surface_20180701000000.nc renamed. It is the combined dataset from Moodle | |
%% Default values that are changed later on by the menu code | |
figtitle = 'chimere_ozone' | |
vistype = 'chimere_ozone' | |
colortype = 'default' | |
%% This code is used to keep you in the menu until you have made a valid choice. If you choose a number out of the range of the options, it will keep asking | |
%% you to choose an option. I learnt how to do this from https://www.youtube.com/watch?v=zLb4ZHFfbO0 | |
clc | |
while true | |
choice = menu(menuChoices) | |
if choice == 1 | |
disp('Ensemble Ozone Data Will Be Visualised') | |
vistype = 'ensemble_ozone' | |
figtitle = 'Ensemble Ozone' | |
ready = true | |
break | |
elseif choice == 2 | |
disp('Ensemble Ozone Data Will Be Visualised') | |
vistype = 'chimere_ozone' | |
figtitle = 'Chimere Ozone' | |
ready = true | |
break | |
elseif choice == 3 | |
disp('Emep Ozone Data Will Be Visualised') | |
vistype = 'emep_ozone' | |
figtitle = 'Emep Ozone' | |
ready = true | |
break | |
elseif choice == 4 | |
disp('Match Ozone Data Will Be Visualised') | |
vistype = 'match_ozone' | |
figtitle = 'Match Ozone' | |
ready = true | |
break | |
elseif choice == 5 | |
disp('Eurad Ozone Data Will Be Visualised') | |
vistype = 'eurad_ozone' | |
figtitle = 'Eurad Ozone' | |
ready = true | |
break | |
elseif choice == 6 | |
clc | |
while true | |
colourmodei = menu(colourchoices) | |
%% Using information from https://uk.mathworks.com/matlabcentral/fileexchange/30161-matlab-colormaps-as-seen-by-color-blind-users | |
%% I will set the colormap which will best show a strong gradiant for each color blindness type | |
if colourmodei == 1 | |
disp("Default Colouring Applied!") | |
colortype = 'default' | |
break | |
elseif colourmodei == 2 | |
disp("Protanopia Friendly Colouring Applied!") | |
colortype = 'spring' | |
break | |
elseif colourmodei == 3 | |
disp("Deuteranopia Friendly Colouring Applied!") | |
colortype = 'winter' | |
break | |
elseif colourmodei == 4 | |
disp("Tritanopia Friendly Colouring Applied!") | |
colortype = 'autumn' | |
break | |
end | |
end | |
end | |
end | |
ozonedata = ncread(filename, vistype) | |
long = ncread(filename, 'lon') | |
lat = ncread(filename, 'lat') | |
hours = ncread(filename, 'hour') | |
time = length(hours) | |
[X,Y] = meshgrid(long, lat) | |
clc %% Clears the console after the data has been read from the dataset | |
%%Creates a new figure with the title dependant on the menu choice. Makes the figure fullscreen | |
figure('Name',figtitle,'units','normalized','outerposition',[0 0 1 1]) | |
%%Use of strcmpi (String comparison) Learnt from https://uk.mathworks.com/matlabcentral/answers/356801-matrix-dimensions-must-agree-while-using-if | |
%% This if else block is used to change the color of the map dependent on what is selected in the menu, if nothing is selected it will use the value default | |
if strcmpi('default', colortype) | |
colormap default | |
elseif strcmpi('spring', colortype) | |
colormap spring | |
elseif strcmpi('winter', colortype) | |
colormap winter | |
elseif strcmpi('autumn', colortype) | |
colormap autumn | |
end | |
%%This loop is to update the ozone data depending on the hour. The dataset has hours from 0-23 (24 hours) | |
for i = 1:time | |
%%This is a psuedocolor plot. It displays matrix data as an array of colored cells. More info here: https://uk.mathworks.com/help/matlab/ref/pcolor.html | |
datamap = pcolor(X,Y, ozonedata(:,:,i)') | |
%% EdgeAlpha is set to 0 to hide the grid lines | |
datamap.EdgeAlpha = 0; | |
ylabel('Longitude') | |
xlabel('Latitude') | |
%% Taken from Moodle example. Uses MatLab mapping toolbox to overlay major cities onto the datamap. Also to overlay land, lakes and rivers. | |
land = shaperead('landareas', 'UseGeoCoords', true); | |
geoshow(gca, land, 'FaceColor', [0.5 0.7 0.5]) | |
lakes = shaperead('worldlakes', 'UseGeoCoords', true); | |
geoshow(lakes, 'FaceColor', 'blue') | |
rivers = shaperead('worldrivers', 'UseGeoCoords', true); | |
geoshow(rivers, 'Color', 'blue') | |
cities = shaperead('worldcities', 'UseGeoCoords', true); | |
geoshow(cities, 'Marker', '.', 'Color', 'red') | |
%% Creates a bar on the grid, takes the pcolor data and creates a bar that displays what the color of the plot signifies. | |
label = colorbar | |
label.Label.String = 'Ozone Level' | |
%% The title on the plot is updated for every hour. So the user can see what the ozone level was for that hour. | |
title(sprintf('The time is : %f',hours(i))) | |
%% A pause for every hour, so you have a chance to see the plot before it changes to the next hour. | |
pause(0.1) | |
end | |