-
Notifications
You must be signed in to change notification settings - Fork 0
/
telplot2avi.m
98 lines (85 loc) · 2.09 KB
/
telplot2avi.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
function h=telplot(INFILE,VAR,TIMESTEP,LIMS)
% Plots a patch for a TELEMAC2D triangular, finite element style mesh
% (i.e. a Seraphin format file)
%
% usage:
% h=telplot(INFILE,VAR,TIMESTEP,LIMS)
%
% where:
% INFILE = filename of Seraphin file (setting to [], or no inputs, will invoke a uigetfile menu)
% VAR = variable number (default = 1)
% TIMESTEP = timestep number (default = 1)
% LIMS = [min max] limits for colour bar, (default are limits of data)
%
% The function returns the handle to the patch object
%
% example:
% telplot('seraphin_example.res',4,1)
%
% author: Thomas Benson, HR Wallingford
% email: [email protected]
% release date: 13-Aug-2009
%
% updated by Ehsan Sarhadi, AnteaGroup
% email: [email protected]
% 21-Feb-2014
% check inputs
if nargin<1
INFILE = [];
end
if nargin<2
VAR=[];
end
if nargin<3
TIMESTEP=[];
end
if nargin<4
LIMS=[];
end
if isempty(VAR)
% choosing the variable to animate
VAR=4;
end
if isempty(TIMESTEP)
TIMESTEP=1;
end
% load the header
m=telheadr(INFILE);
% loop for creating the movie
% the number of timestep which you want to show in the movie (10)
for TIMESTEP=1:18
% load the timestep
m=telstepr(m,TIMESTEP);
% check inputs are in range
if VAR>m.NBV
error(['VAR (input 2) is too large. There are only ' num2str(m.NBV) ' variables in the file.'])
end
if TIMESTEP>m.NSTEPS
error(['TIMESTEP (input 3) is too large. There are only ' num2str(m.NSTEPS) ' timesteps in the file.'])
end
% plot the patch
h=patch('faces',m.IKLE,'vertices',m.XYZ,'FaceVertexCData',m.RESULT(:,VAR), ...
'FaceColor','interp','EdgeColor','none','linewidth',0.01);
axis equal
axis tight
set(gca,'box','on')
xlabel('Latitude (m)')
ylabel('Longitude (m)')
colorbar
% change the colour scaling
if isempty(LIMS)
% scale varies in each timestep
% caxis([min(m.RESULT(:,VAR)) max(m.RESULT(:,VAR))]);
% scale remains constant in each timestep
caxis([min(-2) max(2)]);
else
caxis(LIMS);
end
% creating the movie
Mov(TIMESTEP) = getframe(gcf)
end
% Create AVI File
% fps, frames per second
movie2avi(Mov,'output.avi','fps',2)
% close the file
fclose(m.fid);