Skip to content

Commit c429e04

Browse files
authored
Merge pull request #11 from Deltares/qp/bugfix/UNST-9530_correct_vector_direction
Slicing improvements; station sorting; initial support for Tecplot ascii files; various minor changes
2 parents 91f2ed6 + d2a47d5 commit c429e04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2293
-924
lines changed

src/tools_lgpl/matlab/quickplot/progsrc/arbcross.m

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
VGRIDStr = 'VGRID';
148148
XGRID = varargin{1}(:,:,1);
149149
YGRID = varargin{2}(:,:,1);
150-
[FaceNodeConnect,QUADTRI] = grid2tri(XGRID,YGRID);
150+
[FaceNodeConnect,faceToGridIndex] = grid2faces(XGRID,YGRID);
151151
EdgeNodeConnect = [];
152152
layeredxy = size(varargin{1},3)>1;
153153
nFaces = 0;
@@ -213,7 +213,7 @@
213213
else
214214
EdgeNodeConnect = [];
215215
end
216-
QUADTRI = [];
216+
faceToGridIndex = [];
217217
nFaces = size(FaceNodeConnect,1);
218218
end
219219

@@ -246,22 +246,9 @@
246246
end
247247
end
248248
%
249-
% Remove diagonals ... maybe it would be faster to not put them in in
250-
% the first place, but maybe I need them again in the future for
251-
% consistency.
252-
%
253-
if ~isempty(QUADTRI)
254-
iFace = QUADTRI(iFace);
255-
rm = find((iFace(1:end-1)==iFace(2:end)) & ~isnan(x(2:end-1,1)));
256-
x(rm+1,:) =[];
257-
y(rm+1,:) =[];
258-
wght(rm+1,:) =[];
259-
iFace(rm+1,:) =[];
260-
iNode(rm+1,:) =[];
261-
fracudist(rm+1,:)=[];
262-
outside(rm,:) =[];
263-
dxt(rm,:) =[];
264-
dyt(rm,:) =[];
249+
% optionally map faces back to linear indices into the 2D grid arrays
250+
if ~isempty(faceToGridIndex)
251+
iFace = faceToGridIndex(iFace);
265252
end
266253
%
267254
% Expand coordinates to 3D if original x/y arrays were 3D.
@@ -275,7 +262,10 @@
275262
%
276263
if ~isempty(EdgeNodeConnect)
277264
edgeCrossing = sum(~isnan(wght) & wght~=0,2)==2;
278-
edgeNodes = sort(iNode(:,1:2),2);
265+
edgeNodes = iNode;
266+
edgeNodes(wght == 0 | isnan(wght)) = inf;
267+
edgeNodes = sort(edgeNodes,2);
268+
edgeNodes = edgeNodes(:,1:2);
279269
EdgeNodeConnect = sort(EdgeNodeConnect,2);
280270
[isEdge,edgeNr] = ismember(edgeNodes,EdgeNodeConnect,'rows');
281271
iEdge = NaN(size(wght,1),1);
@@ -373,27 +363,40 @@
373363
end
374364

375365

376-
function [tri,quadtri] = grid2tri(X,Y)
377-
%GRID2TRI converts a curvilinear grid into a triangular grid
378-
% [TRI,QUADTRI]=GRID2TRI(XGRID,YGRID)
379-
% Splits the quadrangles of the curvilinear grid along the main diagonal
380-
% and returns the triangle definition table TRI (indicating the corner
381-
% points of the triangles as indices into XGRID, YGRID) and an array
382-
% QUADTRI that contains for every triangle the index of the quadrangle to
383-
% which the triangle belongs (index into an array of size SIZE(XGRID)-1).
366+
function [faceNodeConnect,faceToGridIndex] = grid2faces(xGrid,yGrid)
367+
%GRID2FACES converts a curvilinear grid into a quad grid
368+
%
369+
% Syntax
370+
% [faceNodeConnect,faceToGridIndex] = grid2faces(xGrid,yGrid)
371+
%
372+
% Input Arguments
373+
% xGrid - X-coordinates of curvilinear grid
374+
% array of size nRows x nCols
375+
% yGrid - Y-coordinates of curvilinear grid
376+
% array of size nRows x nCols
377+
%
378+
% Output Arguments
379+
% faceNodeConnect - face-node connectivity: each row of the array lists
380+
% the four linear indices of the nodes defining the boundary of the
381+
% face. Only faces are defined for which the xGrid and yGrid values of
382+
% all four nodes are not NaN.
383+
% array of size nFaces x 4
384+
% faceToGridIndex - the linear index of the grid cell for each defined
385+
% face. The linear index of the grid cell is defined as the linear
386+
% index of the grid cell in an array of size (nRows-1) x (nCols-1).
387+
% vector of length nFaces
384388

385-
szX = size(X);
386-
% [m,n]=ndgrid(1:szX(1),1:szX(2));
389+
% generate a node index array for the "lowest" node index
390+
szX = size(xGrid);
387391
I = reshape(1:prod(szX),szX);
388392
I = I(1:end-1,1:end-1);
389393
I = I(:);
390-
quad = (1:prod(szX-1))';
391394

392-
tri = [I I+1 I+szX(1)+1; I I+szX(1) I+szX(1)+1];
393-
quadtri = [quad;quad];
394-
% mtri = [m(I);m(I)];
395-
% ntri = [n(I);n(I)];
395+
% generate full set of faces
396+
faceNodeConnect = [I I+1 I+szX(1)+1 I+szX(1)];
397+
faceToGridIndex = (1:prod(szX-1))';
396398

397-
k = any(isnan(X(tri)) | isnan(Y(tri)),2);
398-
tri(k,:) = [];
399-
quadtri(k) = [];
399+
% reduce to fully defined cells only
400+
k = any(isnan(xGrid(faceNodeConnect)) | isnan(yGrid(faceNodeConnect)),2);
401+
faceNodeConnect(k,:) = [];
402+
faceToGridIndex(k) = [];

src/tools_lgpl/matlab/quickplot/progsrc/asciiwind.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,9 @@ function Local_write_netcdf_spw(Structure,ncid,wind_opt)
10011001
keyw = '';
10021002
value = Line;
10031003
else
1004-
keyw = lower(deblank(Line(1:eq-1)));
1005-
value = strtrim(Line(eq+1:end));
1004+
eq1 = eq(1);
1005+
keyw = lower(deblank(Line(1:eq1-1)));
1006+
value = strtrim(Line(eq1+1:end));
10061007
end
10071008

10081009

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
COLORMAP
2+
NAME=jet (5% grey band)
3+
SPACE=RGB
4+
0.0000 0 0 128
5+
0.1250 0 0 255
6+
0.4750 0 255 255
7+
0.4750 245 245 245
8+
0.5250 245 245 245
9+
0.5250 255 255 0
10+
0.8750 255 0 0
11+
1.0000 128 0 0

src/tools_lgpl/matlab/quickplot/progsrc/d3d_qp.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4609,13 +4609,13 @@
46094609
I.Method=2;
46104610
I.AllFigures=1;
46114611
I.DPI=72;
4612-
I.InvertHardcopy=0;
4612+
I.BlackAxesWhiteFig=0;
46134613
md_print(Fig,I)
46144614
case 'clipmeta'
46154615
I.PrtID='Metafile to clipboard';
46164616
I.Method=1;
46174617
I.AllFigures=1;
4618-
I.InvertHardcopy=1;
4618+
I.BlackAxesWhiteFig=1;
46194619
md_print(Fig,I)
46204620
otherwise
46214621
if ~isempty(cmdargs)
@@ -4625,9 +4625,9 @@
46254625
I.AllFigures=1;
46264626
I.Color=cmdargs{5};
46274627
if length(cmdargs)>5
4628-
I.InvertHardcopy=cmdargs{6};
4628+
I.BlackAxesWhiteFig=cmdargs{6};
46294629
else
4630-
I.InvertHardcopy=1;
4630+
I.BlackAxesWhiteFig=1;
46314631
end
46324632
if length(cmdargs)>6
46334633
I.PageLabels=cmdargs{7};
@@ -4641,7 +4641,7 @@
46414641
I.DPI=qp_settings('print_DPI');
46424642
I.AllFigures=0;
46434643
I.Color=qp_settings('print_colour');
4644-
I.InvertHardcopy=qp_settings('print_inverthardcopy');
4644+
I.BlackAxesWhiteFig=qp_settings('print_inverthardcopy');
46454645
I.PageLabels=qp_settings('print_pagelabels');
46464646
I.SelectFrom=get_nondialogs;
46474647
[I,FigNew]=md_print('getsettings',Fig,I);
@@ -4680,9 +4680,9 @@
46804680
qp_settings('print_method',I.Method);
46814681
qp_settings('print_DPI',I.DPI);
46824682
qp_settings('print_colour',I.Color);
4683-
qp_settings('print_inverthardcopy',I.InvertHardcopy);
4683+
qp_settings('print_inverthardcopy',I.BlackAxesWhiteFig);
46844684
qp_settings('print_pagelabels',I.PageLabels);
4685-
args={filename I.PrtID I.Method I.DPI I.Color I.InvertHardcopy I.PageLabels};
4685+
args={filename I.PrtID I.Method I.DPI I.Color I.BlackAxesWhiteFig I.PageLabels};
46864686
end
46874687
set(sld,'vis','on')
46884688
set(psh,'vis','on')
@@ -5177,9 +5177,9 @@
51775177
'showinactiveopt', 'defaultfigurepos','timezonehandling', ...
51785178
'enforcedtimezone', 'netcdf_use_fillvalue','export_max_ntimes', ...
51795179
'update_showversion', 'defaultrenderer','defaultsmoothing', ...
5180-
'ghostscript', 'ghostscript_browse'}
5180+
'ghostscript', 'ghostscript_browse','station_sorting'}
51815181
args = qp_prefs(UD,mfig,cmd,cmdargs);
5182-
if logfile
5182+
if logfile && ~ismember(cmd,{'preferences','prefpane'})
51835183
writelog(logfile,logtype,args{:});
51845184
end
51855185

src/tools_lgpl/matlab/quickplot/progsrc/private/analytical_solution.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
[varargout{1:2}]=gettimezone(FI,idom,Props);
9595
return
9696
case 'stations'
97-
varargout={readsts(FI,Props,0)};
97+
varargout={readsts(FI,Props,varargin{:})};
9898
return
9999
case 'subfields'
100100
varargout={getsubfields(FI,Props,varargin{:})};

src/tools_lgpl/matlab/quickplot/progsrc/private/arcgridfil.m

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
[varargout{1:2}]=gettimezone(FI,domain,Props);
9090
return
9191
case 'stations'
92-
varargout={readsts(FI,Props,0)};
92+
varargout={readsts(FI,Props,varargin{:})};
9393
return
9494
case 'subfields'
9595
varargout={getsubfields(FI,Props,varargin{:})};
@@ -503,14 +503,6 @@
503503
end
504504
% -----------------------------------------------------------------------------
505505

506-
507-
% -----------------------------------------------------------------------------
508-
function S=readsts(FI,Props,t)
509-
510-
%======================== SPECIFIC CODE =======================================
511-
S={};
512-
% -----------------------------------------------------------------------------
513-
514506
% -----------------------------------------------------------------------------
515507
function [NewFI,cmdargs]=options(FI,mfig,cmd,varargin)
516508
Inactive=get(0,'defaultuicontrolbackground');

src/tools_lgpl/matlab/quickplot/progsrc/private/asciiwindfil.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
[varargout{1:2}]=gettimezone(FI,domain,Props);
9090
return
9191
case 'stations'
92-
varargout={readsts(FI,Props,0)};
92+
varargout={readsts(FI,Props,varargin{:})};
9393
return
9494
case 'subfields'
9595
varargout={getsubfields(FI,Props,varargin{:})};

src/tools_lgpl/matlab/quickplot/progsrc/private/cfxfil.m

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
[varargout{1:2}]=gettimezone(FI,domain,Props);
7979
return
8080
case 'stations'
81-
varargout={{}};
81+
varargout={readsts(FI,Props,varargin{:})};
8282
return
8383
case 'subfields'
8484
varargout={{}};
@@ -323,11 +323,3 @@
323323
T=T(t);
324324
end
325325
% -----------------------------------------------------------------------------
326-
327-
328-
% -----------------------------------------------------------------------------
329-
function S=readsts(FI,Props,t)
330-
331-
%======================== SPECIFIC CODE =======================================
332-
S={};
333-
% -----------------------------------------------------------------------------

src/tools_lgpl/matlab/quickplot/progsrc/private/d3d_bothfil.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
[varargout{1:2}]=gettimezone(FI,domain,Props);
8989
return
9090
case 'stations'
91-
varargout={readsts(FI,Props,0)};
91+
varargout={readsts(FI,Props,varargin{:})};
9292
return
9393
case 'subfields'
9494
varargout={{}};
@@ -356,4 +356,7 @@
356356
%======================== SPECIFIC CODE =======================================
357357
[S,Chk]=vs_get(FI,'HISBOT','NAMSTD','quiet');
358358
S=cellstr(S);
359+
if nargin>2 && ~isequal(t,0)
360+
S=S(t);
361+
end
359362
% -----------------------------------------------------------------------------

src/tools_lgpl/matlab/quickplot/progsrc/private/d3d_simfil.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
[varargout{1:2}]=gettimezone(FI,idom,Props);
102102
return
103103
case 'stations'
104-
varargout={readsts(FI,Props,0)};
104+
varargout={readsts(FI,Props,varargin{:})};
105105
return
106106
case 'subfields'
107107
varargout={getsubfields(FI,Props,varargin{:})};

0 commit comments

Comments
 (0)