Skip to content

Commit

Permalink
Changes in class Date, a fix for the summary post-proc., and more
Browse files Browse the repository at this point in the history
  • Loading branch information
h-dh committed Aug 26, 2015
1 parent 073f6ae commit 6cddb67
Show file tree
Hide file tree
Showing 18 changed files with 624 additions and 607 deletions.
77 changes: 33 additions & 44 deletions include/date.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ class Date
applied unit is day.*/
void addTime(double val, std::string unit="");

//! convert yyymmdd[.f] to ISO-8601
static std::string
convertFormattedToISO_8601(double f) ;
static std::string
convertFormattedToISO_8601(std::string) ;

//! A usage description and examples
static void
Expand All @@ -210,39 +215,23 @@ class Date
std::string
getCalendar(void){ return currCalendar;}

//! Return the real current date.
static std::string
getCurrentDate(void);

//! Get string representation (ISO-8601)
std::string
getDate( void );

//! Convert val to ISO-8601.
/*! If val is relative to a reference date, then this is returned
in ISO-8601 format. If reference was not set before, then
val is considered a Julian day. The bool set true states
that val is a Julian day anyway.*/
std::string // val must be a Julian date if isRel.==false
getDate( double val, bool=false );

//! Convert a Julian Day ISO-8601.
std::string
getDate( Julian & );
Date // val must be a Julian Date number if isRel.==false
getDate(double val, bool=false) ;

//! Get relative or absolute date.
/*! Provide time units relative to date and return ISO-8601 string.
If 'enableSetDate=true', then a reference date is extracted and
set (see setDate(string) from the std::string parameter before
a relative part is considered. In case of failure,
'not-a-valid-date' string is returned.*/
std::string
getDate( std::string, bool enableSetDate=false );
Date
getDate(std::string, bool enableSetDate=false);

//! Get ISO-8601 string for the given date elements.
std::string
getDate( double yr, double mo, double dy,
double hr, double mi, double se );
//! Get the day of the year and month.
double getDay( void );

Expand Down Expand Up @@ -276,13 +265,15 @@ class Date
//! Get double representation of the integer hour.
double getHour( void );

//! convert yyymmdd[.f] to ISO-8601
static std::string
getIso8601(double f) ;
static std::string
getIso8601(std::string) ;
std::string
getISO_8601(void);

//! Get the julian date.
std::string
getISO_8601( double y, double mo, double d,
double h=0, double mi=0, double s=0,
bool isError=false);

//! Get the julian date.
long double
getJulianDay(long double add=0.) const
{ return jul.getJulianDay() + add ;}
Expand Down Expand Up @@ -321,6 +312,10 @@ class Date
//! Get time lag to and in units of the relative time step.
double getSince(Date &d, const char *ref="");

//! Return the real current date.
static std::string
getTodayStr(void);

//! Get the unit of the reference date
std::string
getUnits(void){ return unitStr; }
Expand Down Expand Up @@ -350,21 +345,16 @@ class Date

//! Set date by date-encoded float
/*! At present: (%Y%m%d.%f)*/
bool setDate( double f, std::string cal="" );

//! Set date from parameters.
bool setDate( double y, double mnth, double d,
double h=0, double min=0, double s=0 );
bool setDate( double f, std::string cal="", std::string monLen="" );

//! Set reference date.
/*! String could be "7 minutes since 1955-01-01 00:00", i.e.
contain a reference date and the unit of relative time.*/
bool setDate( std::string, std::string cal="", std::string mLen="");

//! Set coding of string.
/*! At present, only "%Y%m%d.%f" must be given explicitly.
Code 'yymmdd_hhmmss.f' is tested by default.*/
void setDateCode( std::string s){dateCode=s;}
//! Set date from parameters.
bool setDate( double y, double mnth, double d,
double h=0, double min=0, double s=0 );

void setFormattedDate(void){isFormattedDate=true;}

Expand Down Expand Up @@ -392,10 +382,13 @@ class Date

//! Set the unit of the reference date
/*! Purpose: for a reference date without units */
bool setUnits(std::string s);
void setUnits(std::string s, int unitSign=1);

bool size(void){ return isDateSet; }

std::string
str(void) ;

private:
enum Calendar { GREGORIAN, PROLEPTIC_GREGORIAN, JULIAN,
EQUAL_MONTHS, ALL_LEAP, NO_LEAP, NONE } ;
Expand Down Expand Up @@ -432,13 +425,8 @@ class Date
void exceptionError(std::string );

/* double getDayLightST( void );*/
std::string
getDateISO_8601(void);
std::string
getDateISO_8601( double y, double mo, double d,
double h=0, double mi=0, double s=0,
bool isError=false);
void getDayTime(double d, double *h, double *m, double *s);
static void
getDayTime(double d, double *h, double *m, double *s);
double getLocalTimeZone( void ) ;

Julian gregorian2Julian( double y, double mo, double d, double hour ) ;
Expand Down Expand Up @@ -469,10 +457,11 @@ class Date
Julian modelDate2Julian( double y, double mo=0., double d=0.,
double h=0., double mi=0., double s=0.) ;

bool parseISO_8601(std::string& );
bool parseISO_8601(std::string );

Julian prolGreg2Julian( double y, double mo, double d, double deziH ) ;

void setUnitsAndClear(std::string& s);
void string2Date(std::string &);
void string2ModelDate(std::string &);
};
Expand Down
16 changes: 10 additions & 6 deletions include/hdhC.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ convertTime(std::string targetUnit, std::string time,
std::string unit="");

//! Convert a floating number into a string.
/*!Format: ?[w=int?][p=int[|adj]?][f=int?][s[ci]]?\n
/*!Format: ?[w=int?][p=int[|][adj]?][f=char?][s[ci]|float]?\n
?: separator (by default ','). The pre- and post-fix may
be omitted for the default. If changed, then the prefix
has to be formed by twice a character (not: w, p,f,s).
w: width of the field,
p: precision with 'adj' discarding tariling zeros and dec. point,
f: filling character, sci: scientific notation.
Note: assignment '=' may be omitted.*/

p: precision with 'adj' discarding trailing zeros and dec. point,
f: filling character
sci: scientific notation.
float: floating notation.
Note: assignment '=' may be omitted. By default sci is used for abs-values
greater than 100000. and smaller than 0.000001.
*/
std::string
double2String( double z, std::string flag);

Expand All @@ -186,7 +189,8 @@ double2String( double z, std::string flag);
Format of 'flag' is 'n_X with n leading positions filled by
character X. The _-char may be omitted if X is not a number.
Negative value of d indicates rounding with additional
elimination of trailing zeros and a trailing decimal point.*/
elimination of trailing zeros and a trailing decimal point.
*/
std::string
double2String( double z, int d=-5, std::string flag="");

Expand Down
22 changes: 10 additions & 12 deletions include/nc_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,7 @@ void
// vector ------------------
template <typename Type>
void
setAtt(std::string vName, std::string aName,
std::vector<Type> &values)
setAtt(std::string vName, std::string aName, std::vector<Type> &values)
{setAtt(getVarID(vName), aName, values) ;}

template <typename To, typename From>
Expand All @@ -758,14 +757,14 @@ void
template <typename Type>
void
setAtt(std::string vName, std::string aName,
Type *values, size_t sz)
{setAtt(getVarID(vName), aName, values, sz) ;}
Type *arr, size_t sz)
{setAtt(getVarID(vName), aName, arr, sz) ;}

template <typename To, typename From>
void
setAtt(std::string vName, std::string aName,
From *values, size_t sz, To x)
{setAtt(getVarID(vName), aName, sz, x) ;}
From *arr, size_t sz, To x)
{setAtt(getVarID(vName), aName, arr, sz, x) ;}

// plain value, but also a const char*. So , take special care.
template <typename Type>
Expand Down Expand Up @@ -809,12 +808,12 @@ void
// array ------------------
template <typename Type>
void
setGlobalAtt(std::string aName, Type *values, size_t sz)
{setAtt(NC_GLOBAL, aName, values, sz) ;}
setGlobalAtt(std::string aName, Type *arr, size_t sz)
{setAtt(NC_GLOBAL, aName, arr, sz) ;}

template <typename To, typename From>
void
setGlobalAtt(std::string aName, From *values, size_t sz, To x)
setGlobalAtt(std::string aName, From *arr, size_t sz, To x)
{setAtt(NC_GLOBAL, aName, sz, x) ;}

// plain value, but also a const char*. So , take special care.
Expand Down Expand Up @@ -1125,13 +1124,12 @@ void
// array
template <typename T>
void
setAtt(int varid, std::string aName, T *values, size_t sz);
setAtt(int varid, std::string aName, T *arr, size_t sz);

// array and conversion
template <typename To, typename From>
void
setAtt(int varid, std::string aName,
From *values, size_t sz, To x);
setAtt(int varid, std::string aName, From *arr, size_t sz, To x);

// plain value
template <typename From>
Expand Down
1 change: 1 addition & 0 deletions include/qa_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class QA_Data
void setName(std::string);
void setNextFlushBeg(size_t n);
void setStatisticsAttribute(NcAPI*);
void setValidRangeAtt(NcAPI*, std::string&, double* arr, size_t sz, nc_type);
void store(hdhC::FieldData &);

void test( int, hdhC::FieldData &);
Expand Down
9 changes: 5 additions & 4 deletions scripts/qa-DKRZ
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,8 @@ copyPreamble()
{
local i zsTxt

# if [ -e $EXP_LOGDIR/${CURR_EXP_NAME}.log ] ; then
if [ -e $EXP_LOGDIR/${CURR_EXP_NAME}.log ] ; then
:
# # a new qa svn revision number?
# local rev_0 rev_1

Expand Down Expand Up @@ -996,7 +997,7 @@ copyPreamble()
# sTxt[0]="3qa_svn_revision: ${rev_1}"
# log
# fi
# else
else
if [ ${isShow:-f} = f ] ; then
cp ${SESSION_LOGDIR}/session.prmbl $EXP_LOGDIR/${CURR_EXP_NAME}.log
fi
Expand All @@ -1013,7 +1014,7 @@ copyPreamble()
# sTxt[0]="3qa_svn_revision: ${rev_1}"
# log
# fi
# fi
fi

# if [ ${#zsTxt[*]} -gt 0 ] ; then
# for(( i=0 ; i < ${#zsTxt[*]} ; ++i )) ; do
Expand Down Expand Up @@ -3244,7 +3245,7 @@ logConfiguration()
# a preamble will be copied to all log-files
local preamble=${SESSION_LOGDIR}/session.prmbl

# this file is prepented to all exp-log-files
# this file is prepended to all exp-log-files
tryCom \
echo '---' > $preamble
echo '# Log-file of a QA session started by qa-DKRZ' \
Expand Down
16 changes: 8 additions & 8 deletions scripts/taskSummary
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ processBlk()

summaryHR()
{
local p=$annotations/${exp}.log
local aIn=$annotations/${exp}.note

txt="Annotation summary of the QA of experiment\n \
${exp}\
Expand All @@ -82,7 +82,7 @@ txt="Annotation summary of the QA of experiment\n \
\n\nAccess to the logfiles:\n \
${QA_RESULTS}/check_logs \
\n\nPath to the annotations in YAML format:\n\
$(pwd)/${p}\n\
$(pwd)/${aIn}\n\
\n\n"

mkdir -p $summary/$exp
Expand Down Expand Up @@ -151,12 +151,12 @@ txt="Annotation summary of the QA of experiment\n \
if [ "${PROJECT}" = CORDEX ] ; then
if ! expr match "$exp" '.*r0i0p0' &> /dev/null ; then
if [ ${#std_table} -gt 0 ] ; then
/bin/bash ${QA_PATH}/scripts/findNotDelivered --project=CORDEX ${DEBUG_X} \
/bin/bash ${QA_PATH}/scripts/findNotDelivered ${DEBUG_X} \
--project=CORDEX \
--period=$outP \
--table=${std_table} \
--out=$outA \
--yaml \
isFoundNotDelivered=t
--yaml
fi
fi
fi
Expand All @@ -177,7 +177,7 @@ txt="Annotation summary of the QA of experiment\n \
fi

# find tags of the yaml annotation file, if any
if [ ! -f $p ] ; then
if [ ! -f $aIn ] ; then
echo -e " \n\n==== Annotation: none =========================\n" \
>> $outA
return
Expand All @@ -194,7 +194,7 @@ txt="Annotation summary of the QA of experiment\n \

tags[${#tags[*]}]="${line[1]}"
fi
done < $annotations/${exp}.log
done < $aIn

# clear old results
\rm -f $summary/$exp/L*
Expand Down Expand Up @@ -245,7 +245,7 @@ txt="Annotation summary of the QA of experiment\n \
unset line[0]
impct="${line[*]}"
fi
done < $annotations/${exp}.log
done < $aIn
done

local f fc
Expand Down

0 comments on commit 6cddb67

Please sign in to comment.