Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • startR startR
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 29
    • Issues 29
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Earth SciencesEarth Sciences
  • startRstartR
  • Wiki
  • Examples

Examples · Changes

Page history
Update Examples authored Oct 31, 2019 by aho's avatar aho
Hide whitespace changes
Inline Side-by-side
Examples.md
View page @ 66c8cc5c
......@@ -618,3 +618,112 @@ r <- Compute(wf,
</p>
</details>
## Interpolation in Start()
<details><summary>CLICK ME</summary>
</p>
<br/>
Do the interpolation within Start(), and compare with Load() result. When the Start() parameter `transform_extra_cells = 2`, the two results will be the same.
```r
# ------------------------------------------------------------------
# Do the interpolation within Start(). Compare with Load().
# ------------------------------------------------------------------
library(startR)
library(s2dverification)
obs_path <- '/esarchive/recon/ecmwf/era5/monthly_mean/$var$_f1h/$var$_$sdate$.nc'
pobs <- paste0('/esarchive/recon/ecmwf/era5/monthly_mean/',
'$VAR_NAME$_f1h/$VAR_NAME$_$YEAR$$MONTH$.nc')
var_name<-'sfcWind'
lons.min <- 0
lons.max <- 10
lats.min <- 0
lats.max <- 10
#-------------------------
# Start()
#-------------------------
obs <- Start(dat = obs_path,
var = var_name,
sdate = '201811',
time = 'all',
latitude = values(list(lats.min, lats.max)),
latitude_reorder = Sort(),
longitude = values(list(lons.min, lons.max)),
synonims = list(longitude = c('lon', 'longitude'),
latitude = c('lat', 'latitude')),
transform = CDORemapper,
transform_extra_cells = 2,
transform_params = list(grid = 'r360x181',
method = 'conservative',
crop = c(lons.min, lons.max, lats.min, lats.max)),
transform_vars = c('latitude', 'longitude'),
return_vars = list(time = NULL,
latitude = 'dat',
longitude = 'dat'),
split_multiselected_dims = TRUE,
merge_across_dims = TRUE,
#num_procs = 4,
retrieve = T)
# -- Result --
dim(obs)
# dat var sdate time latitude longitude
# 1 1 1 1 11 11
range(obs)
#[1] 1.090472 4.987585
str(attr(obs, 'Variables')$common[[var_name]]$dim[[1]])
# $ name : chr "longitude"
# $ vals : num [1:11(1d)] 0 1 2 3 4 5 6 7 8 9 ...
str(attr(obs, 'Variables')$common[[var_name]]$dim[[2]])
# $ name : chr "latitude"
# $ vals : num [1:11(1d)] 0 1 2 3 4 5 6 7 8 9 ...
obs[1,1,1,1,,1]
# [1] 4.987585 4.299388 4.007287 3.758497 3.673881 3.908989 2.224407 1.774090
# [9] 1.800998 1.718733 1.816074
#-------------------------
# s2dverification::Load()
#-------------------------
obs1 <- Load(var = var_name,
obs = list(list(path = pobs)),
sdates = '20181101',
leadtimemin = 1,
leadtimemax = 1,
output = 'lonlat',
grid = 'r360x181',
method = 'conservative',
storefreq = 'monthly',
latmin = lats.min,
latmax = lats.max,
lonmin = lons.min,
lonmax = lons.max)
# -- Result --
dim(obs1$obs)
#dataset member sdate ftime lat lon
# 1 1 1 1 11 11
range(obs1$obs)
#[1] 1.0905 4.9876
str(obs1)
# $ lon : num [1:11(1d)] 0 1 2 3 4 5 6 7 8 9 ...
# $ lat : num [1:11(1d)] 10 9 8 7 6 5 4 3 2 1 ...
obs1$obs[1,1,1,1,,1] #when lon = 0
# [1] 1.8161 1.7187 1.8010 1.7741 2.2244 3.9090 3.6739 3.7585 4.0073 4.2994
#[11] 4.9876
#-----------------------
# Comparison
#-----------------------
diff <- drop(obs)[11:1, ] - drop(obs1$obs) #lat order is different
range(diff)
#[1] -4.918404e-05 4.693756e-05
```
</p>
</details>
\ No newline at end of file
Clone repository
  • Examples
  • FAQs
  • Home