Higher resolution grids
Closed this issue · 7 comments
I am looking to create a higher than 1/8 degree ocean grid.
As a first step I just tried to change the r
parameter:
Changing it to 10 seemed to work (havent checked the output carefully yet), but when I change it to 12 this error pops up.
./ocean_grid_generator.py -f julius_test/ocean_hgrid_res0.08.nc -r 12 --no_changing_meta
Requesting Mercator grid with phi range: phi_s,phi_n= -66.85954724706843 64.0589597296948
y*= [-2182 2019] nj= 4202
Equator is not going to be a u-point!
Fixing this by shifting the bounds!
y*= [-2183 2018] nj= 4202
Supergrid has an odd number of area cells!
Fixing this by shifting the y_star[1]
y*= [-2183 2017] nj= 4201
Generating Mercator grid with phi range: phi_s,phi_n= [-66.89227423 64.02248205]
Equator is at j= 2183
number of js= 4201
Generating bipolar grid bounded at latitude 64.0407387829004
number of js= 1423
Generating regular lat-lon grid between latitudes -78.0 -66.9086322432972
generated regular lat-lon grid between latitudes -78.0 -66.9086322432972
number of js= 679
Generating displaced pole grid bounded at latitude -78.01635894949366
rdp= 0.2 , doughnut= 0.12
The number of j's is not even. Fixing this by cutting one row at south.
number of js= 365
Stitching the grids together...
Writing netcdf file with ny,nx= 6664 8640
Traceback (most recent call last):
File "./ocean_grid_generator.py", line 776, in <module>
main(sys.argv[1:])
File "./ocean_grid_generator.py", line 767, in main
write_nc(x3,y3,dx3,dy3,area3,angle3,axis_units='degrees',fnam=gridfilename,description=desc,history=hist,source=source,no_changing_meta=no_changing_meta)
File "./ocean_grid_generator.py", line 341, in write_nc
anglev[:]=angle_dx
File "netCDF4/_netCDF4.pyx", line 4648, in netCDF4._netCDF4.Variable.__setitem__
File "netCDF4/_netCDF4.pyx", line 4913, in netCDF4._netCDF4.Variable._put
File "netCDF4/_netCDF4.pyx", line 1754, in netCDF4._netCDF4._ensure_nc_success
RuntimeError: NetCDF: Operation not allowed in define mode
I am not yet very familiar with this code. Would this be a common problem?
The only thing i noticed is that the 1/12 grid has an even number of y cells (Writing netcdf file with ny,nx= 6664 8640
, while the 1/10
(Writing netcdf file with ny,nx= 5555 7200
) and the example 1/8 from the Makefile
(Writing netcdf file with ny,nx= 4441 5760
) seem to produce an odd number of y cells. Could this be a problem?
I investigated further and this seems to be a netcdf problem with files > 2 GB. Did you ever encounter this?
I was able to get it to work by changing the format
input for write_nc
to NETCDF3_64BIT_OFFSET
. Should I submit a pull request for an additional --high-res
option flag, which switches the format? Or is it possible to switch the format based on an estimated file size within write_nc
?
@jbusecke Thanks for the effort.
I reproduce the issue. But, I couldn't use format=NETCDF3_64BIT_OFFSET on my platform as I get an error:
ValueError: format must be 'NETCDF4', 'NETCDF4_CLASSIC', 'NETCDF3_64BIT', or 'NETCDF3_CLASSIC', got 'NETCDF3_64BIT_OFFSET'
However, it seems format=NETCDF3_64BIT works just fine and generated a 4.6GB grid for 1/16 degrees. Do you see any draw backs with using NETCDF3_64BIT?
If not, I'll ask around to see if we can make this the default.
Also, please note that the consistency of the grids other than 0.5,0.25,0.125 degrees are not tested
and I have to make adjustments to the tool as I find issues. Currently I am working on generating 1/16 degrees, hopefully testing it this week.
I just tested 1/12 with 'NETCDF3_64BIT' and it works for me.
Do you see any draw backs with using NETCDF3_64BIT?
Nope, nothing from my end.
Also, please note that the consistency of the grids other than 0.5,0.25,0.125 degrees are not tested
and I have to make adjustments to the tool as I find issues. Currently I am working on generating 1/16 degrees, hopefully testing it this week.
Noted. Also, I would be curious what steps are involved in the testing of a horizontal grid. I would be happy to test the 1/16 or a 1/12 or 1/10 setup, if you could give me some pointers.
Thanks, I merged in the fix which was also blessed by Alistair.
The easiest thing is to use --plot argument to the tool to visualize the grid.
But that is hardly enough.
Unfortunately I don't have unit tests of the grid other than the checks I put in the tool. I should add a few more like comparing with the known areas and arc lengths on the globe.
The ultimate tests are integration tests, being able to generate a model topography, a mosaic file (which puts some constraints on the shape of grid elements), regrid forcing data to the new grid, and finally run the model using it. We are actively working on this.
I will close this for now, since I decided to go ahead with the 1/8 deg setup. Thanks for all the help