Typical usage of digger.analyze

Typical usage of digger.analyze functions is provided within the context of an example landslide-tsunami simulation.

All of the code is extracted from the file digger/examples/post-run/barry_arm/setpostprocess.py.

In addition to highighting the functionality of digger.analyze, this file includes some common postprocessing steps using tools from digger.utils. These are briefly described here.

Geospatial file conversion

D-Claw generates files in a very specific format and it may be useful to convert these 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()