Commit 62196f0f authored by remi cresson's avatar remi cresson
Browse files

ENH: new implementation for cumul. Time range is now set using (startday,...

ENH: new implementation for cumul. Time range is now set using (startday, startmonth, duration) instead of (doy1, doy2)
parent 245e586b
......@@ -180,26 +180,25 @@ private:
AddParameter(ParameterType_Group, "ndvi", "NDVI Time series");
// Method to reduce NDVI time series
AddParameter(ParameterType_Choice, "ndvi.reduce", "Method to reduce time series");
AddChoice("ndvi.reduce.cumul","Cumul between two dates (day1 of month1 and day2 of month2) of the year");
AddParameter(ParameterType_Int, "ndvi.reduce.cumul.day1", "Day 1");
AddParameter(ParameterType_Int, "ndvi.reduce.cumul.day2", "Day 2");
AddParameter(ParameterType_Int, "ndvi.reduce.cumul.month1", "Month 1");
AddParameter(ParameterType_Int, "ndvi.reduce.cumul.month2", "Month 2");
SetMinimumParameterIntValue("ndvi.reduce.cumul.day1", 1);
SetMinimumParameterIntValue("ndvi.reduce.cumul.day2", 1);
SetMaximumParameterIntValue("ndvi.reduce.cumul.day1", 31);
SetMaximumParameterIntValue("ndvi.reduce.cumul.day2", 31);
SetDefaultParameterInt ("ndvi.reduce.cumul.day1", 1);
SetDefaultParameterInt ("ndvi.reduce.cumul.day2", 31);
SetMinimumParameterIntValue("ndvi.reduce.cumul.month1", 1);
SetMinimumParameterIntValue("ndvi.reduce.cumul.month2", 1);
SetMaximumParameterIntValue("ndvi.reduce.cumul.month1", 12);
SetMaximumParameterIntValue("ndvi.reduce.cumul.month2", 12);
SetDefaultParameterInt ("ndvi.reduce.cumul.month1", 7); // July
SetDefaultParameterInt ("ndvi.reduce.cumul.month2", 10); // October
AddChoice("ndvi.reduce.max","Maximum in the year");
AddChoice("ndvi.reduce.amplitude","Amplitude in the year");
AddParameter(ParameterType_Choice, "ndvi.reduce", "Method to reduce NDVI time series");
AddChoice("ndvi.reduce.cumul" , "Cumul between two dates of the year, starting from ddstart/mmstart and during nbdays");
AddChoice("ndvi.reduce.max" , "Maximum in the year");
AddChoice("ndvi.reduce.amplitude", "Amplitude in the year");
AddParameter(ParameterType_Int, "ndvi.reduce.cumul.startday", "Start day");
SetMinimumParameterIntValue ("ndvi.reduce.cumul.startday", 1);
SetMaximumParameterIntValue ("ndvi.reduce.cumul.startday", 31);
SetDefaultParameterInt ("ndvi.reduce.cumul.startday", 1);
MandatoryOff ("ndvi.reduce.cumul.startday");
AddParameter(ParameterType_Int, "ndvi.reduce.cumul.startmonth", "Start month");
SetMinimumParameterIntValue ("ndvi.reduce.cumul.startmonth", 1);
SetMaximumParameterIntValue ("ndvi.reduce.cumul.startmonth", 12);
SetDefaultParameterInt ("ndvi.reduce.cumul.startmonth", 11); // november
MandatoryOff ("ndvi.reduce.cumul.startmonth");
AddParameter(ParameterType_Int, "ndvi.reduce.cumul.nbdays", "Cumul duration (number of days)");
SetMinimumParameterIntValue ("ndvi.reduce.cumul.nbdays", 1);
SetMaximumParameterIntValue ("ndvi.reduce.cumul.nbdays", 365);
SetDefaultParameterInt ("ndvi.reduce.cumul.nbdays", 150); // 150 days ~ 5 months
MandatoryOff ("ndvi.reduce.cumul.nbdays");
// Output NDVI (slope,p-value,corr) image
AddParameter(ParameterType_OutputImage, "ndvitrend", "Output image for NDVI trend (Contains [slope, pvalue, correlation])");
......@@ -215,28 +214,23 @@ private:
AddParameter(ParameterType_Group, "rain", "Rainfall Time series");
// Method to reduce raifall time series
AddParameter(ParameterType_Choice, "rain.reduce", "Method to reduce time series");
AddChoice("rain.reduce.cumul","Cumul between two dates (day1 of month1 and day2 of month2) of the year");
AddParameter(ParameterType_Int, "rain.reduce.cumul.day1", "Day 1");
AddParameter(ParameterType_Int, "rain.reduce.cumul.day2", "Day 2");
AddParameter(ParameterType_Int, "rain.reduce.cumul.month1", "Month 1");
AddParameter(ParameterType_Int, "rain.reduce.cumul.month2", "Month 2");
SetMinimumParameterIntValue("rain.reduce.cumul.day1", 1);
SetMinimumParameterIntValue("rain.reduce.cumul.day2", 1);
SetMaximumParameterIntValue("rain.reduce.cumul.day1", 31);
SetMaximumParameterIntValue("rain.reduce.cumul.day2", 31);
SetDefaultParameterInt ("rain.reduce.cumul.day1", 1);
SetDefaultParameterInt ("rain.reduce.cumul.day2", 31);
MandatoryOff ("rain.reduce.cumul.day1");
MandatoryOff ("rain.reduce.cumul.day2");
SetMinimumParameterIntValue("rain.reduce.cumul.month1", 1);
SetMinimumParameterIntValue("rain.reduce.cumul.month2", 1);
SetMaximumParameterIntValue("rain.reduce.cumul.month1", 12);
SetMaximumParameterIntValue("rain.reduce.cumul.month2", 12);
SetDefaultParameterInt ("rain.reduce.cumul.month1", 6); // June
SetDefaultParameterInt ("rain.reduce.cumul.month2", 10); // October
MandatoryOff ("rain.reduce.cumul.month1");
MandatoryOff ("rain.reduce.cumul.month2");
AddParameter(ParameterType_Choice, "rain.reduce", "Method to reduce rainfall time series");
AddChoice("rain.reduce.cumul", "Cumul between two dates of the year, starting from ddstart/mmstart and during nbdays");
AddParameter(ParameterType_Int, "rain.reduce.cumul.startday", "Start day");
SetMinimumParameterIntValue ("rain.reduce.cumul.startday", 1);
SetMaximumParameterIntValue ("rain.reduce.cumul.startday", 31);
SetDefaultParameterInt ("rain.reduce.cumul.startday", 1);
MandatoryOff ("rain.reduce.cumul.startday");
AddParameter(ParameterType_Int, "rain.reduce.cumul.startmonth", "Start month");
SetMinimumParameterIntValue ("rain.reduce.cumul.startmonth", 1);
SetMaximumParameterIntValue ("rain.reduce.cumul.startmonth", 12);
SetDefaultParameterInt ("rain.reduce.cumul.startmonth", 11); // november
MandatoryOff ("rain.reduce.cumul.startmonth");
AddParameter(ParameterType_Int, "rain.reduce.cumul.nbdays", "Cumul duration (number of days)");
SetMinimumParameterIntValue ("rain.reduce.cumul.nbdays", 1);
SetMaximumParameterIntValue ("rain.reduce.cumul.nbdays", 365);
SetDefaultParameterInt ("rain.reduce.cumul.nbdays", 150); // 150 days ~ 5 months
MandatoryOff ("rain.reduce.cumul.nbdays");
// Output residues
AddParameter(ParameterType_OutputImage, "residues", "Output image for NDVI residues");
......@@ -349,10 +343,9 @@ private:
m_NDVICumulReduceFilter = TSCumulatedRangeReduceFilterType::New();
m_NDVICumulReduceFilter->SetInput(m_NDVIConcatener->GetOutput());
m_NDVICumulReduceFilter->GetFunctor().SetDates(ndviDates);
m_NDVICumulReduceFilter->GetFunctor().SetDay1(GetParameterInt("ndvi.reduce.cumul.day1"));
m_NDVICumulReduceFilter->GetFunctor().SetDay2(GetParameterInt("ndvi.reduce.cumul.day2"));
m_NDVICumulReduceFilter->GetFunctor().SetMonth1(GetParameterInt("ndvi.reduce.cumul.month1"));
m_NDVICumulReduceFilter->GetFunctor().SetMonth2(GetParameterInt("ndvi.reduce.cumul.month2"));
m_NDVICumulReduceFilter->GetFunctor().SetStartDay(GetParameterInt ("ndvi.reduce.cumul.startday"));
m_NDVICumulReduceFilter->GetFunctor().SetStartMonth(GetParameterInt("ndvi.reduce.cumul.startmonth"));
m_NDVICumulReduceFilter->GetFunctor().SetNbOfDays(GetParameterInt ("ndvi.reduce.cumul.nbdays"));
reducedNDVI = m_NDVICumulReduceFilter->GetOutput();
}
else if (GetParameterInt("ndvi.reduce") == MAX)
......@@ -474,11 +467,10 @@ private:
// Reduce rainfall
m_RFCumulReduceFilter = TSCumulatedRangeReduceFilterType::New();
m_RFCumulReduceFilter->SetInput(m_RFConcatener->GetOutput());
m_RFCumulReduceFilter->GetFunctor().SetDates(ndviDates);
m_RFCumulReduceFilter->GetFunctor().SetDay1(GetParameterInt("rain.reduce.cumul.day1"));
m_RFCumulReduceFilter->GetFunctor().SetDay2(GetParameterInt("rain.reduce.cumul.day2"));
m_RFCumulReduceFilter->GetFunctor().SetMonth1(GetParameterInt("rain.reduce.cumul.month1"));
m_RFCumulReduceFilter->GetFunctor().SetMonth2(GetParameterInt("rain.reduce.cumul.month2"));
m_RFCumulReduceFilter->GetFunctor().SetDates(rainDates);
m_RFCumulReduceFilter->GetFunctor().SetStartDay(GetParameterInt ("rain.reduce.cumul.startday"));
m_RFCumulReduceFilter->GetFunctor().SetStartMonth(GetParameterInt("rain.reduce.cumul.startmonth"));
m_RFCumulReduceFilter->GetFunctor().SetNbOfDays(GetParameterInt ("rain.reduce.cumul.nbdays"));
// Resample rainfall
LinearInterpolatorType::Pointer linInterpolator = LinearInterpolatorType::New();
......
......@@ -148,7 +148,6 @@ inline TOutputPixel operator ()(const TInputPixel& input) const
output.Fill(this->GetInputNoDataValue());
DatesType dates = this->GetDates();
int firstYear = dates[0].year;
for (unsigned int i = 0; i < input.Size(); i++)
{
......@@ -158,26 +157,25 @@ inline TOutputPixel operator ()(const TInputPixel& input) const
// Range check
if (inValue != this->GetInputNoDataValue())
{
if (dates[i].IsInRange(m_Month1, m_Day1, m_Month2, m_Day2))
if (dates[i].IsInRange(m_Month, m_Day, m_NbOfDays))
{
output[index] += inValue;
}
}
}
return output;
}
void SetDay1(int day) { m_Day1 = day; }
void SetDay2(int day) { m_Day2 = day; }
void SetMonth1(int month) { m_Month1 = month; }
void SetMonth2(int month) { m_Month2 = month; }
void SetStartDay(int day) { m_Day = day; }
void SetStartMonth(int month) { m_Month = month; }
void SetNbOfDays(int n) { m_NbOfDays = n; }
private:
int m_Day1;
int m_Day2;
int m_Month1;
int m_Month2;
int m_Day;
int m_Month;
int m_NbOfDays;
}; // TSCumulatedRangeReduceFunctor
......@@ -368,6 +366,8 @@ public:
// Compute output pixel
inline TOutputPixel operator ()(const TInputPixel& input) const
{
const int firstDate = GetDates()[0].julianday;
TOutputPixel outpixel;
outpixel.SetSize(numberOfComponentsPerPixel);
outpixel.Fill(m_OutputNoDataValue);
......@@ -385,7 +385,7 @@ public:
if (input[i] != m_InputNoDataValue)
{
OutputPixelValueType val = static_cast<OutputPixelValueType>(input[i]);
OutputPixelValueType ival = static_cast<OutputPixelValueType>(GetDates()[i].julianday);
OutputPixelValueType ival = static_cast<OutputPixelValueType>(GetDates()[i].julianday - firstDate);
sum += val;
isum += ival;
sqSum += val*val;
......@@ -498,6 +498,7 @@ public:
SlopeAndPValueLabelingFunctor()
{
numberOfComponentsPerPixel = 1;
m_InputNoDataValue = 0;
}
// Destructor
......@@ -724,6 +725,7 @@ public:
FactorsLabelingFunctor()
{
numberOfComponentsPerPixel = 1;
m_InputNoDataValue = 0;
}
// Destructor
......@@ -822,7 +824,7 @@ public:
return label;
}
/* Set / Get input no-data value */
// Set / Get input no-data value
void SetInputNoDataValue(InputPixelValueType value) { m_InputNoDataValue = value; }
InputPixelValueType GetInputNoDataValue() const { return m_InputNoDataValue; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment