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?
BigData/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.
87 lines (82 sloc)
2.46 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
%assign new figure to variable f | |
f = figure; | |
colorbar | |
%global variable cb | |
global cb | |
%c = 1; | |
%set ui cb (color blind) checkbox | |
set(gcf, 'Position', [150, 100, 700, 700], 'Color', 'White') | |
cb = uicontrol('Parent', f, 'Style', 'checkbox', 'String', 'Color Blind', ... | |
'Position', [200,75,100,20], 'BackgroundColor', 'black', 'ForegroundColor', 'White'); | |
%run menu function | |
menu(f) | |
%assing ncfile variable to default nc file | |
ncfile = strcat("data/CHIMERE.nc"); | |
%call for readfile function | |
readfile(ncfile,f) | |
clf | |
%create function called read file | |
function readfile(file, f) | |
global cb | |
%save file into local variable ncfile | |
ncfile = file; | |
%from file saved each variable into its local variable | |
lon = ncread(ncfile,'longitude'); | |
lat = ncread(ncfile,'latitude'); | |
time = ncread(ncfile,'time'); | |
%create XY matrix from lon and lat and convert them into double type | |
[X,Y] = meshgrid(lon, lat); | |
X = double(X); | |
Y = double(Y); | |
%create a for loop for time | |
for t = 1:length(time) | |
%check of close figure conditions to avoid errors from matlab | |
if ~ishghandle(f) | |
break | |
end | |
if ~isvalid(f) | |
break | |
end | |
%pause for 1 second each time to easier see and understand the | |
%animation | |
pause(1) | |
%load matrix from the nc file | |
matrix = ncread(file,'unknown',[1 1 t],[length(lon) length(lat) 1]); | |
%create the map and plots | |
worldmap('Europe') | |
load coastlines | |
plotm(coastlat, coastlon, 'k') | |
%show time as map title | |
title(sprintf('time: %i:00', (t-1))) | |
surfm(Y, X, matrix','FaceAlpha', 0.75); | |
%if statement for colorblind checkbox | |
if(cb.Value == 1) | |
colormap summer | |
end | |
if(cb.Value ==0) | |
colormap default | |
end | |
end | |
end | |
%menu function to allow user to switch between the 7 data | |
function menu(f) | |
%global needed variables | |
global c | |
global ncfile | |
%create ui text and drop down menu | |
uicontrol('Parent',f,'Style','text','Position',[40,100,100,13],... | |
'String','Choose Data:','BackgroundColor', f.Color); | |
c = uicontrol(f,'Style','popupmenu'); | |
c.Position = [60 75 80 20]; | |
c.String = {'CHIMERE','EMEP','ENSEMBLE', 'EURAD', 'MATCH', 'MOCAGE', 'SILAM'}; | |
c.Callback = @selection; | |
%local function for callback when user selects from dropdown | |
function selection(src,event) | |
val = c.Value; | |
str = c.String; | |
str{val}; | |
%read the selected data and pass it to readfile function | |
ncfile = strcat("data/",str{val},".nc"); | |
readfile(ncfile,f) | |
end | |
end | |