Which tool is the stablest tools to create ROMS grid?

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
leo_lee
Posts: 7
Joined: Mon Mar 12, 2018 2:19 pm
Location: Meteorology and Oceanology Institution of NUDT

Which tool is the stablest tools to create ROMS grid?

#1 Unread post by leo_lee »

Hi, I am a beginner to ROMS learning, I have tried many ROMS grid generation tools, such as Seagrid easygrid and GridBuilder.

Seagrid and easygrid tools have not been updated for a long time, so when I use them in matlab, I always encounter many errors.
I have been using the GridBuilder tool. But it can't be opened sporadically.
so I want to know if there is a up-to-date grid generation tool or what is the wide-used tool to create ROMS grid?


Thanks for your attention and your reply.

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#2 Unread post by CharlesJames »

GridBuilder is now available as a Matlab Toolbox (.mltbx) including source code from John Luick's Austides site (http://austides.com/downloads). Once installed, it should run from the command line under any recent version of Matlab. If you are having problems with program please let me know the specifics including any error messages you are getting.

victory9269
Posts: 2
Joined: Sat Aug 26, 2017 12:59 am
Location: Tsinghua University

Re: Which tool is the stablest tools to create ROMS grid?

#3 Unread post by victory9269 »

Hi Charles

I am a new GridBuilder user. I use an old coarse grid generated by seagrid to get a fine subgrid by GridBuilder. Then problems show up when I try to generate a contact file using the ROMS function 'contact'. The error message is:

Reference to non-existent field 'contact'.
Error in grid_connections (line 635)
dg = S.contact(cr).donor_grid;
Error in contact (line 312)
S = grid_connections(G, S);

Then if the coarse and fine grids are both generated by Gridbuilder, errors also happen during generation of a contact file:
undefined function or variable 'FCr'.
Error in contact>refine_coordinates (line 721)
FSr.Values = G(dg).angle(:); R.angle = FCr(XrF, YrF);
Error in contact>refinement (line 1512)
R = refine_coordinates (cr, dg, rg, G, S, MaskInterp);
error contact (line 327)
[P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp);

Thanks, Victor
CharlesJames wrote:GridBuilder is now available as a Matlab Toolbox (.mltbx) including source code from John Luick's Austides site (http://austides.com/downloads). Once installed, it should run from the command line under any recent version of Matlab. If you are having problems with program please let me know the specifics including any error messages you are getting.

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#4 Unread post by CharlesJames »

Hi Victor,

Unfortunately I haven't added support for creating multiple nested grids into GruidBuilder since I've only done off-line nesting. For now you'll have to add the nesting attributes manually to the attributes in the new grid to use contact.m. I'll look into it for the next time I update the program. If I know the parent grid, I should be able to compute the refinement attributes and the contact file at the same time but I'll need to learn more about the process to be able to test the generated grids.

cheers,


Charles

User avatar
hpd14thu
Posts: 68
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Re: Which tool is the stablest tools to create ROMS grid?

#5 Unread post by hpd14thu »

CharlesJames wrote:Hi Victor,

Unfortunately I haven't added support for creating multiple nested grids into GruidBuilder since I've only done off-line nesting. For now you'll have to add the nesting attributes manually to the attributes in the new grid to use contact.m. I'll look into it for the next time I update the program. If I know the parent grid, I should be able to compute the refinement attributes and the contact file at the same time but I'll need to learn more about the process to be able to test the generated grids.

cheers,


Charles
Hi Charles,

I am also a new user. I wonder that if I can just set the corner in the map your provide? I wanna use the exact value(for example 10°N 10°E) as the gird corner, but I did not find that function. Thank you and look for your reply.

Peida

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#6 Unread post by CharlesJames »

Hi Peida,

It sounds like being able to specify exact corner coordinates would be a useful feature to add, I'll try and put something together. In the meantime you can import custom reference points in a text file as comma deliminated x,y pairs. These points will plot as small black + symbols on the map at the exact points specified. By creating a free format grid, you can then drag each corner over one of the fixed reference points, by repeating this and zooming in on the corners you can get arbitrarily close to the exact coordinate but I realize it would be somewhat tedious to get it down to double precision accuracy.

I'll take the last two questions as suggestions and see if I can fit in another update later this year.

thanks,
CJ

User avatar
hpd14thu
Posts: 68
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Re: Which tool is the stablest tools to create ROMS grid?

#7 Unread post by hpd14thu »

CharlesJames wrote:Hi Peida,

It sounds like being able to specify exact corner coordinates would be a useful feature to add, I'll try and put something together. In the meantime you can import custom reference points in a text file as comma deliminated x,y pairs. These points will plot as small black + symbols on the map at the exact points specified. By creating a free format grid, you can then drag each corner over one of the fixed reference points, by repeating this and zooming in on the corners you can get arbitrarily close to the exact coordinate but I realize it would be somewhat tedious to get it down to double precision accuracy.

I'll take the last two questions as suggestions and see if I can fit in another update later this year.

thanks,
CJ

Hi Charles,

Thank you for your reply. And I find another way to specify exact corner coordinates: I use Matlab to generate a nc.file containing the lon and lat data, then I open this file in Gridbuilder.

Thanks again,
Peida

victory9269
Posts: 2
Joined: Sat Aug 26, 2017 12:59 am
Location: Tsinghua University

Re: Which tool is the stablest tools to create ROMS grid?

#8 Unread post by victory9269 »

CharlesJames wrote:Hi Victor,

Unfortunately I haven't added support for creating multiple nested grids into GruidBuilder since I've only done off-line nesting. For now you'll have to add the nesting attributes manually to the attributes in the new grid to use contact.m. I'll look into it for the next time I update the program. If I know the parent grid, I should be able to compute the refinement attributes and the contact file at the same time but I'll need to learn more about the process to be able to test the generated grids.

cheers,


Charles
Hi Charles

Many thanks for your answer. The GridBuilder is a nice tool and we are looking forward to its update.

Regards, Victor

User avatar
jivica
Posts: 172
Joined: Mon May 05, 2003 2:41 pm
Location: The University of Western Australia, Perth, Australia
Contact:

Re: Which tool is the stablest tools to create ROMS grid?

#9 Unread post by jivica »

Just adding comment when Sasa is not going to ;)

I find extremely useful Alex's tool for generating curvlinear orthogonality error free grids and suggest you to have a look at the older posts:

viewtopic.php?f=23&t=3878&p=14908

and

viewtopic.php?f=14&t=4775&p=18530#p18530

It is easy to create grid and the gird is of high quality (i.e. ortho error ~0)

p.s. there are other packages as well (based on Pavel Sakov's gridgen) that can make amazing grids as well (just google).

Cheers
I.

c.drinkorn
Posts: 110
Joined: Thu Mar 08, 2018 2:47 am
Location: German Research Centre for Geosciences

Re: Which tool is the stablest tools to create ROMS grid?

#10 Unread post by c.drinkorn »

Hi all,

I am trying to "replace" the topography in an existing ROMS grid file. But when I load the grid file into GridBuilder I get the error:

Code: Select all

Error using griddedInterpolant
Grid is improperly defined.

Error in setROMSgrid (line 59)
BathyInterpolant=griddedInterpolant(bathymetry.xbathy,bathymetry.ybathy,bathymetry.zbathy,'linear','none');

Error in GridBuilderCallbacks (line 74)
                setROMSgrid(SG);

Error in GridBuilder>mImROMS_Callback (line 440)
GridBuilderCallbacks(hObject,eventdata,handles)

Error in gui_mainfcn (line 95)
        feval(varargin{:});

Error in GridBuilder (line 42)
    gui_mainfcn(gui_State, varargin{:});

Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)GridBuilder('mImROMS_Callback',hObject,eventdata,guidata(hObject)) 
Error while evaluating Menu Callback.
My grid is an Arctic grid, i.e. it has a pole in it. I don't know if that poses a problem to GridBuilder. The grid I am using has not been generated by me. I could investigate it further but "improperly" is quite a vague statement.

Thanks for any hints or help!

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#11 Unread post by CharlesJames »

Hi,

I haven't tested GridBuilder or ROMS with a polar grid before, the error message is from Matlab's griddedInterpolant routine which usually wants a ndgrid type x,y coordinate so it may be my routines for reading in topography with a pole in it are falling over a bit, if the routine didn't get the x,y into a suitable configuration that would cause a problem. If you can send me a copy of the grid and topography i can see what is required to read it in correctly. Assuming I can fix it easily, that will add a nice new capability to the program.

Charles

c.drinkorn
Posts: 110
Joined: Thu Mar 08, 2018 2:47 am
Location: German Research Centre for Geosciences

Re: Which tool is the stablest tools to create ROMS grid?

#12 Unread post by c.drinkorn »

Hi Charles,

I sent you an email with the files. In the meanwhile, I will try myself to find a solution, too.

Cheers,
Cate

c.drinkorn
Posts: 110
Joined: Thu Mar 08, 2018 2:47 am
Location: German Research Centre for Geosciences

Re: Which tool is the stablest tools to create ROMS grid?

#13 Unread post by c.drinkorn »

Okay, I managed to load my grid file into gridBuilder by adding these two lines to the getDefaultBathymetry function:

Code: Select all

if axlim(1)<-180;axlim(1)=-180;end
if axlim(2)>180;axlim(2)=180;end
By remapping my new topography to the old grid file grid and writing a simple script to load lon_rho, lat_rho and z into a respective .mat file (containing xbathy, ybathy and zbathy), I also managed to replace the topography and export an actual grid. What's still disturbing is a seam between min and max lon. I guess, I'll have to modify my input topography accordingly. But for now I am happy to at least have a new grid file for first simulation attempts. :)

Looking forward to hearing your opinion on my rudimentary fix! :lol:

lcbernardo
Posts: 88
Joined: Wed Oct 01, 2014 8:57 pm
Location: International Coastal Research Center

Re: Which tool is the stablest tools to create ROMS grid?

#14 Unread post by lcbernardo »

After looking through recent posts in this thread, I thought I'd try posting about some grid generation related issues I've been having. Though I've tried using Gridbuilder a few times before, it's only this week that I really started using it for an application I'm setting up. It works great for the most part, and I find it to be very useful for creating regional scale grids. I've been trying to create a finer scale grid though, for a domain 4 km x 2 km, and a grid cell size of approximately 50 meters, and I've been having some difficulty as the program really slows down or even stops working whenever I try to translate or adjust the size of the grid through the corner points. I've tried using both the standalone version as well as the Matlab toolbox, but I encounter the same situation. Is this a known issue for Gridbuilder?

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#15 Unread post by CharlesJames »

It is interesting that both these issues seem to relate to getDefaultBathymetry which is used to open the ETOPO2 default and extract topography for the region, this might not always be necessary if the user has imported their own topography first but it is still called and kept in reserve to fill in gaps if the domain is moved around outside the imported topography limits. Both grids are fairly extreme examples of domains, one is very, very small, the other is probably 360 degrees in longitude, and I think that is what is triggering these bugs. In the very small domain I don't think it is the 50m resolution that is the problem (I can do that fairly easily with a larger domain) but the size of the domain itself. For 4km x 2km ETOPO2 may have fewer that two depth points which means the griddedInterpolant routine will not work - I'll modify the code to maintain a minimum of decent number of points in an array regardless of domain size, that should keep it from falling over. I assume you will be importing much higher resolution topography and coastline, ETOPO2 is no use at 50m. For the polar example, I'm sorry I didn't get the grid file in my email, if the file is too large it may not have gotten through my work address, we have fairly low limits on attachments, perhaps you can post it on the forum or send me a dropbox link to it. I'm assuming the grid will be rectangular with +90 as the upper boundary and periodic BC at +/-180 is that right? The fix that Cate came up with suggests the function can't handle the fact that there are two boundaries at +/- 180 that are effectively the same longitude, the fact that you are getting a seam in the data suggests that the topography at one of the boundaries is being lost, I'll have a look at that and see if I can write that to handle the special case of "around the world" grids, it will be relevant for other models like that as well. Thanks for the feed back, I'll post here when I've got a fix.

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#16 Unread post by CharlesJames »

I've made a small fix to getDefaultBathymetry.m which is hopefully attached, if too few eTOPO points are found in the model domain this should ensure that the nearest array of depths that include the model domain are still returned. I'm not sure if this will help with the polar grid yet I'll have to do some more testing. If this works ok I'll include it in the next update.
Attachments
getDefaultBathymetry.m
This modified getDefaultBathymetry file should ensure there is always at least a 2x2 array of eTOPO topography regardless of domain size.
(3.67 KiB) Downloaded 917 times

c.drinkorn
Posts: 110
Joined: Thu Mar 08, 2018 2:47 am
Location: German Research Centre for Geosciences

Re: Which tool is the stablest tools to create ROMS grid?

#17 Unread post by c.drinkorn »

Hi Charles,

I attached the grid file and the topography (remapped to the grid file's grid). I included your fix into getDefaultBathymetry but unfortunately this didn't solve the problem so I still had to add the lines for axlim(1) and axlim(2).
I appreciate if you try and find a solution for the polar application but no need to hurry. :)

I have one more question: When creating a new mask from topography, does GridBuilder use the loaded topography or the ETOPO? Thank you!

//Cate
Attachments
A20_topo_Miocene.nc
(917.39 KiB) Downloaded 1002 times
A20_grd_openBering_double.nc
(6.84 MiB) Downloaded 963 times

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#18 Unread post by CharlesJames »

OK, I see what you have now, it is a rectangular grid but includes the north pole so the gridbuilder default projection is very distorted and the sides are not calculated correctly. To allow gridbuilder to manipulate this grid or others like it I'd need to add a sterographic projection to allow grids like yours to appear rectangular and get the boundaries and topography right.

The problems loading the default topography were due to expanding the domain by 10% on each boundary to ensure enough eTOPO bathymetry was included for small grids, since I shifted this task to the getDefaultBathymetry program this isn't required anymore. It was causing a problem with grids that run from -180 to 180 since it created domains that were more than 360 degrees wide and eTOPO couldn't provide topography for that. Your fix worked fine as it restored the proper limits within the function, but by eliminating the domain expansion that problem shouldn't crop up again. I've attached a new setROMSgrid routine that fixes this if used in conjuction with the previous getDefaultBathymetry file I posted - I'll try and get an update including both these fixes up as soon as possible.

GridBuilder uses the user topography for masking if topography based masking is selected, but I don't think the topography in your example will be correctly mapped in Spherical coordiates so you may not get the results you want.

I've had requests before for stereographic projections so maybe it's time to look at integrating it like the Cartesian/Spherical selection - this may take a bit of time though since there are a lot of dependent functions to update.
Attachments
setROMSgrid.m
remove expansion of domain for eTopo bathymetry - now handled in getDefaultBathymetry.
(3.01 KiB) Downloaded 1019 times

lcbernardo
Posts: 88
Joined: Wed Oct 01, 2014 8:57 pm
Location: International Coastal Research Center

Re: Which tool is the stablest tools to create ROMS grid?

#19 Unread post by lcbernardo »

CharlesJames wrote:I've made a small fix to getDefaultBathymetry.m which is hopefully attached, if too few eTOPO points are found in the model domain this should ensure that the nearest array of depths that include the model domain are still returned. I'm not sure if this will help with the polar grid yet I'll have to do some more testing. If this works ok I'll include it in the next update.
Hi Charles,

Thank you for your explanation, and for this fix in getDefaultBathymetry.m. I'll give it a try and see if I still have the issues I mentioned previously. But you are right of course, I intend to input my own higher resolution bathymetry and coastline for the modeling grid I am setting up. I'll give you some feedback once I'm successfully able to do so.

Lawrence

lcbernardo
Posts: 88
Joined: Wed Oct 01, 2014 8:57 pm
Location: International Coastal Research Center

Re: Which tool is the stablest tools to create ROMS grid?

#20 Unread post by lcbernardo »

Hi Charles,

I'd just like to share that I've been able to use GridBuilder for my relatively small domain without any issues after using the updated getDefaultBathymetry.m I'm finding though that the default coastline even at highest resolution seems to have some mismatch with some commonly used tools, particularly Google Earth. But I guess this is not much of a problem since the software allows for user created coastlines and bathymetry, which I've been able to successfully use for my domain.

You mentioned that the griddedInterpolant function in Matlab is used to interpolate the bathymetry. I could probably have a closer look at the code, but even so I'd like to ask which interpolation and extrapolation methods are used, and if they can be changed (and would it be advisable to do so). Thank you as always for your efforts in developing this tool.

Lawrence

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#21 Unread post by CharlesJames »

The coastlines are the latest GSHHG coastline polygons which are GWS84 but even at full resolution they will be coarser than your grid - not sure why Google Maps would be different but the Google map elements might be higher resolution or they may use a different datum.

I use the interpolants to speed up bathymetry calculations when grids are manipulated, eTOPO comes on a regular grid so griddedInterpolant works well and quickly, if a user supplies bathymetry on a regular grid we use griddedInterpolant for that too but if the bathymetry is on scattered or curvilinear points then you have to use scatteredInterpolant which is slower and sensitive to grid spacing.

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#22 Unread post by CharlesJames »

victory9269 wrote: Thu Mar 14, 2019 3:10 am Hi Charles

I am a new GridBuilder user. I use an old coarse grid generated by seagrid to get a fine subgrid by GridBuilder. Then problems show up when I try to generate a contact file using the ROMS function 'contact'. The error message is:

Reference to non-existent field 'contact'.
Error in grid_connections (line 635)
dg = S.contact(cr).donor_grid;
Error in contact (line 312)
S = grid_connections(G, S);

Then if the coarse and fine grids are both generated by Gridbuilder, errors also happen during generation of a contact file:
undefined function or variable 'FCr'.
Error in contact>refine_coordinates (line 721)
FSr.Values = G(dg).angle(:); R.angle = FCr(XrF, YrF);
Error in contact>refinement (line 1512)
R = refine_coordinates (cr, dg, rg, G, S, MaskInterp);
error contact (line 327)
[P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp);

Thanks, Victor
CharlesJames wrote:GridBuilder is now available as a Matlab Toolbox (.mltbx) including source code from John Luick's Austides site (http://austides.com/downloads). Once installed, it should run from the command line under any recent version of Matlab. If you are having problems with program please let me know the specifics including any error messages you are getting.
Although this was from a while ago, I finally had reason to create a some nested grids and was able to see the problem first hand. There are a couple of issues here, first, if you want to create a refinement nested grid the first thing you have to do is make sure the psi points for the parent grid align exactly with the psi points on the refined grid (or at least every 5th point for a 5x refinement). This is because contact.m uses inpolygon, not only to find points in the grid but to find the parent psi points that are ON the boundary - since the psi points are generated in GridBuilder by averaging the rho points there are usually very small round-off errors between the parent psi points and the corresponding psi points in the nested grid which leads to inpolygon thinking they are not on the boundary. Because no corresponding boundary is found the contact field is never created and you get the first error above. Also, the way GridBuilder works is that when you multiply the number of xi and eta cells by 5 (i.e. 5x refinement) it starts at a point just outside the boundary rho points where psi points would exist if there were cells for the boundary rho points, this means you will typically have to trim a few rows and columns off each boundary to get to the boundary psi points that correspond to the parent psi points. So if you replace the values of the psi points with the exact corresponding point in the parent grid and trim the edges you should get past the first error (as long as you have added the global attributes - parent_grid, refinement_factor, parent_Imin, parent_Imax, parent_Jmin, and parent_Jmax - to the nested grid file).

The second error had me scratching my head - but it turns out it is a bug in the code - FCr is the interpolant for a Cartesian grid, if you are doing a spherical grid all those FCr interpolants shuld be FSr - you can see the line 721 in your error message that the FSr is the the interpolant being modified. Fix that and you will then get to one final bug. In the version of contact.m that I just downloaded, at the end of the refinement sub-function a default empty refinement structure is created, in that version the Cartesian fields x_rho, y_rho, x_psi, y_psi, x_u, y_u, x_v, and y_v are defined even for Spherical grids but shouldn't be. I put all the definitions inside the corresponding "if spherical ..., else ..." so that they don't get defined for spherical grids - that way the structure is the same shape as the one created by the first grid and they can be put into same S.refined field (around line 327 in my contact.m) while the program loops through grids.

This worked to generate the contact file, now I still have to test it out to see if the grids nest correctly. Unfortunately I can't think of a simple way to integrate all that into GridBuilder, it really needs to be done in post processing as there are too many different things a user could be trying to do with nesting and I can't really anticipate them all. Grid builder will create a suitable nested grid to start working on in so far as it shares psi points with the parent grid, but the steps to fix the values of the shared points and trimming the edges will still need to be done on a case by case basis.

Charles

novice
Posts: 27
Joined: Fri Jan 18, 2013 6:02 pm
Location: Indian Institute of Technology

Re: Which tool is the stablest tools to create ROMS grid?

#23 Unread post by novice »

Hi Dr. Charles,

I installed the GridBuilder.mltbx in Matlab2019B running on an Ubuntu system. I got the following error while trying to initiate GridBuilder. I would be grateful if you can give any suggestions regarding this.

Thanks in advance.



>> GridBuilder
Unrecognized function or variable 'varcheck'.

Error in getMapCoord (line 6)
varcheck('x0',0);

Error in setGuiInitial (line 135)
[xlims, ~]=getMapCoord([-180 180],[0 0],'ll2xy',0,0);

Error in GridBuilderCallbacks (line 11)
setGuiInitial(handles);

Error in GridBuilder>GridBuilder_OpeningFcn (line 92)
GridBuilderCallbacks('Initialize',eventdata,handles);

Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

Error in GridBuilder (line 42)
gui_mainfcn(gui_State, varargin{:});

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#24 Unread post by CharlesJames »

Yep, that's a bug! varcheck is a routine I made to check if a variable is passed in or not, I didn't include varcheck in the toolbox and I don't use it in any other routines. If you can open up getMapCoord and change the first couple of lines of code from

varcheck('x0',0);
varcheck('y0',0);

to

if ~exist('x0','var');x0=0;end
if ~exist('y0','var');y0=0;end

it should work OK, I'll provide an updated toolbox as soon as I can

thanks,
Charles

gli353
Posts: 30
Joined: Tue May 14, 2019 1:39 pm
Location: The University of Auckland

Re: Which tool is the stablest tools to create ROMS grid?

#25 Unread post by gli353 »

Hi, Charles,
I uploaded a quick fix to the problem (at least working for the refinement-subclass, telescoped grid), viewtopic.php?f=23&t=5525. Hopefully other subclasses could be addressed in the future, probably we could add a dropdown list for creating subgrid: if it is *just* a subgrid, or it is the smaller grid to be used in online nesting, and choose which subclass of nesting we wish to deal with. Probably this will still turn out to be a very case-by-case issue... anyways, hope my post could help address this problem.

CharlesJames wrote: Tue Mar 31, 2020 5:54 am
victory9269 wrote: Thu Mar 14, 2019 3:10 am Hi Charles

I am a new GridBuilder user. I use an old coarse grid generated by seagrid to get a fine subgrid by GridBuilder. Then problems show up when I try to generate a contact file using the ROMS function 'contact'. The error message is:

Reference to non-existent field 'contact'.
Error in grid_connections (line 635)
dg = S.contact(cr).donor_grid;
Error in contact (line 312)
S = grid_connections(G, S);

Then if the coarse and fine grids are both generated by Gridbuilder, errors also happen during generation of a contact file:
undefined function or variable 'FCr'.
Error in contact>refine_coordinates (line 721)
FSr.Values = G(dg).angle(:); R.angle = FCr(XrF, YrF);
Error in contact>refinement (line 1512)
R = refine_coordinates (cr, dg, rg, G, S, MaskInterp);
error contact (line 327)
[P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp);

Thanks, Victor
CharlesJames wrote:GridBuilder is now available as a Matlab Toolbox (.mltbx) including source code from John Luick's Austides site (http://austides.com/downloads). Once installed, it should run from the command line under any recent version of Matlab. If you are having problems with program please let me know the specifics including any error messages you are getting.
Although this was from a while ago, I finally had reason to create a some nested grids and was able to see the problem first hand. There are a couple of issues here, first, if you want to create a refinement nested grid the first thing you have to do is make sure the psi points for the parent grid align exactly with the psi points on the refined grid (or at least every 5th point for a 5x refinement). This is because contact.m uses inpolygon, not only to find points in the grid but to find the parent psi points that are ON the boundary - since the psi points are generated in GridBuilder by averaging the rho points there are usually very small round-off errors between the parent psi points and the corresponding psi points in the nested grid which leads to inpolygon thinking they are not on the boundary. Because no corresponding boundary is found the contact field is never created and you get the first error above. Also, the way GridBuilder works is that when you multiply the number of xi and eta cells by 5 (i.e. 5x refinement) it starts at a point just outside the boundary rho points where psi points would exist if there were cells for the boundary rho points, this means you will typically have to trim a few rows and columns off each boundary to get to the boundary psi points that correspond to the parent psi points. So if you replace the values of the psi points with the exact corresponding point in the parent grid and trim the edges you should get past the first error (as long as you have added the global attributes - parent_grid, refinement_factor, parent_Imin, parent_Imax, parent_Jmin, and parent_Jmax - to the nested grid file).

The second error had me scratching my head - but it turns out it is a bug in the code - FCr is the interpolant for a Cartesian grid, if you are doing a spherical grid all those FCr interpolants shuld be FSr - you can see the line 721 in your error message that the FSr is the the interpolant being modified. Fix that and you will then get to one final bug. In the version of contact.m that I just downloaded, at the end of the refinement sub-function a default empty refinement structure is created, in that version the Cartesian fields x_rho, y_rho, x_psi, y_psi, x_u, y_u, x_v, and y_v are defined even for Spherical grids but shouldn't be. I put all the definitions inside the corresponding "if spherical ..., else ..." so that they don't get defined for spherical grids - that way the structure is the same shape as the one created by the first grid and they can be put into same S.refined field (around line 327 in my contact.m) while the program loops through grids.

This worked to generate the contact file, now I still have to test it out to see if the grids nest correctly. Unfortunately I can't think of a simple way to integrate all that into GridBuilder, it really needs to be done in post processing as there are too many different things a user could be trying to do with nesting and I can't really anticipate them all. Grid builder will create a suitable nested grid to start working on in so far as it shares psi points with the parent grid, but the steps to fix the values of the shared points and trimming the edges will still need to be done on a case by case basis.

Charles

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: Which tool is the stablest tools to create ROMS grid?

#26 Unread post by neelbasak08 »

CharlesJames wrote: Tue Mar 31, 2020 5:54 am
victory9269 wrote: Thu Mar 14, 2019 3:10 am Hi Charles

I am a new GridBuilder user. I use an old coarse grid generated by seagrid to get a fine subgrid by GridBuilder. Then problems show up when I try to generate a contact file using the ROMS function 'contact'. The error message is:

Reference to non-existent field 'contact'.
Error in grid_connections (line 635)
dg = S.contact(cr).donor_grid;
Error in contact (line 312)
S = grid_connections(G, S);

Then if the coarse and fine grids are both generated by Gridbuilder, errors also happen during generation of a contact file:
undefined function or variable 'FCr'.
Error in contact>refine_coordinates (line 721)
FSr.Values = G(dg).angle(:); R.angle = FCr(XrF, YrF);
Error in contact>refinement (line 1512)
R = refine_coordinates (cr, dg, rg, G, S, MaskInterp);
error contact (line 327)
[P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp);

Thanks, Victor
CharlesJames wrote:GridBuilder is now available as a Matlab Toolbox (.mltbx) including source code from John Luick's Austides site (http://austides.com/downloads). Once installed, it should run from the command line under any recent version of Matlab. If you are having problems with program please let me know the specifics including any error messages you are getting.
Although this was from a while ago, I finally had reason to create a some nested grids and was able to see the problem first hand. There are a couple of issues here, first, if you want to create a refinement nested grid the first thing you have to do is make sure the psi points for the parent grid align exactly with the psi points on the refined grid (or at least every 5th point for a 5x refinement). This is because contact.m uses inpolygon, not only to find points in the grid but to find the parent psi points that are ON the boundary - since the psi points are generated in GridBuilder by averaging the rho points there are usually very small round-off errors between the parent psi points and the corresponding psi points in the nested grid which leads to inpolygon thinking they are not on the boundary. Because no corresponding boundary is found the contact field is never created and you get the first error above. Also, the way GridBuilder works is that when you multiply the number of xi and eta cells by 5 (i.e. 5x refinement) it starts at a point just outside the boundary rho points where psi points would exist if there were cells for the boundary rho points, this means you will typically have to trim a few rows and columns off each boundary to get to the boundary psi points that correspond to the parent psi points. So if you replace the values of the psi points with the exact corresponding point in the parent grid and trim the edges you should get past the first error (as long as you have added the global attributes - parent_grid, refinement_factor, parent_Imin, parent_Imax, parent_Jmin, and parent_Jmax - to the nested grid file).

The second error had me scratching my head - but it turns out it is a bug in the code - FCr is the interpolant for a Cartesian grid, if you are doing a spherical grid all those FCr interpolants shuld be FSr - you can see the line 721 in your error message that the FSr is the the interpolant being modified. Fix that and you will then get to one final bug. In the version of contact.m that I just downloaded, at the end of the refinement sub-function a default empty refinement structure is created, in that version the Cartesian fields x_rho, y_rho, x_psi, y_psi, x_u, y_u, x_v, and y_v are defined even for Spherical grids but shouldn't be. I put all the definitions inside the corresponding "if spherical ..., else ..." so that they don't get defined for spherical grids - that way the structure is the same shape as the one created by the first grid and they can be put into same S.refined field (around line 327 in my contact.m) while the program loops through grids.

This worked to generate the contact file, now I still have to test it out to see if the grids nest correctly. Unfortunately I can't think of a simple way to integrate all that into GridBuilder, it really needs to be done in post processing as there are too many different things a user could be trying to do with nesting and I can't really anticipate them all. Grid builder will create a suitable nested grid to start working on in so far as it shares psi points with the parent grid, but the steps to fix the values of the shared points and trimming the edges will still need to be done on a case by case basis.

Charles

Hello Mr. Charles

I am using GridBuilder tool generously provided by you to create my grids for ROMS application. Now I need to generate a nested grid for an existing grid which I created using GridBuilder tool. Is there a way to generated nested grid using GridBuilder ? What I actually intend to do is within my larger parent grid, select a small region within that and increase the resolution of meshing only in that small region.

Is there a possibility to perform such a task using GridBuilder ? I tried using Create a new subgrid icon in GridBuilder to select the small region of grid , but then it prompted me clear the unselected region in it. Now if I save the grid for the small region will I be able to directly put it in my ROMS .in application file to run my ROMS model ? Or is there a few things that I need to do more? I was unable to find a documentation of nested grid in GridBuilder reference guide.

Kind regards
-Neel

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: Which tool is the stablest tools to create ROMS grid?

#27 Unread post by neelbasak08 »

CharlesJames wrote: Tue Mar 31, 2020 5:54 am
victory9269 wrote: Thu Mar 14, 2019 3:10 am Hi Charles

I am a new GridBuilder user. I use an old coarse grid generated by seagrid to get a fine subgrid by GridBuilder. Then problems show up when I try to generate a contact file using the ROMS function 'contact'. The error message is:

Reference to non-existent field 'contact'.
Error in grid_connections (line 635)
dg = S.contact(cr).donor_grid;
Error in contact (line 312)
S = grid_connections(G, S);

Then if the coarse and fine grids are both generated by Gridbuilder, errors also happen during generation of a contact file:
undefined function or variable 'FCr'.
Error in contact>refine_coordinates (line 721)
FSr.Values = G(dg).angle(:); R.angle = FCr(XrF, YrF);
Error in contact>refinement (line 1512)
R = refine_coordinates (cr, dg, rg, G, S, MaskInterp);
error contact (line 327)
[P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp);

Thanks, Victor
CharlesJames wrote:GridBuilder is now available as a Matlab Toolbox (.mltbx) including source code from John Luick's Austides site (http://austides.com/downloads). Once installed, it should run from the command line under any recent version of Matlab. If you are having problems with program please let me know the specifics including any error messages you are getting.
Although this was from a while ago, I finally had reason to create a some nested grids and was able to see the problem first hand. There are a couple of issues here, first, if you want to create a refinement nested grid the first thing you have to do is make sure the psi points for the parent grid align exactly with the psi points on the refined grid (or at least every 5th point for a 5x refinement). This is because contact.m uses inpolygon, not only to find points in the grid but to find the parent psi points that are ON the boundary - since the psi points are generated in GridBuilder by averaging the rho points there are usually very small round-off errors between the parent psi points and the corresponding psi points in the nested grid which leads to inpolygon thinking they are not on the boundary. Because no corresponding boundary is found the contact field is never created and you get the first error above. Also, the way GridBuilder works is that when you multiply the number of xi and eta cells by 5 (i.e. 5x refinement) it starts at a point just outside the boundary rho points where psi points would exist if there were cells for the boundary rho points, this means you will typically have to trim a few rows and columns off each boundary to get to the boundary psi points that correspond to the parent psi points. So if you replace the values of the psi points with the exact corresponding point in the parent grid and trim the edges you should get past the first error (as long as you have added the global attributes - parent_grid, refinement_factor, parent_Imin, parent_Imax, parent_Jmin, and parent_Jmax - to the nested grid file).

The second error had me scratching my head - but it turns out it is a bug in the code - FCr is the interpolant for a Cartesian grid, if you are doing a spherical grid all those FCr interpolants shuld be FSr - you can see the line 721 in your error message that the FSr is the the interpolant being modified. Fix that and you will then get to one final bug. In the version of contact.m that I just downloaded, at the end of the refinement sub-function a default empty refinement structure is created, in that version the Cartesian fields x_rho, y_rho, x_psi, y_psi, x_u, y_u, x_v, and y_v are defined even for Spherical grids but shouldn't be. I put all the definitions inside the corresponding "if spherical ..., else ..." so that they don't get defined for spherical grids - that way the structure is the same shape as the one created by the first grid and they can be put into same S.refined field (around line 327 in my contact.m) while the program loops through grids.

This worked to generate the contact file, now I still have to test it out to see if the grids nest correctly. Unfortunately I can't think of a simple way to integrate all that into GridBuilder, it really needs to be done in post processing as there are too many different things a user could be trying to do with nesting and I can't really anticipate them all. Grid builder will create a suitable nested grid to start working on in so far as it shares psi points with the parent grid, but the steps to fix the values of the shared points and trimming the edges will still need to be done on a case by case basis.

Charles
Dear Charles, I was also facing some issues with generating contact for my nested grid . I had created my coarse grid using GridBuilder tool and then generated the refined grid using the script coarse2fine.m provided by ROMS package in matlab_dir/grid . When I try to execute conatct.m script, I encounter the following error:
Gnames = {'phillipines_grd_1.nc', 'phillipines_grd_1_c.nc'};
>> Cname = 'phillipines_contact.nc';
>> [S,G] = contact(Gnames, Cname);
Unrecognized function or variable 'RFactors'.

Error in contact (line 311)
G(ng).refine_factor = RFactors(ng);
Is there a way to solve this issue or is it anything I'm doing wrong ?

Here I'm attaching the scripts I used and my grid file for your reference.

Any help is deeply appreciated by me.
Kind regards
-Neel
Attachments
matlab log for coarse2fine script.txt
(4.29 KiB) Downloaded 880 times
error generated when running contact.txt
(257 Bytes) Downloaded 911 times
phillipines_grd_1_c.nc
finer created created from coarser one using coarse2fine.m
(18.66 KiB) Downloaded 841 times
phillipines_grd_1.nc
coarse grid created using GridBuilder
(6.85 MiB) Downloaded 872 times
coarse2fine.m
(20.86 KiB) Downloaded 814 times
contact.m
(128.62 KiB) Downloaded 885 times

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#28 Unread post by CharlesJames »

Hi Neel,

The version of contact.m you have attached doesn't have a line 311 with G(ng).refine_factor = RFactors(ng) on it, perhaps you have another contact.m file that is shadowing the one you want to use?

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: Which tool is the stablest tools to create ROMS grid?

#29 Unread post by neelbasak08 »

Thanks Mr. Charles,

Another conatct.m version was overshadowing my original one. But now the contact.m version I intend to use (the one I attached) gives me the following error :
>> Gnames = {'phillipines_grd_1.nc', 'phillipines_grd_1_c.nc'};
>> Cname = 'phillipines_contact.nc';
>> [S,G] = contact(Gnames, Cname);

Summary of Contact Regions Processed:

Grid 01: phillipines_grd_1.nc
Grid 02: phillipines_grd_1_c.nc

Contact Donor Receiver
Region Grid Grid

01 01 02
02 02 01

Subscripted assignment between dissimilar structures.

Error in contact (line 329)
S.refined(cr) = R;

>>
I also got the following figures in my MATLAB.

Is that an issue with my coarser grid file which I created using gridbuilder tool ? Or is it an issue with finer grid ? Is there a way to remove it ?

Any help is appreciated by me.

Kind regards
-Neel
Attachments
2.jpg
3.jpg
4.jpg
5.jpg
6.jpg

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#30 Unread post by CharlesJames »

It looks like there is still a bug in the refinement routine - when it returns a structure of empty fields for R it also includes empty rho,psi,u,and v coordinates for a non spherical grid (i.e. x_rho,x_psi, etc.) since you are using a spherical grid the size of the structures don't match so you get an error.

It's not my code but if you want a quick work-around I would add the following lines at the end of the last if statement in the refinement sub-routine (at line 2202 in your version)

if spherical
R=rmfield(R,{'x_rho','y_rho','x_psi','y_psi','x_u','y_u','x_v','y_v'});
end

This should ensure that the R structures will have the same fields for both cr values


Charles

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: Which tool is the stablest tools to create ROMS grid?

#31 Unread post by neelbasak08 »

Thanks Mr. Charles for your previous reply.

I had a query pertaining to issue I faced using GridBuilder tool. According to user guide GridBuilder provides the facility to input user defined bathymetry and coastline data according to this statement :
Bathymetry: GridBuilder can read in data from a variety of bathymetry files including three column ASCII files (Seagrid, Geosciences Australia, etc.). GridBuilder will also try and extract bathymetry from a wide array of netCDF files including ROMS grid filesor Matlab files. The x, y and z coordinates will be read from any variable with one of the following names:o'X', 'x', 'xbathy', 'lon', 'Lon', 'longitude', 'Longitude', 'LON', 'x_rho', or 'lon_rho'o'Y', 'y', 'ybathy', 'lat', 'Lat', 'latitude', 'Latitude', 'LAT', 'y_rho', or 'lat_rho'o'Z','h','z','zbathy','depth','Depth','DEPTH','Elevation','Band1',or 'depths'Coastlines: Grid builder can read in coastlines from two column ASCII files with polygons separated by NaNs or from Matlab files with any of the following x, y variable nameso‘x’, ’lon’, ’Lon’, ’longitude’, ’Longitude’, or ’LON’o‘y’, ‘lat’, ‘Lat’, ‘latitude’, ‘Latitude’, or ‘LAT’
But when I try to input bathymetry data for my custom region (data is in the form of a netcdf format .nc as well as ASC format .asc downloaded from GEBCO), it shows an error which says :
No recognised bathymetry formats. Please contact us so we can add file formats to future updates.
Also a similar error occurs when I try to input my coastline data from GSHHG (data is in the form of a bunch of netcdf files .nc format).

Am I doing something wrong or is it just that my file formats aren't suited for GridBuilder tool ? If former, could you please direct me in the right direction ?

Kind regards
-Neel

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#32 Unread post by CharlesJames »

I recently had a query about GEBCO - the vertical coordinate is called 'Elevation' rather than 'elevation' and the parser is case sensitive - an easy fix if you are using matlab and have the toolbox is

edit getUserBathymetry.m
And at line 13 add ‘elevation’ to the zfields cell array i.e.

zfields={'Z','H','h','z','zbathy','depth','Depth','DEPTH','Elevation','Band1','depths','topo_depth5','height','elevation'};

I've updated this now for future releases

Actually for anyone having issues loading bathymetry from netCDF files, if the names in the input file don't match those in getUserBathymetry.m they can be added to the xfields, yfields and zfields variables and the parser should read them.

The coastline data included with GridBuilder is GSHHS data and the next release should be updated to the latest version. Because the binary format is quite complicated (it has to accommodate polygons like Antarctica, lakes, islands in lakes and lakes on islands in lakes, etc.), I use an indexing system to find the relevant polygons which requires separate index files and I haven't made this a standard format for user coastlines. If you want to import your own I suggest you convert to ASCII files or Matlab '.mat' - if you have two columns with the x and y coordinates of the coastal polygons, use NaNs in the columns to separate multiple polygon coordinates, then GridBuilder will be able to read the coastlines and use them for mask refinement - also coastlines in the old Seagrid format should load fine.

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: Which tool is the stablest tools to create ROMS grid?

#33 Unread post by neelbasak08 »

Thank you Mr Charles !

I had another query. This one is regarding masking during grid generation in GridBuilder. When I try to observe mask_rho in MATLAB for my generated grid, i get the following result: A bunch of rows ending with zeros and I mean a lot of zeroes. Also with a bunch of ones.

I believe 1 represents mask being applied at that lat-lon coordinate and 0 represents mask not being applied at that lat-lon coordinate. The more the number of zeroes, higher the chances of having improper masking in the grid. Again that's just my understanding and I'm pretty sure I am mostly wrong in this. Please do correct me.

How should I be improving my masking in that case ? I usually follow the user guide manual provided with GridBuilder Windows GUI. Which says to apply mask the following way:
The next thing to examine is the grid mask. GridBuilder can generate masks in two ways –either through the bathymetry (which is fast) or by selecting points within the GSHHG coastline polygons (slower but more accurate). GridBuilder recomputes the mask whenever the location of any grid cells are modified so for improved performance select “Use Topography” until you have finished positioning and forming your grid, then select “Use GSHHG coastlines” to get best possible mask before editing.To display and edit the current mask, first, click on “Mask” within the Grid Elements panel. This will turnoff the Orthogonality plot (you can turnoff the grid too if that makes it easier to see) and you will see the new mask. We can modify the mask to clear any anomalies that might lead to poor performance such as isolated cells or inlets. Select Modify Mask from the Screen Mode panel. Then select “Isolated Cells” from the Selection Type drop-down menu in the Mask Edit panel. Red stars are plotted to highlight the questionable cells –these can either be edited manually by clicking on the cell –or filled automatically by pushing the “Fill Selected” button. Next select “Isolated Bays”, these are cells with only one open boundary –you may not always want to fill these but they can sometimes cause problems –for now use the “Fill Selected” button. You may have to repeat several times as filling in some bays may create new ones –the menu will return to Isolated Bays as long as there are bays to fill. You can also search for narrow channels (one cell open at either end) which can be a problem when connecting to isolated bodies of water but we won’t worry about them now.
And for modifying the bathymetry, I first set min depth as 2 m and max depth as default whatever shows in that box then first apply Shapiro BC constant filter of order 2 and apply depth below ==0 and then apply negative adjustment filter by keeping target rx0==0.2

Does positive adjustment or shapiro b.c. smooth help improve my mask ? Or like I may load the earlier grid again and perform the exact same steps and look for mask improvement ?

Kind Regards
-Neel
Attachments
masking_rho output.txt
grid size L300 x M150
(53.96 KiB) Downloaded 949 times

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#34 Unread post by CharlesJames »

what you have posted looks like the partial output from a diary file, it is not showing the full mask so I can't really comment. If you want to display your mask using a spherical grid you need to import the lon_rho,lat_rho, and mask_rho points and plot it up with something like pcolor. That should show you what your mask looks like in Matlab which should be pretty much what you see in GridBuilder, you might need to set the lineStyle in the pcolor image to 'none' if you have a high resolution grid so you can see the individual cells.

The bathymetry and mask are only linked if you are doing the fast bathymetry, I think the only time you really want to do this is if you are doing wetting and drying and have very good bathymetry - most of the time the mask will be better if you use the coastline (default or user) to define the edges. Smoothing the bathymetry can help prevent some instabilities in model runs and is generally a good idea - the positive and negative adjustment filters are fairly blunt instruments but will usually get the result you want and I have had good success with them. Shapiro is an incremental smoothing filter so you usually need need to reapply it several times to reduce the grid stiffness parameter rx0. Depending on the version of GridBuilder you are using, setting minimum depth will either set every depth in the model domain (masked and unmasked) to the minimum depth or, more recently, I have restricted this to only unmasked cells. This can lead to some artefacts (cliffs) if you set this and then open up a mask cell - so I would only do bathymetry adjustments only once you've finalised your mask.

lcbernardo
Posts: 88
Joined: Wed Oct 01, 2014 8:57 pm
Location: International Coastal Research Center

Re: Which tool is the stablest tools to create ROMS grid?

#35 Unread post by lcbernardo »

I'd like to report what seems to be a bug in the Gridbuilder MATLAB toolbox. I have been using it in Matlab R2019b, and I noticed that when I set a minimum depth and then perform some smoothing, within Gridbuilder it seems to be okay. But when I export to a netcdf file to create a ROMS grid, it seems that the negative depths remain in the created ROMS grid file. I wonder if anyone else has had this situation? I think it is easy enough for me to resolve and change the values using MATLAB or so, but I've been trying to assist some students new to modeling and for whom it would cause more confusion.

Lawrence

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#36 Unread post by CharlesJames »

Hi Lawrance,

I think in the last release of GridBuilder I made it so that bathymetry modifications only affect unmasked parts of the grid, so that setting a minimum depth would set that value where the unmasked depth was less the minimum. Bathymetry that was masked remains as it was and for land topography those values are negative. This was to be consistent with orthogonality and gradient calculations that also ignore masked regions. That "feature" does create some confusion and hasn't been particularly helpful and creates odd looking cliffs at the boundary, although I think the grids should still work fine as long as the mask remains consistent with the smoothed bathymetry. You can check by loading h and the mask_rho and setting h to nan wherever mask_rho=0, there shouldn't be any negative values now -if there still are then there might be a bug in that version. The latest update, which I will release soon, has an option to use or not use the mask when making changes to the bathymetry, unticking this will probably provide you with the functionality that you expect. For example, the minimum depth to 2m and not using the mask will make all the terrain 2m as well. As long as you are not using wetting and drying this should be fine, and if you are using wetting and drying you won't want to set a minimum depth.

I've just checked an exported grid from the newest version and it looks like it is behaving itself so I'll try and get that out soon.

Charles

lcbernardo
Posts: 88
Joined: Wed Oct 01, 2014 8:57 pm
Location: International Coastal Research Center

Re: Which tool is the stablest tools to create ROMS grid?

#37 Unread post by lcbernardo »

Hi Charles. Thank you for the detailed explanation of the functionality in the currently uploaded version. And as you said, I think the latest update which gives the option of using the mask or not when making smoothing and other bathymetry changes may indeed make possible what I wanted to achieve. I'll be checking the website occasionally and will update my files as soon as the new ones are out.

Lawrence

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: Which tool is the stablest tools to create ROMS grid?

#38 Unread post by neelbasak08 »

Hello Dr Charles,

I am facing some issue regarding mesh generated using gridbuilder exe for Windows. After my grid file is created and I try to view it in MATLAB, I see something like this:
>> ncdisp(file)
Source:
C:\Users\aBc\Documents\MATLAB\TPXO\lombok_v3_grd_test.nc
Format:
64bit
Global Attributes:
title = 'CustomGrid'
date = '29 Mar 2021'
type = 'ROMS grid file'
Dimensions:
xi_rho = 100
eta_rho = 50
xi_u = 99
eta_u = 50
xi_v = 100
eta_v = 49
xi_psi = 99
eta_psi = 49
one = 1
s_rho = 15
s_w = 16
I see that the xi_u variable and xi_v variable do not match also the eta_u and eta_v variable does not match. As a result, when I try to visualise my ROMS simulation output file in some visualisation tool such as Panoply by NASA, I cannot combine u momentum variable and v momentum variable as u momentum variable uses xi_u and eta_u variable and v momentum variable uses xi_v and eta_v variable, since their dimension does not match so their combination doesn't happen.

I am attaching my grid file for your reference.

Is there a way to solve this issue?

Kind regards
Neel
Attachments
lombok_v3_grd_test.nc
grid file generated with GridBuilder
(779.38 KiB) Downloaded 913 times

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: Which tool is the stablest tools to create ROMS grid?

#39 Unread post by kate »

An Arakawa C-grid is supposed to be staggered, with different sizes of the different variables. I haven't used panoply, but you need to teach your plotting tools about the staggered C-grid.

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: Which tool is the stablest tools to create ROMS grid?

#40 Unread post by neelbasak08 »

Thanks Kate,

I got to work around those dissimilar variables to combine in Panoply. Now I face some other issue.

Thanks a lot

Regards
Neel

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: Which tool is the stablest tools to create ROMS grid?

#41 Unread post by neelbasak08 »

CharlesJames wrote: Wed Apr 28, 2021 2:26 am Hi Lawrance,

I think in the last release of GridBuilder I made it so that bathymetry modifications only affect unmasked parts of the grid, so that setting a minimum depth would set that value where the unmasked depth was less the minimum. Bathymetry that was masked remains as it was and for land topography those values are negative. This was to be consistent with orthogonality and gradient calculations that also ignore masked regions. That "feature" does create some confusion and hasn't been particularly helpful and creates odd looking cliffs at the boundary, although I think the grids should still work fine as long as the mask remains consistent with the smoothed bathymetry. You can check by loading h and the mask_rho and setting h to nan wherever mask_rho=0, there shouldn't be any negative values now -if there still are then there might be a bug in that version. The latest update, which I will release soon, has an option to use or not use the mask when making changes to the bathymetry, unticking this will probably provide you with the functionality that you expect. For example, the minimum depth to 2m and not using the mask will make all the terrain 2m as well. As long as you are not using wetting and drying this should be fine, and if you are using wetting and drying you won't want to set a minimum depth.

I've just checked an exported grid from the newest version and it looks like it is behaving itself so I'll try and get that out soon.

Charles
Hello Mr Charles!
I am facing kind of a similar issue as well, while trying to create a mesh for the entire Philippines using GridBuilder.exe in Windows, when I set the minimum depth to 2m(which is what I want) and keeping max depth to default, then apply bathymetry smoothing parameters Apply below 10m Shapiro B.C. constant filter > Target rx0 = 0.2 Negative adjustments.
After it's done and I saved the grid, when I open it again, the minimum depth changes to -Inf. And in some cases where it didn't change to -Inf, when I tried to use that grid as a parent grid to create a child grid for nesting using coarse2fine.m, my minimum depth in the child automatically changes to negative random value

Is there a way to resolve this issue in the tool?

Kind regards
-Neel

remit
Posts: 15
Joined: Mon Jun 21, 2021 12:40 pm
Location: bmkg

Re: Which tool is the stablest tools to create ROMS grid?

#42 Unread post by remit »

andrebelem wrote: Fri Aug 06, 2021 11:26 pm
CharlesJames wrote: Wed Oct 31, 2018 11:48 pm GridBuilder is now available as a Matlab Toolbox (.mltbx) including source code from John Luick's Austides site (http://austides.com/downloads). Once installed, it should run from the command line under any recent version of Matlab. If you are having problems with program please let me know the specifics including any error messages you are getting.
Hello @Charles,
I recently installed GridBuilder in a new matlab (2021) and at the end of the installation I got the error below. I believe that some file related to the coastline is missing. Can you help me by showing the way?

---error----
>> GridBuilder
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in setGuiInitial (line 234)
GSHHS.(res{i}).bin=uint8(fread(fid,'uint8'));

Error in GridBuilderCallbacks (line 11)
setGuiInitial(handles);

Error in GridBuilder>GridBuilder_OpeningFcn (line 92)
GridBuilderCallbacks('Initialize',eventdata,handles);

Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure),
varargin{:});

Error in GridBuilder (line 42)
gui_mainfcn(gui_State, varargin{:});
Hi, @CharlesJames I have got the same problem with GridBuilder in Matlab 2020a..

Code: Select all

>> GridBuilder
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in setGuiInitial (line 234)
        GSHHS.(res{i}).bin=uint8(fread(fid,'uint8'));

Error in GridBuilderCallbacks (line 11)
        setGuiInitial(handles);

Error in GridBuilder>GridBuilder_OpeningFcn (line 92)
GridBuilderCallbacks('Initialize',eventdata,handles);

Error in gui_mainfcn (line 220)
    feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

Error in GridBuilder (line 42)
    gui_mainfcn(gui_State, varargin{:});
and when I'm install and use GridBuilder.exe, I have same problem with fread function. I suspect there is a wrong command in using the fread function.. Thx

xuyue17thu
Posts: 1
Joined: Tue Feb 14, 2017 4:57 pm
Location: Hydraulic Engineering - Tsinghua University

Re: Which tool is the stablest tools to create ROMS grid?

#43 Unread post by xuyue17thu »

remit wrote: Sun Aug 08, 2021 5:01 pm
andrebelem wrote: Fri Aug 06, 2021 11:26 pm
CharlesJames wrote: Wed Oct 31, 2018 11:48 pm GridBuilder is now available as a Matlab Toolbox (.mltbx) including source code from John Luick's Austides site (http://austides.com/downloads). Once installed, it should run from the command line under any recent version of Matlab. If you are having problems with program please let me know the specifics including any error messages you are getting.
Hello @Charles,
I recently installed GridBuilder in a new matlab (2021) and at the end of the installation I got the error below. I believe that some file related to the coastline is missing. Can you help me by showing the way?

---error----
>> GridBuilder
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in setGuiInitial (line 234)
GSHHS.(res{i}).bin=uint8(fread(fid,'uint8'));

Error in GridBuilderCallbacks (line 11)
setGuiInitial(handles);

Error in GridBuilder>GridBuilder_OpeningFcn (line 92)
GridBuilderCallbacks('Initialize',eventdata,handles);

Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure),
varargin{:});

Error in GridBuilder (line 42)
gui_mainfcn(gui_State, varargin{:});
Hi, @CharlesJames I have got the same problem with GridBuilder in Matlab 2020a..

Code: Select all

>> GridBuilder
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in setGuiInitial (line 234)
        GSHHS.(res{i}).bin=uint8(fread(fid,'uint8'));

Error in GridBuilderCallbacks (line 11)
        setGuiInitial(handles);

Error in GridBuilder>GridBuilder_OpeningFcn (line 92)
GridBuilderCallbacks('Initialize',eventdata,handles);

Error in gui_mainfcn (line 220)
    feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

Error in GridBuilder (line 42)
    gui_mainfcn(gui_State, varargin{:});
and when I'm install and use GridBuilder.exe, I have same problem with fread function. I suspect there is a wrong command in using the fread function.. Thx
I have also encountered this problem and found that the within the ...\Toolboxes\GridBuilder_toolbox\code\Data, the source files are GB_..., However, in the setGuiInitial.m, the lines before line 234 only read file naming "gshhs_c.b" or others, it has not been updated therefore the name doesn't match.
One can simply add the GB_ before the ‘gshhs’ and the right files can be read.

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#44 Unread post by CharlesJames »

Sorry, I haven't been following the forum too closely recently. I did have a problem with the coastline files in one of the updates, which I is fixed now - I wanted to distinguish the gshhs files used by GridBuilder from the ones I had in my own directories by prefixing them with GB_, this was all ok except I missed one reference in the initialisation script which caused GridBuilder to fail when started up, I didn't notice it myself because my own gsshs files shadowed the new ones so it still worked fine for me. We have since updated the both the toolbox and executable version so this bug should not occur again, if you have already fixed it as xuyue17thu advised then it should all work fine anyway.

Charles

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#45 Unread post by CharlesJames »

neelbasak08 wrote: Tue Jun 01, 2021 4:41 am
CharlesJames wrote: Wed Apr 28, 2021 2:26 am Hi Lawrance,

I think in the last release of GridBuilder I made it so that bathymetry modifications only affect unmasked parts of the grid, so that setting a minimum depth would set that value where the unmasked depth was less the minimum. Bathymetry that was masked remains as it was and for land topography those values are negative. This was to be consistent with orthogonality and gradient calculations that also ignore masked regions. That "feature" does create some confusion and hasn't been particularly helpful and creates odd looking cliffs at the boundary, although I think the grids should still work fine as long as the mask remains consistent with the smoothed bathymetry. You can check by loading h and the mask_rho and setting h to nan wherever mask_rho=0, there shouldn't be any negative values now -if there still are then there might be a bug in that version. The latest update, which I will release soon, has an option to use or not use the mask when making changes to the bathymetry, unticking this will probably provide you with the functionality that you expect. For example, the minimum depth to 2m and not using the mask will make all the terrain 2m as well. As long as you are not using wetting and drying this should be fine, and if you are using wetting and drying you won't want to set a minimum depth.

I've just checked an exported grid from the newest version and it looks like it is behaving itself so I'll try and get that out soon.

Charles
Hello Mr Charles!
I am facing kind of a similar issue as well, while trying to create a mesh for the entire Philippines using GridBuilder.exe in Windows, when I set the minimum depth to 2m(which is what I want) and keeping max depth to default, then apply bathymetry smoothing parameters Apply below 10m Shapiro B.C. constant filter > Target rx0 = 0.2 Negative adjustments.
After it's done and I saved the grid, when I open it again, the minimum depth changes to -Inf. And in some cases where it didn't change to -Inf, when I tried to use that grid as a parent grid to create a child grid for nesting using coarse2fine.m, my minimum depth in the child automatically changes to negative random value

Is there a way to resolve this issue in the tool?

Kind regards
-Neel
Hi Neel,
Sorry, haven't been on the Forum for a while,

I wasn't able to duplicate the problem with the latest executable (v1.3.1) so it's possible the problem has been resolved.

To try and reproduce the error I used the Lombok grid you previously posted,

I imported the grid then went to Modify Bathymetry, I unticked mask and hit reset - this should reset the bathymetry to what you originally started with using the contents of the hraw variable in the grid.
Then I re-ticked mask so it would apply any subsequent changes to only the masked areas.

Then I tried to follow the procedure you outlined above:

First I set minimum depth to 2
Then I used the Shapiro B.C. constant filter (2nd order) and applied it once to values below 10m.
Then I switched to the Negative Adjustment algorithm with a target rx0 of 0.2 and applied it
Then I saved the grid
I also exported it to a ROMS grid file to see if there were any issues there.

When I reloaded the grid, and when I inspected the ROMS grid I didn't see any issues with the depths,

Two things did occur to me -

first, I've never been happy with the Negative Adjustment algorithm, I used the old GRID_SmoothNegative_rx0 routine but it seems to create quite drastic changes and causes a lot of artefacts, I may revisit it and make sure it is working as expected. the Positive Adjustment is much gentler and generally gives much better looking bathymetry.

Secondly, is it possible that you set the "Surface" to 10m rather than the "Apply Below" when using Shapiro? Moving the surface is really only for inundation problems and usually the mask would need to be regenerated too. I tried setting surface to 10m and Negative Adjustment did flood the grids with -infs. Interestingly, It didn't cause problems with the positive adjustment algorithm.

I would try just setting the minimum depth to 2m and only using the positive adjustment algorithm to get your target rx0 of 0.2, hopefully this will create a useable grid.

Charles

Kosa
Posts: 35
Joined: Mon Jan 12, 2015 4:12 pm
Location: URI GSO

Re: Which tool is the stablest tools to create ROMS grid?

#46 Unread post by Kosa »

Has anyone had success installing GridBuilder_toolbox.mltbx on the new ARM-based Macs?

I get the error "toolbox cannot be installed because it is not a valid toolbox file"

My setup:
- Hardware: M2 Macbook Air
- Operating system: macOS 12.4
- Matlab: R2022a

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#47 Unread post by CharlesJames »

I haven't tested on Macs, the toolbox installed ok on a Matlab R2022b prerelease running on a PC, it doesn't use any mex files so I'm not sure why it wouldn't install on a Mac, if you can install the toolbox on a PC and do '>>which GridBuilder' in Matlab you should get the location of the GridBuilder.m file, if you copy that directory (probably called GridBuilder_toolbox) and contents (~360MB) to your Mac and add it to the Matlab path, with all subdirectories, hopefully it will work.

Charles

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: Which tool is the stablest tools to create ROMS grid?

#48 Unread post by Dan_chan »

Hi,

I used grid matlab tool (from https://www.myroms.org/svn/src/matlab/grid/) to generate my nested grid contact nc. But, I met the same problem as the second question of floor #22.

Code: Select all

%% create grd nc of parent domain [99-140,0-26]
>> x = 99:1:140;
>> y = 0:1:26;
>> [rlon,rlat] = meshgrid(x,y);
>> rlon = rlon';
>> rlat = rlat';
>> Ga = 'test1_grd_a.nc';
>> G1 = set_grid(rlon,rlat,Ga,'spline','f');

%% nest: subdomain from parent [128-138,14-24]
>> Gc = 'test1_grd_c.nc';
>> Imin = 30;
>> Imax = 40;
>> Jmin = 15;
>> Jmax = 25;
>> Gn2 = coarse2fine(Ga,Gc,5,Imin,Imax,Jmin,Jmax);

%% nest grid contact
>> Cnames = 'test1_ngc2_5.nc';
>> Gnames = {Ga,Gc};
>> [S,G] = contact(Gnames, Cnames);
error shows like:

Code: Select all

 Summary of Contact Regions Processed:
  
   Grid 01: test1_grd_a.nc
   Grid 02: test1_grd_c.nc
  
   Contact   Donor   Receiver
    Region    Grid       Grid
  
     01        01        02
     02        02        01
  
Error using griddedInterpolant/parenReference
Interpolation requires at least two sample points for each grid dimension.

Error in contact>refine_coordinates (line 715)
    FCr.Values = G(dg).angle(:);    R.angle = FCr(XrF, YrF);

Error in contact>refinement (line 1512)
  R = refine_coordinates (cr, dg, rg, G, S, MaskInterp);

Error in contact (line 327)
    [P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp);
I checked the lon/lat_rho or lon/lat_psi of parent and subparent grid file, and made sure they had common points.

I am still confused on the error.

Many thanks in advance.

Dan

Kosa
Posts: 35
Joined: Mon Jan 12, 2015 4:12 pm
Location: URI GSO

Re: Which tool is the stablest tools to create ROMS grid?

#49 Unread post by Kosa »

CharlesJames wrote: Wed Sep 21, 2022 2:06 am I haven't tested on Macs, the toolbox installed ok on a Matlab R2022b prerelease running on a PC, it doesn't use any mex files so I'm not sure why it wouldn't install on a Mac, if you can install the toolbox on a PC and do '>>which GridBuilder' in Matlab you should get the location of the GridBuilder.m file, if you copy that directory (probably called GridBuilder_toolbox) and contents (~360MB) to your Mac and add it to the Matlab path, with all subdirectories, hopefully it will work.

Charles
Thanks Charles, for your reply and for creating and maintaining such a valuable tool. Your workaround worked!

:arrow: I copied over the full `GridBuilder_toolbox` directory from my older mac (where it did work) and then added all of the files to my path recursively, via `addpath(genpath('/path/to/GridBuilder_toolbox/))` and am able to run `GridBuilder.m`

Unfortunately, I have no insight into why R2022a couldn't open the toolbox on my M2 Macbook. I don't understand what a `*.mltbx` file is, but it almost seems like just some sort of proprietary compression format, since it's not some compiled executable or anything. So if this is a problem that anyone else experiences, perhaps offering the GridBuilder_toolbox directory as a simple .zip might be a quick solution (users would just need to manually add the toolbox to their path).

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: Which tool is the stablest tools to create ROMS grid?

#50 Unread post by Dan_chan »

Hi Kosa,

For Mac (apple silicon is also ok), you might just double click "GridBuilder_toolbox.mltbx" in Matlab window, and it will be loaded in your matlab toolbox automatically. Then, run "GridBuilder" command directly, Gui will show.

Hope it could help.

Dan

Dan_chan
Posts: 38
Joined: Wed Apr 17, 2019 2:37 am
Location: IAP, UCAS

Re: Which tool is the stablest tools to create ROMS grid?

#51 Unread post by Dan_chan »

Remarkably, I tested contact function in lake_jersey app, came with the same error. I run the command according to https://www.myroms.org/wiki/Lake_Jersey ... xample_ADE. I guess something may need to update.

Code: Select all

>> Gnames = {'lake_jersey_grd_a.nc', 'lake_jersey_grd_d.nc', 'lake_jersey_grd_e.nc'};
>> Cname  = 'lake_jersey_ngc_3g_ade.nc';
>> [S,G] = contact(Gnames, Cname);
  
 Summary of Contact Regions Processed:
  
   Grid 01: lake_jersey_grd_a.nc
   Grid 02: lake_jersey_grd_d.nc
   Grid 03: lake_jersey_grd_e.nc
  
   Contact   Donor   Receiver
    Region    Grid       Grid
  
     01        01        02
     02        02        01
     03        02        03
     04        03        02
  
Error using griddedInterpolant/parenReference
Interpolation requires at least two sample points for each grid dimension.

Error in contact>refine_coordinates (line 729)
  FCr.Values = G(dg).angle(:);      R.angle = FCr(XrF, YrF);

Error in contact>refinement (line 1512)
  R = refine_coordinates (cr, dg, rg, G, S, MaskInterp);

Error in contact (line 327)
    [P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp);
I am sure I update the grid matlab tool with svn.

Dan_chan wrote: Wed Sep 21, 2022 4:13 pm Hi,

I used grid matlab tool (from https://www.myroms.org/svn/src/matlab/grid/) to generate my nested grid contact nc. But, I met the same problem as the second question of floor #22.

Code: Select all

%% create grd nc of parent domain [99-140,0-26]
>> x = 99:1:140;
>> y = 0:1:26;
>> [rlon,rlat] = meshgrid(x,y);
>> rlon = rlon';
>> rlat = rlat';
>> Ga = 'test1_grd_a.nc';
>> G1 = set_grid(rlon,rlat,Ga,'spline','f');

%% nest: subdomain from parent [128-138,14-24]
>> Gc = 'test1_grd_c.nc';
>> Imin = 30;
>> Imax = 40;
>> Jmin = 15;
>> Jmax = 25;
>> Gn2 = coarse2fine(Ga,Gc,5,Imin,Imax,Jmin,Jmax);

%% nest grid contact
>> Cnames = 'test1_ngc2_5.nc';
>> Gnames = {Ga,Gc};
>> [S,G] = contact(Gnames, Cnames);
error shows like:

Code: Select all

 Summary of Contact Regions Processed:
  
   Grid 01: test1_grd_a.nc
   Grid 02: test1_grd_c.nc
  
   Contact   Donor   Receiver
    Region    Grid       Grid
  
     01        01        02
     02        02        01
  
Error using griddedInterpolant/parenReference
Interpolation requires at least two sample points for each grid dimension.

Error in contact>refine_coordinates (line 715)
    FCr.Values = G(dg).angle(:);    R.angle = FCr(XrF, YrF);

Error in contact>refinement (line 1512)
  R = refine_coordinates (cr, dg, rg, G, S, MaskInterp);

Error in contact (line 327)
    [P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp);
I checked the lon/lat_rho or lon/lat_psi of parent and subparent grid file, and made sure they had common points.

I am still confused on the error.

Many thanks in advance.

Dan

badpa.reza
Posts: 11
Joined: Mon Nov 01, 2021 9:25 pm
Location: State University of New York

Re: Which tool is the stablest tools to create ROMS grid?

#52 Unread post by badpa.reza »

Hi there,

I am a new GridBuilder user. I'm trying to build a grid for a Lake in Africa using GridBuilder_toolbox.mltbx v1.3. When I want to check When I want to modify Bathymetry, the depth of Min and Max are both negative in the Depth Edit Section, does this mean the code cannot recognize the depth of the Lake or is not available the bathymetry for this lake? The lake is not connected to open seas.
Can I solve this problem?

I appreciate your time and guidance in advance.

User avatar
CharlesJames
Posts: 43
Joined: Thu May 24, 2007 12:12 pm
Location: South Australian Research and Development Institute

Re: Which tool is the stablest tools to create ROMS grid?

#53 Unread post by CharlesJames »

Hi,

The default bathymetry, which is eTOPO, probably doesn't have enough resolution to provide useful topography for your lake - or if the lake is above sea-level it will treat it all as land (negative values). if you think the lake is above sea-level but has resolvable features, you can try to provide a surface offset in the Depth Edit panel. Otherwise, try and find some higher resolution bathymetry for the lake and surrounding region - some land points will help determine the orientation of z coordinate (+ up or down), a .csv file with columns for x, y, and z is probably the easiest to set up. If you can, set the bathymetry so that 0 is height of the surface and depths are positive downwards.
if you go under 'File'>'Import'>'Bathymetry Data', you should then be able to select your own bathymetry to use and then hopefully the model grid will behave better.

Charles

badpa.reza
Posts: 11
Joined: Mon Nov 01, 2021 9:25 pm
Location: State University of New York

Re: Which tool is the stablest tools to create ROMS grid?

#54 Unread post by badpa.reza »

Dear Prof. Charles James,

Thank you so much for your response. I am sure that the lake (in Africa) is above sea-level. I am trying to find some higher-resolution bathymetry for the lake. After that, I use your guidance about building a bathymetry file with x, y, z columns as a .CVS file.

I sincerely appreciated your time and help.

Regards,
Reza

9tkay
Posts: 2
Joined: Wed Jun 21, 2023 1:10 pm

Re: Which tool is the stablest tools to create ROMS grid?

#55 Unread post by 9tkay »

Hi,

I created two ROMS grids using the standalone GridBuilder tool and selected that I did want to create a refinement grid suitable for ROMS nesting when creating the second grid. A grid refinement level of 3x was chosen.

When creating the contact file for the two grids using the MATLAB code contact.m, the error listed below results.

Unrecognized field name "contact".
Error in grid_connections (line 638)
dg = S.contact(cr).donor_grid;
Error in contact (line 312)
S = grid_connections(G, S);

I have seen that other individuals have had similar errors, and that previously (2019), nesting attributes needed to be added manually to the attributes in the new grid when using contact.m. From 2020, it was noted that with grids created in GridBuilder, rounding issues can result from the use of inpolygon in contact.m.

Are changes needed to the .nc files for the grids before using contact.m, or do changes only need to be made in the MATLAB contact.m code after the grids have been created in order to create a contact file?

Thanks for helping.

abiola
Posts: 6
Joined: Sat Dec 03, 2022 5:05 pm
Location: Florida Atlantic University

Re: Which tool is the stablest tools to create ROMS grid?

#56 Unread post by abiola »

Hi 9tkay,

You may use the coarse2fine function. It may solve your problem.

9tkay
Posts: 2
Joined: Wed Jun 21, 2023 1:10 pm

Re: Which tool is the stablest tools to create ROMS grid?

#57 Unread post by 9tkay »

Thanks abiola.

I am trying to find a way to successfully make the contact file without having to make changes to my current grids, but so far it seems like new grids will be needed. With new grids, the coarse2fine code will be helpful.

Post Reply