Creating Observation Files using TextPad (05/29/09)

CRHM Platform

Creating Observation Files using TextPad.

Climatic data for driving CRHM comes from many sources and in many different formats.   However, it is usually possible to put the data into columns and then the following procedure using CRHM and TextPad can be used to generate a CRHM observation file.

Steps.

  1. Create dates - Use the project file "Make_Dates.prj".  The first part of this project is listed below.

Description - Make_Dates.prj to create obs file

###### Version: CRHM 3.04 Creation: 05/14/09 14:09

Dimensions:

######

nhru 1

nlay 1

nobs 1

######

Macros:

######

######

Observations:

######

######

Dates:

######

1979 1 1 1

1985 10 5

######

Modules:
... etc.

Under field "Dates: "

    Edit the start date and end date to the required range. The format is YYYY MM DD and for the start date there is the additional field FREQ,  where FREQ is the number of intervals in the day, e.g. Daily - 1, Hourly - 24, etc.

  1. Run this project in CHRM. Then export RUN_ID as either an "Observation" or "Excel" file.  The former is more convenient as the dates are in a readable format.

Observation format.

run_ID(1) 1

######

1979 1 1 0 0 1

1979 1 2 0 0 1

1979 1 3 0 0 1

Excel format.

run_ID(1) 1

######

29856 1

29857 1

29858 1

Adding Data Header and Columns.

    Data can be prepared using Excel and exported as a text tab deliminated file or in TextPad.  TextPad is a text editor with the additional feature that its "Block Select Mode" allows for column editing.  For column editing,  tabs instead of spaces makes it possible to align the columns.

    Fortunately, TextPad has the "Regular expression" feature option when searching and replacing which allows the user to do "intelligent" find/replaces.  If a file has used spaces between columns they can be changed to tabs by enabling "Regular expression" and applying:- "Find what: [space\t]+      Replace with: \t".  Now it is only necessary to change the tab size in order to accommodate wider columns.

    It is best to handle the data columns first and add the header portion of the file last. When pasting data into the Dates.obs file transfer columns containing dates and times and use them to compare with  with the CRHM dates to detect any errors, missing data, incorrect intervals etc. After thorough checking, delete these extra columns.  There should be no extra spaces or tabs at the end of lines or at the end of the file.

    The file dates.prj has a variable run_ID(1).  Its header and data column should be deleted.

    The header should be added with TextPad with the "Block Select Mode" deselected.  The "####" symbols separate the header and data portions of the file.

    The first line must be present and is not used by CHRM.  It can be used by the user to comment the file.

    Every column of data requires a line specifying the name to appear in CRHM, # of columns (normally 1), units enclosed in brackets,  followed by an optional comment.  One or more spaces separates the fields.

    After these lines filters may be added.

Testing.

    The file is tested by loading into CRHM.  CRHM will find most errors and suggest solutions.  Depending upon the error, it may be necessary to close CRHM before testing the corrections.

Notes.

  1. Use only full days. A day starts ONE interval after midnight and ends at midnight. E.g. "1979 1 1 1 30" to  "1979 1 2  0 0" (or  "1979 1   1 24 0") where format is "YYYY MM DD hh mm".
  2. Dates must be sequential with NO gaps.
  3. Missing data fields must have a place holder, e.g. -9999 etc.
  4.