Skip to content

Commit

Permalink
removed some not used stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
matakleo committed Jun 3, 2024
1 parent 483c09b commit e0cdc5e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 302 deletions.
67 changes: 23 additions & 44 deletions cdm/core/src/main/java/ucar/nc2/filter/Classifier.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ucar.nc2.filter;

import java.io.IOException;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
import ucar.ma2.Array;
import ucar.ma2.DataType;
import ucar.nc2.dataset.VariableDS;
Expand All @@ -27,15 +26,14 @@ public double convert(double val) {
return classifyArray(val);
}


// Custom exception for invalid values ?
/** Custom exception for invalid values */
public static class InvalidValueException extends Exception {
public InvalidValueException(String message) {
super(message);
}
}

// Method to classify int array
/** for a single double */
public int classifyArray(double val) {
int classifiedVal;
if (val >= 0) {
Expand All @@ -47,7 +45,19 @@ public int classifyArray(double val) {
return classifiedVal;
}

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

return classifiedVal;
}

/** for a single int ? */
public int classifyArray(int val) {
int classifiedVal;
if (val >= 0) {
Expand All @@ -59,6 +69,12 @@ public int classifyArray(int val) {
return classifiedVal;
}

/**
* Method to classify int array
* maybe not needed if enhancement applied only to doubles and floats?
*/

/** Classify integer array */
public int[] classifyArray(int[] inputArray) throws InvalidValueException {
int[] classifiedArray = new int[inputArray.length];

Expand All @@ -72,7 +88,7 @@ public int[] classifyArray(int[] inputArray) throws InvalidValueException {
return classifiedArray;
}

// Method to classify double array
/** Classify double array */
public int[] classifyArray(double[] inputArray) throws InvalidValueException {
int[] classifiedArray = new int[inputArray.length];

Expand All @@ -90,7 +106,7 @@ public int[] classifyArray(double[] inputArray) throws InvalidValueException {
return classifiedArray;
}

// Method to classify float array
/** Classify float array */
public int[] classifyArray(float[] inputArray) throws InvalidValueException {
int[] classifiedArray = new int[inputArray.length];

Expand All @@ -108,43 +124,6 @@ public int[] classifyArray(float[] inputArray) throws InvalidValueException {
return classifiedArray;
}


public static void main(String[] args) {
try {
// Example usage
Classifier classifier = new Classifier();

int[] intArray = {10, -5, 0, 20, 5};
double[] doubleArray = {10.5, -5.5, 0.0, 20.1, 5.0};
float[] floatArray = {10.5f, -5.5f, 0.0f, 20.1f, 5.0f};

int[] intResult = classifier.classifyArray(intArray);
int[] doubleResult = classifier.classifyArray(doubleArray); // This will throw an exception
int[] floatResult = classifier.classifyArray(floatArray); // This will throw an exception

// Print the classified arrays
System.out.print("Classified int array: ");
for (int value : intResult) {
System.out.print(value + " ");
}
System.out.println();

System.out.print("Classified double array: ");
for (int value : doubleResult) {
System.out.print(value + " ");
}
System.out.println();

System.out.print("Classified float array: ");
for (int value : floatResult) {
System.out.print(value + " ");
}
System.out.println();

} catch (InvalidValueException e) {
System.err.println(e.getMessage());
}
}
}


246 changes: 0 additions & 246 deletions cdm/core/src/main/java/ucar/nc2/filter/QuantileTransformer1D.java

This file was deleted.

9 changes: 0 additions & 9 deletions cdm/core/src/test/data/ncml/enhance/testClassifier.ncml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@
<values>1 2 3 4 5</values>
</variable>

<variable name="intNegatives" shape="5" type="int">
<attribute name="classify"/>
<values>-1 -2 -3 -4 -5</values>
</variable>

<variable name="intMix" shape="5" type="int">
<attribute name="classify"/>
<values>1 -2 0 4 -5</values>
</variable>


</netcdf>
Loading

0 comments on commit e0cdc5e

Please sign in to comment.