Land Sea Masking Scripts

From WikiROMS
Jump to: navigation, search
Matlab: Land/Sea Masking Scripts

This page describes several Matlab scripts in the matlab/landmask repository sub-directory, which are used to process ROMS Land/Sea mask.



add_coastline.m
Adds coastline data to ROMS Grid NetCDF file. This is the coastline data used to facilitate Land/Sea masking editing.
add_coastline  (ncfile, Clon, Clat)
On Input:
ncfile: ROMS Grid NetCDF file name (string)
Clon: Coastline longitude (1D array, degree_east)
Clat: Coastline latitude (1D array, degree_north)


editmask.m
GUI for manual editing of ROMS Land/Sea mask on RHO-points. To accelerate the processing, the Land/Sea mask is edited in (I,J) grid coordinates. If the (I,J) coordinates are not provided, it will compute and write them into a file. If called without one or both arguments, it will prompt for the needed file name(s). If the coastline data is in grid_file, it will read it and convert to (I,J) fractional coordinates.
editmask  (grid_file, coast_file)
On Input:
grid_file: ROMS Grid NetCDF file name containing the grid and mask arrays (string)
coast_file: Matlab file name containing the coastline (lon, lat) or (I,J) fractional coordinates (string; optional)
Mouse shortcuts:
double click: zoom in
right click: zoom out
middle click: change editing mode


editscope.m
GUI for manual editing of ROMS adjoint sensitivity scope mask on RHO-points. To accelerate the processing, the Land/Sea mask is edited in (I,J) grid coordinates. If the (I,J) coordinates are not provided, it will compute and write them into a file. If called without one or both arguments, it will prompt for the needed file name(s). If the coastline data is in grid_file, it will read it and convert to (I,J) fractional coordinates.
editscope  (grid_file, coast_file)
On Input:
grid_file : ROMS Grid NetCDF file name containing the grid and mask arrays (string)
coast_file: Matlab file name containing the coastline (lon, lat) or (I,J) fractional coordinates (string; optional)
Mouse shortcuts:
double click: zoom in
right click: zoom out
middle click: change editing mode


ijcoast.m
Converts coastline data to ROMS (I,J) fractional coordinates to facilitate Land/Sea masking editing with editmask.
C = ijcoast  (ncfile, coast_file)
On Input:
ncname: ROMS grid NetCDF file name (string)
coast_file: Coastline file name (string)
On Output:
C: Coastline data (struct array)
C.grid ROMS Grid NetCDF file name
C.coast Coastline file name
C.indices Coastline indices file name
C.lon Coastline longitudes
C.lat Coastline latitudes
C.Icst Coastline I-grid coordinates, (0:L)
C.Jcst Coastline J-grid coordinates, (0:M)


landsea.m
Computes the Land/Sea mask for an application grid atomatically and writes it into an input NetCDF file. The Land/Sea mask is computed from closed coastlines polygons extracted from the GSHHS data set if the (clon, clat) coastline data is not provided.
F = lansea  (ncfile, clon, clat)
On Input:
ncname: ROMS grid NetCDF file name (string)
clon: Coastline longitude (1D array; degrees_west)
clat: Coastline latitude (1D array; degrees_north)
On Output:
F: Land/Sea mask data (struct array)
F.mask_rho Mask on ρ-points (2D array)
F.mask_psi Mask on ψ-points (2D array)
F.mask_u Mask on u-points (2D array)
F.mask_v Mask on v-points (2D array)


read_mask.m
Reads in ROMS grid bathymetry and Land/Sea mask at ρ-point from NetCDF file.
[spherical, x, y, bath, rmask] = read_mask  (ncfile)
On Input:
ncname: ROMS grid NetCDF file name (string)
On Output:
spherical: Spherical switch (logical)
x: X-location of ρ-points
y: Y-location of ρ-points
bath: Bathymetry at ρ-points
rmask: Land/Sea mask at ρ-points


read_scope.m
Reads in ROMS grid bathymetry and adjoint sensitivity scope mask at ρ-points from NetCDF file.
[spherical, x, y, bath, rmask] = read_mask  (ncfile)
On Input:
ncname: ROMS grid NetCDF file name (string)
On Output:
spherical: Spherical switch (logical)
x: X-location of ρ-points
y: Y-location of ρ-points
bath: Bathymetry at ρ-points
rmask: Land/Sea mask at ρ-points


uvp_masks.m
Computes the Land/Sea masks at u-, v-, and ψ-points from the mask on ρ-points.
[umask, vmask, vmask] = uvp_masks  (rmask)
On Input:
rmask: Land/Sea mask on ρ-points (2D array)
On Output:
umask: Land/Sea mask on u-points (2D array)
vmask: Land/Sea mask on v-points (2D array)
rmask: Land/Sea mask on ψ-points (2D array)


uv_scope.m
Computes the adjoint sensitivity scope masks at u- and v-points from the scope mask on ρ-points.
[Uscope, Vscope] = uvp_masks  (Rscope)
On Input:
Rscope: Scope mask on ρ-points (2D array)
On Output:
Uscope: Scope mask on u-points (2D array)
Vscope: Scope mask on v-points (2D array)


write_mask.m
Writes out Land/Sea mask data into ROMS Grid NetCDF file.
status = write_mask  (ncfile, rmask, umask, vmask, pmask)
On Input:
ncname: ROMS grid NetCDF file name (string)
rmask: Land/Sea mask on ρ-points (2D array)
umask: Land/Sea mask on u-points (2D array)
vmask: Land/Sea mask on v-points (2D array)
pmask: Land/Sea mask on ψ-points (2D array)
On Output:
status: Error flag


write_scope.m
Writes out adjoint sensitivity scope mask data into ROMS Grid NetCDF file.
status = write_mask  (ncfile, Rscope, Uscope, Vscope)
On Input:
ncname: ROMS grid NetCDF file name (string)
Rscope: Adjoint sensitivity scope mask on ρ-points (2D array)
Uscope: Adjoint sensitivity scope mask on u-points (2D array)
Vscope: Adjoint sensitivity scope mask on v-points (2D array)
On Output:
status: Error flag