⚲
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 (775 Bytes)
RE: converting .csv to .nc to perform time-based statistics
» kyle.rb
Ralf Mueller
, 2020-05-04 09:46
require
'cdo'
require
'parallel'
cdo
=
Cdo
.
new
inputs
=
File
.
open
(
ARGV
[
0
]).
readlines
.
map
(
&
:chomp
).
map
(
&
:split
)
Parallel
.
each
(
inputs
,
in_threads:
12
)
{
|
input
|
year
,
month
,
day
,
hour
,
*
values
=
input
month
=
month
.
rjust
(
2
,
'0'
)
day
=
day
.
rjust
(
2
,
'0'
)
hour
=
hour
.
rjust
(
2
,
'0'
)
puts
"##############################:
#{
year
}
-
#{
month
}
-
#{
day
}
T
#{
hour
}
:00:00"
values
.
each_with_index
{
|
value
,
index
|
cdo
.
settaxis
(
"
#{
year
}
-
#{
month
}
-
#{
day
}
,
#{
hour
}
:00:00,1hours"
,
input:
"-setname,var
#{
index
}
-const,
#{
value
}
,r1x1"
,
output:
"var
#{
index
}
_
#{
year
}
-
#{
month
}
-
#{
day
}
_
#{
hour
}
.nc"
,
options:
'-f nc'
)
}
}
(
0
..
5
).
each
{
|
i
|
cdo
.
cat
(
input:
Dir
.
glob
(
"var
#{
i
}
_*.nc"
).
sort
,
output:
"VAR
#{
i
}
.nc"
)
}
# cleanup with:
# rm var*nc
« Previous
1
2
3
…
7
Next »
(1-1/7)
Loading...