Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
3ed09448
Commit
3ed09448
authored
1 year ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Remapweights: add parameter map3d
parent
a5aa5bef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!145
M214003/develop
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Remapweights.cc
+55
-21
55 additions, 21 deletions
src/Remapweights.cc
with
55 additions
and
21 deletions
src/Remapweights.cc
+
55
−
21
View file @
3ed09448
...
...
@@ -31,7 +31,38 @@
#include
"griddes.h"
#include
"cdo_options.h"
#include
"util_string.h"
#include
"pmlist.h"
static
void
get_parameter
(
int
offset
,
int
&
neighbors
,
bool
&
map3D
,
std
::
string
&
grid
)
{
auto
pargc
=
cdo_operator_argc
()
-
offset
;
if
(
pargc
)
{
auto
pargv
=
cdo_get_oper_argv
();
pargv
.
erase
(
pargv
.
begin
(),
pargv
.
begin
()
+
offset
);
KVList
kvlist
;
kvlist
.
name
=
cdo_module_name
();
if
(
kvlist
.
parse_arguments
(
pargc
,
pargv
)
!=
0
)
cdo_abort
(
"Parse error!"
);
if
(
Options
::
cdoVerbose
)
kvlist
.
print
();
for
(
const
auto
&
kv
:
kvlist
)
{
const
auto
&
key
=
kv
.
key
;
if
(
kv
.
nvalues
>
1
)
cdo_abort
(
"Too many values for parameter key >%s<!"
,
key
);
if
(
kv
.
nvalues
<
1
)
cdo_abort
(
"Missing value for parameter key >%s<!"
,
key
);
const
auto
&
value
=
kv
.
values
[
0
];
// clang-format off
if
(
key
==
"grid"
)
grid
=
parameter_to_word
(
value
);
else
if
(
key
==
"neighbors"
)
neighbors
=
parameter_to_int
(
value
);
else
if
(
key
==
"map3D"
||
key
==
"map3d"
)
map3D
=
parameter_to_bool
(
value
);
else
cdo_abort
(
"Invalid parameter key >%s<!"
,
key
);
// clang-format on
}
}
}
static
void
remap_write_weights
(
const
std
::
string
remapWeightsFile
,
const
RemapSwitches
&
remapSwitches
,
RemapType
&
remap
)
...
...
@@ -64,8 +95,9 @@ add_operators(void)
class
ModuleRemapweights
{
RemapSwitches
remapSwitches
;
int
numRemaps
=
0
;
int
numNeighbors
=
0
;
int
numRemaps
{
0
};
int
numNeighbors
{
0
};
bool
map3D
{
false
};
CdoStreamID
streamID1
;
int
vlistID1
;
...
...
@@ -115,21 +147,26 @@ public:
if
(
Options
::
cdoVerbose
)
cdo_print
(
"Extrapolation %s!"
,
remapExtrapolate
?
"enabled"
:
"disabled"
);
{
operator_input_arg
(
"grid description file or name"
);
if
(
operfunc
==
GENDIS
&&
cdo_operator_argc
()
==
2
)
{
auto
inum
=
parameter_to_int
(
cdo_operator_argv
(
1
));
if
(
inum
<
1
)
cdo_abort
(
"Number of nearest neighbors out of range (>0)!"
);
numNeighbors
=
inum
;
}
else
{
operator_check_argc
(
1
);
}
}
operator_input_arg
(
"grid description file or name"
);
auto
targetGrid
=
cdo_operator_argv
(
0
);
int
offset
=
string_starts_with
(
targetGrid
,
"grid="
)
?
0
:
1
;
if
(
cdo_operator_argc
()
>
offset
)
{
int
numNeighborsParam
=
0
;
get_parameter
(
offset
,
numNeighborsParam
,
map3D
,
targetGrid
);
if
(
map3D
)
remapParams
.
genMultiWeights
=
1
;
if
(
operfunc
==
GENDIS
)
{
if
(
numNeighborsParam
<
0
)
cdo_abort
(
"Number of nearest neighbors out of range (>0)!"
);
if
(
numNeighborsParam
>
0
)
numNeighbors
=
numNeighborsParam
;
}
}
else
{
operator_check_argc
(
1
);
}
gridID2
=
cdo_define_grid
(
cdo_operator_argv
(
0
)
);
gridID2
=
cdo_define_grid
(
targetGrid
);
if
(
gridInqType
(
gridID2
)
==
GRID_GENERIC
)
cdo_abort
(
"Unsupported target grid type (generic)!"
);
streamID1
=
cdo_open_read
(
0
);
...
...
@@ -194,10 +231,7 @@ public:
if
(
remapGrids
[
gridIndex
])
{
if
(
numRemaps
==
0
)
{
gridIDout
=
var
.
gridID
;
}
if
(
numRemaps
==
0
)
{
gridIDout
=
var
.
gridID
;
}
else
if
(
gridIDout
!=
var
.
gridID
)
{
continue
;
...
...
@@ -293,7 +327,7 @@ public:
outFile
+=
".nc"
;
}
//remap_write_weights(outFile, remapSwitches, remap);
//
remap_write_weights(outFile, remapSwitches, remap);
if
(
numRemaps
>
1
)
writeWorker
.
join
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment