The problem with the coast temperature calculated by the function micro_era5

38 views
Skip to first unread message

linxuan Ma

unread,
Sep 17, 2025, 11:41:55 PM9/17/25
to NicheMapR
Hi Mike,

Previously I successfully calculated microclimate temperatures for the coast, but during my recent analysis I found something trouble and I am troubled about how to fix it.

That is, I found that the coastal temperatures calculated using micro_era5 were significantly higher in areas embedded in land than in areas protruding into the ocean.

Like this:
HH4X]P$ZXN[H6MBJ2F7{FM.pngLand on the left and ocean on the right.

I suspect this has something to do with the fact that ERA5 has both marine and terrestrial data, and that there is not such a noticeable difference using purely terrestrial data such as worldclim and terraclimate.

So I'm wondering if there is a way that all coastal points can calculate the microclimate based on the same side and not be disturbed.

This may be even more difficult in the case where the coastline accuracy doesn't match ERA5, and I can't find a suitable solution for this, so I'm asking you for advice.

Best wishes,
Linxuan Ma


David Klinges

unread,
Sep 18, 2025, 7:53:49 AM9/18/25
to linxuan Ma, NicheMapR
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")


--
You received this message because you are subscribed to the Google Groups "NicheMapR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nichemapr+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/nichemapr/9c93efcd-32ee-4e98-8e7c-513d3eb531b0n%40googlegroups.com.


--
David Klinges, PhD
Assistant Professor, Rutgers University (incoming)
Reply all
Reply to author
Forward
0 new messages