3.3. Setting up the grid

Once the LTL forcing file has been set-up, it can be used to create the parameters that will be used to generate the Osmose grid.

Recovering the grid parameters is done by using the extract_grid_param function:

rm(list=ls())

library("osmose")
setwd("/home/nbarrier/Modeles/osmose/git-applis/doc_user/newconf/_static")

ltl_file = system.file(package="osmose", "extdata", "gog_v4", 
                       "corr_eco3m_gog44_conversion_factor.nc")

# extract the grid parameters
gridpar = extract_grid_param(ltl_file, lonname="longitude", 
                             latname="latitude", csv="grid_param.csv")
gridpar
Longitude and Latitudes are 1D.
They are be converted into 2D arrays.
                                              value
grid.java.classname fr.ird.osmose.grid.OriginalGrid
grid.nlon                                        40
grid.nlat                                        26
grid.lowright.lat                  33.2827208709717
grid.lowright.lon                  13.2567700606126
grid.upleft.lat                    34.9970680999756
grid.upleft.lon                    9.92158611004169

In this example, the parameters are written in the grid_param.csv, which is readable by Osmose.

The LTL forcing file can also be used to generate CSV file containing the land-sea mask of the Osmose domain. This is done by using the extract_grid_mask function.

# extract the grid mask file
mask = extract_grid_mask(ltl_file, varname="COPC", output_file="grid_mask.csv", fillVal=0)

# revert data for the plot
mask = apply(mask, 2, rev)

png("mask.png")
par(mar = c(2, 2, 2, 2)) # Set the margin on all sides to 2
image(t(mask), useRaster=TRUE, col = c("black", "white"), xaxt="n", yaxt="n")

Hint

Note that this function can also be used to create map files for fish movements or spatial fishing efforts.

../_images/mask.png

Fig. 3.1 Land-sea mask generated by the extract_grid_mask function.