Hi Linxuan,
Without knowing where/when your data represents I can't say for sure, but I imagine this is because ERA5 pixels over oceans/seas have artificially lower variation than ERA5 pixels over land. If so, it's not that areas protruding into the ocean are cooler across all timesteps, but that daytime maxima are cooler (and nighttime minima are warmer) than inland pixels. So the "disturbance" you're referring to is simply part of the original ERA5 data, and because the coarse resolution of ERA5 doesn't perfectly capture coastlines.
We correct this in ERA5 data as part of the `mcera5` package, which feeds ERA5 data into micro_era5. `mcera5` uses an empirically-calibrated correction factor to increase diel variation for pixels that are predominantly ocean (which ERA5 thinks are in fact entirely ocean). We describe this in the mcera5 paper (
Klinges et al. 2022 MEE), and I've pasted a toy example of R code below.
If you want to try to remove differences in diel variation between coastal and inland pixels (which do indeed occur in reality, although usually not quite to the extent represented in ERA5 data), you can tune the argument `dtr_cor_fac` handed to extract_clim(). For doing so within NicheMapR's
micro_era5(), this entails forking the NicheMapR package and modifying any instances of extract_clim() within the micro_era5() function. The default value of dtr_cor_fac is 1.285, you might want to try 1.5 or greater. With that said, this may make your microclimate predictions less realistic, even if more visually appealing.
Best,
Dave
library(ggplot2)
x <- c(1:48) # Dummy data for 2 days (48 hours)
y <- sin(x) * 8 + 10 # dummy temperature data
df <- data.frame(
x = x,
y = y,
tme = seq(as.POSIXlt("2023-01-01 00:00", tz = "UTC"),
as.POSIXlt("2023-01-02 23:00", tz = "UTC"), by = 3600)
)
# coastal correction with proportion land (landprop) of 0.5 and
# default correction factor of 1.285
# note: `landprop` is typically derived from an ERA5 layer that is downloaded with other
# ERA5 data
out <- mcera5:::coastal_correct(df$y, df$tme, landprop = 0.5, cor_fac = 1.285)
# coastal correction with proportion land (landprop) of 0.5 and
# higher correction factor of 1.5
# note: `landprop` is typically derived from an ERA5 layer that is downloaded with other
# ERA5 data
out2 <- mcera5:::coastal_correct(df$y, df$tme, landprop = 0.5, cor_fac = 2)
ggplot(df) +
# original data
geom_line(aes(x,y), color = "black") +
# corrected with cor_fac = 1.285
geom_line(aes(x,out), color = "blue") +
# corrected with cor_fac = 2
geom_line(aes(x,out2), color = "orange")