Skip to content

Commit

Permalink
finalize reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
matakleo committed Jun 28, 2024
1 parent 47673fc commit 9d1b75a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 38 deletions.
16 changes: 4 additions & 12 deletions cdm/core/src/main/java/ucar/nc2/dataset/VariableDS.java
Original file line number Diff line number Diff line change
Expand Up @@ -943,18 +943,10 @@ private void createEnhancements() {
if (normalizerAtt != null && this.enhanceMode.contains(Enhance.ApplyNormalizer) && dataType.isFloatingPoint()) {
this.normalizer = Normalizer.createFromVariable(this);
}
// I need to comment this one out, otherwise it applies the
// @Override
// public double convert(double val) {
// return classifyArray(val);
// }
// so for now I just turn it off. How else could we do this?


// Attribute classifierAtt = findAttribute(CDM.CLASSIFY);
// if (classifierAtt != null && this.enhanceMode.contains(Enhance.ApplyClassifier) && dataType.isNumeric()) {
// this.classifier = Classifier.createFromVariable(this);
// }
Attribute classifierAtt = findAttribute(CDM.CLASSIFY);
if (classifierAtt != null && this.enhanceMode.contains(Enhance.ApplyClassifier) && dataType.isNumeric()) {
this.classifier = Classifier.createFromVariable(this);
}
}

public Builder<?> toBuilder() {
Expand Down
27 changes: 1 addition & 26 deletions cdm/core/src/main/java/ucar/nc2/filter/Classifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


public class Classifier implements Enhancement {
private int classifiedVal;
private String[] AttCat;
private List<int[]> rules = new ArrayList<>();

Expand Down Expand Up @@ -65,31 +64,7 @@ public int[] classifyWithAttributes(Array arr) {
return classifiedArray;
}

/** Classify double array */
public int[] classifyDoubleArray(Array arr) {
int[] classifiedArray = new int[(int) arr.getSize()];
int i = 0;
IndexIterator iterArr = arr.getIndexIterator();
while (iterArr.hasNext()) {
Number value = (Number) iterArr.getObjectNext();
if (!Double.isNaN(value.doubleValue())) {

classifiedArray[i] = classifyArray(value.doubleValue());
}
i++;
}
return classifiedArray;
}

/** for a single double */
public int classifyArray(double val) {
if (val >= 0) {
classifiedVal = 1;
} else {
classifiedVal = 0;
}
return classifiedVal;
}

public int classifyArrayAttribute(double val) {
for (int[] rule : rules) {
Expand All @@ -112,7 +87,7 @@ private List<int[]> loadClassificationRules() {

@Override
public double convert(double val) {
return classifyArray(val);
return classifyArrayAttribute(val);
}

public static int[] stringToIntArray(String str) {
Expand Down

0 comments on commit 9d1b75a

Please sign in to comment.