Skip to content

Commit

Permalink
CF.cpp fix for auxiliary coord vars having _FillValue
Browse files Browse the repository at this point in the history
  • Loading branch information
h-dh committed Feb 11, 2016
1 parent 4107a55 commit 01426b3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 14 deletions.
1 change: 1 addition & 0 deletions include/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Base : public IObj

//see rules for varName and srcName in attach()
std::vector<Variable> variable;
std::vector<std::string> variableNames; // in the sequence of variable

std::vector<Variable> srcVariable;
std::vector<std::string> obsolete_srcVarName;
Expand Down
56 changes: 45 additions & 11 deletions src/CF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,8 @@ CF::checkCoordinateValues(Variable& var, bool isFormTermAux, T x)
// Exceptions:
// variables named by a formula_terms attribute
// and auxiliary coordinate variables
bool testMonotony=true;
if( !var.coord.isCoordVar || isFormTermAux )
testMonotony=false;
bool testMonotony= ( !var.coord.isCoordVar || isFormTermAux ) \
? false : true ;

MtrxArr<T> mv;

Expand Down Expand Up @@ -520,7 +519,7 @@ CF::checkCoordinateValues(Variable& var, bool isFormTermAux, T x)
}

// any kind of missing value
if( mv.valExcp->exceptionCount.size() )
if( var.coord.isCoordVar && mv.valExcp->exceptionCount.size() )
{
bool isFirst[]={ true, true, true, true, true, true};

Expand Down Expand Up @@ -768,7 +767,7 @@ CF::checkGroupRelation(void)

capt += "oordinate " ;
capt += hdhC::tf_var(var.name) ;
capt += "is not related to any other " + n_variable ;
capt += "seems to be unrelated to any other " + n_variable ;

(void) notes->operate(capt) ;
notes->setCheckCF_Str( fail );
Expand Down Expand Up @@ -1336,6 +1335,30 @@ CF::finalAtt_coordinates_B(void)
continue;
if( var.isLabel )
continue;

// a variable depends soley on coordinate dimensions
bool isSole=true;
for( size_t j=0 ; j < var.dimName.size() ; ++j )
{
size_t pos;
if( hdhC::isAmong(var.dimName[j], pIn->variableNames, pos) )
{
if( ! pIn->variable[pos].coord.isCoordVar )
{
isSole=false;
break;
}
}
else
{
isSole=false;
break;
}
}

if(isSole)
continue;

if( pIn->nc.isIndexType(var.name) )
continue;

Expand Down Expand Up @@ -1747,21 +1770,32 @@ CF::getAssociatedGroups(void)
if(isSD)
{
// data vars must only depend on a single dim
std::string onlyDim;
std::vector<std::string> vs_single;
std::vector<size_t> vs_count;

for( size_t i=0 ; i < pIn->varSz ; ++i )
{
Variable& var = pIn->variable[i];

if( var.isDataVar() )
{
if( var.dimName.size() != 1 )
return;
else
onlyDim=var.dimName[0] ;
if( var.dimName.size() == 1 )
{
size_t vs_ix;
if( hdhC::isAmong(var.dimName[0], vs_single, vs_ix) )
++vs_count[vs_ix];
else
{
vs_single.push_back(var.dimName[0]) ;
vs_count.push_back(1);
}
}
}
}

associatedGroups.push_back(onlyDim);
for( size_t i=0 ; i < vs_single.size() ; ++i )
if( vs_count[i] > 1 )
associatedGroups.push_back(vs_single[i]);
}

return;
Expand Down
1 change: 1 addition & 0 deletions src/InFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ InFile::openNc(bool isNew)
makeVariable( &nc, var[j] );

vIx[ var[j] ] = j ;
variableNames.push_back(variable.back().name);
}

// a pseudo-variable for the global attributes
Expand Down
5 changes: 2 additions & 3 deletions tables/projects/CF/CF_check-list.conf
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ Variable contains Inf/NaN values & CF_12a

Coordinate variable should be strictly monotonic & CF_12b

[CF <1.6: Auxiliary] coordinate variable should not have attribute \
_FillValue/missing_value & CF_12c
Coordinate variable should not have attribute _FillValue/missing_value & CF_12c

[CF <1.6: Auxiliary] coordinate variable should not have a missing_value of any \
Coordinate variable should not have a missing_value of any \
kind, i.e. MV, _FV, out of valid_min/_max/_range, or default MV & CF_12d

Index variable must have data & CF_12e
Expand Down

0 comments on commit 01426b3

Please sign in to comment.