climate indices tool for E-OBS data (used only with ecad_indices_stations)
For an example of how to add indices from climind
into gridclimind
you can have a look at the 7d185d65 commit in gridclimind
(‘Added last three compound indices…etc’). In general, adding an index you will have to take the following steps:
Add a function to climind
which uses the correct interface, i.e.:
function(ci, freq=c("annual”), cur_sub)
Where:
ci
is the input object, this will be provided by gridlcimind
.freq
the supported list of time resolutions. Typically this will be freq=c("monthly", "annual", "halfyear", "seasonal”)
.Add the metadata information to eobs.json (inst/extdata/metadata_config_files
in the gridclimind project) in the index.metadata
list. For example:
"csdi": {
"long.name": "Cold Spell Duration Index",
"units": "days",
"base.period.attr": true,
"standard.name": "cold_spell_duration_index",
"calculation.function.name": "climdex.csdi",
"additional_arguments": {
"spells.can.span.years": false
},
"supported.time.resolutions": "annual",
"include.time.prefix.in.long.name": true,
"required.variables": "tmin"
}
Note that:
additional_arguments
is optional. These extra input arguments are fed to the listed calculation.function.name
, i.e. the new function we created in step 1.supported.time.resolutions
and required.variables
can also be a list of values, e.g.:"ww": {
"long.name": "Warm-wet days",
"units": "",
"base.period.attr": false,
"standard.name": "warm_wet_days",
"calculation.function.name": "climdex.wd",
"additional_arguments": {
"precip.thresh": "q75",
"precip.op": ">",
"temp.thresh": "q75",
"temp.op": ">"
},
"supported.time.resolutions": ["annual", "monthly", "seasonal", "halfyear"],
"include.time.prefix.in.long.name": true,
"required.variables": ["prec", "tavg"]
}
Add the index file to the test suite:
Go to the output directory, this is listed in the output_data_path
variable, e.g.:
output_data_path
[1] "/var/folders/dm/smk5_rf53bg057ql34rmhnq80000gn/T//RtmpphG0Nw"
Copy the nc file for the index you added to /your/installation/of/gridclimind/tests/testthat/reference_ncfiles/generate_all_indices_test/
. This could be up to 4 files, depended on the supported time resolutions.
3. The reference rds files for the metadata test will change probably. After checking that the change is really related to the addition of a new index, simply delete the offending rds files and rerun the test. This will generate new reference files which contain the new index.
Commit the changes in the gridlcimind package to git.
The list of variables that gridclimind
is aware of is stored in the metadata json
file under generic.metadata$variable.name.map
. There you list how each of the possible input variables is called in the input NetCDF files. Some important notes:
variable.name.map
on the left hand side need to match those used in gridclimind
and climind
. A good resource here is the climind::climdexInput.raw
function which uses all of these names. climind::climdexInput.raw
there is no way to calculate the indices. You can read the data from the input NetCDF files, but there will be no way to build the input data object for the indices. So, you need to add support for a variable to climind
first and then add it to the gridclimind
variable.name.map
.Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.