Site object¶
Module openquake.hazardlib.site
defines Site
.
-
class
openquake.hazardlib.site.
FilteredSiteCollection
(indices, complete)[source]¶ A class meant to store proper subsets of a complete collection of sites in a memory-efficient way.
Parameters: - indices – an array of indices referring to the complete site collection
- complete – the complete site collection the filtered collection was derived from
Notice that if you filter a FilteredSiteCollection fsc, you will get a different FilteredSiteCollection referring to the complete SiteCollection fsc.complete, not to the filtered collection fsc.
-
backarc
¶ Extract backarc array from FilteredSiteCollection
-
expand
(data, placeholder)[source]¶ Expand a short array data over a filtered site collection of the same length and return a long array of size total_sites filled with the placeholder.
The typical workflow is the following: there is a whole site collection, the one that has an information about all the sites. Then it gets filtered for performing some calculation on a limited set of sites (like for instance filtering sites by their proximity to a rupture). That filtering process can be repeated arbitrary number of times, i.e. a collection that is already filtered can be filtered for further limiting the set of sites to compute on. Then the (supposedly expensive) computation is done on a limited set of sites which still appears as just a
SiteCollection
instance, so that computation code doesn’t need to worry about filtering, it just needs to handle site collection objects. The calculation result comes in a form of 1d or 2d numpy array (that is, either one value per site or one 1d array per site) with length equal to number of sites in a filtered collection. That result needs to be expanded to an array of similar structure but the one that holds values for all the sites in the original (unfiltered) collection. This is whatexpand()
is for. It creates a result array oftotal_sites
length and puts values fromdata
into appropriate places in it remembering indices of sites that were chosen for actual calculation and leavingplaceholder
value everywhere else.Parameters: - data – 1d or 2d numpy array with first dimension representing values computed for site from this collection.
- placeholder – A scalar value to be put in result array for those sites that were filtered out and no real calculation was performed for them.
Returns: Array of length
total_sites
with values fromdata
distributed in the appropriate places.
-
filter
(mask)[source]¶ Create a FilteredSiteCollection with only a subset of sites from this one.
Parameters: mask – Numpy array of boolean values of the same length as this filtered sites collection. True
values should indicate that site with that index should be included into the filtered collection.Returns: A new FilteredSiteCollection
instance, unless all the values inmask
areTrue
, in which case this site collection is returned, or if all the values inmask
areFalse
, in which case method returnsNone
. New collection has data of only those sites that were marked for inclusion in mask.See also
expand()
.
-
lats
¶ Extract lats array from FilteredSiteCollection
-
lons
¶ Extract lons array from FilteredSiteCollection
-
mesh
¶ Return a mesh with the given lons and lats
-
sids
¶ Extract sids array from FilteredSiteCollection
-
total_sites
¶ The total number of the original sites, without filtering
-
vs30
¶ Extract vs30 array from FilteredSiteCollection
-
vs30measured
¶ Extract vs30measured array from FilteredSiteCollection
-
z1pt0
¶ Extract z1pt0 array from FilteredSiteCollection
-
z2pt5
¶ Extract z2pt5 array from FilteredSiteCollection
-
class
openquake.hazardlib.site.
Site
(location, vs30, vs30measured, z1pt0, z2pt5, backarc=False, id=0)[source]¶ Site object represents a geographical location defined by its position as well as its soil characteristics.
Parameters: - location – Instance of
Point
representing where the site is located. - vs30 – Average shear wave velocity in the top 30 m, in m/s.
- vs30measured – Boolean value,
True
ifvs30
was measured on that location andFalse
if it was inferred. - z1pt0 – Vertical distance from earth surface to the layer where seismic waves start to propagate with a speed above 1.0 km/sec, in meters.
- z2pt5 – Vertical distance from earth surface to the layer where seismic waves start to propagate with a speed above 2.5 km/sec, in km.
- backarc" – Boolean value,
True
if the site is in the subduction backarc andFalse
if it is in the subduction forearc or is unknown - id – Optional parameter with default 0. If given, it should be an integer identifying the site univocally.
Raises: ValueError – If any of
vs30
,z1pt0
orz2pt5
is zero or negative.Note
Sites
are pickleable- location – Instance of
-
class
openquake.hazardlib.site.
SiteCollection
(sites)[source]¶ A collection of
sites
.Instances of this class are intended to represent a large collection of sites in a most efficient way in terms of memory usage.
Note
Because calculations assume that
Sites
are on the Earth’s surface, all depth information in aSiteCollection
is discarded. The collection mesh will only contain lon and lat. So even if aSiteCollection
is created from sites containing depth in their geometry, iterating over the collection will yieldSites
with a reference depth of 0.0.Parameters: sites – A list of instances of Site
class.-
backarc
¶ backarc array
-
expand
(data, placeholder)[source]¶ For non-filtered site collections just checks that data has the right number of elements and returns it. It is here just for API compatibility with filtered site collections.
-
filter
(mask)[source]¶ Create a FilteredSiteCollection with only a subset of sites from this one.
Parameters: mask – Numpy array of boolean values of the same length as this sites collection. True
values should indicate that site with that index should be included into the filtered collection.Returns: A new FilteredSiteCollection
instance, unless all the values inmask
areTrue
, in which case this site collection is returned, or if all the values inmask
areFalse
, in which case method returnsNone
. New collection has data of only those sites that were marked for inclusion in mask.See also
expand()
.
-
classmethod
from_points
(lons, lats, site_ids, sitemodel)[source]¶ Build the site collection from
Parameters: - lons – a sequence of longitudes
- lats – a sequence of latitudes
- site_ids – a sequence of distinct integers
- sitemodel – an object containing the attributes reference_vs30_value, reference_vs30_type, reference_depth_to_1pt0km_per_sec, reference_depth_to_2pt5km_per_sec, reference_backarc
-
indices
¶ The full set of indices from 0 to total_sites - 1
-
mesh
¶ Return a mesh with the given lons and lats
-
vs30
¶ vs30 array
-
vs30measured
¶ vs30measured array
-
z1pt0
¶ z1pt0 array
-
z2pt5
¶ z2pt5 array
-
-
openquake.hazardlib.site.
eq
(array1, array2)[source]¶ Compare two numpy arrays for equality and return a boolean
-
openquake.hazardlib.site.
prop
¶ Extract sids array from FilteredSiteCollection