Skip to content

Commit

Permalink
CF: revisited, reshaped, resharpened
Browse files Browse the repository at this point in the history
  • Loading branch information
h-dh committed Dec 23, 2015
1 parent d7b18f2 commit ff60029
Show file tree
Hide file tree
Showing 12 changed files with 1,502 additions and 1,476 deletions.
Binary file modified CF-TestSuite/Txt.tar.bz2
Binary file not shown.
2 changes: 2 additions & 0 deletions include/annotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class Annotation : public IObj
bool findIndex(std::string &key, bool only=false);
std::vector<std::string>
getAnnotation(std::string tag);
std::vector<std::string>
getAnnotation(std::string tag, std::vector<std::string>& txt);
std::string
getCheckResults(void);
int getExitValue(void);
Expand Down
122 changes: 59 additions & 63 deletions include/cf.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,86 +46,86 @@ class CF : public IObj

void chap2(void); // names
void chap2_reco(void); // NetCDF files and components
void chap2_1(void); // filename
void chap2_2(void); // dimensions
void chap2_3(void); // names
void chap2_3_reco(void); // names
void chap2_4(void); // dimensions
void chap2_4_reco(void); // dimensions of a variable
void chap2_5_1(void); // missing data
void chap2_6(void); // attributes
bool chap2_6_1(void); // convention
void chap2_6_2_reco(void); // title and history
void chap21(void); // filename
void chap22(void); // dimensions
void chap23(void); // names
void chap23_reco(void); // names
void chap24(void); // dimensions
void chap24_reco(void); // dimensions of a variable
void chap251(void); // missing data
void chap26(void); // attributes
bool chap261(void); // convention
void chap262_reco(void); // title and history

void chap3(void); //
void chap3_reco(void); // description of data
void chap3_3(void); // standard_name etc.
void chap3_4(void); // ancillary_variables
void chap3_5(void); // flags
void chap3_5_reco(void); // description of data
void chap33(void); // standard_name etc.
void chap34(void); // ancillary_variables
void chap35(void); // flags
void chap35_reco(void); // description of data

void chap4(void); // Coordinate Types
bool chap4(Variable&); // Coordinate Types
bool chap4_1(Variable&); // lat/lon coordinate
bool chap4_3(Variable&); // vertical coordinate
bool chap4_3_1(Variable&); // vertical dimensional coord
void chap4_3_2(void); // vertical dimensionless coord
bool chap4_3_2(Variable&, std::vector<std::string>&, std::vector<std::string>&,
bool chap41(Variable&); // lat/lon coordinate
bool chap43(Variable&); // vertical coordinate
bool chap431(Variable&); // vertical dimensional coord
void chap432(void); // vertical dimensionless coord
bool chap432(Variable&, std::vector<std::string>&, std::vector<std::string>&,
int ft_jx, int sn_jx);
// check of standard_name vs. formula_terms (case: dimless vertical coord)
bool chap4_3_2_checkSNvsFT( Variable& var,
bool chap432_checkSNvsFT( Variable& var,
std::vector<std::string>& valid_sn,
std::vector<std::string>& valid_ft,
int& valid_sn_ix,
int& ft_ix, int& sn_ix, std::string& units );
void chap4_3_2_deprecatedUnits(Variable&, std::string &units);
void chap4_3_2_getParamVars( Variable&,
void chap432_deprecatedUnits(Variable&, std::string &units);
void chap432_getParamVars( Variable&,
std::vector<std::string>& valid_sn,
std::vector<std::string>& valid_ft,
int& valid_ft_ix, int& valid_sn_ix, int att_ft_ix,
std::vector<std::pair<std::string, std::string> >& att_ft_pv) ;
void chap4_3_2_verify_FT(Variable&, int, std::string &reqFormTerms,
void chap432_verify_FT(Variable&, int, std::string &reqFormTerms,
int att_ft_ix, std::vector<std::string> &fTerms,
std::vector<std::pair<std::string, std::string> >& p_found_ft);
bool chap4_4(Variable&); // time
void chap4_4a_reco(Variable&); // ref time 0
bool chap4_4_1(Variable&); // calendar
bool chap44(Variable&); // time
void chap44a_reco(Variable&); // ref time 0
bool chap441(Variable&); // calendar

void chap5(void); // Coordinate Systems
void chap5_reco(void); // coordinate types
void chap5_0(void); // dim-list of variables; post-poned
void chap5_1(Variable&); // coordinate variables
void chap5_2(void); // coordinate attribute(s)
void chap5_3(void); // reduced horizontal grid:
// void chap5_4(void); // time series of station data
// void chap5_5(void); // trajectories: checked implicitely
void chap5_6(void); // grid mapping
int chap5_6_gridMappingVar(Variable& dv, std::string &, std::string);
void chap5_6_attProps(Variable& dataVar,
void chap50(void); // dim-list of variables; post-poned
void chap51(Variable&); // coordinate variables
void chap52(void); // coordinate attribute(s)
void chap53(void); // reduced horizontal grid:
// void chap54(void); // time series of station data
// void chap55(void); // trajectories: checked implicitely
void chap56(void); // grid mapping
int chap56_gridMappingVar(Variable& dv, std::string &, std::string);
void chap56_attProps(Variable& dataVar,
std::string mCV[]); // map coordinates

void chap6(void); // labels

void chap7(void); // cells
void chap7_3_inqBounds(Variable&, std::vector<std::string>& name,
void chap73_inqBounds(Variable&, std::vector<std::string>& name,
std::vector<std::string>& method, bool );
void chap7_1(void); // pertains to both boundaries and climatologies
void chap7_1_reco(Variable&); // cell boundaries
void chap7_2(void); // cell measure
void chap7_3(void); // cell methods
bool chap7_3_cellMethods_Comment(std::string&, Variable&) ;
bool chap7_3_cellMethods_Method(std::string&, Variable&) ;
bool chap7_3_cellMethods_Name(std::string&, Variable&) ;
void chap7_3b_reco(Variable&, std::vector<std::string> &dim );
bool chap7_3_3(std::string& method, Variable&, std::string mode) ;
bool chap7_3_4a(std::string&) ;
void chap7_3_4b(Variable&, std::vector<std::string> &dim, std::vector<std::string> &method);
void chap7_4a(void); // climatological statistics
bool chap7_4b(Variable&, std::vector<std::string> &name, std::vector<std::string> &method) ;
void chap71(void); // pertains to both boundaries and climatologies
void chap71_reco(Variable&); // cell boundaries
void chap72(void); // cell measure
void chap73(void); // cell methods
bool chap73_cellMethods_Comment(std::string&, Variable&) ;
bool chap73_cellMethods_Method(std::string&, Variable&) ;
bool chap73_cellMethods_Name(std::string&, Variable&) ;
void chap73b_reco(Variable&, std::vector<std::string> &dim );
bool chap733(std::string& method, Variable&, std::string mode) ;
bool chap734a(std::string&) ;
void chap734b(Variable&, std::vector<std::string> &dim, std::vector<std::string> &method);
void chap74a(void); // climatological statistics
bool chap74b(Variable&, std::vector<std::string> &name, std::vector<std::string> &method) ;

void chap8(void); // reduction of data size
void chap8_1(Variable&); // packed data
void chap8_2(Variable&); // compression by gathering (scal_factor, offset)
void chap81(Variable&); // packed data
void chap82(Variable&); // compression by gathering (scal_factor, offset)

void chap9(void); // discrete sampling geometries (CF-1.6)
void chap9_featureType(std::vector<std::string> &validFeatureType,
Expand All @@ -146,6 +146,7 @@ class CF : public IObj
bool chap9_trajectoryProfile(std::vector<int>& xyzt_ix, std::vector<size_t>& dv_ix);

void applyOptions(void);
void analyseCoordWeights(void);
void attributeSpellCheck(void);

void checkCoordinateValues(Variable&, bool isFormTermAux=false) ;
Expand All @@ -167,17 +168,16 @@ template <typename T>
void finalAtt(void) ;
void finalAtt_axis(void);
void finalAtt_coordinates(void);
void finalAtt_coordinates_A(std::vector<size_t>& dv_ix,
std::vector<size_t>& cv_ix, std::vector<size_t>& acv_ix );
void finalAtt_coordinates_B(std::vector<size_t>& dv_ix,
std::vector<size_t>& cv_ix, std::vector<size_t>& acv_ix );
void finalAtt_coordinates_C(std::vector<size_t>& dv_ix,
std::vector<size_t>& cv_ix, std::vector<size_t>& acv_ix );
void finalAtt_coordinates_A(void);
void finalAtt_coordinates_B(void);
void finalAtt_coordinates_C(void);
void finalAtt_positive(void);
void finalAtt_units(void);
void final_dataVar(void);
void findAmbiguousCoords(void);
bool findLabel(Variable&);
void findCellMeasures(Variable&);
void findIndexVar(void);
bool findLabel(Variable&);
void getAssociatedGroups(void);
void getDims(void);
std::vector<std::string>
Expand All @@ -187,16 +187,14 @@ template <typename T>
void getVarStateEvidences(Variable&);
void hasBounds(Variable&);
void initDefaults(void);
void inqAuxVersusPureCoord(void);
bool isBounds(Variable&);
bool isChap6_labelSubstAuxCoord(Variable& coord_aux, std::vector<std::string>& ca);
bool isChap9_specialLabel(Variable& label, Variable& var);
bool isCompressAux(Variable&);
bool isCompressEvidence(Variable&, bool*) ; // bool* for int-type
// bool isCompliant(void){ return isCF;}
bool isLatitude(void);
bool isLongitude(void);
bool isXYZinCoordAtt(bool withT=false);
bool isXYZinCoordAtt(size_t v_ix);
bool parseUnits( std::string s);
void postAnnotations(void);

Expand Down Expand Up @@ -286,11 +284,9 @@ template <typename T>
static std::vector<char> attType; // S: string, N: numeric, D: data type
std::vector<std::string> dimensions;
std::vector<size_t> effDims_ix;
std::vector<size_t> varRepDims_ix;

// properties of coordinates attributes
std::vector<std::pair<int, int> > ca_pij;
std::vector<int> ca_ix; // ca_vx[i] points to var_ix, def.: -1
std::vector<std::vector<std::string> > ca_vvs ;
};

Expand Down
18 changes: 16 additions & 2 deletions include/hdhC.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ findPos(T, std::vector<T>&);
//! return vector composed to a char-separated string
/*! A space follows 'sep', if isSpace=true*/
std::string
getComposedVector(std::vector<std::string>& vs, bool isSpace=false, char sep=',');
getVector2Str(std::vector<std::string>& vs, bool isSpace=false, char sep=',');

//! Get non-alpha characters.
/*! Return empty if no one was found.*/
Expand Down Expand Up @@ -373,8 +373,13 @@ isAlpha(std::string, bool isContains=false);
bool
isAlphaNum(unsigned char);

// "": exact, "beg"|"end": match from begin|end, "find": anywhere
bool
isAmong(std::string&, std::vector<std::string>& set);
isAmong(std::string&, std::vector<std::vector<std::string> >& set,
std::string mode="");

bool
isAmong(std::string&, std::vector<std::string>& set, std::string mode="");

template <typename T>
bool
Expand Down Expand Up @@ -417,7 +422,16 @@ interpolArray2Array( int idxa, int idxn , int idya, int idyn,
double spv, double **fa, double **fn);
*/

//! Itemise a string, e.g. "a: b c d: e f" --> "a: b c", "d: e f"
/*! pos indicates the position of key. empty --> key must macth,
first --> at the beginning, last --> at the end */
std::vector<std::string>
itemise(std::string&, std::string key, std::string pos=empty);

//! Convert int to string (based on K&R).
std::vector<std::string>
itoa(std::vector<int>& );

std::string
itoa(int n );

Expand Down
22 changes: 8 additions & 14 deletions include/variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class VariableMeta

double addOffset;
uint32_t checksum; //fletcher-32
size_t dimSize;
double doubleFillValue;
double doubleMissingValue;
void *fillValue;
Expand Down Expand Up @@ -70,22 +69,18 @@ class VariableMeta
{
bool isAny;
bool isCoordVar; // coordinate variable, e.g. time(time) with units
bool isT;
bool isX;
bool isY;
bool isZ;
bool isZ_p;
bool isZ_DL; //dimensionless coord

int indication_X;
int indication_Y;
int indication_Z;
int indication_T;
std::vector<char> cType;
std::vector<bool> isC;
std::vector<int> weight;
};
Coordinates coord;

int countData;
int countAux;
int indication_DV;
int weight_DV;
int isUnlimited_; // access by isUnlimited() method

bool isArithmeticMean; // externally set
Expand Down Expand Up @@ -135,6 +130,7 @@ class Variable : public VariableMeta
{
public:

void addWeight(int) ; // int--> index 0: X, 1: Y, 2: Z, 3: T, -1: decrease all
void addDataCount(int i=1) ;
void addAuxCount(int i=1) ;
void clear(void);
Expand All @@ -145,7 +141,6 @@ class Variable : public VariableMeta
template<typename T>
void setExceptions( T*, MtrxArr<T>*) ;

void disableAmbiguities(void);
int getAttIndex(std::string, bool tryLowerCase=true) ;
// forceLowerCase==true will return the value always as lower-case
std::string
Expand All @@ -159,9 +154,8 @@ class Variable : public VariableMeta
getDimNameStr(bool isWithVar=false, char sep=',');
int getVarIndex(){ return id ;}
bool isAuxiliary(void) { return (countAux > countData ) ? true : false ;}
bool isCoordinate(void)
{return coord.isAny || coord.isX || coord.isY || coord.isZ || coord.isT ;}
bool isDataVar(void) { return (countData > countAux ) ? true : false ;}
bool isCoordinate(void);
bool isDataVar(void){ return (countData >= countAux ) ? true : false ; }
bool isUnlimited(void) ;
bool isValidAtt(std::string s, bool tryLowerCase=true);
bool isValidAtt(std::string s, std::string sub_str);
Expand Down
5 changes: 4 additions & 1 deletion scripts/dkrz-cf-checker
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ for(( i=0 ; i < ${#fs[*]} ; ++i )) ; do

if [ ${isTestSuite:-f} = t ] && echo ${fs[i]} | grep -q Fail ; then
asdf="$(ncdump -h ${fs[i]} | grep :comment[^[:digit:]])"
echo -e "${asdf#*:}\n"
echo "${asdf#*:}"
# asdf="$(ncdump -h ${fs[i]} | grep :note)"
# test "${asdf}" && echo -e "${asdf#*:}"
echo -e "\n"
fi
done
Expand Down
11 changes: 11 additions & 0 deletions src/Annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ Annotation::findIndex(std::string &key, bool isOnly)

std::vector<std::string>
Annotation::getAnnotation(std::string tag)
{
std::vector<std::string> s;
return getAnnotation(tag, s);
}

std::vector<std::string>
Annotation::getAnnotation(std::string tag, std::vector<std::string>& txt)
{
std::vector<std::string> vs;

Expand All @@ -343,14 +350,18 @@ Annotation::getAnnotation(std::string tag)

for( it=mp.begin() ; it != mp.end() ; ++it )
{
// remove internal versioning
size_t sz;
if( (sz=it->first.find('|')) == std::string::npos )
sz = it->first.size();

str = it->first.substr(0,sz) ;

if( str.find(tag) < std::string::npos )
{
vs.push_back(str);
txt.push_back(it->second);
}
}

return vs;
Expand Down

0 comments on commit ff60029

Please sign in to comment.