Loading and plotting data on irregular grids
I could successfully load and plot data on irregular grids in R with startR and s2dverification (the data is interpolated onto regular):
module load R
module load CDO
R
library(startR)
# Loading data on irregular grid
repos_path <- '/esarchive/exp/ecearth/i00k/monthly_mean/heatc/ohc_2d_avg_0-300m_i00k_$sdate$_fc0-4_*.nc'
heatc <- Start(repos = repos_path,
sdate = 'first',
var = 'heatc_sl',
ensemble = 'all',
x = 'all',
y = 'all',
time = 'all',
return_vars = list(var_names = NULL),
var_var = 'var_names')
# Loading longitude and latitude matrices from mask file
mask_path <- '/esnas/autosubmit/con_files/mask.regions.Ec3.0_O1L46.nc'
lon <- Start(repos = mask_path,
var = 'nav_lon',
t = 'first',
z = 'first',
x = 'all',
y = 'all',
return_vars = list(var_names = NULL),
var_var = 'var_names')
lons <- Subset(lon$Data, 1:4, list(1, 1, 1, 1), drop = 'selected')
lat <- Start(repos = mask_path,
var = 'nav_lat',
t = 'first',
z = 'first',
x = 'all',
y = 'all',
return_vars = list(var_names = NULL),
var_var = 'var_names')
lats <- Subset(lat$Data, 1:4, list(1, 1, 1, 1), drop = 'selected')
# CDO interpolation
library(s2dverification)
heatc_reg <- CDORemap(heatc$Data, lons, lats, 't106grid', 'bil')
# The heatc_reg has dims
# c(repository = 1, sdate = 1, variable = 1, ensemble = 1,
# lon = 319, lat = 115, time = 120)
# Plotting map
PlotLayout(PlotEquiMap, c('lat', 'lon'),
heatc_reg$data_array[1,1,1,,,,1],
heatc_reg$lons, heatc_reg$lats,
toptitle = '5 i00k heatc members for 1 timestep',
titles = paste('Member', 1:5), units = 'C')
I have also given a try to loading data with startR from within python, in order to use python tools to plot on irregular maps afterwards. For some reason I don't know yet, it crashes:
module load rpy2
module load CDO
python
import rpy2.robjects.packages
import rpy2.robjects as robjects
base = rpy2.robjects.packages.importr('base')
startR = rpy2.robjects.packages.importr('startR')
#library(startR)
repos_path = '/esarchive/exp/ecearth/i00k/monthly_mean/heatc/ohc_2d_avg_0-300m_i00k_$sdate$_fc0-4_*.nc'
heatc = startR.Start(repos = repos_path,
sdate = 'first',
var = 'heatc_sl',
time = 'all',
ensemble = 'all',
x = 'all',
y = 'all')#,
#return_vars = robjects.ListVector({'var_names': base.c()}),
#var_var = 'var_names')
mask_path = '/esnas/autosubmit/con_files/mask.regions.Ec3.0_O1L46.nc'
lon = startR.Start(repos = mask_path,
var = 'nav_lon',
t = 'first',
z = 'first',
x = 'all',
y = 'all',
return_vars = base.list(var_names = NULL),
var_var = 'var_names')
lon = startR.Start(repos = mask_path,
var = 'nav_lat',
t = 'first',
z = 'first',
x = 'all',
y = 'all',
return_vars = base.list(var_names = robjects.NULL),
var_var = 'var_names')