Bay-Delta SELFE Tools

Table Of Contents

Previous topic

Working with SMS

Next topic

Assigning bathymetry

Model time conversion

The SELFE *.th file has two flavors, binary and text. Both are multicolumn formats, with elapsed time in seconds in the left column since the start of the simulation and the other columns representing values. There is no datum within the file to link elapsed time to calendar or geophysical time, and it is hard to search for events, re-use the *.th file with a different start date or make sense of orphaned files.

The model_time.py script is a utility that performs conversions between geophysical and elapsed times.

model_time.py

Interpret model times in elapsed seconds and translate between calendar time and elapsed. The script requires a subcommand like: $ model_time.py to_elapsed. You can also get subject-specific help on a subcommand by typing $ model_time.py subcommand –help

usage: model_time.py [-h] {to_elapsed,to_date,clip} ...
Sub-commands:
to_elapsed

Convert input datetime string or *.th file with datetime column to equivalent output in elapsed seconds.

usage: model_time.py to_elapsed [-h] [--start START] [--annotate]
                                [--step [STEP]] [--out OUT]
                                dated_input [dated_input ...]
Positional arguments:
dated_input One or more dates to be converted in ISO-like format 2009-03-12T00:00:00 (time can be ommitted) or the name of a *.th file with the time column in this format.
Options:
--start Starting date and time basis for output if the input is a file. Allows a larger database with readable times to be clipped
--annotate=False
 Undocumented
--step Model time step. If given, answer will be the integer time step.
--out Name of output file. If input is a *.th file the file will be converted and output to this file, otherwise printed to screen
to_date

Convert input elapsed seconds or *.th file with elapsed seconds as the time column to equivalent output with a datetime or annotated with datetimes.

usage: model_time.py to_date [-h] --start START [--step [STEP]] [--annotate]
                             [--out OUT]
                             elapsed_input [elapsed_input ...]
Positional arguments:
elapsed_input One or more numbers representing elapsed seconds since the start argument or the name of a *.th file with the time column in elapsed seconds.
Options:
--start Start time in ISO-like format 2009-03-12T00:00:00. Time part is optional.
--step Model time step. If given, answer will be the integer time step.
--annotate=False
 Undocumented
--out Name of output file. If input is a *.th file the file will be converted and output to this file, otherwise printed to screen
clip

Clip (subset) an input file in elapsed time to a new, later, start date

usage: model_time.py clip [-h] --start START --clip_start CLIP_START
                          [--out OUT]
                          elapsed_input [elapsed_input ...]
Positional arguments:
elapsed_input One or more numbers representing elapsed seconds since the start argument or the name of a *.th file with the time column in elapsed seconds.
Options:
--start Start time in ISO-like format 2009-03-12T00:00:00. Time part is optional.
--clip_start Starting date for output.
--out Name of output file. If input is a *.th file the file will be converted and output to this file, otherwise printed to screen