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 acrop_extentoralignthat 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
TorF.Lists are space-separated, e.g.
-95.0 -65.0 15.0 45.0.
topo.data¶
Header¶
99999.0 =: topo_missing # replace no_data_value in topofile
0 =: test_topography # (Type topography specification)
2 =: ntopofiles
topo_missingValue that replaces each file’s own
no_data_valueafter loading (default99999.0).test_topography0means use the files listed below.1to3select built-in analytic bathymetries, and no file blocks follow.ntopofilesNumber of file blocks that follow. A netCDF file whose crop crosses the antimeridian is written as two blocks (see
lon_wrap_offsetbelow), so this can be larger than the number of entries intopofiles.
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_pathAbsolute path to the file.
topo_typeFormat of the file:
2or3(ASCII),4(netCDF) or5(GeoTIFF); see Topography data. A negative value flips the sign of Z on load.crop_extentx1 x2 y1 y2, the region to keep, in domain coordinates (afterx_shift/y_shift), orNonefor the whole file.coarsenKeep every
coarsen-th point (1keeps all of them).bufferNumber of grid points kept outside
crop_extenton each side.alignx y, a point the coarsened grid passes through, orNoneto start the coarsened grid atcrop_extent.0.0 0.0is a real value here, a lattice through the origin, not “unset”.x_shift,y_shiftAdded to the file’s coordinates:
x_domain = x_file + x_shift.z_shiftAdded to every value that is not missing, after
negate_z.negate_zTflips the sign of every value, independently of a negativetopo_type.lon_wrap_offsetAdded to the file’s longitudes, for a netCDF file. It is
0.0unless the crop crosses the antimeridian: such a crop is written as two blocks for the same file, one with offset0.0and one with360.0or-360.0. For an ASCII file it must be0.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_nameNames of the elevation variable and of the x and y coordinate variables.
nc_unitsThe elevation variable’s
unitsattribute, exactly as it appeared whenmake dataran, orNoneif it had none. Fortran compares it with the file and stops if it has changed, sincenc_scale_factorwas 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_factorMultiplies the values to give meters:
1.0for a file in meters,1000.0for one in kilometers. Units are resolved once, in Python; Fortran only applies the factor. A file with nounitsis read as meters; see GeoClaw NetCDF Input System.nc_fill_value,nc_fill_actionThe file’s fill value (
Noneif 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_factorAs for topo, for the deformation variable.
nc_time_nameName of the time coordinate. Fortran reads the times from the file.
nc_time_unitsThe time variable’s
unitsattribute as it appeared atmake data(Noneif absent). As withnc_units, Fortran stops if it has changed.nc_time_scaleSeconds per unit of the time axis:
1.0for"seconds",3600.0for"hours since 2011-03-11 05:46:00".nc_time_offsetSeconds added to the scaled times, or
None. Fortran computes each time ast = 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 byDTopography.write()keeps its times. Such a file carries ageoclaw_time_referenceattribute 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_dtopoSee 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).