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/visualisation.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
97 lines (87 sloc)
4.52 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%This is my visualition code for 5011CEM. | |
%The packages required for this code to run are: Map Viewer | |
%The files required in the same directory for this code are: o3_surface_20180701000000.nc (the 24 combined file from moodle.) | |
%Colorblind Reference (default colormaps) : https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/30161/versions/4/screenshot.png | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%% file used for the data visualised in graph. contains the ozone data over 24 hours for multiple ozone models. this is overlayed over the map. | |
ncfile = 'o3_surface_20180701000000.nc'; %variable for the .nc file used | |
clc; | |
b = 1; %bool value | |
c = 1; %bool value | |
ncdisp(ncfile); %displays info about the file in the terminal. not necessary but useful for reference. | |
if (c == 1) %% if statement for the menu. Menu allows the user to choose which ozone model they would like to view whilst also assigning their choice to title. | |
modelchoice = menu('Which model would you like to see?', 'Chimere', 'Emep', 'Ensemble', 'Eurad','Lotoseuros','Match','Mocage','Silam'); %% options that are shown in the menu. | |
if modelchoice == 1 | |
ozone_choice = ('chimere_ozone'); | |
titlechoice = 'chimere_ozone'; | |
elseif modelchoice == 2 | |
ozone_choice = ('emep_ozone'); | |
titlechoice = 'emep_ozone'; | |
elseif modelchoice == 3 | |
ozone_choice = ('ensemble_ozone'); | |
titlechoice = 'ensemble_ozone'; | |
elseif modelchoice == 4 | |
ozone_choice = ('eurad_ozone'); | |
titlechoice = 'eurad_ozone'; | |
elseif modelchoice == 5 | |
ozone_choice = ('lotoseuros_ozone'); | |
titlechoice = 'lotoseuros_ozone'; | |
elseif modelchoice == 6 | |
ozone_choice = ('match_ozone'); | |
titlechoice = 'match_ozone'; | |
elseif modelchoice == 7 | |
ozone_choice = ('mocage_ozone'); | |
titlechoice = 'mocage_ozone'; | |
elseif modelchoice == 8 | |
ozone_choice = ('silam_ozone'); | |
titlechoice = 'silam_ozone'; | |
end | |
c = 0; | |
end | |
clc; | |
ozone_end = ncread(ncfile, ozone_choice); % reads one specific model from the combined file depending on the user choice in the menu above. | |
lon = ncread(ncfile,'lon'); %% variable for lon variable | |
lat = ncread(ncfile,'lat'); %% variable for lat variable | |
time = ncread(ncfile,'hour'); %% time variable | |
noofhours = length(time) ; %% length variable for time to be used in loop below. | |
[X,Y] = meshgrid(lon,lat) ; | |
figure('Name', titlechoice,'NumberTitle','off'); %%formats the figure info shown | |
set(gcf, 'Position', get(0, 'Screensize')); %% sets the figure to fullscreen | |
clf; | |
for i = 1:noofhours %% this for loop runs the graph and menus that the user interacts with | |
clf; | |
map = pcolor(X,Y,ozone_end(:,:,i)') ; %% sets up the data that is overlayed over the map. | |
map.EdgeAlpha = 0; | |
ylabel('Longitude') %% Y Axis Label | |
xlabel('Latitude') %% X Axis label | |
if (b == 1) %menu goes down once option has been picked and b value is set to 0. | |
info = menu('Color Accessibility Options', 'Default', 'Protanopia (red weakness)','Deuteranopia (green weakness)','Tritanopia (blue/yellow weakness)','Monochromacy'); | |
if info == 1 | |
colormap default; | |
elseif info == 2 | |
colormap winter; %%stands out the most for Protanopia based on figure linked above. | |
elseif info == 3 | |
colormap cool; %%stands out the most for Deuteranopia based on figure linked above. | |
elseif info == 4 | |
colormap copper; %%stands out the most for Tritanopia based on figure linked above. | |
elseif info == 5 | |
colormap bone; %%Greyscale Option | |
end | |
b = 0; | |
end | |
UIControl_FontSize_bak = get(0, 'DefaultUIControlFontSize'); | |
set(0, 'DefaultUIControlFontSize', 30); %% only way to change text size in menu. only works on consecutive runs of the code, not the first. | |
clc | |
cities = shaperead('worldcities', 'UseGeoCoords', true); %%shows landmark cities | |
geoshow(cities, 'Marker', '.', 'Color', 'red') | |
c = colorbar; % shows a colorbar relative to the colormap being used on the figure on the righthand side of the map. Can be toggled via figure options. | |
c.Label.String = 'Ozone Levels'; | |
load coast; | |
hold on; | |
C = load('coast'); % loads the coast for the map. | |
plot(C.long,C.lat,'k') %plots the map | |
shading interp ; | |
title(sprintf('The time is : %f',time(i))) %% title for each hour is shown each loop above the map. | |
pause(0.1) %% this is the pause between each hour shown. not actually 0.1 seconds however due to hardware limitations. | |
end |