shakelib.sites

class shakelib.sites.Sites(vs30grid, vs30measured_grid=None, backarc=None, defaultVs30=686.0)[source]

Bases: object

An object to encapsulate information used to generate a GEM SitesContext.

Construct a Sites object.

Parameters:
  • vs30grid – MapIO Grid2D object containing Vs30 values.

  • vs30measured_grid – Boolean array indicating whether Vs30 values were measured or derived (i.e., from topographic slope).

  • backarc – Boolean array indicating whether site is in the subduction backarc.

  • defaultVs30 – Default Vs30 value to use in locations where Vs30Grid is not specified.

classmethod fromBounds(xmin, xmax, ymin, ymax, dx, dy, defaultVs30=686.0, vs30File=None, vs30measured_grid=None, backarc=None, padding=False, resample=False)[source]

Create a Sites object by defining a center point, resolution, extent, and Vs30 values.

Parameters:
  • xmin – X coordinate of left edge of bounds.

  • xmax – X coordinate of right edge of bounds.

  • ymin – Y coordinate of bottom edge of bounds.

  • ymax – Y coordinate of top edge of bounds.

  • dx – Resolution of desired grid in X direction.

  • dy – Resolution of desired grid in Y direction.

  • defaultVs30 – Default Vs30 value to use if vs30File not specified.

  • vs30File – Name of GMT or GDAL format grid file containing Vs30 values.

  • vs30measured_grid – Boolean grid indicating whether Vs30 values were measured or derived (i.e., from slope).

  • backarc – Boolean array indicating whether site is in the subduction backarc.

  • padding – Boolean indicating whether or not to pad resulting Vs30 grid out to edges of input bounds. If False, grid will be clipped to the extent of the input file.

  • resample – Boolean indicating whether or not the grid should be resampled.

classmethod fromCenter(cx, cy, xspan, yspan, dx, dy, defaultVs30=686.0, vs30File=None, vs30measured_grid=None, backarc=None, padding=False, resample=False)[source]

Create a Sites object by defining a center point, resolution, extent, and Vs30 values.

Parameters:
  • cx – X coordinate of desired center point.

  • cy – Y coordinate of desired center point.

  • xspan – Width of desired grid.

  • yspan – Height of desired grid.

  • dx – Resolution of desired grid in X direction.

  • dy – Resolution of desired grid in Y direction.

  • defaultVs30 – Default Vs30 value to use if vs30File not specified.

  • vs30File – Name of GMT or GDAL format grid file containing Vs30 values.

  • vs30measured_grid – Boolean grid indicating whether Vs30 values were measured or derived (i.e., from slope).

  • backarc – Boolean array indicating whether site is in the subduction backarc.

  • padding – Boolean indicating whether or not to pad resulting Vs30 grid out to edges of input bounds. If False, grid will be clipped to the extent of the input file.

  • resample – Boolean indicating whether or not the grid should be resampled.

getSitesContext(lldict=None, rock_vs30=None)[source]

Create a SitesContext object by sampling the current Sites object.

Parameters:
  • lldict

    Either

    • None, in which case the SitesContext for the complete Sites grid is returned, or

    • A location dictionary (elements are ‘lats’ and ‘lons’ and each is a numpy array). Each element must have the same shape. In this case the SitesContext for these locaitons is returned.

  • rock_vs30

    Either

    • None, in which case the SitesContext will reflect the Vs30 grid in the Sites instance, or

    • A float for the rock Vs30 value, in which case the SitesContext will be constructed for this constant Vs30 value.

Returns:

SitesContext object.

Raises:

ShakeLibException – When lat/lon input sequences do not share dimensionality.

getVs30Grid()[source]

Returns: Grid2D object containing Vs30 values for this Sites object.

getNxNy()[source]

Returns: The number of grid points in x and y.