Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
looks like all works??
Browse files Browse the repository at this point in the history
matakleo committed Jul 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 66ead40 commit c39b033
Showing 5 changed files with 39 additions and 19 deletions.
20 changes: 8 additions & 12 deletions cdm/core/src/main/java/ucar/nc2/dataset/VariableDS.java
Original file line number Diff line number Diff line change
@@ -275,10 +275,6 @@ Array convert(Array data, Set<NetcdfDataset.Enhance> enhancements) {
// TODO: change to a provider for extensible Enhancements
List<Enhancement> toApply = new ArrayList<>();





if (enhancements.contains(Enhance.ConvertUnsigned) && unsignedConversion != null) {
toApply.add(unsignedConversion);
convertedType = unsignedConversion.getOutType();
@@ -291,16 +287,16 @@ Array convert(Array data, Set<NetcdfDataset.Enhance> enhancements) {
toApply.add(scaleOffset);
convertedType = scaleOffset.getScaledOffsetType();
}
if (enhancements.contains(Enhance.ApplyStandardizer) && standardizer != null) {
toApply.add(standardizer);
}
if (enhancements.contains(Enhance.ApplyNormalizer) && normalizer != null) {
toApply.add(normalizer);
}
if (enhancements.contains(Enhance.ApplyClassifier) && classifier != null) {
toApply.add(classifier);
/** this == variableDS */
for (Enhance enhance : enhancements) {
for (EnhancementProvider service : ServiceLoader.load(EnhancementProvider.class)) {
if (service.appliesTo(enhance, this)) {
toApply.add(service.returnObject(this));
}
}
}


double[] dataArray = (double[]) data.get1DJavaArray(DataType.DOUBLE);

dataArray = Arrays.stream(dataArray).parallel().map((num) -> {
16 changes: 10 additions & 6 deletions cdm/core/src/main/java/ucar/nc2/filter/Classifier.java
Original file line number Diff line number Diff line change
@@ -171,12 +171,16 @@ public boolean canDo (Set<Enhance> enhancements){
public boolean appliesTo(Enhance enhance, AttributeContainer attributes) {
return enhance == Enhance.ApplyClassifier && attributes.findAttribute(CDM.CLASSIFY)!= null;
}
// @Override
// public void applyEnhancement(Object instance) {
// Attribute classifierAtt = findAttribute(CDM.CLASSIFY);
// if (classifierAtt != null && instance.enhanceMode.contains(Enhance.ApplyClassifier) && instance.dataType.isNumeric()) {
// instance.classifier = Classifier.createFromVariable(instance);
// }
@Override
public boolean appliesTo(Enhance enhance,VariableDS var){
return enhance == Enhance.ApplyClassifier && var.classifier!=null;
}

public Classifier returnObject( VariableDS var){
return var.classifier;
}



}

Original file line number Diff line number Diff line change
@@ -36,7 +36,10 @@ public interface EnhancementProvider {

boolean appliesTo(Enhance enhance, AttributeContainer attributes);

boolean appliesTo(Enhance enhance, VariableDS var);

void Create(VariableDS var);
Enhancement returnObject(VariableDS var);


// void applyEnhancement(Object instance);
10 changes: 10 additions & 0 deletions cdm/core/src/main/java/ucar/nc2/filter/Normalizer.java
Original file line number Diff line number Diff line change
@@ -98,6 +98,16 @@ public boolean canDo (Set<Enhance> enhancements){
public boolean appliesTo(Enhance enhance, AttributeContainer attributes) {
return enhance == Enhance.ApplyNormalizer && attributes.findAttribute(CDM.NORMALIZE)!= null;
}
@Override
public boolean appliesTo(Enhance enhance,VariableDS var){
return enhance == Enhance.ApplyNormalizer && var.normalizer!= null;
}
@Override
public Normalizer returnObject( VariableDS var){
return var.normalizer;
}




}
9 changes: 8 additions & 1 deletion cdm/core/src/main/java/ucar/nc2/filter/Standardizer.java
Original file line number Diff line number Diff line change
@@ -102,8 +102,15 @@ public boolean canDo (Set<Enhance> enhancements){
public boolean appliesTo(Enhance enhance, AttributeContainer attributes) {
return enhance == Enhance.ApplyStandardizer && attributes.findAttribute(CDM.STANDARDIZE)!= null;
}
@Override
public boolean appliesTo(Enhance enhance,VariableDS var){
return enhance == Enhance.ApplyStandardizer && var.standardizer!= null;
}


@Override
public Standardizer returnObject( VariableDS var){
return var.standardizer;
}
}
}

0 comments on commit c39b033

Please sign in to comment.