Skip to contents

Validate tables against the model

Usage

validate_data(dataset = NULL, path = NULL)

Arguments

dataset

(list) A dataset of the structure returned by read_data().

path

(character) Path to a directory containing hymetDP tables as files.

Value

(list) If any checks fail, then a list of validation issues are returned along with a warning. If no issues are found then NULL is returned.

Details

Validation checks:

  • File names - File names are the hymetDP table names.

  • Table presence - Required tables are present.

  • Column names - Column names of all tables match the model.

  • Column presence - Required columns are present.

  • Column classes - Column classes match the model specification.

  • Datetime format - Date and time formats follow the model specification.

  • Primary keys - Primary keys of tables are unique.

  • Composite keys - Composite keys (unique constraints) of each table are unique.

  • Referential integrity - Foreign keys have a corresponding primary key.

  • Coordinate format - Values are in decimal degree format.

  • Coordinate range - Values are within -90 to 90 and -180 to 180.

  • Elevation - Values are less than Mount Everest (8848 m) and greater than Mariana Trench (-10984 m).

  • CV Terms - Terms used are valid ODM controlled vocabulary terms, when required.

Note

This function is used by hymetDP creators (to ensure what has been created is valid), maintainers (to improve the quality of archived hymetDP datasets), and users (to ensure the data being used is free of error).

Examples


if (FALSE) {
# Write a set of hymetDP tables to file for validation

mydir <- paste0(tempdir(), "/dataset")
dir.create(mydir)
write_tables(
  path = mydir,
  DataValues = hymet_L1$tables$DataValues,
  Methods = hymet_L1$tables$Methods,
  Variables = hymet_L1$tables$Variables,
  Sources = hymet_L1$tables$Sources,
  Sites = hymet_L1$tables$Sites,
  QualityControlLevels = hymet_L1$tables$QualityControlLevels,
  Qualifiers = hymet_L1$tables$Qualifiers,
  SeriesCatalog = hymet_L1$tables$SeriesCatalog)

# Validate
validate_data(path = mydir)

# Clean up
unlink(mydir, recursive = TRUE)
}