Issue on check_refine.m

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
MBendoni
Posts: 6
Joined: Thu Jan 24, 2019 7:16 pm
Location: CNR-ISMAR

Issue on check_refine.m

#1 Unread post by MBendoni »

Dear all,

I write to ask for a problem arose using the check_refine function to control the consistency between parent and child grid. It is not so crucial since it is a tool to check, instead of produce necessary files to run the model, but I am not sure a similar problem may arise somewhere else in the functions provided in the matlab toolbox. However, it is a rounding problem related to the indexing.

Here you have the modified code of the check_refine.m function to resolve the issue (of course something better is possible):

Code: Select all

YrF = [YpF(1)-half YpF+half];                    % RHO-points  
% Start modification
% Idg = fix(XrF(Imid) - 0.5) + 1;
% Jdg = fix(YrF(Jmid) - 0.5) + 1;
Idg = ceil(XrF(Imid));
Jdg = ceil(YrF(Jmid));
% End modification			
[Yrg,Xrg] = meshgrid(Jdg,Idg);

and this is the matlab output for the variables XrF and Idg the case of Hurrican Sandy with the grids from the COAWST/Project/Sandy folder (Sandy_roms_grid.nc, Sandy_roms_grid_ref3.nc) both for the previous (Idg_old) and the modified indexing (rows 10-11 have the same index for the old version):

[XrF(Imid(1:15))' Idg_old(1:15)' Idg(1:15)']

ans =

22.5 23 23
23.5 24 24
24.5 25 25
25.5 26 26
26.5 27 27
27.5 28 28
28.5 29 29
29.5 30 30
30.5 31 31
31.5 32 32
32.5 32 33
33.5 33 34
34.5 34 35
35.5 35 36
36.5 36 37

If format long is activated in matlab it is possible to check that 32 is instead 31.99999 and the function fix() rounds it to 31 instead of 32 (during the call 'fix(XrF(Imid) - 0.5)').

I noticed such an issue because with the check_refine function I got really high differences between the variables S(dg).h(dg_index) and S(rg).h_avg and it was due to the wrong indexing instead of real differences in the bathymetries.

Hope it helps.

Post Reply