Dear Zixuan Chen,
The problem is in the mcera5 package, so an issue for Dave Klinges to fix. But I traced it to the mcera5:::nc_to_df internal function. If you source the modified version below after loading the mcera5 package that should get you back up and running.
All the best,
Mike
nc_to_df
<- function (nc, long, lat, start_time, end_time, dtr_cor = TRUE,
dtr_cor_fac = 1)
{
dat <- tidync::tidync(nc) %>% tidync::hyper_filter(longitude = longitude ==
long, latitude = latitude == lat) %>% tidync::hyper_tibble() %>%
dplyr::mutate(., obs_time = lubridate::ymd_hms("1900:01:01 00:00:00") +
(time * 3600), timezone = lubridate::tz(obs_time)) %>%
dplyr::filter(., obs_time >= start_time & obs_time <
end_time + 1) %>% dplyr::rename(., pressure = sp) %>%
dplyr::mutate(., temperature = t2m - 273.15, lsm = dplyr::case_when(lsm <
0 ~ 0, lsm >= 0 ~ lsm), temperature = dplyr::case_when(dtr_cor ==
TRUE ~ coastal_correct(temperature, lsm, dtr_cor_fac),
dtr_cor == FALSE ~ temperature), humidity = humfromdew(d2m -
273.15, temperature, pressure), windspeed = sqrt(u10^2 +
v10^2), windspeed = windheight(windspeed, 10, 2),
winddir = (atan2(u10, v10) * 180/pi + 180)%%360,
cloudcover = tcc * 100, netlong = abs(
avg_snlwrf
) *
0.0036, downlong = msdwlwrf * 0.0036, uplong = netlong +
downlong, emissivity = downlong/uplong, jd = julday(lubridate::year(obs_time),
lubridate::month(obs_time), lubridate::day(obs_time)),
si = siflat(lubridate::hour(obs_time), lat, long,
jd, merid = 0)) %>% dplyr::mutate(., rad_dni = fdir *
1e-06, rad_glbl = ssrd * 1e-06, rad_glbl = rad_calc(rad_glbl,
obs_time, long, lat), rad_dni = rad_calc(rad_dni, obs_time,
long, lat), rad_dif = rad_glbl - rad_dni * si) %>% dplyr::mutate(.,
szenith = 90 - solalt(lubridate::hour(obs_time), lat,
long, jd, merid = 0)) %>% dplyr::select(., obs_time,
temperature, humidity, pressure, windspeed, winddir,
emissivity, cloudcover, netlong, uplong, downlong, rad_dni,
rad_dif, szenith, timezone)
return(dat)
}