Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Creation of MOM6 grid

prasanna

Prasanna Kanti Ghoshal
Member
Hi,
I want to create a MOM6 grid without using any conversion from ROMS grid to MOM6 grid. Can anyone help me ???
 

cermak

Rob Cermak
Member
Please try an early release of gridtools and try to utilize this example for converting your ROMS grid to MOM6. We ported the original code in Kate's repo to gridtools. I have been working on testing it before formally releasing it.


You will need to clone the gridtools repository from github and use the "rel033" branch to use the updated code and example script.

$ git clone GitHub - ESMG/gridtools: A collection of grid generation tools.
$ cd gridtools
$ git checkout rel033

At this point, you should see mkGridsExample13.py in the examples folder.
 

prasanna

Prasanna Kanti Ghoshal
Member
Please try an early release of gridtools and try to utilize this example for converting your ROMS grid to MOM6. We ported the original code in Kate's repo to gridtools. I have been working on testing it before formally releasing it.


You will need to clone the gridtools repository from github and use the "rel033" branch to use the updated code and example script.

$ git clone GitHub - ESMG/gridtools: A collection of grid generation tools.
$ cd gridtools
$ git checkout rel033

At this point, you should see mkGridsExample13.py in the examples folder.
Thank you. I am trying it first. If any problem occurs, I will let you know.
 

prasanna

Prasanna Kanti Ghoshal
Member
""$ git checkout rel033"" is not working.
It is showing this :
error: pathspec 'rel033' did not match any file(s) known to git.
 

prasanna

Prasanna Kanti Ghoshal
Member
Sir,
I changed the file name and run it .
But this following error is coming:
"
Traceback (most recent call last):
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/backends/file_manager.py", line 199, in _acquire_with_cache_info
file = self._cache[self._key]
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/backends/lru_cache.py", line 53, in __getitem__
value = self._cache[key]
KeyError: [<class 'netCDF4._netCDF4.Dataset'>, ('/home/prasanna/Downloads/gridtools/INPUT/ocean_mosaic.nc',), 'a', (('clobber', True), ('diskless', False), ('format', 'NETCDF4'), ('persist', False))]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 75, in <module>
inputDirectory=inputDir,topographyVariable='h')
File "/home/prasanna/Downloads/gridtools/gridtools/gridutils.py", line 1604, in convertGrid
mom6.write_MOM6_solo_mosaic_file(self, **kwargs)
File "/home/prasanna/Downloads/gridtools/gridtools/grids/mom6.py", line 356, in write_MOM6_solo_mosaic_file
stringVars={'mosaic': 255, 'gridlocation': 255, 'gridfiles': 255, 'gridtiles': 255}))
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/core/dataset.py", line 1910, in to_netcdf
invalid_netcdf=invalid_netcdf,
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/backends/api.py", line 1060, in to_netcdf
store = store_open(target, mode, format, group, **kwargs)
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/backends/netCDF4_.py", line 380, in open
return cls(manager, group=group, mode=mode, lock=lock, autoclose=autoclose)
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/backends/netCDF4_.py", line 328, in __init__
self.format = self.ds.data_model
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/backends/netCDF4_.py", line 389, in ds
return self._acquire()
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/backends/netCDF4_.py", line 383, in _acquire
with self._manager.acquire_context(needs_lock) as root:
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/backends/file_manager.py", line 187, in acquire_context
file, cached = self._acquire_with_cache_info(needs_lock)
File "/home/prasanna/miniconda/envs/xesmf_env/lib/python3.7/site-packages/xarray/backends/file_manager.py", line 205, in _acquire_with_cache_info
file = self._opener(*self._args, **kwargs)
File "src/netCDF4/_netCDF4.pyx", line 2307, in netCDF4._netCDF4.Dataset.__init__
File "src/netCDF4/_netCDF4.pyx", line 1925, in netCDF4._netCDF4._ensure_nc_success
PermissionError: [Errno 13] Permission denied: b'/home/prasanna/Downloads/gridtools/INPUT/ocean_mosaic.nc' "

Can you give me a clue about the source of the error?
Thanking you.
 

cermak

Rob Cermak
Member
I will have to look into that. Even though "overwrite=True", the library is not honoring that request. If you need to run the conversion script several times, be sure the INPUT directory is empty. That is definitely not one of the most helpful error messages.
 

prasanna

Prasanna Kanti Ghoshal
Member
Thank you Sir. I checked the INPUT directory and then again gave it a try. It is created from ROMS to MOM grid. Thank you again Sir.
 

prasanna

Prasanna Kanti Ghoshal
Member
ncdump -h ocean_test.nc
netcdf ocean_test {
dimensions:
nyp = 1511 ;
nxp = 2159 ;
nx = 2158 ;
ny = 1510 ;
variables:
string tile ;
tile:geometry = "spherical" ;
double x(nyp, nxp) ;
x:standard_name = "geographic_longitude" ;
x:units = "degrees_east" ;
x:sha256 = "cdb89af3597f56f1bd7ee3079568d0b7a830685bd2d8d19af79f34c75f8f0a24" ;
double y(nyp, nxp) ;
y:standard_name = "geographic_latitude" ;
y:units = "degrees_north" ;
y:sha256 = "845ba5b246c325c0542a6ced8266a70e26718964bc36185f396e3d276c283214" ;
double dx(nyp, nx) ;
dx:units = "meters" ;
dx:sha256 = "5144a5b82013e61e68b9bc48cf7c1ec36bd26b776de51680eb4cb4f0899e214d" ;
double dy(ny, nxp) ;
dy:units = "meters" ;
dy:sha256 = "3676a895a8c4c44418394ee1d712500660c6bd71ad7ac8a2334c32fd619821d7" ;
double area(ny, nx) ;
area:units = "meters^2" ;
area:sha256 = "6e7ac7df9df05cab779e9f00d64e2ee18bdae9d5bbdfc2d0cdb9ada67952e38d" ;
double angle_dx(nyp, nxp) ;
angle_dx:units = "radians" ;
angle_dx:sha256 = "47c88fe78dc33e50f02e06e9402a07ca4f50dbaef55825427039b1999b6308dc" ;

// global attributes:
:grid_version = "0.2" ;
:code_version = "ESMG/gridtools: [\'heads/exp/rel033-0-gd2f136c6ad\', \'\']" ;
:history = "2021-12-16: gridtools.grid.mom6.convert_ROMS_to_MOM6 + kwargs" ;

But Sir, variable long is not there.
""
:projection = "Mercator" ;
:grid_centerX = 75. ;
:grid_centerY = 0. ;
:grid_centerUnits = "degrees" ;
:grid_dx = 90 ;
:grid_dxUnits = "degrees" ;
:grid_dy = 60 ;
:grid_dyUnits = "degrees" ;
:grid_tilt = 0. ; ""
These features are also not there. As we are converting from ROMS to MOM6, Is it the reason behind this?
 

prasanna

Prasanna Kanti Ghoshal
Member
Yes Sir, standard_name is there for x and y but for dx and dy it is not there. Though I found they are "grid_edge_x_distance" and "
grid_edge_y_distance".
Can you provide me a study material for better understanding of MOM6 grid structure and why it is so and also for ROMS?
 

prasanna

Prasanna Kanti Ghoshal
Member
Sir,
I have the following questions :
1. What would be the horizontal resolution for MOM6 grid if I change it from ROMS grid? Is it same as ROMS resolution?
2. What about the vertical structure/bathymetry for MOM6 grid?
3. Can I change horizontal resolution and vertical levels in " ESMG/gridtools" ?
 

cermak

Rob Cermak
Member
Here are some answers:

1. The horizontal resolution should be the same when converting a ROMS grid to a MOM6 grid using the gridtools library.
2. If there is a depth field in the ROMS grid ('h'), the conversion routine should create an ocean_topog.nc file if writeTopography=True is set when using convertGrid().
3. Gridtools cannot modify horizontal or vertical levels.

An ncdump -h of the ocean_topog.nc file:
Code:
netcdf ocean_topog {
dimensions:
    ny = 1392 ;
    nx = 1080 ;
variables:
    double depth(ny, nx) ;
        depth:units = "meters" ;
        depth:standard_name = "topographic depth at Arakawa C h-points" ;
        depth:sha256 = "f2d93f2c215790e5790314a1e4413c18797d57b49b4b6fabc3d57fc3cd1f28f2" ;

// global attributes:
        :grid_version = "0.2" ;
        :code_version = "ESMG/gridtools: [\'tags/0.3.2-0-g6764e65407-dirty\', \'\']" ;
        :history = "2021-12-08: gridtools.grid.mom6.convert_ROMS_to_MOM6 + kwargs" ;
}
 

prasanna

Prasanna Kanti Ghoshal
Member
Sir,
I have a question . I am assigned to a task to create a MOM6 grid with the following feature :
"Vertical resolution - 75 layers
You have to choose the best coordinate system for representing the vertical layers."
How to start working with this characteristics? I am stuck in the last part. Help me please.
 
This is an active research area and there are no easy answers. Will you have open boundaries? If so, the z-star coordinate has been behaving better than "hycom1" for reasons we don't fully understand. I have a vertical file with 75 levels with 2 m resolution at the surface. It was created by someone else and I don't know how generate them. I could email it to you if you send me your email in a private message.

What exactly do you need your vertical levels/layers to represent?
 
Top