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
b95381b2
Commit
b95381b2
authored
1 year ago
by
Oliver Heidmann
Browse files
Options
Downloads
Patches
Plain Diff
class rework Fillmiss.cc
parent
9b8443cf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!78
M300433/class reworks/multiple class reworks 8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Fillmiss.cc
+95
-63
95 additions, 63 deletions
src/Fillmiss.cc
with
95 additions
and
63 deletions
src/Fillmiss.cc
+
95
−
63
View file @
b95381b2
...
...
@@ -390,99 +390,131 @@ setmisstodis(Field &field1, Field &field2, int numNeighbors)
setmisstodis
(
field1
.
nmiss
,
field1
.
grid
,
field1
.
vec_d
,
field2
.
vec_d
,
field1
.
missval
,
numNeighbors
);
}
void
*
Fillmiss
(
void
*
process
)
class
ModuleFillmiss
{
cdo_initialize
(
process
);
CdoStreamID
streamID1
;
CdoStreamID
streamID2
;
// clang-format off
auto
FILLMISS
=
cdo_operator_add
(
"fillmiss"
,
0
,
0
,
"nfill"
)
;
auto
FILLMISSONESTEP
=
cdo_operator_add
(
"fillmiss2"
,
0
,
0
,
"nfill"
);
auto
SETMISSTONN
=
cdo_operator_add
(
"setmisstonn"
,
0
,
0
,
""
)
;
auto
SETMISSTODIS
=
cdo_operator_add
(
"setmisstodis"
,
0
,
0
,
"number of neighbors"
)
;
int
taxisID1
;
int
taxisID2
;
int
operatorID
;
int
nfill
;
auto
operatorID
=
cdo_operator_id
();
VarList
varList1
;
Field
field1
,
field2
;
void
(
*
fill_method
)(
Field
&
,
Field
&
,
int
)
=
&
setmisstodis
;
int
FILLMISS
,
FILLMISSONESTEP
,
SETMISSTONN
,
SETMISSTODIS
;
public:
void
init
(
void
*
process
)
{
cdo_initialize
(
process
);
// clang-format off
FILLMISS
=
cdo_operator_add
(
"fillmiss"
,
0
,
0
,
"nfill"
);
FILLMISSONESTEP
=
cdo_operator_add
(
"fillmiss2"
,
0
,
0
,
"nfill"
);
SETMISSTONN
=
cdo_operator_add
(
"setmisstonn"
,
0
,
0
,
""
);
SETMISSTODIS
=
cdo_operator_add
(
"setmisstodis"
,
0
,
0
,
"number of neighbors"
);
operatorID
=
cdo_operator_id
();
if
(
operatorID
==
FILLMISS
)
fill_method
=
&
fillmiss
;
else
if
(
operatorID
==
FILLMISSONESTEP
)
fill_method
=
&
fillmiss_one_step
;
else
if
(
operatorID
==
SETMISSTONN
)
fill_method
=
&
setmisstodis
;
else
if
(
operatorID
==
SETMISSTODIS
)
fill_method
=
&
setmisstodis
;
// clang-format on
// clang-format on
auto
nfill
=
(
operatorID
==
SETMISSTODIS
)
?
4
:
1
;
nfill
=
(
operatorID
==
SETMISSTODIS
)
?
4
:
1
;
// Argument handling
auto
oargc
=
cdo_operator_argc
();
if
(
oargc
==
1
)
{
nfill
=
parameter_to_int
(
cdo_operator_argv
(
0
));
if
(
operatorID
==
FILLMISS
&&
(
nfill
<
1
||
nfill
>
4
))
cdo_abort
(
"nfill out of range!"
);
}
else
if
(
oargc
>
1
)
cdo_abort
(
"Too many arguments!"
);
// Argument handling
auto
oargc
=
cdo_operator_argc
();
if
(
oargc
==
1
)
{
nfill
=
parameter_to_int
(
cdo_operator_argv
(
0
));
if
(
operatorID
==
FILLMISS
&&
(
nfill
<
1
||
nfill
>
4
))
cdo_abort
(
"nfill out of range!"
);
}
else
if
(
oargc
>
1
)
cdo_abort
(
"Too many arguments!"
);
auto
streamID1
=
cdo_open_read
(
0
);
streamID1
=
cdo_open_read
(
0
);
auto
vlistID1
=
cdo_stream_inq_vlist
(
streamID1
);
auto
vlistID2
=
vlistDuplicate
(
vlistID1
);
auto
vlistID1
=
cdo_stream_inq_vlist
(
streamID1
);
auto
vlistID2
=
vlistDuplicate
(
vlistID1
);
auto
taxisID1
=
vlistInqTaxis
(
vlistID1
);
auto
taxisID2
=
taxisDuplicate
(
taxisID1
);
vlistDefTaxis
(
vlistID2
,
taxisID2
);
taxisID1
=
vlistInqTaxis
(
vlistID1
);
taxisID2
=
taxisDuplicate
(
taxisID1
);
vlistDefTaxis
(
vlistID2
,
taxisID2
);
auto
streamID2
=
cdo_open_write
(
1
);
cdo_def_vlist
(
streamID2
,
vlistID2
);
streamID2
=
cdo_open_write
(
1
);
cdo_def_vlist
(
streamID2
,
vlistID2
);
V
arList
varList1
;
varListInit
(
varList1
,
vlistID1
);
v
arList
Init
(
varList1
,
vlistID1
)
;
}
Field
field1
,
field2
;
void
run
()
{
int
tsID
=
0
;
while
(
true
)
{
auto
nrecs
=
cdo_stream_inq_timestep
(
streamID1
,
tsID
);
if
(
nrecs
==
0
)
break
;
int
tsID
=
0
;
while
(
true
)
{
auto
nrecs
=
cdo_stream_inq_timestep
(
streamID1
,
tsID
);
if
(
nrecs
==
0
)
break
;
cdo_taxis_copy_timestep
(
taxisID2
,
taxisID1
);
cdo_
taxis_copy
_timestep
(
taxis
ID2
,
t
axi
sID
1
);
cdo_
def
_timestep
(
stream
ID2
,
tsID
);
cdo_def_timestep
(
streamID2
,
tsID
);
for
(
int
recID
=
0
;
recID
<
nrecs
;
++
recID
)
{
int
varID
,
levelID
;
cdo_inq_record
(
streamID1
,
&
varID
,
&
levelID
);
field1
.
init
(
varList1
[
varID
]);
cdo_read_record
(
streamID1
,
field1
);
for
(
int
recID
=
0
;
recID
<
nrecs
;
++
recID
)
{
int
varID
,
levelID
;
cdo_inq_record
(
streamID1
,
&
varID
,
&
levelID
);
field1
.
init
(
varList1
[
varID
]);
cdo_read_record
(
streamID1
,
field1
);
cdo_def_record
(
streamID2
,
varID
,
levelID
);
cdo_def_record
(
streamID2
,
varID
,
levelID
);
if
(
field1
.
nmiss
==
0
)
{
cdo_write_record
(
streamID2
,
field1
);
}
else
{
auto
gridtype
=
gridInqType
(
varList1
[
varID
].
gridID
);
if
((
operatorID
==
FILLMISS
||
operatorID
==
FILLMISSONESTEP
)
&&
(
gridtype
==
GRID_GME
||
gridtype
==
GRID_UNSTRUCTURED
))
cdo_abort
(
"%s data unsupported!"
,
gridNamePtr
(
gridtype
));
if
(
field1
.
nmiss
==
0
)
{
cdo_write_record
(
streamID2
,
field1
);
}
else
{
auto
gridtype
=
gridInqType
(
varList1
[
varID
].
gridID
);
if
((
operatorID
==
FILLMISS
||
operatorID
==
FILLMISSONESTEP
)
&&
(
gridtype
==
GRID_GME
||
gridtype
==
GRID_UNSTRUCTURED
))
cdo_abort
(
"%s data unsupported!"
,
gridNamePtr
(
gridtype
));
field2
.
init
(
varList1
[
varID
]);
field2
.
init
(
varList1
[
varID
]
);
fill_method
(
field1
,
field2
,
nfill
);
fill_method
(
field1
,
field2
,
nfill
);
field2
.
nmiss
=
field_num_mv
(
field2
);
field2
.
nmiss
=
field_num_mv
(
field2
);
cdo_write_record
(
streamID2
,
field2
);
}
}
cdo_write_record
(
streamID2
,
field2
)
;
}
}
tsID
++
;
}
}
tsID
++
;
}
void
close
()
{
cdo_stream_close
(
streamID2
);
cdo_stream_close
(
streamID1
);
cdo_stream_close
(
streamID2
);
cdo_stream_close
(
streamID1
);
cdo_finish
();
}
};
cdo_finish
();
void
*
Fillmiss
(
void
*
process
)
{
ModuleFillmiss
fillmiss
;
fillmiss
.
init
(
process
);
fillmiss
.
run
();
fillmiss
.
close
();
return
nullptr
;
}
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