Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ucar.nc2.grib.GribNumbers;
import ucar.nc2.grib.GribTables;
import ucar.nc2.grib.coverage.GribCoverageDataset;
import ucar.nc2.grib.grib2.Grib2Utils;
import ucar.nc2.grib.grib2.table.Grib2Tables;
import ucar.unidata.util.StringUtil2;
import java.io.IOException;
Expand Down Expand Up @@ -166,11 +167,12 @@ public void addGlobalAttributes(AttributeContainer result) {
* if variable name is duplicate of existing variable name (this should not normally occur):
* _n (where n begins with 1 for first duplicate) (ex: TMAX_P8_L103_GCA0_6h_1)
*
* VAR_%d-%d-%d[_error][_L%d][_layer][_I%s_S%d][_D%d][_Prob_%s]
* VAR_%d-%d-%d[_error][_L%d][_layer][_I%s_S%d][_D%d][_Prob_%s][_A%d_%s]
* %d-%d-%d = discipline-category-paramNo
* L = level type
* S = stat type
* D = derived type
* A = aerosol type
*/
@Override
protected String makeVariableId(GribCollectionImmutable.VariableIndex vindex) {
Expand Down Expand Up @@ -213,6 +215,11 @@ private static String makeVariableId(GribCollectionImmutable.VariableIndex vinde
f.format("_Prob_%s", s);
}

if (vindex.getAerosolType() >= 0) {
f.format("_A%d", vindex.getAerosolType());
f.format("_%s", Grib2Utils.makeAerosolRangeSuffix(vindex.getAerosolRange()));
}

return f.toString();
}
}
Expand Down Expand Up @@ -252,6 +259,12 @@ else if (vindex.getProbabilityName() != null && !vindex.getProbabilityName().isE
v.addAttribute(new Attribute("Grib2_Probability_Name", vindex.getProbabilityName()));
}

if (vindex.getAerosolType() >= 0) {
v.addAttribute(new Attribute("Grib2_Aerosol_Type", vindex.getAerosolType()));
v.addAttribute(new Attribute("Grib2_Aerosol_Name", vindex.getAerosolName()));
v.addAttribute(new Attribute("Grib2_Aerosol_Range", vindex.getAerosolRange()));
Comment thread
lesserwhirls marked this conversation as resolved.
}

if (vindex.getGenProcessType() >= 0) {
String genProcessTypeName = cust2.getGeneratingProcessTypeName(vindex.getGenProcessType());
if (genProcessTypeName != null)
Expand Down
9 changes: 9 additions & 0 deletions grib/src/main/java/ucar/nc2/grib/collection/Grib2Iosp.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ static String makeVariableNameFromTable(Grib2Tables cust, GribCollectionImmutabl
if (vindex.getPercentileValue() >= 0) {
f.format("_Percentile%2d", vindex.getPercentileValue());
}

if (vindex.getAerosolType() >= 0) {
f.format("_%s", GribUtils.makeNameFromDescription(vindex.getAerosolName()));
f.format("_%s", Grib2Utils.makeAerosolRangeSuffix(vindex.getAerosolRange()));
}
return f.toString();
}
}
Expand Down Expand Up @@ -144,6 +149,10 @@ static String makeVariableLongName(Grib2Tables cust, GribCollectionImmutable.Var
f.format(" %d Percentile", vindex.getPercentileValue());
}

if (vindex.getAerosolName() != null && !vindex.getAerosolName().isEmpty()) {
f.format(" (%s %s)", vindex.getAerosolName(), vindex.getAerosolRange());
}

if (vindex.getLevelType() != GribNumbers.UNDEFINED) { // satellite data doesnt have a level
f.format(" @ %s", cust.getCodeTableValue("4.5", vindex.getLevelType()));
if (vindex.isLayer()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,18 @@ public String getProbabilityName() {
return info.probabilityName;
}

public int getAerosolType() {
return info.aerosolType;
}

public String getAerosolName() {
return info.aerosolName;
}

public String getAerosolRange() {
return info.aerosolRange;
}

public boolean isLayer() {
return info.isLayer;
}
Expand Down Expand Up @@ -825,6 +837,9 @@ public final class Info {
@Nullable
final String intvName; // eg "mixed intervals, 3 Hour, etc"
final String probabilityName;
final int aerosolType;
final String aerosolName;
final String aerosolRange;
final boolean isLayer, isEnsemble;
final int genProcessType;
final int spatialStatType;
Expand All @@ -840,6 +855,9 @@ public Info(GribCollectionMutable.VariableIndex gcVar) {
this.probType = gcVar.probType;
this.intvName = gcVar.getTimeIntvName();
this.probabilityName = gcVar.probabilityName;
this.aerosolType = gcVar.aerosolType;
this.aerosolName = gcVar.aerosolName;
this.aerosolRange = gcVar.aerosolRange;
this.isLayer = gcVar.isLayer;
this.isEnsemble = gcVar.isEnsemble;
this.genProcessType = gcVar.genProcessType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ public class VariableIndex implements Comparable<VariableIndex> {
public final int category, parameter, levelType, intvType, ensDerivedType, probType, percentile;
private String intvName; // eg "mixed intervals, 3 Hour, etc"
public final String probabilityName;
public final int aerosolType;
public final String aerosolName;
public final String aerosolRange;
public final boolean isLayer, isEnsemble;
public final int genProcessType;
public final int spatialStatType;
Expand Down Expand Up @@ -476,6 +479,9 @@ private VariableIndex(GroupGC g, GribTables customizer, int discipline, int cent
this.ensDerivedType = -1;
this.probType = -1;
this.probabilityName = null;
this.aerosolType = -1;
this.aerosolName = null;
this.aerosolRange = null;
this.percentile = -1;

this.genProcessType = pds.getGenProcess(); // LOOK process vs process type ??
Expand Down Expand Up @@ -517,6 +523,17 @@ private VariableIndex(GroupGC g, GribTables customizer, int discipline, int cent
this.probabilityName = null;
}

if (pds.isAerosol()) {
Grib2Pds.PdsAerosol pdsAerosol = (Grib2Pds.PdsAerosol) pds;
this.aerosolType = pdsAerosol.getAerosolType();
this.aerosolName = pdsAerosol.getAerosolName();
this.aerosolRange = pdsAerosol.getAerosolRange();
} else {
this.aerosolType = -1;
this.aerosolName = null;
this.aerosolRange = null;
}

if (pds.isPercentile()) {
Grib2Pds.PdsPercentile pdsPctl = (Grib2Pds.PdsPercentile) pds;
this.percentile = pdsPctl.getPercentileValue();
Expand Down Expand Up @@ -560,6 +577,9 @@ protected VariableIndex(GroupGC g, VariableIndex other) {
this.ensDerivedType = other.ensDerivedType;
this.probabilityName = other.probabilityName;
this.probType = other.probType;
this.aerosolType = other.aerosolType;
this.aerosolName = other.aerosolName;
this.aerosolRange = other.aerosolRange;
this.genProcessType = other.genProcessType;
this.spatialStatType = other.spatialStatType;
this.isEnsemble = other.isEnsemble;
Expand Down Expand Up @@ -619,8 +639,9 @@ public String toString() {
return MoreObjects.toStringHelper(this).add("tableVersion", tableVersion).add("discipline", discipline)
.add("category", category).add("parameter", parameter).add("levelType", levelType).add("intvType", intvType)
.add("ensDerivedType", ensDerivedType).add("probType", probType).add("intvName", intvName)
.add("probabilityName", probabilityName).add("isLayer", isLayer).add("genProcessType", genProcessType)
.add("cdmHash", gribVariable.hashCode()).toString();
.add("probabilityName", probabilityName).add("aerosolName", aerosolName).add("aerosolRange", aerosolRange)
.add("isLayer", isLayer).add("genProcessType", genProcessType).add("cdmHash", gribVariable.hashCode())
.toString();
}

public String toStringComplete() {
Expand All @@ -629,8 +650,9 @@ public String toStringComplete() {
.add("recordsLen", recordsLen).add("gribVariable", gribVariable).add("coordIndex", coordIndex)
.add("category", category).add("parameter", parameter).add("levelType", levelType).add("intvType", intvType)
.add("ensDerivedType", ensDerivedType).add("probType", probType).add("intvName", intvName)
.add("probabilityName", probabilityName).add("isLayer", isLayer).add("isEnsemble", isEnsemble)
.add("genProcessType", genProcessType).add("spatialStatType", spatialStatType).toString();
.add("probabilityName", probabilityName).add("aerosolName", aerosolName).add("aerosolRange", aerosolRange)
.add("isLayer", isLayer).add("isEnsemble", isEnsemble).add("genProcessType", genProcessType)
.add("spatialStatType", spatialStatType).toString();
}

public String toStringShort() {
Expand All @@ -644,6 +666,9 @@ public String toStringShort() {
if (probabilityName != null && !probabilityName.isEmpty()) {
sb.format(" prob=%s", probabilityName);
}
if (aerosolName != null && !aerosolName.isEmpty()) {
sb.format(" aerosol=%s (%s)", aerosolName, aerosolRange);
}
sb.format(" cdmHash=%d}", gribVariable.hashCode());
return sb.toString();
}
Expand Down
Loading