Learn R Programming

s2dverification (version 2.4.0)

.LoadDataFile: Load Data From File Into Environment

Description

This function receives a 'work piece', a named list which contains information on a data file to be loaded. It can be run in 'explore' mode or in 'load' mode. When running in 'explore' mode, the metadata of the file is read and the sizes of the dimensions in the file are returned in a named list:
  • 'nmemb': Number of members
'nltime': Number of lead-times 'lon': Longitudes in the file 'lat': Latitudes in the file

Usage

.LoadDataFile(work_piece, explore_dims = FALSE, silent = FALSE)

Arguments

work_piece
Named list with information on the file to load or explore and additional parameters. The needed variables in the work piece are:
  • In explore mode:
    • dataset_type: 'exp'/'obs'
  • filename: full path to the data file

Value

  • When called in 'explore' mode, a named list is returned with the found lengths for members, leadtimes and the latitudes and longitudes already trimmed and reordered if needed. The names are 'nmemb', 'nltime', 'lon', 'lat'. If it is a file from a file-per-member dataset, the number of files that match the filename replacing the $MEMBER$ part by an asterisk is returned (which is the supposed number of members). There are known issues with this method of detection. See documentation on parameter 'nmember' and 'nmemberobs' in Load() function. When called in 'calculation' mode, TRUE is returned if the file was found and FALSE is returned otherwise.

item

  • In load mode:
    • dataset_type: 'exp'/'obs'
    filename: full path to the data file dimnames: named list with names 'longitudes', 'latitudes' and 'members' and with values the associated actual dimension names inside the NetCDF files. namevar: name of the variable in the nc file is_2d_var: TRUE/FALSE grid: common grid into which interpolate or NULL if no interpolation remap: interpolation method ('remapbil'/'remapdis'/'remapcon'/'remapbic') lon_limits: c(lon_min, lon_max) lat_limits: c(lat_min, lat_max) is_file_per_dataset: TRUE/FALSE startdates: in the case that filename points to a whole dataset file, the list of starting dates to load must be specified. c('sdate1', 'sdate2', ...) out_pointer: big.matrix descriptor pointing to the array (transformed into a matrix) where to keep the data dims: named list with dimension sizes of the original array into which the data is kept. Names must be c(['nlon', ]['nlat', ]'nltime', 'nmember', 'nsdates', 'ndat'). indices: vector of initial positions corresponding to each dimension in 'dims' where to store data in the original array. First two indices ('nlon', 'nlat') can be missing. nmember: number of members expected to be loaded mask: complete (untrimmed + interpolated if needed) mask to activate/deactivate data points, with dimensions c('lon', 'lat') leadtimes: vector of time indices to be loaded from the file var_limits: c(var_min, var_max)
  • explore_dims
  • silent

cr

  • Takes by default the value FALSE (calculation mode).
  • When deactivated any warning messages will still be displayed. Takes by default the value FALSE (verbose mode).

Examples

Run this code
data <- s2dverification:::.LoadDataFile(list(dataset_type = 'exp', 
        filename = system.file('sample_data/model/experiment/monthly_mean', 
                               'tos_3hourly/tos_19901101.nc', 
                               package = 's2dverification'),
        namevar = 'tos', is_2d_var = TRUE, lon_limits = c(-12, 40), 
        lat_limits = c(27, 48), is_file_per_member = FALSE, 
        dimnames = list(longitudes = 'longitude', latitudes = 'latitude', 
        members = 'ensemble')), explore_dims = TRUE, silent = FALSE)

Run the code above in your browser using DataLab