Skip to content

Commit

Permalink
Add support for a parameter that can disable including source subset …
Browse files Browse the repository at this point in the history
…variables for a NcCF dataset. (#256)
  • Loading branch information
ChrisJohnNOAA authored Feb 20, 2025
1 parent 749d1a2 commit 815b870
Show file tree
Hide file tree
Showing 6 changed files with 1,325 additions and 636 deletions.
15 changes: 11 additions & 4 deletions WEB-INF/classes/gov/noaa/pfel/coastwatch/pointdata/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -6776,6 +6776,7 @@ private int checkConsistent(String errorInMethod, String varName, int oldValue,
* @param conOps The corresponding operators. Remember that regex constraints will be tested on
* the source values!
* @param conValues The corresponding values.
* @param includeSubsetVariables whether or not to add subset variables to the attributes.
* @throws Exception if trouble. No matching data is not an error and returns an empty table (0
* rows and 0 columns).
*/
Expand All @@ -6785,7 +6786,8 @@ public void readNcCF(
int standardizeWhat,
StringArray conNames,
StringArray conOps,
StringArray conValues)
StringArray conValues,
boolean includeSubsetVariables)
throws Exception {
// FUTURE optimization: instead of reading all of 1D obs variables,
// find first and last set bit in obsKeep, just read a range of values,
Expand Down Expand Up @@ -7535,8 +7537,11 @@ else if (loadVariableNames.size() > 0)
globalAttributes.set(cdmOuterName, subsetVars.toString()); // may be "", that's okay
if (cdmInnerName != null)
globalAttributes.set(cdmInnerName, ""); // nLevel=2 will set it properly below
globalAttributes.set(
"subsetVariables", subsetVars.toString()); // nLevel=2 will set it properly below

if (includeSubsetVariables) {
globalAttributes.set(
"subsetVariables", subsetVars.toString()); // nLevel=2 will set it properly below
}

// apply constraints (if there is data)
BitSet outerKeep = null; // implies outerTable.nColumns = 0, so assume all are good
Expand Down Expand Up @@ -8261,7 +8266,9 @@ else if (loadVariableNames.size() > 0)
innerTableNRows = innerTable.nRows();
globalAttributes.set(cdmInnerName, cdmInnerVars.toString()); // may be "", that's okay
subsetVars.append(cdmInnerVars);
globalAttributes.set("subsetVariables", subsetVars.toString()); // may be "", that's okay
if (includeSubsetVariables) {
globalAttributes.set("subsetVariables", subsetVars.toString()); // may be "", that's okay
}

// read the outerIndexPA from vars[indexVar] and ensure valid
// next 3 lines: as if no indexVar (outerDim == scalarDim)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public Table lowGetSourceDataFromFile(
standardizeWhat,
sourceConVars,
sourceConOps,
sourceConValues);
sourceConValues,
EDStatic.config.includeNcCFSubsetVariables);
// } else {
// //Just return a table with globalAtts, columns with atts, but no rows.
// table.readNcMetadata(decompFullName, sourceDataNames.toArray(), sourceDataTypes,
Expand Down Expand Up @@ -315,7 +316,7 @@ public static String generateDatasetsXml(
tStandardizeWhat < 0 || tStandardizeWhat == Integer.MAX_VALUE
? DEFAULT_STANDARDIZEWHAT
: tStandardizeWhat;
dataSourceTable.readNcCF(sampleFileName, null, tStandardizeWhat, null, null, null);
dataSourceTable.readNcCF(sampleFileName, null, tStandardizeWhat, null, null, null, true);
double maxTimeES = Double.NaN;
for (int c = 0; c < dataSourceTable.nColumns(); c++) {
String colName = dataSourceTable.getColumnName(c);
Expand Down Expand Up @@ -385,10 +386,15 @@ public static String generateDatasetsXml(

// subsetVariables (or get from outer variables in some file types?)
if (dataSourceTable.globalAttributes().getString("subsetVariables") == null
&& dataAddTable.globalAttributes().getString("subsetVariables") == null)
&& dataAddTable.globalAttributes().getString("subsetVariables") == null) {
dataAddTable
.globalAttributes()
.add("subsetVariables", suggestSubsetVariables(dataSourceTable, dataAddTable, false));
} else if (dataAddTable.globalAttributes().getString("subsetVariables") == null) {
dataAddTable
.globalAttributes()
.add("subsetVariables", dataSourceTable.globalAttributes().getString("subsetVariables"));
}

// add the columnNameForExtract variable
if (tColumnNameForExtract.length() > 0) {
Expand Down
2 changes: 2 additions & 0 deletions WEB-INF/classes/gov/noaa/pfel/erddap/util/EDConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public class EDConfig {
@FeatureFlag public boolean updateSubsRssOnFileChanges;
@FeatureFlag public final boolean useEddReflection;
@FeatureFlag public boolean enableCors;
@FeatureFlag public boolean includeNcCFSubsetVariables;
@FeatureFlag public boolean useSharedWatchService = true;
@FeatureFlag public boolean redirectDocumentationToGitHubIo = true;

Expand Down Expand Up @@ -614,6 +615,7 @@ public EDConfig(String webInfParentDirectory) throws Exception {
variablesMustHaveIoosCategory =
getSetupEVBoolean(setup, ev, "variablesMustHaveIoosCategory", true);
warName = getSetupEVString(setup, ev, "warName", "erddap");
includeNcCFSubsetVariables = getSetupEVBoolean(setup, ev, "includeNcCFSubsetVariables", false);
useSharedWatchService = getSetupEVBoolean(setup, ev, "useSharedWatchService", true);
redirectDocumentationToGitHubIo =
getSetupEVBoolean(setup, ev, "redirectDocumentationToGitHubIo", true);
Expand Down
Loading

0 comments on commit 815b870

Please sign in to comment.