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-Project/data_visualization.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
71 lines (53 sloc)
1.79 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 [] = data_visualization(source) | |
% source file info | |
data_info = ncinfo(source); | |
%% read data | |
l1 = ncread(source, data_info.Variables(1).Name); | |
l2 = ncread(source, data_info.Variables(2).Name); | |
t = ncread(source, data_info.Variables(3).Name); | |
o = ncread(source, data_info.Variables(4).Name); | |
[X,Y] = meshgrid(l2, l1); | |
figure | |
clf | |
% Create the map | |
worldmap('Europe'); % set the part of the earth to show | |
load coastlines | |
plotm(coastlat,coastlon) | |
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') | |
% Plot the data | |
Z = squeeze(o(:, :, 1)); | |
a = surfm(double(X), double(Y), Z, 'EdgeColor', 'none',... | |
'FaceAlpha', 0.5); % edge colour outlines the edges, 'FaceAlpha', sets the transparency | |
title(sprintf('ozone data on time-instant %s', datetime(t(1),'ConvertFrom','datenum'))) | |
colorbar | |
hold on | |
% refresh data | |
for i = 2:length(t) | |
a.CData = squeeze(o(:, :, i)); % update data | |
drawnow | |
title(sprintf('ozone data on time-instant %s', datetime(t(i),'ConvertFrom','datenum'))) | |
% hold on | |
end | |
% Plot the data | |
Z = squeeze(o(:, :, 1)); | |
NumContours = 5; | |
contourfm(double(X), double(Y), Z, NumContours); | |
title(sprintf('Contour plot ozone data on time-instant %s', datetime(t(1),'ConvertFrom','datenum'))) | |
colorbar | |
hold on | |
% refresh data | |
for i = 2:length(t) | |
Z = squeeze(o(:, :, 1)); | |
contourfm(double(X), double(Y), Z, NumContours); | |
drawnow | |
title(sprintf('Contour plot ozone data on time-instant %s', datetime(t(i),'ConvertFrom','datenum'))) | |
% hold on | |
end | |
end |