Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matlab, KML updates #277

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 42 additions & 24 deletions src/matlab/add_gauges.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

use_forestclaw = strcmpi(format,'forestclaw');

gauges = read_gauges();

np = get(gca,'NextPlot');
set(gca,'NextPlot','add');

Expand All @@ -34,13 +36,6 @@
return
end

fid = fopen('gauges.data','r');
for i = 1:5
% Read first five lines of comments
l = fgetl(fid);
end


if (use_forestclaw)
zmax = 0;
zl = [-20,0];
Expand All @@ -50,47 +45,70 @@
zl = [0,20];
end

gtype = struct('id',[],'longitude',[],'latitude',[],'t0',[],'t1',[]);

l = fgetl(fid); % blank line
l = fgetl(fid); % Get number of gauges
num_gauges = sscanf(l,'%d',1);
num_gauges = length(gauges);
gauge_handles = zeros(num_gauges,1);
for n = 1:num_gauges
l = fgetl(fid);
data = sscanf(l,'%d %e %e %e %d',Inf);
g = gtype;
g.id = data(1);
g.longitude = data(2);
g.latitude = data(3);
g.t0 = data(4);
g.t1 = data(5);
g = gauges(n);
zp = zmax;
hg = plot3(data(2),data(3),zp,'m.','linewidth',3,'markersize',95);
hg = plot3(g.longitude,g.latitude,zp,'m.','linewidth',3,'markersize',95);
set(gca,'zlim',zl);
view(2);
% set(gca,'zlimmode','auto');
set(hg,'Tag','gauge');
set(hg,'userdata',g);
h = text(data(2),data(3),zp,sprintf('%d',data(1)),'fontsize',11,'color','k');
h = text(g.longitude,g.latitude,zp,sprintf('%d',g.id),'fontsize',11,'color','k');
set(h,'HorizontalAlignment','center');
% set(h,'backgroundcolor','none');
gauge_handles(n) = hg;
end


zl = zlim;
if (use_forestclaw)
set(gca,'zlim',[min(zl),zmax]);
else
set(gca,'zlim',[0,zmax]);
end


% Restore hold status
set(gca,'NextPlot',np);
set(gca,'userdata',gauge_handles);

if (nargout > 0)
ghout = gauge_handles;
end

end
end

function gauges = read_gauges()

if (~exist('gauges.data','file'))
fprintf('File gauges.data does not exist. No gauges will be plotted.\n');
return
end

fid = fopen('gauges.data','r');
for i = 1:5
% Read first five lines of comments
fgetl(fid);
end

gtype = struct('id',[],'longitude',[],'latitude',[],'t0',[],'t1',[]);

fgetl(fid); % blank line
l = fgetl(fid); % Get number of gauges
num_gauges = sscanf(l,'%d',1);
gauges(1:num_gauges) = gtype;
for n = 1:num_gauges
l = fgetl(fid);
data = sscanf(l,'%d %e %e %e %d',Inf);
g = gtype;
g.id = data(1);
g.longitude = data(2);
g.latitude = data(3);
g.t0 = data(4);
g.t1 = data(5);
gauges(n) = g;
end

end
3 changes: 3 additions & 0 deletions src/python/visclaw/plotpages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,9 @@ def plotclaw2kml(plotdata):
while (a.startswith('#')):
a = f.readline()

# read line max1d
f.readline()

# read line containing max number of levels
a = f.readline()
ainfo = np.fromstring(a.strip(),sep=' ')
Expand Down