nested grid with pyroms: tutorial and python routines
-
- Posts: 43
- Joined: Wed Nov 30, 2016 11:18 pm
- Location: University of Massachusetts Dartmouth
nested grid with pyroms: tutorial and python routines
Hi all,
This is probably a simple issue, but I need some help. I am trying to build a nested grid for my ROMS configuration. I have built a parent grid setup at 2 km resolution, with climatology/initialization/forcing files (using pyroms). My nested grid needs to be within the parent grid, will have landmasks, with 200 m resolution. Can someone direct me to online tutorials/ppt for building a nested grid within the parent grid.
I am not well versed with Matlab, so I'd like to know which routines in pyroms would help me build a nested grid.
Thanks.
This is probably a simple issue, but I need some help. I am trying to build a nested grid for my ROMS configuration. I have built a parent grid setup at 2 km resolution, with climatology/initialization/forcing files (using pyroms). My nested grid needs to be within the parent grid, will have landmasks, with 200 m resolution. Can someone direct me to online tutorials/ppt for building a nested grid within the parent grid.
I am not well versed with Matlab, so I'd like to know which routines in pyroms would help me build a nested grid.
Thanks.
Re: nested grid with pyroms: tutorial and python routines
Is this online or offline nesting? If online, the nest needs to be a very specific subgrid of the parent, at an odd ratio such a 1:3, 1:5, etc. If offline, just make another grid as you normally would. It can be at any orientation as long as it is entirely within the parent domain.
If online, I think you have to grit your teeth and run Matlab to make the contacts file.
If online, I think you have to grit your teeth and run Matlab to make the contacts file.
-
- Posts: 43
- Joined: Wed Nov 30, 2016 11:18 pm
- Location: University of Massachusetts Dartmouth
Re: nested grid with pyroms: tutorial and python routines
Hi Kate,
I am trying offline nesting. I have a confusion about the bathymetry in the nested grid - My parent grid's bathymetry is smoothed so that my Haidvogel and Haney numbers are: rx0 = 0.17, rx1 = 2.11 . My confusion is about determining the nested grid's bathymetry.
- Should I directly interpolate the parent grid's bathy into the nested grid? Or, I can use the bathy from a high-resolution grid data (like ETOPO) for the nested grid?
- Also, should the nested grid's bathy have to be less than the parent grid's bathy at any location? (in other words, should the bottom-most point in a nested grid always be shallower than the bottom-most point in the parent grid at the same location?)
Please advise. Thanks.
I am trying offline nesting. I have a confusion about the bathymetry in the nested grid - My parent grid's bathymetry is smoothed so that my Haidvogel and Haney numbers are: rx0 = 0.17, rx1 = 2.11 . My confusion is about determining the nested grid's bathymetry.
- Should I directly interpolate the parent grid's bathy into the nested grid? Or, I can use the bathy from a high-resolution grid data (like ETOPO) for the nested grid?
- Also, should the nested grid's bathy have to be less than the parent grid's bathy at any location? (in other words, should the bottom-most point in a nested grid always be shallower than the bottom-most point in the parent grid at the same location?)
Please advise. Thanks.
Re: nested grid with pyroms: tutorial and python routines
I use the best bathymetry I can on each grid, smoothed appropriately. I don't worry about matching them, though some do (like the Mason et al. paper). When interpolating fields, pyroms puts the parent fields onto a z-grid, then remaps laterally, then puts them onto the child grid's vertical grid. That's what you need to do.
Re: nested grid with pyroms: tutorial and python routines
Hello Kate, I have already installed the pyroms according to your indications, but I cannot find any documentation or examples, I have searched and I cannot find how to start using pyroms, I would be grateful if you could tell me where to find help in that regard, best regards and thank you very much.
Re: nested grid with pyroms: tutorial and python routines
The question is what are your needs? Then you can ask how to do that in Python. There is a Python community for geoscientists called Pangeo and they have other resources.
My use of pyroms can be seen through the examples. This is not how things would be done today by the Pangeo community because new packages have emerged since pyroms was written, especially xarray and things that use it like xgcm and xESMF.
Again, what is it that you need to do in Python or some other tool?
My use of pyroms can be seen through the examples. This is not how things would be done today by the Pangeo community because new packages have emerged since pyroms was written, especially xarray and things that use it like xgcm and xESMF.
Again, what is it that you need to do in Python or some other tool?
Re: nested grid with pyroms: tutorial and python routines
Hello Kate, I need pyroms to postprocess the roms outputs, since I already do the preprocessing with Matlab, I am going to look for information about Pangeo, thank you very much.
- jivica
- Posts: 172
- Joined: Mon May 05, 2003 2:41 pm
- Location: The University of Western Australia, Perth, Australia
- Contact:
Re: nested grid with pyroms: tutorial and python routines
You can use faster approach if you are starting new simulation and doing offline down-scaling i.e. 1-way nesting by using "stations" in the parent grid with exact locations of the boundary cells for your nested domain. That way you can save more frequently needed info (i.e. not loosing energy if for example in tidal dominated flow -> DOI information: 10.1016/j.csr.2011.11.017) inside the station file and ROMS is interpolating all that for you. Then, when your parent simulation is done, you'll have station file holding info you need to run nested simulation. We use that method a lot; for operational setup around Hawaii (Brian Powell put it in seapy -> https://github.com/powellb/seapy), for operational ROMS in Adriatic Sea, west coast of Australia ....
Cheers
Ivica
Cheers
Ivica
- neelbasak08
- Posts: 99
- Joined: Wed Dec 09, 2020 3:58 pm
- Location: Thapar Institute of Engineering and Technology, Patiala, PN, India
Re: nested grid with pyroms: tutorial and python routines
Hello Kate.kate wrote: ↑Fri Dec 06, 2019 6:02 pm Is this online or offline nesting? If online, the nest needs to be a very specific subgrid of the parent, at an odd ratio such a 1:3, 1:5, etc. If offline, just make another grid as you normally would. It can be at any orientation as long as it is entirely within the parent domain.
If online, I think you have to grit your teeth and run Matlab to make the contacts file.
I am trying to create a nested grid for my own ROMS model. I use GridBuilder tool to make my ROMS grid. I have a larger grid for which I have the initialization and forcing files. I now wanted to create a a grid that is nested with enhanced resolution within the domains of my larger grid for my ROMS model. If I'm not understanding it wrong, by your statement you mean to say that in order to create that nested grid all I need to do is just create another grid with higher/lower resolution within the domains of larger parent grid and then I could directly use it with my ROMS model ?
I created my refined grid from my parent grid using the script coarse2fine.m script provided with ROMS package.
I was unable to understand child grid (the one you had posted in post 4 of this thread). Do I need to match the nested grid I will create with my parent grid or I can just directly use it with my parent grid as long as it is completely contained within it ? Will I be able to directly put the new grid in my ROMS .in application file to run my ROMS model ?
Kind regards
-Neel
Last edited by neelbasak08 on Tue Mar 02, 2021 7:29 am, edited 1 time in total.
Re: nested grid with pyroms: tutorial and python routines
When doing offline nesting, each domain is a fully independent domain. You run the larger, coarser one first, then use fields from that domain to create the initial/boundary files for the smaller domain. This creation of boundary files for the child grid happens offline, for instance with pyroms, but it doesn't have to be with pyroms. Anyway, yes, the child has its own roms.in.
- neelbasak08
- Posts: 99
- Joined: Wed Dec 09, 2020 3:58 pm
- Location: Thapar Institute of Engineering and Technology, Patiala, PN, India
Re: nested grid with pyroms: tutorial and python routines
Thank you Kate. I understood it. The issue I'm facing is generating Nested Grids Connectivity (NGC) input NetCDF file for my grids. I am using the script contact.m provided in matlab_dir/grid in ROMS package. I have a coarse grid 'phillipines_grd_1.nc' and a fine grid 'phillipines_grd_1_fine.nc'. When I executed the matlab script contact.m I was thrown the following errors:kate wrote: ↑Tue Mar 02, 2021 7:19 am When doing offline nesting, each domain is a fully independent domain. You run the larger, coarser one first, then use fields from that domain to create the initial/boundary files for the smaller domain. This creation of boundary files for the child grid happens offline, for instance with pyroms, but it doesn't have to be with pyroms. Anyway, yes, the child has its own roms.in.
I generated my fine grid using the matlab script coarse2fine.m provided in matlab_dir/grid in ROMS package. And it gave the following output on running>> Gnames = {'phillipines_grd_1.nc', 'phillipines_grd_1_fine.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);
>>
I am attaching my grid files for your reference. Any help is appreciated by me.> F = coarse2fine('phillipines_grd_1.nc','phillipines_grd_1_fine.nc',3)
Interpolating from coarse to fine ...
Computing grid spacing: great circle distances
Number of points: Coarse = 300 x 150, fine = 896 x 446
Requested global attribute "history" not found in: phillipines_grd_1_fine.nc
Writing finer grid variables into: phillipines_grd_1_fine.nc
Wrote f Min= 1.22310e-05 Max= 4.90423e-05
Wrote h Min= NaN Max= NaN
Wrote pm Min= 6.54512e-04 Max= 6.92536e-04
Wrote pn Min= 2.69675e-04 Max= 2.69675e-04
Wrote dmde Min=-2.99595e-01 Max=-7.53537e-02
Wrote dndx Min=-1.82306e-06 Max= 1.82306e-06
Wrote angle Min=-1.12673e-12 Max= 1.17268e-12
Wrote lon_rho Min= 1.16733e+02 Max= 1.29074e+02
Wrote lat_rho Min= 4.81080e+00 Max= 1.96501e+01
Wrote lon_psi Min= 1.16740e+02 Max= 1.29067e+02
Wrote lat_psi Min= 4.82747e+00 Max= 1.96334e+01
Wrote lon_u Min= 1.16740e+02 Max= 1.29067e+02
Wrote lat_u Min= 4.81080e+00 Max= 1.96501e+01
Wrote lon_v Min= 1.16733e+02 Max= 1.29074e+02
Wrote lat_v Min= 4.82747e+00 Max= 1.96334e+01
Wrote mask_rho Min= 0.00000e+00 Max= 1.00000e+00
Wrote mask_psi Min= 0.00000e+00 Max= 2.00000e+00
Wrote mask_u Min= 0.00000e+00 Max= 1.00000e+00
Wrote mask_v Min= 0.00000e+00 Max= 1.00000e+00
F =
struct with fields:
grid_name: 'phillipines_grd_1_fine.nc'
parent_grid: 'phillipines_grd_1.nc'
TimeRecord: []
Lm: 894
Mm: 444
N: 15
coarse_factor: []
refine_factor: 3
parent_Imin: 1
parent_Imax: 299
parent_Jmin: 1
parent_Jmax: 149
Vtransform: 9.96920996838687e+36
Vstretching: 9.96920996838687e+36
theta_s: 9.96920996838687e+36
theta_b: 9.96920996838687e+36
Tcline: 9.96920996838687e+36
hc: 9.96920996838687e+36
s_rho: [15×1 double]
Cs_r: [15×1 double]
s_w: [16×1 double]
Cs_w: [16×1 double]
spherical: 1
uniform: 0
curvilinear: 1
vector_rotation: 1
x_rho: []
y_rho: []
x_psi: []
y_psi: []
x_u: []
y_u: []
x_v: []
y_v: []
lon_rho: [896×446 double]
lat_rho: [896×446 double]
lon_psi: [895×445 double]
lat_psi: [895×445 double]
lon_u: [895×446 double]
lat_u: [895×446 double]
lon_v: [896×445 double]
lat_v: [896×445 double]
lon_perimeter: [2677×1 double]
lat_perimeter: [2677×1 double]
lon_rho_west: [1×446 double]
lat_rho_west: [1×446 double]
lon_rho_east: [1×446 double]
lat_rho_east: [1×446 double]
lon_rho_south: [896×1 double]
lat_rho_south: [896×1 double]
lon_rho_north: [896×1 double]
lat_rho_north: [896×1 double]
lon_u_west: [1×446 double]
lat_u_west: [1×446 double]
lon_u_east: [1×446 double]
lat_u_east: [1×446 double]
lon_u_south: [895×1 double]
lat_u_south: [895×1 double]
lon_u_north: [895×1 double]
lat_u_north: [895×1 double]
lon_v_west: [1×445 double]
lat_v_west: [1×445 double]
lon_v_east: [1×445 double]
lat_v_east: [1×445 double]
lon_v_south: [896×1 double]
lat_v_south: [896×1 double]
lon_v_north: [896×1 double]
lat_v_north: [896×1 double]
mask_rho: [896×446 double]
mask_psi: [895×445 double]
mask_u: [895×446 double]
mask_v: [896×445 double]
angle: [896×446 double]
pm: [896×446 double]
pn: [896×446 double]
dndx: [896×446 double]
dmde: [896×446 double]
h: [896×446 double]
f: [896×446 double]
Kind regards
-Neel
- Attachments
-
- phillipines_grd_1.nc
- coarse grid
- (6.85 MiB) Downloaded 396 times
-
- phillipines_grd_1_fine.nc
- finer grid whichh I created from the coarser one using coarse2fine.m
- (60.92 MiB) Downloaded 620 times
Re: nested grid with pyroms: tutorial and python routines
You are talking about doing online nesting in that case. I have a lot less experience with that than with offline nesting.
- neelbasak08
- Posts: 99
- Joined: Wed Dec 09, 2020 3:58 pm
- Location: Thapar Institute of Engineering and Technology, Patiala, PN, India
Re: nested grid with pyroms: tutorial and python routines
I am not sure what's the difference between online and offline nesting. I'm using MATLAB script to create my finer grids and trying to follow the instruction as demonstrated in https://www.myroms.org/wiki/Lake_Jersey ... troduction
Is there a difference between offline and online nesting. I am not sure how should I do offline nesting then using my existing grid ?
Kind regards
-Neel
Re: nested grid with pyroms: tutorial and python routines
Online nesting requires a special 1:3 or 1:5 relationship between the grids, as in Lake Jersey. Both models are run at the same time and the computer spends a lot of time communicating between the domains for you. That's what the contact stuff is for. I did this only once and it was pretty painfully slow.
Offline nesting is running two completely independent domains, except one is nested within the other. You run the larger domain first, saving daily or whatever. Then you run a script to extract boundary conditions from that domain for your smaller domain. Then you run that by itself. The child grid can be rotated with respect to the parent. Some might say the boundary extraction is slow, but I can at least run it on a handful of cores since doing all the days is embarrassingly parallel.
Offline nesting is running two completely independent domains, except one is nested within the other. You run the larger domain first, saving daily or whatever. Then you run a script to extract boundary conditions from that domain for your smaller domain. Then you run that by itself. The child grid can be rotated with respect to the parent. Some might say the boundary extraction is slow, but I can at least run it on a handful of cores since doing all the days is embarrassingly parallel.
- neelbasak08
- Posts: 99
- Joined: Wed Dec 09, 2020 3:58 pm
- Location: Thapar Institute of Engineering and Technology, Patiala, PN, India
Re: nested grid with pyroms: tutorial and python routines
Oh now I understand, basically offline nesting is first running the model completely with parent grid with ROMS. After the model run is completed , I use the roms_his.nc or roms_dia.nc file to extract boundary condition for the child grid using a custom script. Then I run the child grid standalone with out the parent grid. I believe it's what you meant to say ?kate wrote: ↑Tue Mar 02, 2021 8:20 am Offline nesting is running two completely independent domains, except one is nested within the other. You run the larger domain first, saving daily or whatever. Then you run a script to extract boundary conditions from that domain for your smaller domain. Then you run that by itself. The child grid can be rotated with respect to the parent. Some might say the boundary extraction is slow, but I can at least run it on a handful of cores since doing all the days is embarrassingly parallel.
If possible, could you provide me with the MATLAB script that could extract for the needed domain from my parent domain ? Or a source from where I could get the intended script ?
Actually I am using ROMS for just a month now and it's the first time I will be using nesting so I have absolutely no clue.
Kind regards
-Neel
Re: nested grid with pyroms: tutorial and python routines
Yes, you got it.
I don't use Matlab if I can help it. You should get the script from the ROMS Matlab repository.
I don't use Matlab if I can help it. You should get the script from the ROMS Matlab repository.