Difference between revisions of "Grid Processing Scripts"

From WikiROMS
Jump to navigationJump to search
Line 2: Line 2:


This page describes several Matlab scripts to process ROMS grid.  
This page describes several Matlab scripts to process ROMS grid.  


<section begin=c_contact.m />;<span id="c_contact"></span><span class="blue">c_contact.m</span>
<section begin=c_contact.m />;<span id="c_contact"></span><span class="blue">c_contact.m</span>

Revision as of 19:07, 23 April 2012

Matlab Grid Processing Scripts

This page describes several Matlab scripts to process ROMS grid.


c_contact.m
Creates a new contact coints NetCDF file for a ROMS nesting application. The contact point data is written elsewhere using write_contact.m. if the Ndatum argument is not provided, the datum dimension is unlimited.
c_contact  (ncname, spherical, Ngrids, Ndatum)
On Input:
ncname:   Ouptut contact points NetCDF file name (string)
spherical:   Spherical grid switch (logical)
Ngrids:   Number of nested grids
Ndatum:   Total number of contact points (optional)
c_grid.m
Creates a new ROMS grid NetCDF file or modifies a existing ROMS grid NetCDF file.
status = c_grid  (Lp, Mp, Gname, NewFile, spherical)
On Input:
Lp:   Number of ρ-point in the ξ-direction
Mp:   Number of ρ-point in the η-direction
Gname:   Grid NetCDF file name (string)
NewFile:   Switch to create a new file (logical, optional, default false)
spherical:   Spherical grid switch (logical, optional, default true)
On Ouput:
status:   Error flag
coarse2fine
Given a coarse resolution ROMS Grid NetCDF file (Ginp), this function creates a finer resolution grid in the region specified by the coarser grid coordinates (Imin, Jmin) and (Imax, Jmax). Notice that (Imin, Jmin), and (Imax, Jmax) indices are in terms of the ψ-points because it actually define the physical boundaries of the refined grid. The grid refinement coefficient is specified with Gfactor.
F = coarse2fine  (Ginp, Gout, Gfactor, Imin, Imax, Jmin, Jmax)
On Input:
Ginp:   Input coarser Grid NetCDF file name (string)
Gout:   Output finer Grid NetCDF file name (string)
Gfactor:   Grid refinement factor (3,5,7,9,11,13,15,...)
Imin:   Coarse grid lower-left I-coordinate (ψ-point)
Imax:   Coarse grid upper-right I-coordinate (ψ-point)
Jmin:   Coarse grid lower-left J-coordinate (ψ-point)
Jmax:   Coarse grid upper-right J-coordinate (ψ-point)
On Ouput:
F:   Fine resolution grid structure (struct array)
contact.m
Sets ROMS nested grid contact points for each contact region. The order of the nested grid file names in the input cell array (Gnames) is important. Set the file names in the order of nesting layers and time-stepping in ROMS. The MaskInterp switch is only relevant when processing the contact region of a refinement grid. The setting of land/sea masking in the contact region is critical. Usually it is better to linearly interpolate the finer grid ψ- u-, and v-masks from coarser grid than recomputing via uvp_masks. The recomputed masks may be one point smaller or larger. Use the MaskInterp switch to either interpolate (true) or use uvp_masks (false). Recall that we are not modifying the original refined grid mask, but just computing the mask in the contact region adjacent to finer grid from the coarser grid mask. This is only relevant when there is a land/sea masking features in any of the refinement grid physical boundary. If so, the user just need to experiment with MaskInterp and edit such points during post-processing.
[S, G] = contact  (Gnames, Cname, Lmask, MaskInterp, Lplot)
On Input:
Gnames:   Input Grid NetCDF full path file names (cell array)
Cname:   Ouptut contact points NetCDF file name (string)
Lmask:   Switch to remove contact points over land (logical, optional, default false)
MaskInterp:   Switch to interpolate ψ-, u- and v-masks (true) or compute from interpolated ρ-mask (false). The default is false (logical, optional).
Cname:   Switch to plot various contact points figures (logical, optional, default true)
On Ouput:
S:   Nested grids contact points structure (struct array)
G:   Nested grids structure (1 x Ngrids struct array)
disp_contact.m
Prints the nested grids contact points unique values for each Contact Region. The contact points structure is rich and this simple function facilitates to summarize the contact points values.
disp_contact  (S)
On Input:
ncname:   Contact points structure(struct array)
fine2coarse
Given a finer resolution ROMS Grid NetCDF file (Ginp), this function creates a coarser resolution grid in the region specified by the finer grid coordinates (Imin, Jmin) and (Imax, Jmax). Notice that (Imin, Jmin), and (Imax, Jmax) indices are in terms of the ψ-points because it actually define the physical boundaries of the coarser grid. The grid coarseness coefficient is specified with Gfactor.
C = fine2coarse  (Ginp, Gout, Gfactor, Imin, Imax, Jmin, Jmax)
On Input:
Ginp:   Input finer Grid NetCDF file name (string)
Gout:   Output coarser Grid NetCDF file name (string)
Gfactor:   Grid coarseness factor (3,5,7,9,11,13,15,...)
Imin:   Finer grid lower-left I-coordinate (ψ-point)
Imax:   Finer grid upper-right I-coordinate (ψ-point)
Jmin:   Finer grid lower-left J-coordinate (ψ-point)
Jmax:   Finer grid upper-right J-coordinate (ψ-point)
On Ouput:
C:   Coarser resolution grid structure (struct array)
flip_grid.m
Given a ROMS Grid NetCDF file (Ginp), this function creates a new Grid NetCDF (Gout) with the flipped dimensions, coordinates, and variables.
G = flip_grid  (Ginp, Gout)
On Input:
Ginp:   Input ROMS grid NetCDF file name (string)
Gout:   Output flipped ROMS grid NetCDF file name (string)
On Output:
Sinp:   Flipped Grid structure (struct array)
grid_connections.m
Appends the nested grid connectivity fields between donor and receiver grids for each contact region to the nested grids structure, Sinp.
S = grid_connections  (G, Sinp)
On Input:
G:   Nested grids information structure (1 x Ngrids struct array)
Sinp:   Nested grids contact points structure (struct array)
On Output:
Sinp:   Outdated Nested grids contact points structure (struct array)
grid_perimeter.m
Creates a structure containing information about nested grids perimeters, boundary edges, and other information parameters.
S = grid_perimeter  (Gnames)
On Input:
Gnames:   Input Grid NetCDF full path file names (cell array)
On Output:
Sinp:   Beginning of contact points structure (struct array)
grid_extract.m
Given a larger ROMS Grid NetCDF file (Ginp), this function extracts and creates a sub-domain Grid NetCDF file (Gout) for the sampled region in terms of the larger grid coordinates (Imin, Jmin) and (Imax, Jmax). Notice that the (Imin, Jmin), and (Imax, Jmax) indices are located at ψ-points. They actually define the physical boundaries of the smaller sub-domain grid.
S = grid_extract  (Ginp, Gout, Imin, Imax, Jmin, Jmax)
On Input:
Ginp:   Input coaser Grid NetCDF file name (string) or an existing grid structure (struct array)
Gout:   Output smaller Grid NetCDF file name (string)
Imin:   Larger grid lower-left I-coordinate (ψ-point)
Imax:   Larger grid upper-right I-coordinate (ψ-point)
Jmin:   Larger grid lower-left J-coordinate (ψ-point)
Jmax:   Larger grid upper-right J-coordinate (ψ-point)
On Ouput:
S:   Smaller grid structure (struct array)
plot_contact.m
Plots various figures of contact points for each contact region.
plot_contact  (G, S)
On Input:
G:   Nested grids structure (1 x Ngrids struct array)
S:   Nested grids contact points structure (struct array)
read_contact.m
Reads in the nested grids contact points NetCDF file and loads data into a structure.
[S, G] = read_contact  (ncname)
On Input:
ncname:   Nested grids contact points NetCDF file name (string)
On Output:
S:   Nested grids contact points structure (struct array)
G:   Nested grids structure (1 x Ngrids struct array)
write_contact.m
Writes out the nested grids contact points data generated by contact.m or read_contact.m into a NetCDF.
write_contact   (ncname, S, Lcreate)
On Input:
ncname:   Nested grids contact points NetCDF file name (string)
S:   Nested grids contact points structure (struct array)
Lcreate:   Switch to create a new NetCDF file (logical, optional, default true)