shakelib.utils.containers

class shakelib.utils.containers.ShakeMapInputContainer(hdfobj)[source]

Bases: impactutils.io.smcontainers.ShakeMapContainerBase

HDF container for Shakemap input data.

This class provides methods for getting and setting information on:
  • configuration

  • event (lat,lon,depth,etc.)

  • rupture

  • station data (can also be updated)

  • version history

Instantiate an HDFContainer from an open h5py File Object.

Parameters:

hdfobj – Open h5py File Object.

classmethod createFromInput(filename, config, eventfile, version_history, rupturefile=None, sourcefile=None, momentfile=None, datafiles=None)[source]

Instantiate an InputContainer from ShakeMap input data.

Parameters:
  • filename (str) – Path to HDF5 file that will be created to encapsulate all input data.

  • config (dict) – Dictionary containing all configuration information necessary for ShakeMap ground motion and other calculations.

  • eventfile (str) – Path to ShakeMap event.xml file.

  • rupturefile (str) – Path to ShakeMap rupture text or JSON file.

  • sourcefile (str) – Path to ShakeMap source.txt file.

  • momentfile (str) – Path to ShakeMap moment.xml file.

  • datafiles (list) – List of ShakeMap data (DYFI, strong motion) files.

  • version_history (dict) – Dictionary containing version history.

Returns:

Instance of InputContainer.

Return type:

InputContainer

setRupture(rupture)[source]

Store Rupture object in container.

Parameters:

rupture (dict or Rupture) – Rupture object (Point,Quad, or Edge) or dictionary representation of same.

Raises:

TypeError – If input object or dictionary does not represent a Rupture object.

getRuptureObject()[source]

Retrieve Rupture object from container.

Returns:

Instance of (one of) a Point/Quad/EdgeRupture class.

Return type:

Rupture

Raises:

AttributeError – If rupture object has not been set in the container.

setStationList(stationlist)[source]

Store StationList object in container.

Parameters:

stationlist (StationList) – StationList object.

Raises:

TypeError – If input object or dictionary is not a StationList object.

getStationList()[source]

Retrieve StationList object from container.

Returns:

StationList object.

Return type:

StationList

Raises:

AttributeError – If stationlist object has not been set in the container.

setStationData(datafiles)[source]

Insert observed ground motion data into the container.

Parameters:

datafiles (str) – Path to XML- or JSON-formatted files containing ground motion observations, (macroseismic or instrumented).

addStationData(datafiles)[source]

Add observed ground motion data into the container.

Parameters:

datafiles (sequence) – Sequence of paths to XML- and/or JSON-formatted files containing ground motion observations, (macroseismic or instrumented).

updateRupture(eventxml=None, rupturefile=None)[source]

Update rupture/origin information in container.

Parameters:
  • eventxml (str) – Path to event.xml file.

  • rupturefile (str) – Path to rupture file (JSON or txt format).