Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

CatchmentHandler.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 //
00003 //  Thomas Berger (main author), Pepijn Schreinemachers, and Thorsten Arnold
00004 //
00005 //
00006 //  Hohenheim University (490d)
00007 //  Professorship for Land Use Economics in the Tropics and Subtropics
00008 //
00009 //  May not be distributed without permission by main author
00010 //
00011 //  File:       CatchmentHandler.h (formerly subcatch.h, scuenca.h)
00012 //
00013 //  Contents:   Handles the hydrology-related aspects of the cellular component
00014 //
00015 //
00016 //
00017 //------------------------------------------------------------------------------
00018 
00019 
00020 //dies ist die header-Datei fuer ein Untereinzugsgebiet "subcuenca"
00021 
00022 #ifndef _CatchmentHandler_h
00023 #define _CatchmentHandler_h
00024 
00025 //#include "CatchmentSector.h"
00026 #include "CatchmentSectorAuxiliary.h"
00027 #include "MatrixDouble.h"
00028 #include "Raster2D.h"
00029 #include "BasicEnums.h"
00030 
00031 //New, for dynamic inflows
00032 // ( see: Landscape/src/master/testDynamicRiverFlows.cpp )
00033 #include"Catchment_DynamicRiverFlows.h"
00034 
00035 
00036 
00037 class CropPrecipitation;
00038 class CropWater;
00039 
00040 class TimeHandler;
00041 
00042 class scuenca
00043 {
00044         public:
00045    
00046    
00047    //---------------------------------------------------------------------------
00049 
00050 
00051    // --------------------------------------------------------------------------
00052    virtual void initializeNetInflowsInYear(const MatrixDouble& inflows);
00053    virtual void rememberTypicalNetInflowsInYear(const MatrixDouble& inflows);
00054    virtual void reinitWithTypicalNetInflows();
00055    // see explaination in *.cpp
00056    virtual void makeForecastForNetInflows(int yr_, double forecastError );
00057    
00058         virtual void setInflows(int mTot, MatrixDouble& infl);
00059         virtual bool setOneInflow(int mTot, int inflowID, double flowVal_m3PerSec);
00060 
00061    virtual string getName();//           {  return name;}
00062    virtual int getCatchID()           {  return sc_nummer;}
00063    virtual int getCatchmentID()           {  return sc_nummer;}
00064    virtual int getSubcatchID() const  {  return sc_nummer;};//returns subcatchment ID
00065    virtual int get_sectorsInCuenca(void) {return numberOfActualSectors;};
00066 
00067 
00069 //      virtual double get_b_j(int);//ermittelt b_j fuer einen Sektor
00070 //      virtual double get_g_j(int);//ermittelt g_j fuer einen Sektor
00071         virtual double get_Ext(int);//ermittelt ext fuer einen Sektor
00072    virtual double get_monatl_N(int, int);//ermittelt monatl. Wasser fuer Zufluss
00073    
00074    virtual void addTo_totalMonthlyIrr(int month_, int secID_, double irrAmountSector_);//ermittelt monatl. Wasser fuer Zufluss
00075    virtual double get_totalMonthlyIrr(int month_, int secID_);//ermittelt monatl. Wasser fuer Zufluss
00076    virtual double get_totalMonthlyIrr_sum(int month_);//ermittelt monatl. Wasser fuer Zufluss
00077    
00078    // Collects total water demand in all sectors belonging to catchment
00079    virtual double getGlobalWaterDemand();
00080 
00082    //---------------------------------------------------------------------------
00084 
00085    void addOneToSectorsInSubcatchment(); // when constructing sectors
00086    virtual void initRoutingEmpty(void);
00087 
00088    virtual void readSectorMapFromFile(string fn);      
00089 
00090 
00091 
00092    // Creates raster files in ASCII-Format, readable by GIS
00093    virtual void readAndExtractSectorMapsFromCatchMaps();      
00094 
00095         // More general, used for coupling. 
00096    // Here, a switch is used that determines if data is 
00097    // (a) copied only to sector-level, as mean value; or 
00098    // (b) copied to cell, with "copyRaster2Cell"
00099    virtual void copyRaster2Landscape(Raster2D& catchmentMap, Content cont);
00100    // ... copies to sector, where it is determined if content is stored at cell or at sector level
00101    virtual void copyRaster2Landscape(Raster2D& catchmentMap, Content cont, bool flag_fixCopyToCell);
00102 
00103 
00104    virtual void makeSectorwiseHistogram(MatrixDouble& histogramBySector, Content cont);      
00106         //---------------------------------------------------------------------------
00107 
00109 
00110    // --------------------------------------------------------------------------
00112    // --------------------------------------------------------------------------
00113    void initializeEmpty(void);
00114 //      virtual void EDIC_readFudgeFactors();
00115    virtual void EDIC_readSurfaceAndSubsurfaceRunoffMatrix();
00116    virtual void readparamsIrrigationMethodAndAssignToSectors();
00117    virtual void initializeCropPointersInSectors(CropPrecipitation* p_cropPrecipitation, CropWater* p_cropWat_);
00118 
00119    // --------------------------------------------------------------------------
00121    // --------------------------------------------------------------------------
00122         //diese Funktionen machen Eintraege in den jeweiligen Matrizen fuer einzelne
00123         //Sektoren (Uebergabeparameter: Sektornr., Wert)
00124    virtual void make_derr(int, double);
00125         virtual void make_esc(int, double);
00126 
00127    // Resets Edic routing model
00128    // - Surface return flows
00129    // - Lateral return flows
00130    // - irrigation water accounting
00131    virtual void resetEdicMonthlyReturnFlowData();
00132    virtual void resetEdicAnnualData();
00133 
00134         double return_delta(int sectorIndex);
00135         double return_e(int sectorIndex);
00136 
00137    // If dynamic inflows, then these functions pass information through to class DynamicRiverFlows DynamicFlows;
00138    bool IS_DYNAMIC_INFLOWS() { return isDynamicRiverFlow;};
00139 
00140    // Access
00141    double getFlowForRiverAndYearAndMonth(int riverID_, int y_, int m_, bool isNorthern_);
00142    virtual void setFlowForRiverAndYearAndMonth(int riverID, int yearID, int modelMonth, int valFlowM3);
00143    virtual void setRiver_fullYear(int riverID, int yearID, MatrixDouble& vectorThisYearFlows);
00144 
00145    // Update catchment-N by copying monthly inflows from catchment-DynamicRiverFlows
00146    // ... This is done in the beginning of each month,
00147    // ... if there is true == sub[sc]->IS_DYNAMIC_INFLOWS()
00148    virtual void updateAllInflowsForCurrentMonth(TimeHandler& timeHandle_const);
00149 
00150    // read and write
00151    virtual void read_DynamicRiverFlows(string fn);
00152    virtual void writeDynamicInflowsToFile(string fn);
00154 
00155         //---------------------------------------------------------------------------
00156 
00157 
00159 
00160       virtual void joinCatchmentMap(Content cont, Raster2D& gisFull);
00161       virtual void joinCatchmentMap(Content cont, Raster2D& gisFull, int monthIndex, bool flag_forceToCell);
00162 
00163       virtual void writeToFile_SektorMaps(Content cont);
00164       virtual void writeToFile_SektorMaps_monthly(Content cont, int m);
00165 
00166       virtual void writeInputToFile(char*);
00167 
00169                 virtual void printToScreen(void);
00170       virtual void printEffectiveRouting();
00171       virtual void writeToFileEffectiveRouting();
00172       virtual void printToScreen_allSectors();
00173       virtual void printToScreen_Edic();
00174                 virtual void printOnScreen_MatrixSize(void);
00175       virtual void printInflows();
00177 
00178         //---------------------------------------------------------------------------
00180 
00181 
00182         scuenca(void);
00183    scuenca(int sc);
00184 
00186         virtual ~scuenca ();
00187 
00189 
00190 //---------------------------------------------------------------------------
00191 protected:
00192 //---------------------------------------------------------------------------
00193 
00194 // Moved from global to local. 
00195    // Contains map of all sectors; used to dissect maps and pass them to sector->landscape 
00196    Raster2D gisKey;
00197    
00198    
00199         int sc_nummer;          //Nummer des Untereinzugsgebiets
00200 
00201 
00202         //int NUMINFLOWS;       //Anzahl der Wasservorkommen , noch global
00203    double b_faktor;     //Faktoren zur Aggregation von Sektoren
00204    double g_faktor;
00205 
00206    // Now instead of NUM_SECTORS()
00207         int numberOfActualSectors;    //Anzahl der dazugehoerenden Sektoren
00208                                  // used to be called sek_anzahl
00209 
00210         //enum {MAXELEMS = 1};//Maximum moeglicher Elemente
00211         unsigned num;           //Anzahl der bereits eingetragenen Elemente
00212 
00213         MatrixDouble b_j;       //diese Daten werden in folgende Matrizen
00214         MatrixDouble g_j;       //geschrieben
00215         MatrixDouble d_jk;
00216         MatrixDouble e_jk;
00217 
00218    // For simpler information handling
00219    MatrixDouble totalSectorIrrig;   // dim (sectors X months)
00220    MatrixDouble sumByMonth_Irrig;  // dim (1 X months)
00221 
00222    // Auxiliary Class with irrigation technology parameters
00223    IrrigationMethod paramsIrrigationMethod;
00224 
00225 
00226    //Matrix aller Wasservorkommen
00227    // ... in liter/sec
00228         MatrixDouble N; //Dimension: ( inflows  X  (months+1) )
00229    // ... in m3/sec, same as raw data!
00230    MatrixDouble N_typical_m3Sec; //Dimension: ( inflows  X  (months+1) )
00231 
00232    /* TODO 2 -oArnold -cImplement : Inflows should be defined by catchment, not globally */
00233    // ------------------------------
00234    //      ABOUT INFLOWS
00235    // ------------------------------
00236    //   int NUMINFLOWS;//Anzahl der Wasservorkommen
00237    //
00238    // Now: each inflow also has a name, and an ID.
00239    // These values are stored in BasicData.cpp, and accessible via
00240    //    string INFLOWNAME_val(int val);
00241    //    string INFLOWNAME_pos(int pos);
00242    //    int INFLOWVAL_pos(int pos);
00243    //    void setNUMINFLOWS(int numInflows);
00244    //    int NUMINFLOWS(void);
00245    //    readInflowKey( ABSTRFILE_fn() );
00246    //    ABSTRFILE_fn() is read from file: "AllDefaults.txt"
00247 
00248         MatrixDouble Derr;      //Matrizen werden sukzessive mit Informationen
00249         MatrixDouble Esc;                       //aus den Sektoren aufgefuellt
00250 
00251       //
00252    bool isDynamicRiverFlow;
00253    DynamicRiverFlows DynamicFlows;
00254 
00255 
00256    virtual void speicher_freigeben(void);
00257 
00258 };
00259 
00260 
00261 #endif
00262 

Generated on Thu Aug 28 12:38:44 2008 for MPMAS by  doxygen 1.3.9.1