if (interactive()) {
## Download some data to store
mydata <- cms_download_subset(
product = "GLOBAL_ANALYSISFORECAST_PHY_001_024",
layer = "cmems_mod_glo_phy-cur_anfc_0.083deg_P1D-m",
variable = c("uo", "vo"),
region = c(-1, 50, 10, 55),
timerange = c("2025-01-01 UTC", "2025-01-02 UTC"),
verticalrange = c(0, -2)
)
fn <- tempfile(fileext = ".nc")
cms_write_ncdf(mydata, fn)
mydata2 <- stars::read_mdim(
fn,
## You explicitly need to specify dimension bounds when reading back the data
bounds = c(
longitude = "longitude_bnds",
latitude = "latitude_bnds",
elevation = "elevation_bnds"))
## clean up after our selves
unlink(fn, TRUE, TRUE)
}
Run the code above in your browser using DataLab