Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(ncdf4)
- # files are 229x161x8760
- FILE_1 = nc_open('/emhires-data/data-warehouse/gridded/ERA5/era5-hourly-100m_v_component_of_wind-2018.europe.nc')
- FILE_2 = nc_open('/emhires-data/data-warehouse/gridded/ERA5/era5-hourly-10m_v_component_of_wind-2018.europe.nc')
- lat = ncvar_get(FILE_1, 'latitude')
- lon = ncvar_get(FILE_1, 'longitude')
- data_1 = ncvar_get(FILE_1, 'v100') # 2.5 GB in memory
- data_2 = ncvar_get(FILE_2, 'v10')
- nc_close(FILE_1)
- nc_close(FILE_2)
- cor_value = matrix(NA, ncol = length(lat), nrow = length(lon))
- pb = txtProgressBar(max = length(lon), style = 3)
- for (i in seq(1, length(lon))) {
- setTxtProgressBar(pb, i)
- for (j in seq(1, length(lat))) {
- cor_value[i,j] = cor(data_1[i,j,], data_2[i,j,])
- }
- }
- close(pb)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement