Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
0300b798
Commit
0300b798
authored
Nov 14, 2019
by
Fabian Wachsmann
Browse files
Try to calc cei by bootstrapping histo
parent
f885e7e1
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
0300b798
...
...
@@ -328,7 +328,6 @@ AC_CONFIG_FILES([
test/Timselpctl.test
test/Timstat.test
test/Timstat2.test
test/UserInput.test
test/Varsstat.test
test/Vertint.test
test/Vertstat.test
...
...
src/EcaEtccdi.cc
View file @
0300b798
This diff is collapsed.
Click to expand it.
src/Seaspctl.cc
View file @
0300b798
...
...
@@ -170,7 +170,7 @@ Seaspctl(void *process)
cdoReadRecord
(
streamID1
,
vars1
[
varID
][
levelID
].
vec
.
data
(),
&
nmiss
);
vars1
[
varID
][
levelID
].
nmiss
=
nmiss
;
hset
.
addVarLevelValues
(
varID
,
levelID
,
vars1
[
varID
][
levelID
]);
hset
.
add
Sub
VarLevelValues
(
varID
,
levelID
,
vars1
[
varID
][
levelID
]
,
true
);
}
nsets
++
;
...
...
src/Timpctl.cc
View file @
0300b798
...
...
@@ -158,7 +158,7 @@ timpctl(int operatorID)
cdoReadRecord
(
streamID1
,
vars1
[
varID
][
levelID
].
vec
.
data
(),
&
nmiss
);
vars1
[
varID
][
levelID
].
nmiss
=
nmiss
;
hset
.
addVarLevelValues
(
varID
,
levelID
,
vars1
[
varID
][
levelID
]);
hset
.
add
Sub
VarLevelValues
(
varID
,
levelID
,
vars1
[
varID
][
levelID
]
,
true
);
}
nsets
++
;
...
...
src/Timselpctl.cc
View file @
0300b798
...
...
@@ -186,7 +186,7 @@ Timselpctl(void *process)
cdoReadRecord
(
streamID1
,
vars1
[
varID
][
levelID
].
vec
.
data
(),
&
nmiss
);
vars1
[
varID
][
levelID
].
nmiss
=
nmiss
;
hset
.
addVarLevelValues
(
varID
,
levelID
,
vars1
[
varID
][
levelID
]);
hset
.
add
Sub
VarLevelValues
(
varID
,
levelID
,
vars1
[
varID
][
levelID
]
,
true
);
}
tsID
++
;
...
...
src/Ydaypctl.cc
View file @
0300b798
...
...
@@ -171,7 +171,7 @@ Ydaypctl(void *process)
cdoReadRecord
(
streamID1
,
vars1
[
dayoy
][
varID
][
levelID
].
vec
.
data
(),
&
nmiss
);
vars1
[
dayoy
][
varID
][
levelID
].
nmiss
=
nmiss
;
hsets
[
dayoy
].
addVarLevelValues
(
varID
,
levelID
,
vars1
[
dayoy
][
varID
][
levelID
]);
hsets
[
dayoy
].
add
Sub
VarLevelValues
(
varID
,
levelID
,
vars1
[
dayoy
][
varID
][
levelID
]
,
true
);
}
nsets
[
dayoy
]
++
;
...
...
src/Ydrunpctl.cc
View file @
0300b798
...
...
@@ -198,7 +198,7 @@ Ydrunpctl(void *process)
const
auto
nlevels
=
zaxisInqSize
(
vlistInqVarZaxis
(
vlistID1
,
varID
));
for
(
levelID
=
0
;
levelID
<
nlevels
;
levelID
++
)
for
(
inp
=
0
;
inp
<
ndates
;
inp
++
)
hsets
[
dayoy
].
addVarLevelValues
(
varID
,
levelID
,
vars1
[
inp
][
varID
][
levelID
]);
for
(
inp
=
0
;
inp
<
ndates
;
inp
++
)
hsets
[
dayoy
].
add
Sub
VarLevelValues
(
varID
,
levelID
,
vars1
[
inp
][
varID
][
levelID
]
,
true
);
}
datetime
[
ndates
]
=
datetime
[
0
];
...
...
src/Ymonpctl.cc
View file @
0300b798
...
...
@@ -171,7 +171,7 @@ Ymonpctl(void *process)
cdoReadRecord
(
streamID1
,
vars1
[
month
][
varID
][
levelID
].
vec
.
data
(),
&
nmiss
);
vars1
[
month
][
varID
][
levelID
].
nmiss
=
nmiss
;
hsets
[
month
].
addVarLevelValues
(
varID
,
levelID
,
vars1
[
month
][
varID
][
levelID
]);
hsets
[
month
].
add
Sub
VarLevelValues
(
varID
,
levelID
,
vars1
[
month
][
varID
][
levelID
]
,
true
);
}
nsets
[
month
]
++
;
...
...
src/Yseaspctl.cc
View file @
0300b798
...
...
@@ -177,7 +177,7 @@ Yseaspctl(void *process)
cdoReadRecord
(
streamID1
,
vars1
[
seas
][
varID
][
levelID
].
vec
.
data
(),
&
nmiss
);
vars1
[
seas
][
varID
][
levelID
].
nmiss
=
nmiss
;
hsets
[
seas
].
addVarLevelValues
(
varID
,
levelID
,
vars1
[
seas
][
varID
][
levelID
]);
hsets
[
seas
].
add
Sub
VarLevelValues
(
varID
,
levelID
,
vars1
[
seas
][
varID
][
levelID
]
,
true
);
}
nsets
[
seas
]
++
;
...
...
src/percentiles_hist.cc
View file @
0300b798
...
...
@@ -62,6 +62,15 @@ histBinValue(Histogram &hist, double value)
if
(
bin
>=
0
&&
bin
<
hist
.
nbins
)
INT_PTR
(
hist
.
ptr
)[
bin
]
++
;
}
static
void
histBinSubValue
(
Histogram
&
hist
,
double
value
)
{
assert
(
hist
.
step
>
0
);
const
int
bin
=
cdo
::
min
((
int
)
((
value
-
hist
.
min
)
/
hist
.
step
),
hist
.
nbins
-
1
);
if
(
bin
>=
0
&&
bin
<
hist
.
nbins
&&
INT_PTR
(
hist
.
ptr
)[
bin
]
>
0
)
INT_PTR
(
hist
.
ptr
)[
bin
]
--
;
}
static
void
histBin
(
Histogram
&
hist
)
{
...
...
@@ -124,6 +133,50 @@ histAddValue(Histogram &hist, double value)
return
0
;
}
static
void
histRemoveValue
(
Histogram
&
hist
,
double
value
)
{
int
i
=
0
;
for
(
i
=
0
;
i
<
hist
.
nsamp
;
i
++
)
{
if
(
IS_EQUAL
(
DBL_PTR
(
hist
.
ptr
)[
i
],
value
)
)
{
if
(
i
!=
hist
.
nsamp
-
1
)
DBL_PTR
(
hist
.
ptr
)[
i
]
=
DBL_PTR
(
hist
.
ptr
)[
hist
.
nsamp
-
1
];
break
;
}
}
if
(
i
==
hist
.
nsamp
)
cdoWarning
(
"'%f' not found in histogram!"
,
value
);
else
hist
.
nsamp
--
;
}
static
int
histSubValue
(
Histogram
&
hist
,
double
value
)
{
assert
(
hist
.
nbins
>
0
);
// 2011-08-01 Uwe Schulzweida: added check for rounding errors
if
(
value
<
hist
.
min
&&
(
hist
.
min
-
value
)
<
1e5
)
value
=
hist
.
min
;
if
(
value
>
hist
.
max
&&
(
value
-
hist
.
max
)
<
1e5
)
value
=
hist
.
max
;
if
(
IS_EQUAL
(
hist
.
min
,
hist
.
max
))
return
0
;
if
(
value
<
hist
.
min
||
value
>
hist
.
max
)
return
1
;
if
(
hist
.
nsamp
<
DBL_CAPACITY
(
hist
.
nbins
))
{
histRemoveValue
(
hist
,
value
);
}
else
if
(
hist
.
nsamp
>
DBL_CAPACITY
(
hist
.
nbins
))
{
histBinSubValue
(
hist
,
value
);
hist
.
nsamp
--
;
}
return
0
;
}
static
double
histGetPercentile
(
const
Histogram
&
hist
,
double
p
)
{
...
...
@@ -220,7 +273,7 @@ HistogramSet::defVarLevelBounds(int varID, int levelID, const Field &field1, con
}
void
HistogramSet
::
addVarLevelValues
(
int
varID
,
int
levelID
,
const
Field
&
field
)
HistogramSet
::
add
Sub
VarLevelValues
(
int
varID
,
int
levelID
,
const
Field
&
field
,
bool
lisAdd
)
{
const
auto
&
array
=
field
.
vec
;
assert
(
!
array
.
empty
());
...
...
@@ -237,19 +290,33 @@ HistogramSet::addVarLevelValues(int varID, int levelID, const Field &field)
int
nign
=
0
;
if
(
field
.
nmiss
)
if
(
lisAdd
)
{
for
(
size_t
i
=
0
;
i
<
nhists
;
i
++
)
if
(
!
DBL_IS_EQUAL
(
array
[
i
],
field
.
missval
))
nign
+=
histAddValue
(
hists
[
i
],
array
[
i
]);
if
(
field
.
nmiss
)
{
for
(
size_t
i
=
0
;
i
<
nhists
;
i
++
)
if
(
!
DBL_IS_EQUAL
(
array
[
i
],
field
.
missval
))
nign
+=
histAddValue
(
hists
[
i
],
array
[
i
]);
}
else
{
for
(
size_t
i
=
0
;
i
<
nhists
;
i
++
)
nign
+=
histAddValue
(
hists
[
i
],
array
[
i
]);
}
}
else
{
for
(
size_t
i
=
0
;
i
<
nhists
;
i
++
)
nign
+=
histAddValue
(
hists
[
i
],
array
[
i
]);
if
(
field
.
nmiss
)
{
for
(
size_t
i
=
0
;
i
<
nhists
;
i
++
)
if
(
!
DBL_IS_EQUAL
(
array
[
i
],
field
.
missval
))
nign
+=
histSubValue
(
hists
[
i
],
array
[
i
]);
}
else
{
for
(
size_t
i
=
0
;
i
<
nhists
;
i
++
)
nign
+=
histSubValue
(
hists
[
i
],
array
[
i
]);
}
}
if
(
nign
)
cdoWarning
(
"%d out of %d grid values are out of bounds and have been ignored (%s)"
,
nign
,
nhists
,
__func__
);
}
void
HistogramSet
::
Reset
(
int
varID
,
int
levelID
)
{
...
...
src/percentiles_hist.h
View file @
0300b798
...
...
@@ -79,7 +79,7 @@ public:
void
createVarLevels
(
int
varID
,
int
nlevels
,
size_t
nhists
);
void
defVarLevelBounds
(
int
varID
,
int
levelID
,
const
Field
&
field1
,
const
Field
&
field2
);
void
addVarLevelValues
(
int
varID
,
int
levelID
,
const
Field
&
field
);
void
add
Sub
VarLevelValues
(
int
varID
,
int
levelID
,
const
Field
&
field
,
bool
lisAdd
);
void
getVarLevelPercentiles
(
Field
&
field
,
int
varID
,
int
levelID
,
double
p
);
void
Reset
(
int
varID
,
int
levelID
);
};
...
...
src/printinfo.cc
View file @
0300b798
...
...
@@ -539,7 +539,7 @@ static void
printZaxisReferenceInfo
(
const
int
zaxisID
)
{
int
number
=
0
;
cdiInqKeyInt
(
zaxisID
,
CDI_GLOBAL
,
CDI_KEY_NUMBEROFVGRIDUSED
,
&
number
)
;
/*
cdiInqKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, &number)
*/
if
(
number
>
0
)
{
fprintf
(
stdout
,
"%33s : "
,
"zaxis"
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment