data_observations_File_Types (09/26/05)

CRHM Platform

Observation File Types.

  1. First file - the first observation file loaded in the project.  It determines the model operating time step interval and also the maximum model run time period.
  2. Interval file - any subsequent continuous observation file with a time interval less or equal to one day.
  3. Short interval time - any subsequent interval time which begins earlier or ends later than the first interval file.

First files , interval files and short interval files cannot have any missing data and must be contiguous.  First files and interval files are the easiest to use for modeling as the data set is complete and no status checking is required to handle missing data.  Note that in the preparation of these files the editor may have used interpolation or some other method to generate missing values to make them complete over the desired time period.

  1. Sparse file - an observation file with an interval data of greater than daily or non continuous data.

Sparse files of any time step when accessed by a model module require status checking and programming to handle the periods when no data is available.  The following example demonstrates how to handle intervals with missing data.  Note that the special values for double xLimit and for long lLimit declared in common.h,  are used to indicate undefined values and these values are not plotted by CRHM.

 

class ClassSparse : public ClassModule {

public:

ClassSparse(string Name = "Sparse", String Version = "undefined") : ClassModule(Name, Version){};

long nhru;

// declared variables

float *Ourt; // °C

float *Ourtshort; // °C

float *Ourt2; // °C

float *Ourt2mean;// °C

float *OurD1; //

float *OurD1s; //

float *OurD2; //

float *OurS1; //

float *OurS2; //

// declared parameters

// declared observations

const float *t;

const float *tshort;

const float *t2;

const float *S1;

const float *S2;

const float *D1;

const float *D1s;

const float *D2;

// declared observation function.

const float *t2mean;

// Handles

ClassVar *tHand;

ClassVar *tshortHand;

ClassVar *t2Hand;

ClassVar *D1Hand;

ClassVar *D1sHand;

ClassVar *D2Hand;

ClassVar *S1Hand;

ClassVar *S2Hand;

// Routines

void decl(void);

void init(void);

void run(void);

};

void ClassSparse::decl(void) {

declvar("Ourt", NHRU, "t", "()", &Ourt);

declvar("Ourtshort", NHRU, "tshort", "()", &Ourtshort);

declvar("Ourt2", NHRU, "t2", "()", &Ourt2);

declvar("Ourt2mean", NHRU, "t2mean", "()", &Ourt2mean);

declvar("OurD1", NHRU, "D1", "()", &OurD1);

declvar("OurD1s", NHRU, "D1s", "()", &OurD1s);

declvar("OurD2", NHRU, "D2", "()", &OurD2);

declvar("OurS1", NHRU, "S1", "()", &OurS1);

declvar("OurS2", NHRU, "S2", "()", &OurS2);

 

tHand = declreadobs("t", NOBS, "t", "()", &t);

tshortHand = declreadobs("tshort", NOBS, "tshort", "()", &tshort);

t2Hand = declreadobs("t2", NOBS, "t2", "()", &t2);

D1Hand = declreadobs("D1", NOBS, "?", "(?)", &D1);

D1sHand = declreadobs("D1s", NOBS, "?", "(?)", &D1s);

D2Hand = declreadobs("D2", NOBS, "?", "(?)", &D2);

S1Hand = declreadobs("S1", NOBS, "?", "(?)", &S1);

S2Hand = declreadobs("S2", NOBS, "?", "(?)", &S2);

 

declobsfunc("t2", "t2mean", &t2mean, AVG);

}

void ClassSparse::init(void) {

nhru = getdim(NHRU);

}

void ClassSparse::run(void) {

for(int hh = 0; hh < nhru; ++hh) {

Ourt[hh] = t[0];

 

if(tshortHand->FileData->GoodInterval)

    Ourtshort[hh] = tshort[0];

else

    Ourtshort[hh] = xLimit;

 

if(t2Hand->FileData->GoodInterval)

    Ourt2[hh] = t2[0];

else

    Ourt2[hh] = xLimit;

 

 

Ourt2mean[hh] = t2mean[0];

 

if(D1Hand->FileData->GoodInterval)

    OurD1[hh] = D1[0];

else

    OurD1[hh] = xLimit;

 

if(D1sHand->FileData->GoodInterval)

    OurD1s[hh] = D1s[0];

else

    OurD1s[hh] = xLimit;

 

if(D2Hand->FileData->GoodInterval)

    OurD2[hh] = D2[0];

else

    OurD2[hh] = xLimit;

 

if(S1Hand->FileData->GoodInterval)

    OurS1[hh] = S1[0];

else

    OurS1[hh] = xLimit;

 

if(S2Hand->FileData->GoodInterval)

    OurS2[hh] = S2[0];

else

    OurS2[hh] = xLimit;

}

}

Sample program report.

CURRENT TIME: 5/6/03 10:30

CRHM Version: NON-DLL 5.04

PROJECT FILE NAME:

TestFiles.prj dated 4/29/03 15:06

DIMENSIONS:

nhru 1

nlay 1

nobs 1

OBSERVATIONS:

C:\CRHM\TestFirstFile.obs ( 4/11/98 01:00 - 6/1/98 00:00 Interval = 01:00 )

C:\CRHM\TestDaily.obs ( 4/12/98 00:00 - 6/1/98 00:00 Interval = daily )

C:\CRHM\TestDaily2.obs ( 4/13/98 00:00 - 6/1/98 00:00 Interval = sparse data file )

C:\CRHM\TestSparse.obs ( 4/28/98 12:00 - 5/30/98 12:00 Interval = sparse data file )

C:\CRHM\TestDailyShort.obs ( 4/15/98 00:00 - 4/30/98 00:00 Interval = daily )

C:\CRHM\TestFirst2.obs ( 4/11/98 02:00 - 6/1/98 00:00 Interval = 02:00 )

C:\CRHM\TestFirstFileShort.obs ( 4/12/98 17:00 - 4/29/98 07:00 Interval = 01:00 )

MODULES:

Sparse CRHM basic 05/02/03

DATES:

1998 4 11

1998 6 1

PARAMETERS:

INITIAL STATE:

Description of observation files to run sample program.

  • TestFirstfile.obs - hourly time step supplying t.
  • TestFirst2.obs - every second temperature from TestFirstfile.obs.
  • TestFirstFileShort.obs - middle time period of  TestFirstfile.obs with temperature variable called tshort.
  • TestDaily.obs - daily observations D1.
  • TestDailyShort.obs - same as TestDaily.obs
  • TestDaily2.obs - every second daily observations from TestDaily.obs and called D2
  • TestSparse.obs -sparse observations S1 and S2.