⚲
Project
General
Profile
Sign in
Register
Home
Projects
Imprint + Privacy Policy
Help
Search
:
CDO
All Projects
CDO
Overview
Activity
News
Wiki
Forums
Files
Documentation
Download (1.14 KB)
Tutorial
» ifs2icon_skel.rb
Ralf Mueller
, 2012-09-12 10:24
require
'cdo'
require
'jobqueue'
iFile
=
ARGV
[
0
].
nil?
?
'ifs_oper_T1279_2011010100.grb'
:
ARGV
[
0
]
targetGridFile
=
ARGV
[
1
].
nil?
?
'cell_grid-r2b07.nc'
:
ARGV
[
1
]
targetGridweightsFile
=
ARGV
[
2
].
nil?
?
'cell_weight-r2b07.nc'
:
ARGV
[
2
]
nWorkers
=
ARGV
[
3
].
nil?
?
8
:
ARGV
[
3
]
# lets work in debug mode
Cdo
.
debug
=
true
# create a queue with a predifined number of workers
jq
=
JobQueue
.
new
(
nWorkers
)
# split the input file wrt to variable names,codes,levels,grids,timesteps,...
splitTag
=
"ifs2icon_skel_split_"
#Cdo.splitcode(:in => iFile, :out => splitTag,:options => '-f nc')
Cdo
.
splitname
(
:in
=>
iFile
,
:out
=>
splitTag
,
:options
=>
'-f nc'
)
# collect Files form the split
files
=
Dir
.
glob
(
"
#{
splitTag
}
*.nc"
)
# remap variables in parallel
files
.
each
{
|
file
|
jq
.
push
{
basename
=
file
[
0
..-
(
File
.
extname
(
file
).
size
+
1
)]
Cdo
.
remap
(
targetGridFile
,
targetGridweightsFile
,
:in
=>
file
,
:out
=>
"remapped_
#{
basename
}
.nc"
)
}
}
jq
.
run
# Merge all the results together
Cdo
.
merge
(
:in
=>
Dir
.
glob
(
"remapped_*.nc"
).
join
(
" "
),
:out
=>
'mergedResults.nc'
)
« Previous
1
2
3
4
Next »
(1-1/4)
Loading...