Skip to content

Commit

Permalink
Per #2924, add backward compatibility logic so that when old climo co…
Browse files Browse the repository at this point in the history
…lumn names are requested, the new ones are used.
  • Loading branch information
JohnHalleyGotway committed Jul 17, 2024
1 parent 6a5ff59 commit e689aa8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/libcode/vx_analysis_util/stat_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <iostream>
#include <fstream>
#include <limits.h>
#include <map>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Expand All @@ -34,6 +35,30 @@
using namespace std;


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


//
// MET #2924 Rename climatology column names
//

static map<const char *,const char *> mpr_rename_map = {
{ "CLIMO_MEAN", "OBS_CLIMO_MEAN" },
{ "CLIMO_STDEV", "OBS_CLIMO_STDEV" },
{ "CLIMO_CDF", "OBS_CLIMO_CDF" }
};

static map<const char *,const char *> orank_rename_map = {
{ "CLIMO_MEAN", "OBS_CLIMO_MEAN" },
{ "CLIMO_STDEV", "OBS_CLIMO_STDEV" }
};

static map<STATLineType,map<const char *, const char *>> stat_columns_rename_map = {
{ STATLineType::mpr, mpr_rename_map },
{ STATLineType::orank, orank_rename_map }
};


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


Expand Down Expand Up @@ -444,6 +469,19 @@ if ( is_bad_data(offset) ) {
if ( !get_file()->header().has(col_str, offset) ) offset = bad_data_int;
}

//
// If not found, check renamed columns for backward compatibility
//

if ( is_bad_data(offset) ) {

if ( stat_columns_rename_map.count(Type) ) {
if ( stat_columns_rename_map[Type].count(col_str)) {
return ( get_item((stat_columns_rename_map[Type])[col_str]) );
}
}
}

//
// Return bad data string for no match
//
Expand Down

0 comments on commit e689aa8

Please sign in to comment.