library(urbanR)
library(ncdf4)
# -----  NO2 data:
output_path <- "/esarchive/scratch/nperez/git/Flor/Jan4Nuria/"
results <- readRDS(paste0(output_path, "bcn_NonUniformGrid.rds"))
receptor <- readRDS(paste0(output_path, "target_uniform_grid_bcn.rds"))
dates <- unique(results$date)

plot(receptor)

for (t in 1:24) {
# t = 1
  mean_map <- results[results$date == dates[t],]
  tictoc::tic()
  mean_map_uniform <- regrid(non_uniform_data = mean_map,
                             target_grid = receptor,
                             nc_path = output_path,
                             date = format(dates[t], "%Y-%m-%d-%HH%MM"),
                             var_name = "NO2", var_units = "concentration",
                             var_long_name = "Nitrogen dioxide")
  tictoc::toc()
}

