CMIP6Dict: CMIP6 Controlled Vocabularies (CVs) and Data Request...

Cmip6DictR Documentation

CMIP6 Controlled Vocabularies (CVs) and Data Request Dictionary

Description

The Cmip6Dict object provides functionalities to fetch the latest CMIP6 Controlled Vocabularies (CVs) and Data Request (DReq) information.

Usage

cmip6_dict()

Details

The CMIP6 CVs gives a well-defined set of global attributes that are recorded in each CMIP6 model output, providing information necessary for interpreting the data. The data of CMIP6 CVs is stored as JSON files in the WCRP-CMIP GitHub Repo.

The CMIP6 DReq defines all the quantities from CMIP6 simulations that should be archived. This includes both quantities of general interest needed from most of the CMIP6-endorsed model intercomparison projects (MIPs) and quantities that are more specialized and only of interest to a single endorsed MIP. The raw data of DReq is stored a Microsoft Excel file (CMIP6_MIP_tables.xlsx) in a Subversion repo. The Cmip6Dict object uses the parsed DReq data that is stored in the GitHub Repo.

For more information, please see:

Methods

Public methods


Method version()

Get the version of CVs and Data Request

Usage
Cmip6Dict$version()
Returns

A list of two element:

  • cvs: A numeric_version object giving the version of CVs

  • dreq: A numeric_version object giving the version of Data Request


Method is_empty()

Is it an empty Cmip6Dict?

⁠$is_empty()⁠ checks if this Cmip6Dict is empty, i.e. the ⁠$build() ⁠ or ⁠$load()⁠ method hasn't been called yet and there is no data of CVs and Data Request.

Usage
Cmip6Dict$is_empty()
Returns

A single logical value of TRUE or FALSE.


Method timestamp()

Get the last modified time for CVs

Usage
Cmip6Dict$timestamp()
Returns

A list of 14 DateTimes:

  • "cvs": The last modified time for the whole CV collection

  • "drs": The last modified time for Data Reference Syntax (DRS)

  • "activity_id": The last modified time for Activity ID

  • "experiment_id": The last modified time for Experiment ID

  • "frequency": The last modified time for Frequency

  • "grid_label": The last modified time for Grid Label

  • "institution_id": The last modified time for Institution ID

  • "nominal_resolution": The last modified time for Nominal Resolution

  • "realm": The last modified time for Realm

  • "required_global_attributes": The last modified time for Required Global Attributes

  • "source_id": The last modified time for Source ID

  • "source_type": The last modified time for Source Type

  • "sub_experiment_id": The last modified time for Sub-Experiment ID

  • "table_id": The last modified time for Table ID


Method built_time()

Get the time when the dictionary was built

Usage
Cmip6Dict$built_time()
Returns

A DateTime


Method build()

Fetch and parse all data of CVs and Data Request

Usage
Cmip6Dict$build(token = NULL, force = FALSE)
Arguments
token

A string of GitHub token that is used to access GitHub REST APIs. If NULL, GITHUB_PAT or GITHUB_TOKEN environment variable will be used if exists. Default: NULL.

force

Whether to force to rebuild the dict when it has been already built before. Default: FALSE.

Returns

The updated Cmip6Dict itself.


Method get()

Get the data for a specific CV or Data Request

Usage
Cmip6Dict$get(type)
Arguments
type

A single string indicating the type of data to list. Should be one of:

  • "drs": Data Reference Syntax (DRS)

  • "activity_id": Activity ID

  • "experiment_id": Experiment ID

  • "frequency": Frequency

  • "grid_label": Grid Label

  • "institution_id": Institution ID

  • "nominal_resolution": Nominal Resolution

  • "realm": Realm

  • "required_global_attributes": Required Global Attributes

  • "source_id": Source ID

  • "source_type": Source Type

  • "sub_experiment_id": Sub-Experiment ID

  • "table_id": Table ID

  • "dreq": Data Request

Returns

For "drs", "activity_id"⁠, ⁠"frequency"⁠, ⁠"grid_label"⁠, ⁠"institution_id"⁠, ⁠"source_type"and"sub_experiment_id"', a list.

For "experiment_id", "source_id" and "dreq", a data.table.

For "nominal_resolution", "required_global_attributes" and "table_id", a character vector.


Method save()

Save the Cmip6Dict object

⁠$save()⁠ stores all the core data of current Cmip6Dict object into an RDS file named CMIP6DICT in the specified folder. This file can be reloaded via ⁠$load()⁠ method to restore the last state of current Cmip6Dict object.

Usage
Cmip6Dict$save(dir = getOption("epwshiftr.dir", "."))
Arguments
dir

A single string giving the directory to save the RDS file. Default is set to the global option epwshiftr.dir. The directory will be created if not exists. If this global option is not set, the current working directory is used.

Returns

A single string giving the full path of the RDS file.


Method load()

Load the saved Cmip6Dict object from file

⁠$load()⁠ loads the RDS file named CMIP6DICT that is created using ⁠$save()⁠ method.

Please note that the file should be exactly the same as CMIP6DICT without file extension.

Usage
Cmip6Dict$load(dir = getOption("epwshiftr.dir", "."))
Arguments
dir

A single string giving the directory to find the RDS file. Default is set to the global option epwshiftr.dir. If this global option is not set, the current working directory is used.

Returns

A single string giving the full path of the RDS file.


Method print()

Print a summary of the current Cmip6Dict object

⁠$print()⁠ gives the summary of current Cmip6Dict object including the version of CVs and Data Request, and the last built time.

Usage
Cmip6Dict$print()
Returns

The Cmip6Dict object itself, invisibly.

Author(s)

Hongyuan Jia

Examples

## Not run: 

# create a new Cmip6Dict object
dict <- cmip6_dict()

# by default, there is no data when the Cmip6Dict was created
dict$is_empty()

# fetch and parse all CVs and Data Request data
dict$build()

# get the version of CVs nand Data Request
dict$version()

# get the last modified time for each CV and Data Request
dict$timestamp()

# get the time when the dict was built
dict$built_time()

# get the data of CVs and DReq
dict$get("activity_id")
dict$get("experiment_id")
dict$get("sub_experiment_id")
dict$get("institution_id")
dict$get("source_id")
dict$get("table_id")
dict$get("frequency")
dict$get("grid_label")
dict$get("realm")
dict$get("source_type")
dict$get("dreq")

# save the dict object for later usage
# default location is the value of global option "epwshiftr.dir"
dict$save()

# the saved dict object can be reloaded
new_dict <- cmip6_dict()
new_dict$load()

# print will show the version summary and the last built time
dict$print()

## End(Not run)

hongyuanjia/epwshiftr documentation built on March 14, 2024, 9:17 a.m.