Typical usage of digger.utils

The input and output files for D-Claw are in very specific formats. The functions found in digger.utils help support the creation and modification of these files. Functions like digger.utils.biplanar and digger.utils.logspiral are used by digger.make to create hypothetical post-failure surfaces. Some common D-Claw output postprocessing is described below.

Geospatial file conversion

It may be useful to convert D-Claw ouput into files usable by typical GIS programs. The function digger.utils.fgtools.fg2raster converts a single element of q stored in a fixed grid file into a geotif. It relies on the clawpack fixed grid backends and can either convert a fgout-style file or a fgmax-style file.

Additionally, digger.utils.fgtools.fg2shp will contour a single element of q and provide a PolyLine-type shapefile containing these contours.

# Convert a file to geotif
# This can either be a fgmax or fgout file type.
import numpy as np

from digger.utils.fgtools import fg2raster, fg2shp

fg2raster(
    filein="_output/fgmax0001.txt",
    fileout="fgmax-eta_max.tif",
    varname="eta_max",
    epsg=26906,
    fgtype="fgmax",
)

fg2raster(
    filein="_output/fgout0001.b0061",
    fileout="fgout-h0061.tif",
    varname="h",
    epsg=26906,
    fgtype="fgout",
)

# create a shapefile
fg2shp(
    filein="_output/fgmax0001.txt",
    fileout="arrival-time.shp.zip",
    varname="arrival_time",
    contours=np.arange(0, 300, 10),
    epsg=26906,
    fgtype="fgmax",
)

Construction of a dtopo file

Sometimes one might want to convert the results of one simulation into a topography displacement file for use in a second simulation. Digger provides a function for this purpose, digger.utils.nc2dtopo

# Convert to a topography displacement file
from digger.utils import nc2dtopo

nc2dtopo()