topo.data and dtopo.data File Formats

Note

topo.data and dtopo.data are written by make data, through TopographyData.write() and DTopoData.write(). They are not meant to be written by hand. Change setrun.py instead, and run make data again.

Overview

topo.data lists the topography grids of a run, and dtopo.data the moving-topography (dtopo) files. For each one it gives the file, its format, and the settings that turn the file into the grid GeoClaw loads: crop, coarsening, shifts and so on. The Fortran routines read_topo_settings and read_dtopo_settings in topo_module.f90 read them.

Every line that holds a value has the form:

value                =: key                  # optional comment

Fortran reads the value and then checks that the key is the one it expects at that point. A file from a different version of GeoClaw, with lines added, removed or reordered, therefore stops the run instead of being misread:

ERROR reading topo.data: expected the line for 'topo_path', found:
  '/path/to/topo.nc'   # topo_path
  The file was written by a different version of GeoClaw.
  Regenerate topo.data with 'make data'.

Blank lines and lines starting with # are skipped.

Values are written as follows:

  • Unset values are None, for example a crop_extent or align that was not given, or a netCDF file that declares no fill value.

  • Strings are quoted with single quotes; a quote inside a path is doubled. Paths containing spaces or commas are read correctly.

  • Logicals are T or F.

  • Lists are space-separated, e.g. -95.0 -65.0 15.0 45.0.

topo.data

Per-file block

One block per topography grid, in priority order: the last block has the highest priority (see Priority Convention). Every block has these 11 lines:

'/data/etopo.tt3'    =: topo_path
3                    =: topo_type
None                 =: crop_extent          # [x1 x2 y1 y2], domain coordinates
1                    =: coarsen
0                    =: buffer               # grid points
None                 =: align                # [x y]
0.0                  =: x_shift
0.0                  =: y_shift
0.0                  =: z_shift
F                    =: negate_z
0.0                  =: lon_wrap_offset
topo_path

Absolute path to the file.

topo_type

Format of the file: 2 or 3 (ASCII), 4 (netCDF) or 5 (GeoTIFF); see Topography data. A negative value flips the sign of Z on load.

crop_extent

x1 x2 y1 y2, the region to keep, in domain coordinates (after x_shift/y_shift), or None for the whole file.

coarsen

Keep every coarsen-th point (1 keeps all of them).

buffer

Number of grid points kept outside crop_extent on each side.

align

x y, a point the coarsened grid passes through, or None to start the coarsened grid at crop_extent. 0.0 0.0 is a real value here, a lattice through the origin, not “unset”.

x_shift, y_shift

Added to the file’s coordinates: x_domain = x_file + x_shift.

z_shift

Added to every value that is not missing, after negate_z.

negate_z

T flips the sign of every value, independently of a negative topo_type.

lon_wrap_offset

Added to the file’s longitudes, for a netCDF file. It is 0.0 unless the crop crosses the antimeridian: such a crop is written as two blocks for the same file, one with offset 0.0 and one with 360.0 or -360.0. For an ASCII file it must be 0.0.

These settings come from the TopoFile entry in setrun.py; see Topography file settings.

netCDF lines (topo_type = 4)

A netCDF block has 7 more lines, all prefixed nc_, written by make data after inspecting the file:

'elevation'          =: nc_var_name
'lon'                =: nc_x_name
'lat'                =: nc_y_name
'm'                  =: nc_units
1.0                  =: nc_scale_factor
None                 =: nc_fill_value
'abort'              =: nc_fill_action

They hold only names, unit conversions and choices about the run. Values taken from the file’s data, such as the grid spacing or the extent, stay in the file; Fortran reads them from it. Fortran also works out the order of the dimensions and the direction of the y axis from the file.

nc_var_name, nc_x_name, nc_y_name

Names of the elevation variable and of the x and y coordinate variables.

nc_units

The elevation variable’s units attribute, exactly as it appeared when make data ran, or None if it had none. Fortran compares it with the file and stops if it has changed, since nc_scale_factor was computed from it:

ERROR: /data/gebco.nc
  changed since make data: units of elevation are now 'cm', topo.data has 'm'
  Regenerate topo.data with 'make data'.
nc_scale_factor

Multiplies the values to give meters: 1.0 for a file in meters, 1000.0 for one in kilometers. Units are resolved once, in Python; Fortran only applies the factor. A file with no units is read as meters; see GeoClaw NetCDF Input System.

nc_fill_value, nc_fill_action

The file’s fill value (None if it declares none), and what to do if fill values fall inside the region loaded. For topography this is always 'abort': missing values inside the region stop the run.

dtopo.data

dtopo.data has the same notation:

2                    =: mdtopofiles

'/data/okada.dtt3'   =: dtopo_path
3                    =: dtopo_type
None                 =: crop_extent          # [x1 x2 y1 y2], domain coordinates
1                    =: coarsen
0                    =: buffer               # grid points
None                 =: align                # [x y]
0.0                  =: x_shift
0.0                  =: y_shift
0.0                  =: z_shift
F                    =: negate_z
0.0                  =: lon_wrap_offset

'/data/okada.nc'     =: dtopo_path
4                    =: dtopo_type
...                                          (the same 9 lines)
0.0                  =: lon_wrap_offset
'dz'                 =: nc_var_name
'lon'                =: nc_x_name
'lat'                =: nc_y_name
'time'               =: nc_time_name
'meters'             =: nc_units
1.0                  =: nc_scale_factor
'seconds'            =: nc_time_units
1.0                  =: nc_time_scale
None                 =: nc_time_offset

0.2                  =: dt_max_dtopo

The per-file lines mean the same as in topo.data. For dtopo, Fortran does not implement crop_extent, coarsen, buffer and align yet, so make data refuses a DTopoFile that sets them. x_shift, y_shift, z_shift and negate_z are applied.

netCDF lines (dtopo_type = 4)

nc_var_name, nc_x_name, nc_y_name, nc_units, nc_scale_factor

As for topo, for the deformation variable.

nc_time_name

Name of the time coordinate. Fortran reads the times from the file.

nc_time_units

The time variable’s units attribute as it appeared at make data (None if absent). As with nc_units, Fortran stops if it has changed.

nc_time_scale

Seconds per unit of the time axis: 1.0 for "seconds", 3600.0 for "hours since 2011-03-11 05:46:00".

nc_time_offset

Seconds added to the scaled times, or None. Fortran computes each time as t = nc_time_offset + nc_time_scale * time_in_file.

When nc_time_offset is None, Fortran decides when t = 0 from the file:

  • A duration axis ("seconds", "minutes", …) is used as written, as the times in an ASCII dtopo file are.

  • A dated axis ("<unit> since <date>") written by DTopography.write() keeps its times. Such a file carries a geoclaw_time_reference attribute on its time variable.

  • Any other dated axis starts at its first time.

To put t = 0 at a particular date instead, for example the origin time of an earthquake, set time_reference on the DTopoFile; make data then writes the matching nc_time_offset.

The times must be equally spaced; Fortran stops if they are not. For each file it logs the start time, end time and time step it read to fort.geo.

dt_max_dtopo

See dtopofiles.

1D

The 1D code uses the same notation for its own, shorter layout:

99999.0              =: topo_missing
0                    =: test_topography
1                    =: ntopofiles
F                    =: override_order
'celledges.data'     =: topo_path
1                    =: topo_type

It reads one file and has no per-file settings, so it does not check the keys.

Priority Convention

The last file block in topo.data has the highest priority where grids overlap. Fortran stores this as mtopoorder(i) = mtopofiles+1-i, so the last block gets rank 1.

make data sorts the files by cell area, coarsest first and finest last, before writing them, so the finest grid has the highest priority. This matches the traditional GeoClaw convention of listing files from coarsest to finest. To keep your own order instead, set rundata.topo_data.override_order = True; the last entry in topofiles then has the highest priority. See Topography file ordering.

override_order is used only by Python and is not written to the 2D topo.data.

Entries in setrun.py

The usual form is a TopoFile or DTopoFile, which carries the settings:

from clawpack.geoclaw.topotools import TopoFile

rundata.topo_data.topofiles.append(
    TopoFile('/path/to/topo.tt2', 2, crop_extent=[-100., -60., 10., 50.],
             coarsen=2))

The list form [topo_type, path] is still accepted and means TopoFile(path, topo_type):

rundata.topo_data.topofiles.append([2, '/path/to/topo.tt2'])

The older 6-element form [topo_type, minlevel, maxlevel, t1, t2, path] warns and ignores the level and time values. A Topography in topofiles raises TypeError: a Topography holds data, not the settings used to load it.

topo_type=1 (deprecated): type-1 files (x y z ASCII, one point per line) can still be read and written, with a DeprecationWarning, but the crop and shift settings raise NotImplementedError for them. To convert one:

t = Topography()
t.read('old_file.tt1', topo_type=1)   # DeprecationWarning
t.write('new_file.tt2', topo_type=2)

For scattered point data, grid it onto a regular grid first, with an external tool (scipy.interpolate, GMT) or with interp_unstructured() (see Python tools for working with topo and dtopo).