Skip to content

Instantly share code, notes, and snippets.

@PietrH
Last active November 19, 2024 15:32
Show Gist options
  • Save PietrH/f13fb98f95b37242e59c92407fde1917 to your computer and use it in GitHub Desktop.
Save PietrH/f13fb98f95b37242e59c92407fde1917 to your computer and use it in GitHub Desktop.
Reading CROW radar Vertical Profile of Birds (VPB) data from the RMI using data.table in R
library(magrittr)
rmi_url <- "https://opendata.meteo.be/ftp/observations/radar/vbird/denhb/2024/denhb_vpts_20240128.txt"

header <- readr::read_lines(rmi_url) %>% 
  .[stringr::str_starts(.,"#")] %>%
  tail(1) %>% 
  stringr::str_remove("#") %>% 
  stringr::str_split(" ", simplify = TRUE) %>%
  .[nchar(.) > 0]

data.table::fread(
  rmi_url,
  skip = 4,
  header = FALSE,
  col.names = header
)
#>           date  time  HGHT     u     v     w    ff    dd sd_vvp    gap    dbz
#>          <int> <int> <int> <num> <num> <num> <num> <num>  <num> <char>  <num>
#>    1: 20240128     0     0   NaN   NaN   NaN   NaN   NaN    NaN      T    NaN
#>    2: 20240128     0   200   NaN   NaN   NaN   NaN   NaN    NaN      T    NaN
#>    3: 20240128     0   400   NaN   NaN   NaN   NaN   NaN    NaN      T    NaN
#>    4: 20240128     0   600   NaN   NaN   NaN   NaN   NaN    NaN      T -10.83
#>    5: 20240128     0   800   NaN   NaN   NaN   NaN   NaN    NaN      T  -7.87
#>   ---                                                                        
#> 7196: 20240128  2355  4000   NaN   NaN   NaN   NaN   NaN    NaN      T -11.52
#> 7197: 20240128  2355  4200   NaN   NaN   NaN   NaN   NaN    NaN      T  -8.54
#> 7198: 20240128  2355  4400   NaN   NaN   NaN   NaN   NaN    NaN      T -11.19
#> 7199: 20240128  2355  4600   NaN   NaN   NaN   NaN   NaN    NaN      T -11.02
#> 7200: 20240128  2355  4800   NaN   NaN   NaN   NaN   NaN    NaN      T -11.47
#>         eta  dens   DBZH     n n_dbz n_all n_dbz_all
#>       <num> <num>  <num> <int> <int> <int>     <int>
#>    1:   NaN   NaN    NaN     0     0     0         0
#>    2:   NaN   NaN    NaN     0     0     0         0
#>    3:   NaN   NaN    NaN     0     0     0         0
#>    4:  29.1  2.65  45.88     0   583     9     28080
#>    5:  57.6  5.24  41.56     0  1214     1     24837
#>   ---                                               
#> 7196:  24.9  2.26 -10.96     0  3606     0      3960
#> 7197:  49.4  4.49  -8.56     0  3220     0      3240
#> 7198:  26.8  2.44 -11.19     0  3240     0      3240
#> 7199:  27.9  2.53 -11.02     0  2880     0      2880
#> 7200:  25.1  2.29 -11.47     0  2880     0      2880

Created on 2024-11-19 with reprex v2.1.0

rmi_url <- "https://opendata.meteo.be/ftp/observations/radar/vbird/denhb/2024/denhb_vpts_20240128.txt"
header <- readr::read_lines(rmi_url) %>%
.[stringr::str_starts(.,"#")] %>%
tail(1) %>%
stringr::str_remove("#") %>%
stringr::str_split(" ", simplify = TRUE) %>%
.[nchar(.) > 0]
data.table::fread(
rmi_url,
skip = 4,
header = FALSE,
col.names = header
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment