Delft3D grids to NetCDF
Delft3D grids to NetCDF
Hello,
I'm looking in the possibility of converting some of my Delft3D grids to NetCDF to further run in ROMS.
Does anyone has, or know about, any tools or Matlab scripts that would allow this to be easily accomplished?
Thanks
Joao
I'm looking in the possibility of converting some of my Delft3D grids to NetCDF to further run in ROMS.
Does anyone has, or know about, any tools or Matlab scripts that would allow this to be easily accomplished?
Thanks
Joao
DELFT3D grid to ROMS NetCDF grid
Hi,
We use the DELFT3D grid generator to generate our ROMS curvilinear, orthogonal grids and I have written a Matlab routine to convert a DELFT3D grid to a ROMS NetCDF grid file. As the DELFT3D only generates grid points at wet-points, we need to artificially construct land points (and if necessary give them a fictitious cut-off depth - say 2m) and my script does all this and also constructs the necessary metrics (eg. Coriolis factor, pm, pn, dmde, dndx, etc.) required by ROMS and puts them all into a NetCDF file. If you are interesting in using this Matlab script, please feel free to email me and I will send it to you.
Lyon Lanerolle.
We use the DELFT3D grid generator to generate our ROMS curvilinear, orthogonal grids and I have written a Matlab routine to convert a DELFT3D grid to a ROMS NetCDF grid file. As the DELFT3D only generates grid points at wet-points, we need to artificially construct land points (and if necessary give them a fictitious cut-off depth - say 2m) and my script does all this and also constructs the necessary metrics (eg. Coriolis factor, pm, pn, dmde, dndx, etc.) required by ROMS and puts them all into a NetCDF file. If you are interesting in using this Matlab script, please feel free to email me and I will send it to you.
Lyon Lanerolle.
Re: Delft3D grids to NetCDF
Hi,Lyon.Could you leave your email?
-
- Posts: 1
- Joined: Mon Sep 29, 2008 2:21 pm
- Location: USP
Re: Delft3D grids to NetCDF
Hi Lyon
I have the same problem of João. Cold you send to my e-mail this Matlab Script? (helvio@usp.br)
Thanks
Helvio
I have the same problem of João. Cold you send to my e-mail this Matlab Script? (helvio@usp.br)
Thanks
Helvio
Re: Delft3D grids to NetCDF
My email address is : lyon.lanerolle@noaa.gov
When emailing me, please do so from your official/professional email address (and not from a personal email address)
When emailing me, please do so from your official/professional email address (and not from a personal email address)
-
- Posts: 5
- Joined: Mon May 10, 2010 2:08 pm
- Location: Dept of Environmental Affairs - SA Governemt (& Oceanography SA)
Re: Delft3D grids to NetCDF
Hello,
I ran into this thread by looking for the same solution as the original poster. I've already tried sending a message to the NOAA email - but there's no response. (It was a LONG time ago afterall...)
Nonetheless, I managed to google some scripts, which appear to be a way to convert the Delft grid to Seagrid, and from there to ROMS (Netcdf) grid.
Here's the important links I've come across:
http://svn1.hosted-projects.com/cmgsoft ... lft2roms.m
and
http://svn1.hosted-projects.com/cmgsoft ... rid2roms.m
I'm not sure if these are the same as what Lyon (from NOAA) used, but it appears to be able to do what I need.
There were some dependency issues, some of which I managed to sort out, and also a requirement to have Delft's matlab toolbox.
The place where I got stuck is a dependency called 'gmean' - it appears in lines 87 to 90 of the delft2roms.m script.
Does anyone know where this function comes from? or have access to it? or how its output looks?
Please help
- Regards
I ran into this thread by looking for the same solution as the original poster. I've already tried sending a message to the NOAA email - but there's no response. (It was a LONG time ago afterall...)
Nonetheless, I managed to google some scripts, which appear to be a way to convert the Delft grid to Seagrid, and from there to ROMS (Netcdf) grid.
Here's the important links I've come across:
http://svn1.hosted-projects.com/cmgsoft ... lft2roms.m
and
http://svn1.hosted-projects.com/cmgsoft ... rid2roms.m
I'm not sure if these are the same as what Lyon (from NOAA) used, but it appears to be able to do what I need.
There were some dependency issues, some of which I managed to sort out, and also a requirement to have Delft's matlab toolbox.
The place where I got stuck is a dependency called 'gmean' - it appears in lines 87 to 90 of the delft2roms.m script.
Does anyone know where this function comes from? or have access to it? or how its output looks?
Please help
- Regards
Re: Delft3D grids to NetCDF
The function "gmean" just calculates the mean over the "good" (not NaN) values. If you google "m_cmg" and "gmean.m" you will find it. Please let me know if that delft2roms.m function you found works for you. I might not have completely finished it.
It would be interesting to compare this with Lyon's routine. He can still be reached at: lyon.lanerolle@noaa.gov
but you might have to e-mail him twice to let him know you mean it!
-Rich
It would be interesting to compare this with Lyon's routine. He can still be reached at: lyon.lanerolle@noaa.gov
but you might have to e-mail him twice to let him know you mean it!
-Rich
Re: Delft3D grids to NetCDF
Hi,rsignell and sbergman! Did you have got Lyon's scripts?
I have a complex, curvilinear and orthogongal grid generated by delft3D, and have deleted the land points.I have no idea how to transform it into ROMS grid.My teacher has send email to Lyon for 3~4 times, but get no response.Can you help me or give any advice?
Thanks very much.
I have a complex, curvilinear and orthogongal grid generated by delft3D, and have deleted the land points.I have no idea how to transform it into ROMS grid.My teacher has send email to Lyon for 3~4 times, but get no response.Can you help me or give any advice?
Thanks very much.
Re: Delft3D grids to NetCDF
Hi, I would like to have the script too.
Yet, the email link seems no longer function.
can anyone send me the script.
thank you very much
Yet, the email link seems no longer function.
can anyone send me the script.
thank you very much
-
- Posts: 88
- Joined: Wed Oct 01, 2014 8:57 pm
- Location: International Coastal Research Center
Re: Delft3D grids to NetCDF
Hi,
Recently I've been needing to look into this too as I've been looking through some of my old Delft3D simulations, although I use mostly ROMS and COAWST now. I'd also appreciate information on how such a grid conversion can properly be carried out. I'm using Delft3D version 4.01.
Lawrence
Recently I've been needing to look into this too as I've been looking through some of my old Delft3D simulations, although I use mostly ROMS and COAWST now. I'd also appreciate information on how such a grid conversion can properly be carried out. I'm using Delft3D version 4.01.
Lawrence
Re: Delft3D grids to NetCDF
Usually, I use the following steps to convert Delft3d grid to ROMS
1. Read the Delft3D grid (see example codes)
%Read delft3D grid
%Get PSI-points location
try
fid = fopen(d3dgrd);
catch
disp('ERROR: Cannot Open file')
end
%
for m = 1:5
tline = fgetl(fid);
end
%
eta_num = fscanf(fid,'%d',1);
xi_num = fscanf(fid,'%d',1);
%
tline = fgetl(fid);
tline = fgetl(fid);
%
xx_psi = zeros(xi_num,eta_num);
for m = 1:xi_num
etastr = fscanf(fid,'%5s',1);
eta_no = fscanf(fid,'%d',1);
xx_psi(m,:) = fscanf(fid,'%f',eta_num);
end
%
yy_psi = zeros(xi_num,eta_num);
for m = 1:xi_num
etastr = fscanf(fid,'%5s',1);
eta_no = fscanf(fid,'%d',1);
yy_psi(m,:) = fscanf(fid,'%f',eta_num);
end
fclose(fid)
clear xi_num eta_num
2. Get rho point coordinates and interpolate bathymetry to rho points;
3. Use a script named mat2roms_rps.m to generate netCDF file. https://github.com/sea-mat/seagrid/blob ... roms_rps.m
1. Read the Delft3D grid (see example codes)
%Read delft3D grid
%Get PSI-points location
try
fid = fopen(d3dgrd);
catch
disp('ERROR: Cannot Open file')
end
%
for m = 1:5
tline = fgetl(fid);
end
%
eta_num = fscanf(fid,'%d',1);
xi_num = fscanf(fid,'%d',1);
%
tline = fgetl(fid);
tline = fgetl(fid);
%
xx_psi = zeros(xi_num,eta_num);
for m = 1:xi_num
etastr = fscanf(fid,'%5s',1);
eta_no = fscanf(fid,'%d',1);
xx_psi(m,:) = fscanf(fid,'%f',eta_num);
end
%
yy_psi = zeros(xi_num,eta_num);
for m = 1:xi_num
etastr = fscanf(fid,'%5s',1);
eta_no = fscanf(fid,'%d',1);
yy_psi(m,:) = fscanf(fid,'%f',eta_num);
end
fclose(fid)
clear xi_num eta_num
2. Get rho point coordinates and interpolate bathymetry to rho points;
3. Use a script named mat2roms_rps.m to generate netCDF file. https://github.com/sea-mat/seagrid/blob ... roms_rps.m
Re: Delft3D grids to NetCDF
thank you.
But as the Delft3D4 has a function to convert grid to _roms.nc, I am trying to use it.
However, the _roms.nc has a very strange structure as the boundary is -999 and it is non-readable for ROMS.
Also, pn and pm are 0, which also non-readable for ROMS.
Meanwhile, my ROMS still have error and I am trying to solve it.
Please me more method to convert _roms.nc to the readable roms grid.
Thank you.
But as the Delft3D4 has a function to convert grid to _roms.nc, I am trying to use it.
However, the _roms.nc has a very strange structure as the boundary is -999 and it is non-readable for ROMS.
Also, pn and pm are 0, which also non-readable for ROMS.
Meanwhile, my ROMS still have error and I am trying to solve it.
Please me more method to convert _roms.nc to the readable roms grid.
Thank you.
Re: Delft3D grids to NetCDF
You could read lon_rho, lat_rho, and h from the _roms.nc then use mat2roms_rps.m to generate a *.nc file.
-
- Posts: 88
- Joined: Wed Oct 01, 2014 8:57 pm
- Location: International Coastal Research Center
Re: Delft3D grids to NetCDF
One issue I notice when using Delft3D to output the grid as *_roms.nc is that a line of zeros is added on all four sides of the variables 'lon_rho' and 'lat_rho'. So perhaps these segments need to be deleted first before using mat2roms_rps.m? In this case, the *_roms.nc created by Delft3D will need to be modified as the variable dimensions may need to be adjusted. I imagine this process can be quite confusing, but if it will work to make Delft3D-created grids usable in ROMS, I'll try it.
Re: Delft3D grids to NetCDF
Thanks all, I think i have solved the problem successfully by using a python code.
I create my d3d grid and make bathymetry in delftdashboard and generate _roms.nc.
Then I use my python code to generate the ROMS readable _roms.nc and convert it to swan.grd using COAWST matlab script.
Let me know if you guys want the python script.
I create my d3d grid and make bathymetry in delftdashboard and generate _roms.nc.
Then I use my python code to generate the ROMS readable _roms.nc and convert it to swan.grd using COAWST matlab script.
Let me know if you guys want the python script.
-
- Posts: 88
- Joined: Wed Oct 01, 2014 8:57 pm
- Location: International Coastal Research Center
Re: Delft3D grids to NetCDF
Thank you for your update. I work mainly with matlab, but I think I'd be interested to see the python script if you don't mind sharing it.venuscheung wrote: ↑Tue Dec 17, 2019 9:11 am Thanks all, I think i have solved the problem successfully by using a python code.
I create my d3d grid and make bathymetry in delftdashboard and generate _roms.nc.
Then I use my python code to generate the ROMS readable _roms.nc and convert it to swan.grd using COAWST matlab script.
Let me know if you guys want the python script.
Re: Delft3D grids to NetCDF
Sure. Would you mind to leave your email here?
As I want to double confirm the python code before posting it on here openly to prevent any misleading.
As I want to double confirm the python code before posting it on here openly to prevent any misleading.
-
- Posts: 88
- Joined: Wed Oct 01, 2014 8:57 pm
- Location: International Coastal Research Center
Re: Delft3D grids to NetCDF
Thanks for double confirming the code. You can reach me at: bernardo.l.aa@m.titech.ac.jpvenuscheung wrote: ↑Wed Dec 18, 2019 8:39 am Sure. Would you mind to leave your email here?
As I want to double confirm the python code before posting it on here openly to prevent any misleading.
-
- Posts: 14
- Joined: Thu Oct 03, 2013 6:44 pm
- Location: Personal
Re: Delft3D grids to NetCDF
I have recently build a ROMS grid using RGFGRID and QUICKPLOT, from Delft3D's Graphical User Interface (GUI), and pyroms (https://github.com/ESMG/pyroms).
The main idea is to convert a delft3d grid (.grd) created with RGFGRID into .mat using QUICKPLOT. This will give you the grid vertices in a .mat file.
Then, you can load this file in python and create the ROMS grid using pyroms tools.
If anyone is still interest, I can post my sample script.
The main idea is to convert a delft3d grid (.grd) created with RGFGRID into .mat using QUICKPLOT. This will give you the grid vertices in a .mat file.
Then, you can load this file in python and create the ROMS grid using pyroms tools.
If anyone is still interest, I can post my sample script.
-
- Posts: 88
- Joined: Wed Oct 01, 2014 8:57 pm
- Location: International Coastal Research Center
Re: Delft3D grids to NetCDF
I'm also interested to see it. Perhaps you can share it using the email address I gave in a previous message? Sharing it here directly would be okay too. Thanks!thiago.pdpaula wrote: ↑Thu Dec 19, 2019 2:20 pm I have recently build a ROMS grid using RGFGRID and QUICKPLOT, from Delft3D's Graphical User Interface (GUI), and pyroms (https://github.com/ESMG/pyroms).
The main idea is to convert a delft3d grid (.grd) created with RGFGRID into .mat using QUICKPLOT. This will give you the grid vertices in a .mat file.
Then, you can load this file in python and create the ROMS grid using pyroms tools.
If anyone is still interest, I can post my sample script.
-
- Posts: 14
- Joined: Thu Oct 03, 2013 6:44 pm
- Location: Personal
Re: Delft3D grids to NetCDF
Hi,
I'm attaching a python script here so it may be of use to others.
Good luck.
Thiago.
I'm attaching a python script here so it may be of use to others.
Good luck.
Thiago.
- Attachments
-
- delft2roms_grid.py
- (7.52 KiB) Downloaded 497 times
Re: Delft3D grids to NetCDF
Hi cheung, Could you mind to send your python code for me? Because I have same problem with you regarding -999 in the border area in _roms.nc that i converted from rfgrid delft3d.venuscheung wrote: ↑Tue Dec 17, 2019 9:11 am Thanks all, I think i have solved the problem successfully by using a python code.
I create my d3d grid and make bathymetry in delftdashboard and generate _roms.nc.
Then I use my python code to generate the ROMS readable _roms.nc and convert it to swan.grd using COAWST matlab script.
Let me know if you guys want the python script.
My email is luh.adnyani@research.uwa.edu.au
Thanks before.
Regards,
luh
Re: Delft3D grids to NetCDF
Hi Cheung,
I have encountered the same issue as you regarding the -999 values in the border area of the _roms.nc file that I converted from rfgrid in Delft3D. I'm glad to hear that you were able to solve a similar problem.
Would you mind sharing your Python code with me?
My email is hupp5@mail2.sysu.edu.cn.
Thank you in advance for your help!
Best regards,
Hu
I have encountered the same issue as you regarding the -999 values in the border area of the _roms.nc file that I converted from rfgrid in Delft3D. I'm glad to hear that you were able to solve a similar problem.
Would you mind sharing your Python code with me?
My email is hupp5@mail2.sysu.edu.cn.
Thank you in advance for your help!
Best regards,
Hu