Skip to content

Commit

Permalink
consistency checks
Browse files Browse the repository at this point in the history
  • Loading branch information
h-dh committed Jan 13, 2016
1 parent 8323617 commit 3162325
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 183 deletions.
5 changes: 3 additions & 2 deletions include/qa.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class QA : public IObj

bool checkDataBody(std::string vName="");

void checkProjectTable(InFile &in);
//! true requires a check against the project meta data
bool checkConsistency(InFile &in);

/*! Close records for time and data.*/
void closeEntry(void);
Expand Down Expand Up @@ -177,7 +178,7 @@ class QA : public IObj
std::string tablePath;
struct hdhC::FileSplit qaFile;
struct hdhC::FileSplit table_DRS_CV;
struct hdhC::FileSplit projectTableFile;
struct hdhC::FileSplit consistencyFile;

std::string qaNcfileFlags;

Expand Down
8 changes: 5 additions & 3 deletions include/qa_PT.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
class QA;
class InFile;

class ProjectTable
class Consistency
{
public:
ProjectTable(QA *, InFile*, struct hdhC::FileSplit& );
Consistency(QA *, InFile*, struct hdhC::FileSplit& );

//! Prepare the comparison of dimensions between file and project table.
/*! This is checked for each chunk or atomic data set in each
experiment ensuring conformance.*/
void check(void);
bool check(void);
bool check(Variable&, std::string entryID);

//! Put Attributes of given variable to string
Expand Down Expand Up @@ -46,6 +46,8 @@ class ProjectTable

struct hdhC::FileSplit projectTableFile;

bool status;

Annotation *notes;
InFile *pIn;
QA *qa; //the parent
Expand Down
1 change: 0 additions & 1 deletion include/qa_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,4 @@ class QA_Time
InFile *pIn;
QA *pQA;
};

#endif
6 changes: 6 additions & 0 deletions src/Annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,9 @@ Annotation::printNotes(std::string &tag, std::string &caption,
printHeader(ofsNotes);
}

if( isMultipleTags || !str.size() )
return;

// prevent error message flooding
if( count[currIndex]++ > recErrCountLimit )
return;
Expand Down Expand Up @@ -1154,6 +1157,9 @@ Annotation::printNotes(std::string &tag, std::string &caption,
if( str[i] == '\n' )
str[i] = ';' ;

if( mp_txt[tag].size() )
mp_txt[tag] += ';' ;

mp_txt[tag] += str;

return ;
Expand Down
40 changes: 20 additions & 20 deletions src/QA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ QA::applyOptions(bool isPost)
|| split[0] == "tableProject" ) // dummy
{
if( split.size() == 2 )
projectTableFile.setFile(split[1]);
consistencyFile.setFile(split[1]);
}
}

if( projectTableFile.path.size() == 0 )
projectTableFile.setPath(tablePath);
if( consistencyFile.path.size() == 0 )
consistencyFile.setPath(tablePath);

if( table_DRS_CV.path.size() == 0 )
table_DRS_CV.setPath(tablePath);
Expand Down Expand Up @@ -290,24 +290,24 @@ QA::checkDataBody(std::string vName)
return false;
}

void
QA::checkProjectTable(InFile &in)
bool
QA::checkConsistency(InFile &in)
{
defaultPrjTableName() ;

// Read or write the project table.
ProjectTable projectTable(this, &in, projectTableFile);
projectTable.setAnnotation(notes);
projectTable.setExcludedAttributes( excludedAttribute );
Consistency consistency(this, &in, consistencyFile);
consistency.setAnnotation(notes);
consistency.setExcludedAttributes( excludedAttribute );

projectTable.check();
bool is = consistency.check();

// inquire whether the meta-data checks passed
int ev;
if( (ev = notes->getExitValue()) > 1 )
setExit( ev );

return;
return is;
}

void
Expand Down Expand Up @@ -350,8 +350,8 @@ QA::defaultPrjTableName(void)
// tables names usage: both project and standard tables
// reside in the same path.
// Naming of the project table:
if( ! projectTableFile.is )
projectTableFile.setFilename("pt_NONE.csv");
if( ! consistencyFile.is )
consistencyFile.setFilename("pt_NONE.csv");

return;
}
Expand Down Expand Up @@ -534,11 +534,15 @@ QA::init(void)

qaTime.init(optStr);

// DRS and CV specifications
drs_cv_table.read(table_DRS_CV);
// check consistency between sub-sequent files Oor experiments
if( checkConsistency(*pIn) )
{
// DRS and CV specifications
drs_cv_table.read(table_DRS_CV);

// experiment specific obj: set parent, pass over options
qaExp.run(optStr);
// experiment specific obj: set parent, pass over options
qaExp.run(optStr);
}

// check existance of any data at all
if( (qaTime.isTime || isCheckData )
Expand Down Expand Up @@ -570,10 +574,6 @@ QA::init(void)
// note that this must happen before checkMetaData which uses currQARec
openQA_Nc(*pIn);

// check consistency between sub-sequent files. Must come after
// openQA_Nc.
checkProjectTable(*pIn);

if( getExit() || qaExp.isUseStrict || qaTime.isNoProgress )
{
isCheckData=false;
Expand Down
4 changes: 2 additions & 2 deletions src/QA_CMIP5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3975,8 +3975,6 @@ QA_Exp::checkDataVarNum(void)
void
QA_Exp::checkMetaData(InFile& in)
{
notes->setCheckMetaStr("PASS");

// is it NetCDF-3 classic?
checkNetCDF(in);

Expand Down Expand Up @@ -4521,6 +4519,8 @@ QA_Exp::run(std::vector<std::string>& optStr)
// apply parsed command-line args
applyOptions(optStr);

notes->setCheckMetaStr("PASS");

fVarname = getVarnameFromFilename(pQA->pIn->file.filename);
getFrequency();

Expand Down
8 changes: 3 additions & 5 deletions src/QA_CORDEX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3007,8 +3007,6 @@ QA_Exp::checkHeightValue(InFile &in)
void
QA_Exp::checkMetaData(InFile &in)
{
notes->setCheckMetaStr("PASS");

domainCheck();

// check attributes required in the meta data section of the file
Expand Down Expand Up @@ -3524,7 +3522,7 @@ QA_Exp::checkVariableTypeX(size_t v, size_t i, size_t j, std::string& tName)

std::string s(pQA->pIn->nc.getVarTypeStr(var.name));

if( tAttValue != s )
if( tAttValue != s && !var.isVoid)
{
std::string key("3_2");
if( notes->inq( key, var.name) )
Expand Down Expand Up @@ -4736,6 +4734,8 @@ QA_Exp::run(std::vector<std::string>& optStr)
// apply parsed command-line args
applyOptions(optStr);

notes->setCheckMetaStr("PASS");

fVarname = getVarnameFromFilename();
getFrequency();
getSubTable() ;
Expand All @@ -4755,10 +4755,8 @@ QA_Exp::run(std::vector<std::string>& optStr)
checkVariableType();

if( !isNoTable )
{
// get meta data from file and compare with tables
checkMetaData(*(pQA->pIn));
}

return ;
}
Expand Down

0 comments on commit 3162325

Please sign in to comment.