TUFLOW Viewer - Isodate (Date-Time) Format

From Tuflow
Jump to navigation Jump to search

Tool Description

This page describes how to use date-time format when using QGIS 3.16 or later. Prior versions of QGIS are not recommended for Isodate (Date-Time) format.
Be aware that all layers have individual reference times and may misalign if one is updated and the others are not (e.g. the map outputs are updated, but not the time series outputs).

Date-time can be toggled on by toggling Show as dates below the plot toolbar.
DateTime Show As Dates cb.PNG

This will toggle the time format in the time box from relative time (hh:mm:ss) to absolute time (dd/mm/yyyy hh:mm:ss). The plot will not always update and may require refresh plot Refreshplotblack.png to be clicked before updating the x-axis of the time series plot. After toggling on Show as dates, refer to the following sections for specific information and examples relating to Map Output Results, Time Series Results, Particle Tracking Results and Imported Data (not model results).

Map Ouptuts

For QGIS v3.16+, the reference time for map outputs is controlled natively in the layer's Properties. For TUFLOW Classic and HPC simulation results, this will most likely default to 1999-12-31 14:00:00. TUFLOW FV outputs can contain a reference time specified in the .fvc file and may be correctly set on load.
DateTime Mesh Temporal Properties.PNG

The Zero Date option in Settings >> Options >> Plotting controls the relative time. Consequencely this value has no effect on the date-time displayed in the time box or plot window if Show as dates is toggled on. If Show as dates is toggled off and the Zero Time and the Reference Time are not aligned, then you may find that the relative time in the time box is offset by some value (the results should still work completely fine).
DateTime ZeroDate.PNG

Be aware that all layers have individual reference times and may start mis-aligning if one is updated and the others are not (e.g. the map outputs are updated, but not the time series outputs). Please see relevant links at the bottom of the page on how to work with date-time format with other outputs.

Switching on Date-Time and Changing the Reference Time
DateTime Map Outputs Changing RT Example.gif

Fixing the Relative Time
DateTime Map Outputs Fixing RelTime Example.gif

Time Series Outputs

The Zero Date option in Settings >> Options >> Plotting controls the relative time. Consequencely this value has no effect on the date-time displayed in the time box or plot window if Show as dates is toggled on. If Show as dates is toggled off and the Zero Time and the Reference Time are not aligned, then you may find that the relative time in the time box is offset by some value (the results should still work completely fine).
DateTime ZeroDate.PNG

Once Time Series Outputs have been loaded, it is not currently possible to change the reference time. To set the reference time, this must be done prior to loading the results into TUFLOW Viewer. This can be done either by:

  • Setting Zero Date in Settings >> Options >> Plotting prior to loading the results as this will be used in-lieu of any inherent reference time contained in the results
  • Users can add the following reference time line to the tpc file to set the reference time for the results:
Reference Time == YYYY-MM-DD hh:mm:ss

Note: the date format doesn't have to use this exact form. Other conventions (eg. U.S. convention) can be used.

Turning on Date-Time Format
DateTime TimeSeries Outputs Example.gif

Changing Reference Time
DateTime TimeSeries Outputs Changing RT Example.gif

Particle Tracking Output

The Zero Date option in Settings >> Options >> Plotting controls the relative time. Consequencely this value has no effect on the date-time displayed in the time box or plot window if Show as dates is toggled on. If Show as dates is toggled off and the Zero Time and the Reference Time are not aligned, then you may find that the relative time in the time box is offset by some value (the results should still work completely fine).
DateTime ZeroDate.PNG

Once Particle Tracking Outputs have been loaded, it is not currently possible to change the reference time. Particle results may inherently have a reference time and if this is the case, it is not possible to change unless the user updates this directly in the netCDF file (e.g. either by using Matlab or Python - example presented below using Python). If the particle results do not have a reference time, then it is possible to change the reference time by changing Zero Date in Settings >> Options >> Plotting prior to loading the results. The Zero Date will be adopted in-lieu of any reference time contained in the results.

DateTime Particles Example.gif

Example Python Code to Add or Modify the Reference Time This can be done in QGIS using the Python Console.
Toolbar Python Console.PNG

from netCDF4 import Dataset


ptm = r"C:\TUFLOW\results\particle_output_ptm.nc"  #  Path to particle output netcdf file

# open netcdf file and change the 'long_name' of the Time variable
nc = Dataset(ptm, "r+")
nc['Time'].long_name = "output time from 01/01/2000 00:00:00"  # dd/mm/yyyy hh:mm:ss - if removing reference time, use 'output time' and omit the date string
nc.close()

Imported Data (Not Model Results)

If the user data is imported with dates, then these will be adopted for use when date-time format is used. If dates are not imported with the data then the reference time will be dynamic and be adopted from Settings >> Options >> Plotting >> Zero Date.

DateTime ZeroDate.PNG
Note: Unlike imported model results, relative time is locked on import. So even if the import includes dates, the relative time will not dynamically update if the Zero Date is changed.

DateTime User Data Example.gif

Up
Go-up.png Back to TUFLOW Viewer Main Page