Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PLUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
Land Use Lab
PLUM
Commits
ae936979
Commit
ae936979
authored
4 years ago
by
Peter Alexander
Browse files
Options
Downloads
Patches
Plain Diff
Allow NaN yields to be clustered. Needed for GGCMI
parent
f57bb1b5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ac/ed/lurg/utils/cluster/Cluster.java
+3
-1
3 additions, 1 deletion
src/ac/ed/lurg/utils/cluster/Cluster.java
src/ac/ed/lurg/yield/YieldClusterPoint.java
+7
-3
7 additions, 3 deletions
src/ac/ed/lurg/yield/YieldClusterPoint.java
with
10 additions
and
4 deletions
src/ac/ed/lurg/utils/cluster/Cluster.java
+
3
−
1
View file @
ae936979
...
...
@@ -55,7 +55,9 @@ public class Cluster<K, P extends ClusteringPoint<K>> {
protected
double
distanceFromCentroid
(
ClusteringPoint
<
K
>
p
)
{
double
squaredTotal
=
0
;
for
(
K
key
:
centroid
.
getAllClusteringKeys
())
{
squaredTotal
+=
Math
.
pow
(
centroid
.
getClusteringValue
(
key
)-
p
.
getClusteringValue
(
key
),
2
);
double
a
=
centroid
.
getClusteringValue
(
key
);
double
b
=
p
.
getClusteringValue
(
key
);
squaredTotal
+=
Math
.
pow
(
a
-
b
,
2
);
}
return
Math
.
sqrt
(
squaredTotal
);
...
...
This diff is collapsed.
Click to expand it.
src/ac/ed/lurg/yield/YieldClusterPoint.java
+
7
−
3
View file @
ae936979
...
...
@@ -51,7 +51,11 @@ public class YieldClusterPoint implements ClusteringPoint<String> {
@Override
public
double
getClusteringValue
(
String
key
)
{
double
v
=
getClusteringValueNaN
(
key
);
return
Double
.
isNaN
(
v
)
?
0.0
:
v
;
// LPJ with emulator provides NaN yields. How to cluster these is tricky, but assuming they are 0
}
private
double
getClusteringValueNaN
(
String
key
)
{
switch
(
key
)
{
case
PASTURE:
return
pasture
;
case
WHEAT_MIN:
return
wheatMin
;
...
...
@@ -61,9 +65,9 @@ public class YieldClusterPoint implements ClusteringPoint<String> {
case
MAIZE_MAX:
return
maizeMax
;
case
IRRIG_WATER_AVAL:
return
irrigWaterAval
;
case
PROTECTED_AREA:
return
protectedArea
;
default
:
throw
new
RuntimeException
(
"YieldClusterPoint.getClusteringValue: got unknown value "
+
key
);
}
LogWriter
.
printlnError
(
"YieldClusterPoint.getClusteringValue: got unknown value "
+
key
);
return
Double
.
NaN
;
}
@Override
...
...
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