OCHA-DAP / pa-aa-yem-flooding

GNU General Public License v3.0
3 stars 0 forks source link

ECMWF HRES negative pixel values #16

Open zackarno opened 1 year ago

zackarno commented 1 year ago

It appears there are lots of negative pixel values present in the ECMWF HRES rasters we currently have downloaded. Therefore, wondering if there is any info from ECMWF on this matter as negative precip forecast does not really make sense. The values tend to be quite small, but there are alot of them. Perhaps it makes sense to convert all negative values to 0? Any ideas @turnerm ?

reprex:

library(tidyverse)
library(terra)
#> terra 1.6.47
#> 
#> Attaching package: 'terra'
#> The following object is masked from 'package:tidyr':
#> 
#>     extract

# ECMWF HRES GDRIVE DIR
r_dir <- file.path(
    Sys.getenv("AA_DATA_DIR"),
    "private",
    "processed",
    "yem",
    "ecmwf",
    "strange_coords"
)

# Load random raster 
r <- rast(list.files(r_dir,full.names = T)[2])

# subset bands to 24hr lead time
r_sub_24h_lead <- r["tp_step=24$"]

# filter vals < 0 for example
r_vals_lt0 <- data.frame(
    r_vals = terra::values(r_sub_24h_lead) %>% 
        as.numeric()
    ) %>% 
    filter(r_vals<0) 

# show first 50
r_vals_lt0 %>% 
    head(50)
#>           r_vals
#> 1  -2.004058e-11
#> 2  -2.004058e-11
#> 3  -2.004058e-11
#> 4  -2.004058e-11
#> 5  -2.004058e-11
#> 6  -2.004058e-11
#> 7  -2.004058e-11
#> 8  -2.004058e-11
#> 9  -2.004058e-11
#> 10 -2.004058e-11
#> 11 -2.004058e-11
#> 12 -2.004058e-11
#> 13 -2.004058e-11
#> 14 -2.004058e-11
#> 15 -2.004058e-11
#> 16 -2.004058e-11
#> 17 -2.004058e-11
#> 18 -2.004058e-11
#> 19 -2.004058e-11
#> 20 -2.004058e-11
#> 21 -2.004058e-11
#> 22 -2.004058e-11
#> 23 -2.004058e-11
#> 24 -2.004058e-11
#> 25 -2.004058e-11
#> 26 -2.004058e-11
#> 27 -2.004058e-11
#> 28 -2.004058e-11
#> 29 -2.004058e-11
#> 30 -2.004058e-11
#> 31 -2.004058e-11
#> 32 -2.004058e-11
#> 33 -2.004058e-11
#> 34 -2.004058e-11
#> 35 -2.004058e-11
#> 36 -2.004058e-11
#> 37 -2.004058e-11
#> 38 -2.004058e-11
#> 39 -2.004058e-11
#> 40 -2.004058e-11
#> 41 -2.004058e-11
#> 42 -2.004058e-11
#> 43 -2.004058e-11
#> 44 -2.004058e-11
#> 45 -2.004058e-11
#> 46 -2.004058e-11
#> 47 -2.004058e-11
#> 48 -2.004058e-11
#> 49 -2.004058e-11
#> 50 -2.004058e-11

# print total number of pixels lt 0
nrow(r_vals_lt0)
#> [1] 4792

Created on 2023-04-26 with reprex v2.0.2

turnerm commented 1 year ago

Good find Zack, I can ask ECMWF about it but I suspect it's some kind of interpolation error from MARS.

However, I wouldn't worry too much about it given the magnitude of the values -- even if you sum them all up, you'd get ~1E-7 which is -0.0001 mm, so I don't think setting them to 0 or not will change the results.