///////////////////////////////////////////////////////////
//                                                       //
//                         SAGA                          //
//                                                       //
//      System for Automated Geoscientific Analyses      //
//                                                       //
//                    Module Library:                    //
//                          GR4J                         //
//                                                       //
//-------------------------------------------------------//
//                                                       //
//                    gr4j_sl_v1.h                       //
//                                                       //
//                 Copyright (C) 2007 by                 //
//                     Stefan Liersch                    //
//-------------------------------------------------------//
//                                                       //
//    e-mail:     stefan.liersch@ufz.de                  //
//                stliersch@freenet.de                   //
//                                                       //
//                     2007-03-07                        //
//                                                       //
///////////////////////////////////////////////////////////


//*******************************************************//
//                        ToDo                           //
//-------------------------------------------------------//
// - check valid parameter ranges in input dialog
// - In the current version, the user must prepare a time
//	 series table with following columns:
//	 - PCP in [mm],
//	 - ETp in [mm] / or temperature in [°C],
//	 - Q observed in [m3/s]
//   -> it should be possible in the next version to input
//		Q in [mm] as well
//*******************************************************//

//---------------------------------------------------------
#ifndef HEADER_INCLUDED__gr4j_sl_v1_H
#define HEADER_INCLUDED__gr4j_sl_v1_H

//---------------------------------------------------------
#include "MLB_Interface.h"
#include "gr4j.h"
#include "pet_sl.h"

#include <vector>   // used for storing date string values in array
using namespace std;

typedef std::vector<std::string> date_array;
typedef vector<double> vector_d;
//---------------------------------------------------------

class Cgr4j_v1 : public CSG_Module
{
public:

	// constructor
	Cgr4j_v1(void);

	// destructor
	virtual ~Cgr4j_v1(void);

protected:

	// execute module
	virtual bool		On_Execute			(void);

private:

	//---------------------------------------------------------------

	int					sizeAll; // number of values in selected period
	double*				temperature; // used if no ETp data are available

	// struct GR4J_Parameters defined in 'gr4j.h'
	GR4J_Parameters		X;
	// struct InputData defined in 'gr4j.h'
	InputData			Input;
	// Class Cgr4j containing GR4J equations
	Cgr4j				gr4j;
	CpET*				ETp;
	

	void				_CreateTableSim(CSG_Table *pTable,
										InputData& Input, double* Q_sim,
										double area);

	void				_CreateTableSettings(CSG_Table *pTable_Settings, GR4J_Parameters X, 
											 double NSE, double area, double latitude);
	//---------------------------------------------------------------------
	// Converting a date string 'YYYYMMDD' to three separate integer values
	void				_Get_Date_Int(string date, int &year, int &month, int &day);

	// Create the user dialogs
	void				_CreateDialog1();
	void				_CreateDialog2(CSG_Table* pTable, int dateField,
									   CSG_String& date1, CSG_String& date2,
									   int Choice_ETp_TMP, 
									   double& Latitude, double& area);

};

#endif /* __gr4j_sl_v1_H */