README.md

fvcom.tbx

Project Status: Inactive – The project has reached a stable, usable
state but is no longer being actively developed; support/maintenance
will be provided as time
allows.

fvcom.tbx is an R toolbox for the exploration of unstructured, prism-based hydrodynamic model outputs (i.e. from the Finite Coastal Ocean Volume Model, FVCOM) in R. The package has been designed specifically for the West Coast of Scotland Coastal Modelling System (WeStCOMS), which implements FVCOM. Package development has been motivated by the requirements of ecological research, and the need to link hydrodynamic model outputs with ecological analyses implemented in R. To this end, the package includes functions which facilitate the following operations:

This README file outlines the steps that are required to set up FVCOM outputs for integration with R via fvcom.tbx and some of the main functionality of the package. For further details, please consult the vignette and the reference manual.

Installation

You can install the development version of fvcom.tbx from GitHub with:

devtools::install_github("edwardlavender/fvcom.tbx", build_vignette = TRUE)

If you build the vignette, you can view this with vignette("fvcom.tbx", package = "fvcom.tbx").

Set up

Hydrodynamic model outputs are typically stored as MATLAB® or Network Common Data Form (NetCDF) files. Each file contains information on the model structure (e.g., the model mesh) and all of the model predictions for a specific day. Within each file, model predictions are stored as 2- or 3-dimensional arrays. To integrate these files with R, via fvcom.tbx, follow the workflow detailed below:

  1. Acquire FVCOM files.
  2. Define a directory system in which to store environmental arrays extracted from FVCOM files.
  3. Extract and save environmental arrays from FVCOM files into this directory system.

Acquire files

The first step is to acquire FVCOM files. FVCOM files can be obtained from source or from a remote server. For file acquisition from a remote server, fvcom.tbx includes the thredds_download() function which is designed to download WeStCOMS files from the SAMS thredds server. (Alternatively, thredds_extract() can be used to extract specific predictions from model files on the thredds server.)

From any FVCOM file, it is necessary to obtain the following:

For each FVCOM file, we also need to extract and save the environmental arrays of interest (see below).

Directory conventions

fvcom.tbx is step up to work with environmental arrays rather than the full FVCOM files. Hence, it is necessary to define a set of directories into which, for each FVCOM file, environmental arrays can be extracted and saved. The following directory names are recommended:

To create a directory system in which to store outputs, fvcom.tbx provides the create_wcdirs() function.

Environmental array conventions

With an appropriate directory system in place, the next step is to extract environmental arrays from FVCOM files into this directory system. If you have already obtained the full FVCOM files* (e.g., via thredds_download()), this is a possible workflow:

  1. Define a list of FVCOM file names. The function define_dates2load() can be used to do this.
  2. Load every file in this list into MATLAB® or another programme to check for any corrupt files: large files are easily corrupted during file transfer or download. The vignette provides an example MATLAB® script to do this. Re-acquire working versions of corrupt files before continuing, if necessary.
  3. Load every FVCOM file into MATLAB® or another programme to extract and save the environmental arrays of interest into an established set of directories (see above). The vignette provides an example MATLAB® script to do this.

*An alternative workflow, rather than obtaining the full FVCOM files and then extracting environmental arrays, is to directly extract and only download specific environmental arrays of interest, which may be faster. fvcom.tbx may include functionality via thredds_url() and thredds_extract() functions to implement this approach in future.

For environmental arrays, fvcom.tbx assumes the following conventions:

Armed with the necessary standard FVCOM objects and environmental arrays, we can now proceed to implement functions in fvcom.tbx to build model mesh(es), compute new fields, extract model predictions, explore environmental conditions and validate model predictions with observations.

Build unstructured mesh(es)

Several functions are designed to facilitate building and working with unstructured meshes. These include:

Compute new fields

The compute_field_from_fvcom() is designed for the flexible computation of new fields using existing hydrodynamic model outputs. This is supported by helper functions for commonly desirable fields such as:

There are also some functions for the computation of specific new fields from scratch (such as sun angle) in cases where it is helpful to express variables which are not resolved by the hydrodynamic model across the same mesh (for instance, to investigate the extent of spatiotemporal variation over the same spatial domain). These include the following:

Extract model predictions

Some functions are designed to facilitate the extraction of model predictions from source files. These include the following:

Explore environmental conditions

Some functions are designed to facilitate exploration of environmental conditions through space and/or time. These include the following:

Validate model predictions

validate() facilitates the comparison of observed conditions (including those from animal movement datasets) with predicted conditions to evaluate model skill.

Future functionality

Future developments to fvcom.tbx may include developing the following functionality:

Disclaimer

fvcom.tbx is a new package at an early stage of evolution. Please report issues, comments or suggestions!

Links

WeStCOMS was developed at the Scottish Association for Marine Sciences by Dmitry Aleynik.



edwardlavender/fvcom.tbx documentation built on Nov. 26, 2022, 10:28 p.m.