Skip to content

Commit 77b4f2e

Browse files
committed
further work for Octave compatibility
1 parent 2b7bf73 commit 77b4f2e

File tree

8 files changed

+70
-62
lines changed

8 files changed

+70
-62
lines changed

CODE/matlab/dem.m

+11-5
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,11 @@
205205
% Acknowledgments: Éric Gayer
206206
%
207207
% Created: 2007-05-17 in Guadeloupe, French West Indies
208-
% Updated: 2022-07-21
208+
% Updated: 2022-07-26
209209

210210
% History:
211+
% [2022-07-26] v3.1
212+
% - minor fix for Octave compatibility
211213
% [2022-07-21] v3.0
212214
% - new option 'shading' (stack method with opacity factor)
213215
% - new option 'elevation' (light elevation for stack shading)
@@ -717,7 +719,7 @@
717719
end
718720

719721
% normalisation of Z using CMAP and convertion to RGB
720-
I = ind2rgb(uint16(round((z - zmin)*(size(cmap,1) - 1)/dz) + 1),cmap);
722+
I = ind2rgb(uint16(min(max((z - zmin)/dz,0),1)*(size(cmap,1)-1)),cmap);
721723

722724
if ct > 0
723725
dx = diff(x(1:2));
@@ -990,7 +992,8 @@
990992
yscale = linspace(0,diff(ylim)/2,length(cmap));
991993
ddz = dtick(dz*max(0.5*xyr*diff(xlim)/yscale(end),1));
992994
ztick = (ddz*ceil(zscale(1)/ddz)):ddz:zscale(end);
993-
rgbscale = ind2rgb(uint16(round((zscale - zmin)*(size(cmap,1) - 1)/dz) + 1),cmap);
995+
rgbscale = ind2rgb(uint16(min(max((zscale - zmin)/dz,0),1)*(size(cmap,1)-1)),cmap);
996+
994997
ysc = ylim(1);
995998
hold on
996999
imagesc(xsc + wsc*[-1,1]/2,ysc + yscale,repmat(rgbscale,1,2),'clipping','off');
@@ -1146,11 +1149,14 @@
11461149
fs2 = sprintf('\\fontsize{%d}',round(fs/1.25));
11471150

11481151
if dec
1149-
s = regexprep(sprintf('%7.7g',x),'\.(.*)',sprintf('.{%s$1}',fs2));
1152+
ss = split(sprintf('%1.7g',x),'.');
1153+
s = fliplr(regexprep(fliplr(ss{1}),'(\d{3})','$1 '));
1154+
if length(ss) > 1
1155+
s = sprintf('%s.{%s%s}',s,fs2,ss{2});
1156+
end
11501157
else
11511158
xa = abs(x) + 1/360000;
11521159
sd = sprintf('%d%c',floor(xa),176); % ASCII char 176 is the degree sign
1153-
%sd = sprintf('%d�',floor(xa));
11541160
sm = '';
11551161
ss = '';
11561162
if mod(x,1)

CODE/matlab/mkgraph.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
%
1818
% Authors: F. Beauducel - D. Lafon, WEBOBS/IPGP
1919
% Created: 2002-12-03
20-
% Updated: 2022-07-25
20+
% Updated: 2022-07-26
2121

2222

2323
wofun = sprintf('WEBOBS{%s}',mfilename);
@@ -280,14 +280,14 @@
280280
try
281281
[A,map,alpha] = imread(ff{i});
282282
% applies transparency channel manually (for Octave compatibility)
283-
M = repmat(double(alpha)/255,[1,1,3]);
284-
I = M.*double(A)/255 + (1 - M);
283+
M = repmat(double(alpha)/double(intmax(class(alpha))),[1,1,3]);
284+
I = M.*double(A)/double(intmax(class(A))) + (1 - M);
285285
isz = size(A);
286286
lgh = rh*pp(3)/pp(4);
287287
lgw = lgh*isz(2)*pp(4)/isz(1)/pp(3);
288288
posx = pos0 + strcmp(pos,'right')*(1-lgw);
289289
h = axes('Position',[posx,1-lgh,lgw,lgh],'Visible','off');
290-
imagesc(I)
290+
image(I)
291291
axis off
292292
pos0 = pos0 + (lgw + 0.005)*(1 - 2*strcmp(pos,'right'));
293293
catch

CODE/matlab/mktides.m

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
%
2020
% Author: F. Beauducel, WEBOBS/IPGP
2121
% Created: 2015
22-
% Updated: 2017-02-03
22+
% Updated: 2022-07-26
2323

2424

2525
g = 9.81;
@@ -79,6 +79,5 @@
7979
end
8080

8181
if delflag
82-
rmdir(ptmp,'s');
82+
wosystem(sprintf('rm -rf %s',ptmp));
8383
end
84-

CODE/matlab/plottrans.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
% relative to the node N (structure from readnode) on current figure, using optional
55
% marker size MARKERSIZE (in points).
66
%
7-
% PLOTTRANS(WO,N,SIZE,'utm')
7+
% PLOTTRANS(WO,N,SIZE,'utm')
88
%
99
%
1010
% Author: F. Beauducel, WEBOBS/IPGP
1111
% Created: 2014-08-17, in Yogyakarta, Indonesia
12-
% Updated: 2017-08-02
12+
% Updated: 2022-07-26
1313

1414

1515
NODES = readcfg(WO,WO.CONF_NODES); % loads nodes config.
1616
T = readcfg(WO,NODES.FILE_TELE);
1717

18-
if ~isfield(N,'TRANSMISSION') | ~isstruct(N.TRANSMISSION) | ~isfield(N.TRANSMISSION,'NODES') | N.TRANSMISSION.TYPE < 1
18+
if ~isfield(N,'TRANSMISSION') || ~isstruct(N.TRANSMISSION) || ~isfield(N.TRANSMISSION,'NODES') || N.TRANSMISSION.TYPE < 1
1919
h = [];
2020
return
2121
end

CODE/matlab/readnode.m

+25-28
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
%
3434
% Authors: F. Beauducel, D. Lafon, WEBOBS/IPGP
3535
% Created: 2013-02-22
36-
% Updated: 2022-07-25
36+
% Updated: 2022-07-26
3737

3838

3939
if ~exist('NODES','var')
@@ -125,41 +125,38 @@
125125
clb = sprintf('%s/%s.clb',p,id); % for backwards compatibility
126126
end
127127
if exist(clb,'file')
128-
fid = fopen(clb);
129-
C = textscan(fid,'%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s','Delimiter','|','CommentStyle','#');
130-
fclose(fid);
131-
%[y,m,d,h,n,nv,nm,un,ns,cc,of,et,ga,vn,vm,az,la,lo,al] = textread(f,'%d-%d-%d%d:%d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%*[^\n]','delimiter','|','commentstyle','shell');
128+
C = readdatafile(clb,'CommentStyle','#')';
132129
nn = 1;
133-
for j = 1:length(C{1})
134-
k = strfind(C{3}{j},'-');
130+
for j = 1:size(C,2)
131+
k = strfind(C{3,j},'-');
135132
if isempty(k)
136-
j1 = str2double(C{3}{j});
133+
j1 = str2double(C{3,j});
137134
j2 = j1;
138135
else
139-
j1 = str2double(C{3}{j}(1:(k-1)));
140-
j2 = str2double(C{3}{j}((k+1):end));
136+
j1 = str2double(C{3,j}(1:(k-1)));
137+
j2 = str2double(C{3,j}((k+1):end));
141138
end
142139
for jj = j1:j2
143140
if any(isnan(N.CHANNEL_LIST)) || any(N.CHANNEL_LIST==jj)
144-
CC.dt(nn) = isodatenum(strcat(C{1}(j),{' '},C{2}(j)));
141+
CC.dt(nn) = isodatenum(strcat(C{1,j},{' '},C{2,j}));
145142
CC.nv(nn) = jj;
146-
CC.nm{nn} = C{4}{j};
147-
CC.un{nn} = C{5}{j};
148-
CC.ns{nn} = C{6}{j};
149-
CC.cd{nn} = C{7}{j};
150-
CC.of(nn) = sstr2num(C{8}{j});
151-
CC.et(nn) = sstr2num(C{9}{j});
152-
CC.ga(nn) = sstr2num(C{10}{j});
153-
CC.vn(nn) = sstr2num(C{11}{j});
154-
CC.vm(nn) = sstr2num(C{12}{j});
155-
CC.az(nn) = sstr2num(C{13}{j});
156-
CC.la(nn) = sstr2num(C{14}{j});
157-
CC.lo(nn) = sstr2num(C{15}{j});
158-
CC.al(nn) = sstr2num(C{16}{j});
159-
CC.dp(nn) = sstr2num(C{17}{j});
160-
CC.sf(nn) = sstr2num(C{18}{j});
161-
CC.db{nn} = C{19}{j};
162-
CC.lc{nn} = C{20}{j};
143+
CC.nm{nn} = C{4,j};
144+
CC.un{nn} = C{5,j};
145+
CC.ns{nn} = C{6,j};
146+
CC.cd{nn} = C{7,j};
147+
CC.of(nn) = sstr2num(C{8,j});
148+
CC.et(nn) = sstr2num(C{9,j});
149+
CC.ga(nn) = sstr2num(C{10,j});
150+
CC.vn(nn) = sstr2num(C{11,j});
151+
CC.vm(nn) = sstr2num(C{12,j});
152+
CC.az(nn) = sstr2num(C{13,j});
153+
CC.la(nn) = sstr2num(C{14,j});
154+
CC.lo(nn) = sstr2num(C{15,j});
155+
CC.al(nn) = sstr2num(C{16,j});
156+
CC.dp(nn) = sstr2num(C{17,j});
157+
CC.sf(nn) = sstr2num(C{18,j});
158+
CC.db{nn} = C{19,j};
159+
CC.lc{nn} = C{20,j};
163160
nn = nn + 1;
164161
end
165162
end

CODE/matlab/readnodes.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
%
2020
% Authors: F. Beauducel, D. Lafon, WEBOBS/IPGP
2121
% Created: 2013-02-23
22-
% Updated: 2019-02-07
22+
% Updated: 2022-07-26
2323

2424
if nargin < 2
2525
error('No few input arguments')
@@ -31,7 +31,7 @@
3131
grids = cellstr(grids);
3232
end
3333

34-
if nargin < 3 | isempty(tlim)
34+
if nargin < 3 || isempty(tlim)
3535
tlim = NaN;
3636
end
3737

CODE/matlab/superprocs/gridmaps.m

+15-10
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function gridmaps(grids,outd,varargin)
4040
%
4141
% Author: F. Beauducel, C. Brunet, WEBOBS/IPGP
4242
% Created: 2013-09-13 in Paris, France
43-
% Updated: 2021-05-19
43+
% Updated: 2022-07-21
4444

4545

4646
WO = readcfg;
@@ -117,10 +117,11 @@ function gridmaps(grids,outd,varargin)
117117
lwmajor = field2num(P,'CONTOURLINES_MAJOR_LINEWIDTH',1);
118118
zerolevel = isok(P,'CONTOURLINES_ZERO_LEVEL',0);
119119
convertopt = field2str(WO,'CONVERT_COLORSPACE','-colorspace sRGB');
120+
shading = field2str(P,'SHADING','light');
120121
feclair = field2num(P,'COLOR_LIGHTENING',2);
121122
csat = field2num(P,'COLOR_SATURATION',.8);
122123
zcut = field2num(P,'ZCUT',0.1);
123-
laz = field2num(P,'LIGHT_AZIMUTH',45);
124+
laz = field2num(P,'LIGHT_AZIMUTH',[-45,45]);
124125
lct = field2num(P,'LIGHT_CONTRAST',1);
125126
if isfield(P,'LANDCOLORMAP') && exist(P.LANDCOLORMAP,'file')
126127
cmap = eval(P.LANDCOLORMAP);
@@ -139,7 +140,7 @@ function gridmaps(grids,outd,varargin)
139140
end
140141
demoptions = {'Interp','Lake','LakeZmin',0,'ZCut',zcut,'Azimuth',laz, ...
141142
'Contrast',lct,'LandColor',cmap,'SeaColor',sea,'Watermark',feclair, ...
142-
'Saturation',csat,'latlon','legend','axisequal','manual'};
143+
'Saturation',csat,'latlon','shading',shading,'legend','axisequal','manual'};
143144

144145
% loads all needed grid's parameters & associated nodes
145146
for g = 1:length(grids)
@@ -192,7 +193,7 @@ function gridmaps(grids,outd,varargin)
192193
s = split(grids{g},'.');
193194
G = GRIDS.(s{1}).(s{2});
194195
% GRIDMAPS.rc SRTM1 option applies only if not defined in the PROC's configuration
195-
if isok(P,'DEM_SRTM1') & (~isfield(G,'DEM_SRTM1') || merge)
196+
if isok(P,'DEM_SRTM1') && (~isfield(G,'DEM_SRTM1') || merge)
196197
G.DEM_SRTM1 = 'Y';
197198
end
198199
if request
@@ -304,12 +305,12 @@ function gridmaps(grids,outd,varargin)
304305
clrgb = [0,0,0];
305306
end
306307
if length(dz1) > 1
307-
[~,h] = contour(x,y,z,dz1,'-','Color',clrgb);
308-
set(h,'LineWidth',lwminor);
308+
[~,h] = contour(x,y,z,dz1,'-');
309+
set(h,'LineColor',clrgb,'LineWidth',lwminor);
309310
end
310311
if length(dz0) > 1
311-
[cs,h] = contour(x,y,z,dz0,'-','Color',clrgb);
312-
set(h,'LineWidth',lwmajor);
312+
[cs,h] = contour(x,y,z,dz0,'-');
313+
set(h,'LineColor',clrgb,'LineWidth',lwmajor);
313314
if isok(P,'CONTOURLINES_LABEL')
314315
clabel(cs,h,dz0,'Color',clrgb,'FontSize',7,'FontWeight','bold','LabelSpacing',288)
315316
end
@@ -381,7 +382,8 @@ function gridmaps(grids,outd,varargin)
381382
xylim = [get(gca,'XLim'),get(gca,'YLim')];
382383

383384
% copyright
384-
copyright = sprintf('{\\bf\\copyright %s} - {%s} - %s / %s',WO.COPYRIGHT,strrep(grids{g},'_','\_'),demcopyright,datestr(now,0));
385+
copyright = sprintf('{\\bf\\copyright %s, %s} - {%s} - %s / %s',num2roman(str2double(datestr(now,'yyyy'))), ...
386+
WO.COPYRIGHT,strrep(grids{g},'_','\_'),demcopyright,datestr(now,0));
385387
axes('Position',[pos(1),0,pos(3),pos(2)])
386388
axis([0,1,0,1]); axis off
387389
text(.5,0,copyright,'Color',.4*[1,1,1],'FontSize',9,'HorizontalAlignment','center','VerticalAlignment','bottom')
@@ -437,7 +439,10 @@ function gridmaps(grids,outd,varargin)
437439
txt = regexprep(sprintf('%s: %s',NN(gg).alias{knn},NN(gg).name{knn}),'"','');
438440
fprintf(fid,'<AREA href="%s" title="%s" shape=circle coords="%d,%d,%d">\n',lnk,txt,x,y,r);
439441
else
440-
txt = unicode2native(regexprep(sprintf('<b>%s</b>: %s',NN(gg).alias{knn},NN(gg).name{knn}),'"',''),'utf-8');
442+
txt = regexprep(sprintf('<b>%s</b>: %s',NN(gg).alias{knn},NN(gg).name{knn}),'"','');
443+
try
444+
txt = unicode2native(txt,'UTF-8');
445+
end
441446
txt = regexprep(char(txt),'''','\\''');
442447
fprintf(fid,'<AREA href="%s" onMouseOut="nd()" onMouseOver="overlib(''%s'')" shape=circle coords="%d,%d,%d">\n',lnk,txt,x,y,r);
443448
end

CODE/matlab/superprocs/locastat.m

+8-7
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function locastat(sta)
243243

244244
% profil NS
245245
ax21 = axes('Position',[.455,(.1+pcart)/(1+pcart),.045,.4/(1+pcart)]);
246-
xp = zz2(:,round(size(zz2,2)/2))'; yp = yy2(:,1);
246+
xp = zz2(:,round(size(zz2,2)/2))'; yp = yy2(:,1)';
247247
xp(find(isnan(xp))) = 0;
248248
fill([mmz(1),xp,mmz(1),mmz(1)],yp([1,1:end,end,1]),gris)
249249
set(gca,'XLim',mmz,'YLim',xy2(3:4),'XDir','reverse'), axis off
@@ -380,7 +380,7 @@ function locastat(sta)
380380
end
381381

382382
% --- frame 3: user-defined DEM or interpolated SRTM
383-
if f3dem & utm(ki,1) >= min(xdem) & utm(ki,1) <= max(xdem) & utm(ki,2) >= min(ydem) & utm(ki,2) <= max(ydem)
383+
if f3dem && utm(ki,1) >= min(xdem) && utm(ki,1) <= max(xdem) && utm(ki,2) >= min(ydem) && utm(ki,2) <= max(ydem)
384384
x3 = xdem;
385385
y3 = ydem;
386386
z3 = zdem;
@@ -405,10 +405,10 @@ function locastat(sta)
405405
dem(x3(kx),y3(ky),z3(ky,kx),demoptions{:}); axis off
406406
hold on
407407
[cs,h] = contour(x3(kx),y3(ky),z3(ky,kx),[0,0,50:100:zmax],'-k');
408-
set(h,'LineWidth',.1,'Color',gris2);
408+
set(h,'LineWidth',.1,'LineColor',gris2);
409409
if zmax >= 100
410410
[cs,h] = contour(x3(kx),y3(ky),z3(ky,kx),[100,100,100:100:zmax],'-k');
411-
set(h,'LineWidth',1.5,'Color',gris2);
411+
set(h,'LineWidth',1.5,'LineColor',gris2);
412412
clabel(cs,h,'FontSize',7,'FontWeight','bold','LabelSpacing',288,'Color',gris2)
413413
end
414414
if trans, plottrans(WO,N(ki),15,'utm'); end
@@ -435,7 +435,8 @@ function locastat(sta)
435435
hold off
436436

437437
% ---- copyright (cartouche bas)
438-
message = sprintf(' {\\bf%s} \\copyright %s - %s / %s ',N(ki).ID,WO.COPYRIGHT,demcopyright,datestr(now,0));
438+
message = sprintf(' {\\bf%s} \\copyright %s, %s - %s / %s ',N(ki).ID,num2roman(str2double(datestr(now,'yyyy'))), ...
439+
WO.COPYRIGHT,demcopyright,datestr(now,0));
439440
axes('Position',[0,0,1,pcart/(1+pcart)]); axis([0,1,0,1]); axis off
440441
text(0,.5,message,'FontSize',9,'HorizontalAlignment','left')
441442
if ign
@@ -448,8 +449,8 @@ function locastat(sta)
448449

449450
% ---- exports figure
450451
ftmp = sprintf('%s/locastat',ptmp);
451-
print(gcf,'-depsc2','-loose','-painters',sprintf('%s.ps',ftmp));
452-
wosystem(sprintf('%s %s -density %dx%d %s.ps %s.png',WO.PRGM_CONVERT,convertopt,dpi,dpi,ftmp,ftmp));
452+
print(sprintf('%s.eps',ftmp),'-depsc','-loose','-painters');
453+
wosystem(sprintf('%s %s -density %dx%d %s.eps %s.png',WO.PRGM_CONVERT,convertopt,dpi,dpi,ftmp,ftmp));
453454
wosystem(sprintf('mv -f %s.png %s',ftmp,fimg));
454455

455456
fprintf('done.\n');

0 commit comments

Comments
 (0)