ts2oh Uitilty


ts2oh reads a PRDUTIL tsdata report and writes OH DATACARD time series. ts2oh can also read prior-date OH DATACARD time series, merge the data with a PRDUTIL report, and write updated OH DATACARD time series.

Note: make sure the datacard files that you want to merge with a PRDUTIL report are in the same directory as the ts2oh program. There is no limit to the number of stations and data types in the PRDUTIL report. Each reported station-type can contain up to 500,000 values.

The format of the output datacard file name will be: STATIONID.DATATYPE.YYYYMMDD.YYYYMMDD.datacard (example: ADAM4.STG.19960401.19960508.datacard) The dates will reflect the period of record in the file. The .datacard extension is necessary. When merging, ts2oh first examines the station-types it finds in the PRDUTIL report. Then it looks in the current directory for a corresponding datacard file. The directory can contain any number of files, but if it contains more than one datacard file of the SAME station-type combination, ts2oh will halt with an error message. In other words, for any one invocation of ts2oh, the station-types must be unique in the report and in the directory of files to be merged. They don't all have to match, however.

If a station-type is in the PRDUTIL report but does not exist in the directory of to-be merged files, a new station-type datacard file will be created. If a station-type is a datacard file for merge input but no matching station-type is in the PRDUTIL report, a message will be generated and the file will be copied to outdir to be with the other normal output. During the merge phase, new time series data values from the PRDUTIL report will replace time-matching old datacard data values EXCEPT WHEN the new PRDUTIL data is a **NONE** value (-999) at the beginning of the report.

ts2oh will produce new datacard files and place them in a subdirectory called outdir. Between each cycle, manually review and rotate the datacard files from the outdir directory to the current directory.

To get started, place the ts2oh executable and prdutil reports in an empty directory. Use the name of a prdutil tsdata report as a command argument. EXAMPLE command sequence:
ts2oh cycle1.txt (initial cycle)
mv ./outdir/*.datacard . (move output so that ts2oh can use it as input)
ts2oh cycle2.txt (next cycle merges)
rm *.datacard (remove input datacards just used)
mv ./outdir/*.datacard . (move output so that ts2oh can use it as input)
ts2oh cycle3.txt (repetez...)
rm *.datacard
mv ./outdir/*.datacard .

Messages are written to standard output. Use the > character to direct them to a file if necessary. ts2oh places the day of the month in the datacard format column that is normally used for the card sequence number. It is checked on input. Future data is ignored. Notice that since you provide the name of the PRDUTIL report as a command argument, more than one report can be in the input directory. ts2oh reads and writes one-column formatted datacards. Long station IDs are truncated to 10 chars. Precision will be taken from the PRDUTIL report, not the old datacards, and will end up as F9.something. Precision more than 6 decimal places is ignored. During a merge, the timestep of the station-type must match. ts2oh returns 0 on a normal exit and -1 on an exit taken by an error. Stdout messages always preceed error exits. If ts2oh halts on an error, all output files from that instance should be thrown out. In this early version, ts2oh determines dimension (L or L3) simply by looking at the first character of the TYPE= in the TSDATA report. If it's a C, the ts2oh takes it to mean the dimension is cubic.

Y2K Note: If you use 1900s data and 2000s data in the same file, make sure the minimum difference between the two last two digits of the centuries' year is 40 years. For example: >=1940 & >=2000 is OK, but <=1939 & >=2000 is not. jerryG, 11/02/99


History of Changes

VersionDescription of Changes
Version 1.1a Process a one hour timestep.
Version 1.2 During a merge, retain old values until the **NONE** values in the new report have expired, i.e., when significant values start. If **NONE** values reappear at a later date or if there is nothing to merge with, set **NONE** to missing (-999).
Version 1.2a Corrected rare but erroneous addition of .001 to values during merge caused by need for housekeeping.
Version 1.2b Better implementation of temporary file name.
Version 1.2c Shifted printing of value one column to the left.
Version 1.4 Fixed Y2K bugs.
Version 1.5 Added 24-hour time-step.
Version 1.6 Now able to cycle large numbers of datacard files.
Version 1.7 Added 12-hour time-step.
Version 1.8 The output filename was incorrect date in filename and inserting data incorrectly in the appending process. The problems were in the Y2K code. ABRFC fixed the problems.
Version1.9 Ignore version number in the prdutil header.

HSDB Calibration Software and Utilites


Mail problems, comments
or suggests to

Webmaster
Page Updated: May 14, 2003