Skip to content

Commit

Permalink
BUGFIX: Use correct variable prefix for monthly, seasonal, and annual…
Browse files Browse the repository at this point in the history
… climatologies
  • Loading branch information
paullric committed Sep 2, 2020
1 parent c5126f9 commit 3271a6a
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions src/util/Climatology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,33 @@ enum ClimatologyType {
ClimatologyType_MeanSq
};

///////////////////////////////////////////////////////////////////////////////

std::string ClimoVariablePrefix(
ClimatologyPeriod eClimoPeriod,
ClimatologyType eClimoType
) {
std::string strVariablePrefix;
if (eClimoPeriod == ClimatologyPeriod_Daily) {
strVariablePrefix = "daily";
} else if (eClimoPeriod == ClimatologyPeriod_Monthly) {
strVariablePrefix = "monthly";
} else if (eClimoPeriod == ClimatologyPeriod_Seasonal) {
strVariablePrefix = "seasonal";
} else if (eClimoPeriod == ClimatologyPeriod_Annual) {
strVariablePrefix = "annual";
}
if (eClimoType == ClimatologyType_Mean) {
strVariablePrefix += "mean_";
} else if (eClimoType == ClimatologyType_MeanSq) {
strVariablePrefix += "meansq_";
}
return strVariablePrefix;
}


///////////////////////////////////////////////////////////////////////////////

/// <summary>
/// Produce a climatology over the given input files.
/// </summary>
Expand Down Expand Up @@ -767,14 +794,11 @@ void Climatology(
_ASSERT(itNcDim != mapOutputNcDim.end());
vecVarNcDims.push_back(itNcDim->second);
}
std::string strOutVar;
if (eClimoType == ClimatologyType_Mean) {
strOutVar = std::string("dailymean_") + vecVariableNames[v];
} else if (eClimoType == ClimatologyType_MeanSq) {
strOutVar = std::string("dailymeansq_") + vecVariableNames[v];
} else {
_EXCEPTIONT("Invalid eClimoType");
}

std::string strOutVar =
ClimoVariablePrefix(eClimoPeriod, eClimoType)
+ vecVariableNames[v];

NcVar * varOut =
ncoutfile.add_var(
strOutVar.c_str(),
Expand Down Expand Up @@ -1972,21 +1996,8 @@ try {

std::vector<std::string> vecTempVariableNames;

std::string strVariablePrefix;
if (eClimoPeriod == ClimatologyPeriod_Daily) {
strVariablePrefix = "daily";
} else if (eClimoPeriod == ClimatologyPeriod_Monthly) {
strVariablePrefix = "monthly";
} else if (eClimoPeriod == ClimatologyPeriod_Seasonal) {
strVariablePrefix = "seasonal";
} else if (eClimoPeriod == ClimatologyPeriod_Annual) {
strVariablePrefix = "annual";
}
if (eClimoType == ClimatologyType_Mean) {
strVariablePrefix += "mean_";
} else if (eClimoType == ClimatologyType_MeanSq) {
strVariablePrefix += "meansq_";
}
std::string strVariablePrefix =
ClimoVariablePrefix(eClimoPeriod, eClimoType);

for (int v = 0; v < vecVariableNames.size(); v++) {
vecTempVariableNames.push_back(strVariablePrefix + vecVariableNames[v]);
Expand Down

0 comments on commit 3271a6a

Please # to comment.