Finds and orders the monthly files of one variable in a folder, e.g. the
files written by download_chelsa_monthly() or downloaded by hand. A file
belongs to variable var and month MM when its name contains
_<var>_<MM>_ (so tas does not match tasmax); the month may be
written 01 or 1, as in CHELSA-TraCE21k.
References
Karger, D.N., Conrad, O., Bohner, J., et al. (2017) Climatologies at high resolution for the earth's land surface areas. Scientific Data 4, 170122. doi:10.1038/sdata.2017.122
Examples
d <- tempfile()
dir.create(d)
for (m in 1:12) file.create(file.path(d, sprintf("CHELSA_tas_%02d_1981-2010_V.2.1.tif", m)))
basename(monthly_files(d, "tas"))[1:2]
#> [1] "CHELSA_tas_01_1981-2010_V.2.1.tif" "CHELSA_tas_02_1981-2010_V.2.1.tif"
