| EsgfQuery | R Documentation |
The Earth System Grid Federation (ESGF) is an international collaboration for the software that powers most global climate change research, notably assessments by the Intergovernmental Panel on Climate Change (IPCC).
The ESGF search service exposes RESTful APIs that can be used by clients to query the contents of the underlying search index, and return results matching the given constraints. The documentation of the APIs can be found using this link
EsgfQuery is the workhorse for dealing with ESGF search services.
query_esgf(host = "https://esgf-node.llnl.gov/esg-search")
host |
The URL to the ESGF Search API service. This should be the URL of
the ESGF search service excluding the final endpoint name. Usually
this is |
EsgfQuery objectquery_esgf() returns an EsgfQuery object, which is an R6
object with quite a few methods that can be classified into 3 categories:
Value listing: methods to list all possible values of facets, shards, etc.
Parameter getter & setter: methods to get the query parameter values or set them before sending the actual query to the ESGF search services.
Query responses: methods to collect results for the query response.
When creating an EsgfQuery object, a
facet listing query
is sent to the index node to get all available facets and shards for the
default project (CMIP6).
EsgfQuery object provides three value-listing methods to extract data from
the response of the facet listing query:
EsgfQuery$list_all_facets():
List all available facet names.
EsgfQuery$list_all_shards():
List all available shards.
EsgfQuery$list_all_values():
List all available values of a specific facet.
The ESGF search services support a lot of parameters. The EsgfQuery
contains dedicated methods to set values for most of them, including:
Most common keywords:
facets,
offset,
limit,
fields,
type,
replica,
latest,
distrib
and
shards.
Most common facets:
project,
activity_id,
experiment_id,
source_id,
variable_id,
frequency,
variant_label,
nominal_resolution
and
data_node.
All methods act in a similar way:
If input is given, the corresponding parameter is set and the updated
EsgfQuery object is returned.
This makes it possible to chain different parameter setters, e.g.
EsgfQuery$project("CMIP6")$frequency("day")$limit(1) sets the parameter
project, frequency and limit sequentially.
For parameters that want character inputs, you can put a preceding ! to
negate the constraints, e.g. EsgfQuery$project(!"CMIP6") searches for
all projects except for CMIP6.
If no input is given, the current parameter value is returned. For example,
directly calling EsgfQuery$project() returns the current value of the
project parameter. The returned value can be two types:
NULL, i.e. there is no constraint on the corresponding parameter
An EsgfQueryParam object which is essentially a list of three elements:
value: The input values
negate: Whether there is a preceding ! in the input
name: The parameter name
Despite methods for specific keywords and facets, you can specify arbitrary
query parameters using
EsgfQuery$params() method. For
details on the usage, please see the
documentation.
The query is not sent unless related methods are called:
EsgfQuery$count(): Count the total
number of records that match the query.
You can return only the total number of matched record by calling
EsgfQuery$count(facets = FALSE)
You can also count the matched records for specified facets, e.g.
EsgfQuery$count(facets = c("source_id", "activity_id"))
EsgfQuery$collect(): Collect the
query results and format it into a data.table
EsgfQuery object also provide several other helper functions:
EsgfQuery$build_cache():
By default, EsgfQuery$build_cache() is called when initialize a new
EsgfQuery object. So in general, there is no need to call this
separately. Basically, EsgfQuery$build_cahce() sends a
facet listing query
to the index node and stores the response internally. The response contains
all available facets and shards and is used as a source for validating user
input for parameter setters.
EsgfQuery$url(): Returns the actual
query URL or the wget script URL which can be used to download all files
matching the given constraints..
EsgfQuery$response(): Returns the
actual response of
EsgfQuery$count() and
EsgfQuery$collect(). It is a named
list generated from the JSON response using jsonlite::fromJSON().
EsgfQuery$print(): Print a summary
of the current EsgfQuery object including the host URL, the built time of
facet cache and all query parameters.
new()Create a new EsgfQuery object
When initialization, a
facet listing query
is sent to the index node to get all available facets and shards.
This information will be used to validate inputs for activity_id,
scource_id facets and etc.
EsgfQuery$new(host = "https://esgf-node.llnl.gov/esg-search")
hostThe URL to the ESGF Search API service. This should be
the URL of the ESGF search service excluding the final
endpoint name. Usually this is http://<hostname>/esg-search.
Default is to ses the LLNL (Lawrence Livermore National Laboratory) Index Node, which is
"https://esgf-node.llnl.gov/esg-search".
An EsgfQuery object.
\dontrun{
q <- EsgfQuery$new(host = "https://esgf-node.llnl.gov/esg-search")
q
}
build_cache()Build facet cache used for input validation
A facet cache is data that is fetched using a facet listing query to the index node. It contains all available facets and shards that can be used as parameter values within a specific project.
By default, $build_cache() is called when initialize a new
EsgfQuery object for the default project (CMIP6). So in general,
there is no need to call this method, unless that you want to
rebuild the cache again with different projects after calling
$project().
EsgfQuery$build_cache()
The modified EsgfQuery object.
\dontrun{
q$build_cache()
}
list_all_facets()List all available facet names
EsgfQuery$list_all_facets()
A character vector.
\dontrun{
q$list_all_facets()
}
list_all_shards()List all available shards
EsgfQuery$list_all_shards()
A character vector.
\dontrun{
q$list_all_shards()
}
list_all_values()List all available values of a specific facet
EsgfQuery$list_all_values(facet)
facetA single string giving the facet name.
A named character vector.
\dontrun{
q$list_all_values()
}
project()Get or set the project facet parameter.
EsgfQuery$project(value = "CMIP6")
valueThe parameter value. Default: "CMIP6".
There are two options:
If value is not given, current value is returned.
A character vector or NULL. Note that you can put a preceding ! to negate the facet constraints. For example, $project(!c("CMIP5", "CMIP6")) searches for all projects except for CMIP5 and CMIP6.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$project()
# set the parameter
q$project("CMIP6")
# negate the project constraints
q$project(!"CMIP6")
# remove the parameter
q$project(NULL)
}
activity_id()Get or set the activity_id facet parameter.
EsgfQuery$activity_id(value)
valueThe parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A character vector or NULL. Note that you can put a preceding ! to negate the facet constraints. For example, $activity_id(!c("C4MIP", "GeoMIP")) searches for all activity_ids except for C4MIP and GeoMIP.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$activity_id()
# set the parameter
q$activity_id("ScenarioMIP")
# negate the constraints
q$activity_id(!c("CFMIP", "ScenarioMIP"))
# remove the parameter
q$activity_id(NULL)
}
experiment_id()Get or set the experiment_id facet parameter.
EsgfQuery$experiment_id(value)
valueThe parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A character vector or NULL. Note that you can put a preceding ! to negate the facet constraints. For example, $experiment_id(!c("ssp126", "ssp245")) searches for all experiment_ids except for ssp126 and ssp245.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$experiment_id()
# set the parameter
q$experiment_id(c("ssp126", "ssp585"))
# negate the constraints
q$experiment_id(!c("ssp126", "ssp585"))
# remove the parameter
q$experiment_id(NULL)
}
source_id()Get or set the source_id facet parameter.
EsgfQuery$source_id(value)
valueThe parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A character vector or NULL. Note that you can put a preceding ! to negate the facet constraints. For example, $source_id(!c("CESM2", "CESM2-FV2")) searches for all source_ids except for CESM2 and CESM2-FV2.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$source_id()
# set the parameter
q$source_id(c("BCC-CSM2-MR", "CESM2"))
# negate the constraints
q$source_id(!c("BCC-CSM2-MR", "CESM2"))
# remove the parameter
q$source_id(NULL)
}
variable_id()Get or set the variable_id facet parameter.
EsgfQuery$variable_id(value)
valueThe parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A character vector or NULL. Note that you can put a preceding ! to negate the facet constraints. For example, $variable_id(!c("tas", "pr")) searches for all variable_ids except for tas and pr.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$variable_id()
# set the parameter
q$variable_id(c("tas", "pr"))
# negate the constraints
q$variable_id(!c("tas", "pr"))
# remove the parameter
q$variable_id(NULL)
}
frequency()Get or set the frequency facet parameter.
EsgfQuery$frequency(value)
valueThe parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A character vector or NULL. Note that you can put a preceding ! to negate the facet constraints. For example, $frequency(!c("day", "mon")) searches for all frequencys except for day and mon.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$frequency()
# set the parameter
q$frequency(c("1hr", "day"))
# negate the constraints
q$frequency(!c("1hr", "day"))
# remove the parameter
q$frequency(NULL)
}
variant_label()Get or set the variant_label facet parameter.
EsgfQuery$variant_label(value)
valueThe parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A character vector or NULL. Note that you can put a preceding ! to negate the facet constraints. For example, $variant_label(!c("r1i1p1f1", "r2i1p1f1")) searches for all variant_labels except for r1i1p1f1 and r2i1p1f1.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$variant_label()
# set the parameter
q$variant_label(c("r1i1p1f1", "r1i2p1f1"))
# negate the constraints
q$variant_label(!c("r1i1p1f1", "r1i2p1f1"))
# remove the parameter
q$variant_label(NULL)
}
nominal_resolution()Get or set the nominal_resolution facet parameter.
EsgfQuery$nominal_resolution(value)
valueThe parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A character vector or NULL. Note that you can put a preceding ! to negate the facet constraints. For example, $nominal_resolution(!c("50 km", "1x1 degree")) searches for all nominal_resolutions except for 50 km and 1x1 degree.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$nominal_resolution()
# set the parameter
q$nominal_resolution(c("100 km", "1x1 degree"))
# negate the constraints
q$nominal_resolution(!c("100 km", "1x1 degree"))
# remove the parameter
q$nominal_resolution(NULL)
}
data_node()Get or set the data_node parameter.
EsgfQuery$data_node(value)
valueThe parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A character vector or NULL. Note that you can put a preceding ! to negate the facet constraints. For example, $data_node(!c("cmip.bcc.cma.cn", "esg.camscma.cn")) searches for all data_nodes except for cmip.bcc.cma.cn and esg.camscma.cn.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$data_node()
# set the parameter
q$data_node("esg.lasg.ac.cn")
# negate the constraints
q$data_node(!"esg.lasg.ac.cn")
# remove the parameter
q$data_node(NULL)
}
facets()Get or set the facets parameter for facet counting query.
Note that $facets() only affects
$count()
method when sending a query of facet counting.
EsgfQuery$facets(value)
valueThe facet parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A character vector or NULL. The special notation "*" can be used to indicate that all available facets should be considered.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$facets()
# set the facets
q$facets(c("activity_id", "source_id"))
# use all available facets
q$facets("*")
}
fields()Get or set the fields parameter.
By default, all available metadata fields are returned for each
query. $facets() can be used to limit the number of fields returned
in the query response.
EsgfQuery$fields(value = "*")
valueThe facet parameter value. Default: "*".
There are two options:
If value is not given, current value is returned.
A character vector or NULL. The special notation "*" can be used to indicate that all available fields should be considered.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$fields()
# set the fields
q$fields(c("activity_id", "source_id"))
# use all available fields
q$fields("*")
# remove the parameter
# act the same as above because the default `fields` in ESGF search
# services is `*` if `fields` is not specified
q$fields(NULL)
}
shards()Get or set the shards parameter.
By default, a distributed query targets all ESGF Nodes. $shards()
can be used to execute a distributed search that targets only one or
more specific nodes.
All available shards can be retrieved using
$list_all_shards()
method.
EsgfQuery$shards(value)
valueThe facet parameter value. There are two options:
If value is not given, current value is returned.
A character vector or NULL.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$shards()
# set the parameter
q$shards("localhost:8983/solr/datasets")
# negate the constraints
q$shards(!"localhost:8983/solr/datasets")
# only applicable for distributed queries
q$distrib(FALSE)$shards("localhost:8983/solr/datasets") # Error
# remove the parameter
q$shards(NULL)
}
replica()Get or set the replica parameter.
By default, a query returns all records (masters and replicas)
matching the search criteria, i.e. $replica(NULL).
To return only master records, use $replica(FALSE); to return only
replicas, use $replica(TRUE).
EsgfQuery$replica(value)
valueThe facet parameter value. Default: NULL.
There are two options:
If value is not given, current value is returned.
A flag or NULL.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$replica()
# set the parameter
q$replica(TRUE)
# remove the parameter
q$replica(NULL)
}
latest()Get or set the latest parameter.
By default, a query to the ESGF search services returns only the very
last, up-to-date version of the matching records, i.e.
$latest(TRUE). You can use $latest(FALSE) to return all versions.
EsgfQuery$latest(value = TRUE)
valueThe facet parameter value. Default: TRUE.
There are two options:
If value is not given, current value is returned.
A flag.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$latest()
# set the parameter
q$latest(TRUE)
}
type()Get or set the type parameter.
There are three types in total: Dataset, File or Aggregation.
EsgfQuery$type(value = "Dataset")
valueThe facet parameter value. Default: "Dataset".
There are two options:
If value is not given, current value is returned.
A string.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$type()
# set the parameter
q$type("Dataset")
}
limit()Get or set the limit parameter.
$limit() can be used to limit the number of records to return.
Note that the maximum number of records to return per query for ESGF
search services is 10,000. A warning is issued if input value is
greater than that. In this case, limit will be reset to 10,000.
EsgfQuery$limit(value = 10L)
valueThe facet parameter value. Default: 10.
There are two options:
If value is not given, current value is returned.
An integer.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$limit()
# set the parameter
q$limit(10L)
# `limit` is reset to 10,000 if input is greater than that
q$limit(10000L) # warning
}
offset()Get or set the offset parameter.
If the query returns records that exceed the
limit number,
$offset() can be used to paginate through the available results.
EsgfQuery$offset(value = 0L)
valueThe facet parameter value. Default: 0.
There are two options:
If value is not given, current value is returned.
An integer.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$offset()
# set the parameter
q$offset(0L)
}
distrib()Get or set the distrib facet
By default, the query is sent to all ESGF Nodes, i.e.
$distrib(TRUE).
$distrib(FALSE) can be used to execute the query only on the
target node.
EsgfQuery$distrib(value = TRUE)
valueThe facet parameter value. Default: TRUE.
There are two options:
If value is not given, current value is returned.
A flag.
If value is given, the modified EsgfQuery object.
Otherwise, an EsgfQueryParam object which is essentially a list of three elements:
value: input values.
negate: Whether there is a preceding !.
name: Parameter name.
\dontrun{
# get current value
q$distrib()
# set the parameter
q$distrib(TRUE)
}
params()Get or set other parameters.
$params() can be used to specify other parameters that do not have
a dedicated method, e.g. version, master_id, etc. It can also be
used to overwrite existing parameter values specified using methods
like $activity_id().
EsgfQuery$params(...)
...Parameter values to set. There are three options:
If not given, existing parameters that do not have a dedicated method are returned.
If NULL, all existing parameters that do not have a dedicated
method are removed.
A named vector, e.g. $params(score = 1, table_id = "day") will
set score to 1 and table_id to day.
The ! notation can still be used to negate the constraints, e.g.
$params(table_id = !c("3hr", "day")) searches for all table_id
except for 3hr and day.
If parameters are specified, the modified EsgfQuery object,
invisibly.
Otherwise, an empty list for $params(NULL) or a list of
EsgfQueryParam objects.
\dontrun{
# get current values
# default is an empty list (`list()`)
q$params()
# set the parameter
q$params(table_id = c("3hr", "day"), member_id = "00")
q$params()
# reset existing parameters
q$frequency("day")
q$params(frequency = "mon")
q$frequency() # frequency value has been changed using $params()
# negating the constraints is also supported
q$params(table_id = !c("3hr", "day"))
# use NULL to remove all parameters
q$params(NULL)$params()
}
url()Get the URL of actual query or wget script
EsgfQuery$url(wget = FALSE)
wgetWhether to return the URL of the wget script that can be
used to download all files matching the given constraints.
Default: FALSE.
A single string.
\dontrun{
q$url()
# get the wget script URL
q$url(wget = TRUE)
# You can download the wget script using the URL directly. For
# example, the code below downloads the script and save it as
# 'wget.sh' in R's temporary folder:
download.file(q$url(TRUE), file.path(tempdir(), "wget.sh"), mode = "wb")
}
count()Send a query of facet counting and fetch the results
EsgfQuery$count(facets = TRUE)
facetsNULL, a flag or a character vector. There are three
options:
If NULL or FALSE, only the total number of matched records is
returned.
If TRUE, the value of $facets()
is used to limit the facets. This is the default value.
If a character vector, it is used to limit the facets.
If facets equals NULL or FALSE, or $facets() returns NULL,
an integer.
Otherwise, a named list with the first element always being total
which is the total number of matched records. Other elements have
the same length as input facets and are all named integer vectors.
\dontrun{
# get the total number of matched records
q$count(NULL) # or q$count(facets = FALSE)
# count records for specific facets
q$facets(c("activity_id", "source_id"))$count()
# same as above
q$count(facets = c("activity_id", "source_id"))
}
collect()Send the actual query and fetch the results
$collect() sends the actual query to the ESGF search services and
returns the results in a data.table::data.table. The columns depend
on the value of query type and fields parameter.
EsgfQuery$collect()
A data.table.
\dontrun{
q$fields("source_id")
q$collect()
}
response()Get the response of last sent query
The response of the last sent query is always stored internally and
can be retrieved using $response(). It is a named list generated
from the JSON response using jsonlite::fromJSON().
EsgfQuery$response()
A named list.
\dontrun{
q$response()
}
print()Print a summary of the current EsgfQuery object
$print() gives the summary of current EsgfQuery object including
the host URL, the built time of facet cache and all query parameters.
EsgfQuery$print()
The EsgfQuery object itself, invisibly.
\dontrun{
q$print()
}
Hongyuan Jia
## ------------------------------------------------
## Method `EsgfQuery$new`
## ------------------------------------------------
## Not run:
q <- EsgfQuery$new(host = "https://esgf-node.llnl.gov/esg-search")
q
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$build_cache`
## ------------------------------------------------
## Not run:
q$build_cache()
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$list_all_facets`
## ------------------------------------------------
## Not run:
q$list_all_facets()
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$list_all_shards`
## ------------------------------------------------
## Not run:
q$list_all_shards()
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$list_all_values`
## ------------------------------------------------
## Not run:
q$list_all_values()
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$project`
## ------------------------------------------------
## Not run:
# get current value
q$project()
# set the parameter
q$project("CMIP6")
# negate the project constraints
q$project(!"CMIP6")
# remove the parameter
q$project(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$activity_id`
## ------------------------------------------------
## Not run:
# get current value
q$activity_id()
# set the parameter
q$activity_id("ScenarioMIP")
# negate the constraints
q$activity_id(!c("CFMIP", "ScenarioMIP"))
# remove the parameter
q$activity_id(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$experiment_id`
## ------------------------------------------------
## Not run:
# get current value
q$experiment_id()
# set the parameter
q$experiment_id(c("ssp126", "ssp585"))
# negate the constraints
q$experiment_id(!c("ssp126", "ssp585"))
# remove the parameter
q$experiment_id(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$source_id`
## ------------------------------------------------
## Not run:
# get current value
q$source_id()
# set the parameter
q$source_id(c("BCC-CSM2-MR", "CESM2"))
# negate the constraints
q$source_id(!c("BCC-CSM2-MR", "CESM2"))
# remove the parameter
q$source_id(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$variable_id`
## ------------------------------------------------
## Not run:
# get current value
q$variable_id()
# set the parameter
q$variable_id(c("tas", "pr"))
# negate the constraints
q$variable_id(!c("tas", "pr"))
# remove the parameter
q$variable_id(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$frequency`
## ------------------------------------------------
## Not run:
# get current value
q$frequency()
# set the parameter
q$frequency(c("1hr", "day"))
# negate the constraints
q$frequency(!c("1hr", "day"))
# remove the parameter
q$frequency(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$variant_label`
## ------------------------------------------------
## Not run:
# get current value
q$variant_label()
# set the parameter
q$variant_label(c("r1i1p1f1", "r1i2p1f1"))
# negate the constraints
q$variant_label(!c("r1i1p1f1", "r1i2p1f1"))
# remove the parameter
q$variant_label(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$nominal_resolution`
## ------------------------------------------------
## Not run:
# get current value
q$nominal_resolution()
# set the parameter
q$nominal_resolution(c("100 km", "1x1 degree"))
# negate the constraints
q$nominal_resolution(!c("100 km", "1x1 degree"))
# remove the parameter
q$nominal_resolution(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$data_node`
## ------------------------------------------------
## Not run:
# get current value
q$data_node()
# set the parameter
q$data_node("esg.lasg.ac.cn")
# negate the constraints
q$data_node(!"esg.lasg.ac.cn")
# remove the parameter
q$data_node(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$facets`
## ------------------------------------------------
## Not run:
# get current value
q$facets()
# set the facets
q$facets(c("activity_id", "source_id"))
# use all available facets
q$facets("*")
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$fields`
## ------------------------------------------------
## Not run:
# get current value
q$fields()
# set the fields
q$fields(c("activity_id", "source_id"))
# use all available fields
q$fields("*")
# remove the parameter
# act the same as above because the default `fields` in ESGF search
# services is `*` if `fields` is not specified
q$fields(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$shards`
## ------------------------------------------------
## Not run:
# get current value
q$shards()
# set the parameter
q$shards("localhost:8983/solr/datasets")
# negate the constraints
q$shards(!"localhost:8983/solr/datasets")
# only applicable for distributed queries
q$distrib(FALSE)$shards("localhost:8983/solr/datasets") # Error
# remove the parameter
q$shards(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$replica`
## ------------------------------------------------
## Not run:
# get current value
q$replica()
# set the parameter
q$replica(TRUE)
# remove the parameter
q$replica(NULL)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$latest`
## ------------------------------------------------
## Not run:
# get current value
q$latest()
# set the parameter
q$latest(TRUE)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$type`
## ------------------------------------------------
## Not run:
# get current value
q$type()
# set the parameter
q$type("Dataset")
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$limit`
## ------------------------------------------------
## Not run:
# get current value
q$limit()
# set the parameter
q$limit(10L)
# `limit` is reset to 10,000 if input is greater than that
q$limit(10000L) # warning
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$offset`
## ------------------------------------------------
## Not run:
# get current value
q$offset()
# set the parameter
q$offset(0L)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$distrib`
## ------------------------------------------------
## Not run:
# get current value
q$distrib()
# set the parameter
q$distrib(TRUE)
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$params`
## ------------------------------------------------
## Not run:
# get current values
# default is an empty list (`list()`)
q$params()
# set the parameter
q$params(table_id = c("3hr", "day"), member_id = "00")
q$params()
# reset existing parameters
q$frequency("day")
q$params(frequency = "mon")
q$frequency() # frequency value has been changed using $params()
# negating the constraints is also supported
q$params(table_id = !c("3hr", "day"))
# use NULL to remove all parameters
q$params(NULL)$params()
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$url`
## ------------------------------------------------
## Not run:
q$url()
# get the wget script URL
q$url(wget = TRUE)
# You can download the wget script using the URL directly. For
# example, the code below downloads the script and save it as
# 'wget.sh' in R's temporary folder:
download.file(q$url(TRUE), file.path(tempdir(), "wget.sh"), mode = "wb")
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$count`
## ------------------------------------------------
## Not run:
# get the total number of matched records
q$count(NULL) # or q$count(facets = FALSE)
# count records for specific facets
q$facets(c("activity_id", "source_id"))$count()
# same as above
q$count(facets = c("activity_id", "source_id"))
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$collect`
## ------------------------------------------------
## Not run:
q$fields("source_id")
q$collect()
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$response`
## ------------------------------------------------
## Not run:
q$response()
## End(Not run)
## ------------------------------------------------
## Method `EsgfQuery$print`
## ------------------------------------------------
## Not run:
q$print()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.