Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
pascalhorton committed Dec 6, 2017
2 parents d90a055 + d1a8bf3 commit 27e74f80b6809b9d934c4f96fbb3cbbb647e3d5f
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<atmoswing version="1.0">
<pattern id="NCEI_CDO" name="NCEI Climate Data Online (www7.ncdc.noaa.gov/CDO/cdo)">
<structure_type>constant_width</structure_type>
<header_lines>1</header_lines>
<parse_time>1</parse_time>
<time>
<year char_start="15" char_end="18"/>
<month char_start="19" char_end="20"/>
<day char_start="21" char_end="22"/>
</time>
<data>
<value char_start="119" char_end="123"/>
</data>
</pattern>
</atmoswing>
@@ -290,7 +290,18 @@ a1f asScore::AssessOnArray(float ObservedVal, const a1f &ForcastVals, int NbElem
return a1f();
}
bool asScore::CheckInputs(float ObservedVal, const a1f &ForcastVals, int nbElements) const
bool asScore::CheckObservedValue(float ObservedVal) const
{
// Check that the observed value is not a NaN
if (asTools::IsNaN(ObservedVal)) {
wxLogVerbose(_("The observed value is a NaN for the score calculation."));
return false;
}
return true;
}
bool asScore::CheckVectorLength(const a1f &ForcastVals, int nbElements) const
{
// Check the element numbers vs vector length
wxASSERT_MSG(ForcastVals.rows() >= nbElements,
@@ -301,12 +312,6 @@ bool asScore::CheckInputs(float ObservedVal, const a1f &ForcastVals, int nbEleme
return false;
}
// Check that the observed value is not a NaN
if (asTools::IsNaN(ObservedVal)) {
wxLogWarning(_("The observed value is a NaN for the CRPS score calculation."));
return false;
}
return true;
}
@@ -82,7 +82,9 @@ class asScore
virtual a1f AssessOnArray(float ObservedVal, const a1f &ForcastVals, int NbElements) const;
bool CheckInputs(float ObservedVal, const a1f &ForcastVals, int nbElements) const;
bool CheckObservedValue(float ObservedVal) const;
bool CheckVectorLength(const a1f &ForcastVals, int nbElements) const;
int CleanNans(const a1f &ForcastVals, a1f &ForcastValsSorted, int nbElements) const;
@@ -50,6 +50,15 @@ float asScoreBS::Assess(float ObservedVal, const a1f &ForcastVals, int nbElement
wxASSERT(nbElements > 0);
wxASSERT(!asTools::IsNaN(m_threshold));
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
// Create the container to sort the data
a1f x(nbElements);
@@ -50,9 +50,17 @@ float asScoreBSS::Assess(float ObservedVal, const a1f &ForcastVals, int nbElemen
{
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
wxASSERT(m_scoreClimatology != 0);
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
// First process the BS and then the skill score
asScoreBS scoreBS = asScoreBS();
scoreBS.SetThreshold(GetThreshold());
@@ -50,9 +50,12 @@ float asScoreCRPSAR::Assess(float ObservedVal, const a1f &ForcastVals, int nbEle
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
// Check the element numbers vs vector length and the observed value
if (!CheckInputs(ObservedVal, ForcastVals, nbElements)) {
wxLogWarning(_("The inputs are not conform in the CRPS processing function"));
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
@@ -49,9 +49,12 @@ float asScoreCRPSEP::Assess(float ObservedVal, const a1f &ForcastVals, int nbEle
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
// Check the element numbers vs vector length and the observed value
if (!CheckInputs(ObservedVal, ForcastVals, nbElements)) {
wxLogWarning(_("The inputs are not conform in the CRPS processing function"));
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
@@ -56,12 +56,6 @@ a1f asScoreCRPSHersbachDecomp::AssessOnArray(float ObservedVal, const a1f &Forca
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
// Check the element numbers vs vector length and the observed value
if (!CheckInputs(ObservedVal, ForcastVals, nbElements)) {
wxLogWarning(_("The inputs are not conform in the CRPS Hersbach decomposition function"));
return a2f();
}
// Create the container to sort the data
a1f x = ForcastVals;
@@ -51,9 +51,17 @@ float asScoreCRPSS::Assess(float ObservedVal, const a1f &ForcastVals, int nbElem
{
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
wxASSERT(m_scoreClimatology != 0);
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
// First process the CRPS and then the skill score
asScoreCRPSAR scoreCRPS = asScoreCRPSAR();
scoreCRPS.SetThreshold(GetThreshold());
@@ -66,9 +74,6 @@ float asScoreCRPSS::Assess(float ObservedVal, const a1f &ForcastVals, int nbElem
bool asScoreCRPSS::ProcessScoreClimatology(const a1f &refVals, const a1f &climatologyData)
{
wxASSERT(!asTools::HasNaN(&refVals[0], &refVals[refVals.size() - 1]));
wxASSERT(!asTools::HasNaN(&climatologyData[0], &climatologyData[climatologyData.size() - 1]));
// Containers for final results
a1f scoresClimatology(refVals.size());
@@ -51,6 +51,15 @@ float asScoreCRPSaccurAR::Assess(float ObservedVal, const a1f &ForcastVals, int
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
asScoreCRPSAR scoreCRPSAR = asScoreCRPSAR();
float CRPS = scoreCRPSAR.Assess(ObservedVal, ForcastVals, nbElements);
asScoreCRPSsharpAR scoreCRPSsharpnessAR = asScoreCRPSsharpAR();
@@ -51,6 +51,15 @@ float asScoreCRPSaccurEP::Assess(float ObservedVal, const a1f &ForcastVals, int
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
asScoreCRPSEP scoreCRPSEP = asScoreCRPSEP();
float CRPS = scoreCRPSEP.Assess(ObservedVal, ForcastVals, nbElements);
asScoreCRPSsharpEP scoreCRPSsharpnessEP = asScoreCRPSsharpEP();
@@ -50,9 +50,12 @@ float asScoreCRPSsharpAR::Assess(float ObservedVal, const a1f &ForcastVals, int
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
// Check the element numbers vs vector length and the observed value
if (!CheckInputs(0, ForcastVals, nbElements)) {
wxLogWarning(_("The inputs are not conform in the CRPS processing function"));
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
@@ -50,9 +50,12 @@ float asScoreCRPSsharpEP::Assess(float ObservedVal, const a1f &ForcastVals, int
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
// Check the element numbers vs vector length and the observed value
if (!CheckInputs(0, ForcastVals, nbElements)) {
wxLogWarning(_("The inputs are not conform in the CRPS processing function"));
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
@@ -52,6 +52,15 @@ float asScoreContingencyTable::Assess(float ObservedVal, const a1f &ForcastVals,
wxASSERT(m_quantile > 0);
wxASSERT(m_quantile < 1);
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
// Create the container to sort the data
a1f x(nbElements);
@@ -49,9 +49,12 @@ float asScoreDF0::Assess(float ObservedVal, const a1f &ForcastVals, int nbElemen
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
// Check the element numbers vs vector length and the observed value
if (!CheckInputs(ObservedVal, ForcastVals, nbElements)) {
wxLogWarning(_("The inputs are not conform in the DF0 processing function"));
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
@@ -52,6 +52,15 @@ float asScoreMAE::Assess(float ObservedVal, const a1f &ForcastVals, int nbElemen
wxASSERT(m_quantile > 0);
wxASSERT(m_quantile < 1);
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
// Create the container to sort the data
a1f x(nbElements);
@@ -52,6 +52,15 @@ float asScoreRMSE::Assess(float ObservedVal, const a1f &ForcastVals, int nbEleme
wxASSERT(m_quantile > 0);
wxASSERT(m_quantile < 1);
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
// Create the container to sort the data
a1f x(nbElements);
@@ -47,6 +47,15 @@ float asScoreRankHistogram::Assess(float ObservedVal, const a1f &ForcastVals, in
wxASSERT(ForcastVals.size() > 1);
wxASSERT(nbElements > 0);
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
// Create the container to sort the data
a1f x = ForcastVals;
@@ -59,6 +59,15 @@ float asScoreSEEPS::Assess(float ObservedVal, const a1f &ForcastVals, int nbElem
wxASSERT(m_quantile > 0);
wxASSERT(m_quantile < 1);
// Check inputs
if (!CheckObservedValue(ObservedVal)) {
return NaNf;
}
if (!CheckVectorLength( ForcastVals, nbElements)) {
wxLogWarning(_("Problems in a vector length."));
return NaNf;
}
// Create the container to sort the data
a1f x(nbElements);
@@ -96,17 +96,15 @@ wxString asPredictand::ParameterEnumToString(asPredictand::Parameter parameter)
asPredictand::Unit asPredictand::StringToUnitEnum(const wxString &unitStr)
{
if (unitStr.CmpNoCase("nb") == 0) {
return nb;
} else if (unitStr.CmpNoCase("number") == 0) {
if (unitStr.CmpNoCase("nb") == 0 || unitStr.CmpNoCase("number") == 0) {
return nb;
} else if (unitStr.CmpNoCase("mm") == 0) {
return mm;
} else if (unitStr.CmpNoCase("m") == 0) {
return m;
} else if (unitStr.CmpNoCase("percent") == 0) {
return percent;
} else if (unitStr.CmpNoCase("%") == 0) {
} else if (unitStr.CmpNoCase("inches") == 0 || unitStr.CmpNoCase("in")) {
return in;
} else if (unitStr.CmpNoCase("percent") == 0 || unitStr.CmpNoCase("%") == 0) {
return percent;
} else if (unitStr.CmpNoCase("degC") == 0) {
return degC;
@@ -682,15 +680,9 @@ bool asPredictand::GetFileContent(asCatalogPredictands &currentData, size_t stat
double dateData = asTime::GetMJD(valTimeYear, valTimeMonth, valTimeDay, valTimeHour,
valTimeMinute, 0);
// Check again date vector
if (std::abs(dateData - m_time(timeIndex)) > 0.0001) {
wxString errorMessage = wxString::Format(
_("Value in data : %6.4f (%s), value in time array : %6.4f (%s). In file %s"),
dateData, asTime::GetStringTime(dateData, "DD.MM.YYYY"), m_time(timeIndex),
asTime::GetStringTime(m_time(timeIndex), "DD.MM.YYYY"),
currentData.GetStationFilename(stationIndex));
wxLogError(_("The time value doesn't match: %s"), errorMessage);
return false;
// Find matching date
while (dateData - m_time(timeIndex) > 0.0001) {
timeIndex++;
}
}
@@ -757,15 +749,9 @@ bool asPredictand::GetFileContent(asCatalogPredictands &currentData, size_t stat
double dateData = asTime::GetMJD(valTimeYear, valTimeMonth, valTimeDay, valTimeHour,
valTimeMinute, 0);
// Check again date vector
if (std::abs(dateData - m_time(timeIndex)) > 0.001) {
wxString errorMessage = wxString::Format(
_("Value in data : %6.4f (%s), value in time array : %6.4f (%s). In file %s"),
dateData, asTime::GetStringTime(dateData, "DD.MM.YYYY"), m_time(timeIndex),
asTime::GetStringTime(m_time(timeIndex), "DD.MM.YYYY"),
currentData.GetStationFilename(stationIndex));
wxLogError(_("The time value doesn't match: %s"), errorMessage);
return false;
// Find matching date
while (dateData - m_time(timeIndex) > 0.0001) {
timeIndex++;
}
}
@@ -50,7 +50,7 @@ class asPredictand
enum Unit
{
nb, mm, m, percent, degC, degK
nb, mm, m, in, percent, degC, degK
};
enum TemporalResolution
Oops, something went wrong.

0 comments on commit 27e74f8

Please sign in to comment.