datasets¶
The synthetic town, the open-data fetchers and the DEM regridding.
quakecascade.datasets
¶
Demonstration inputs: a deterministic synthetic town and open-data fetchers.
synthetic_town builds a small, fully synthetic city in a projected
metric CRS (UTM zone 35N coordinates, about 3 km across) with every input the
cascade needs: a fault trace with a dip geometry, building footprints with
storeys, heights, Hazus types, occupants, dwelling units and Vs30, a noded road
grid with classes and widths, hospitals and fire stations, candidate open-space
sites, a unit grid with residents, a coarse DEM and pipe lengths by material.
Nothing in it describes a real place; the numbers exist to exercise the chain,
including a few deliberately missing values that show how status codes travel.
The fetch_* functions download open data (OpenStreetMap via osmnx, the
Copernicus GLO-30 DEM from its public AWS bucket, the GEM Global Active Faults
database from GitHub). They need network access and optional packages, import
those lazily, and are never called by the test-suite.
SYNTHETIC_CRS
module-attribute
¶
CRS of the synthetic town (WGS 84 / UTM zone 35N, metres).
SYNTHETIC_FAULT_SOURCE
module-attribute
¶
Source string of the synthetic fault. It is not a real structure.
COPERNICUS_DEM_URL
module-attribute
¶
Copernicus DEM GLO-30 tile URL template on the public AWS Open Data bucket.
GEM_FAULTS_URL
module-attribute
¶
GEM Global Active Faults harmonised GeoJSON (CC BY-SA 4.0).
GEM_COMPASS
module-attribute
¶
Compass directions used in the GEM dip_dir field, as azimuths (degrees from north).
Town
dataclass
¶
Town(
crs,
fault_trace,
fault,
buildings,
roads,
hospitals,
fire_stations,
sites,
units,
dem,
dem_transform,
pipes,
attribution=dict(),
)
Inputs of one cascade run.
Frames are GeoDataFrames when geopandas is installed, otherwise pandas
DataFrames with a geometry column of Shapely objects.
Attributes:
| Name | Type | Description |
|---|---|---|
crs |
str
|
Projected metric CRS of every geometry. |
fault_trace |
LineString
|
Surface trace of the scenario fault. |
fault |
FaultGeometry
|
Dip, dip azimuth and seismogenic depths with their source. |
buildings |
frame
|
|
roads |
frame
|
|
hospitals, fire_stations |
frame
|
Points with |
sites |
frame
|
Candidate open-space depot/assembly sites: |
units |
frame
|
Planning units (500 m cells): |
dem |
ndarray
|
Elevation grid (m), row 0 at the top. |
dem_transform |
tuple
|
|
pipes |
DataFrame
|
|
attribution |
dict
|
Licence and provenance notes. |
synthetic_town
¶
A deterministic synthetic town for demonstrations and tests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
int
|
Seed of the generator. The same seed gives identical inputs on every machine. |
0
|
Returns:
| Type | Description |
|---|---|
Town
|
About 500-700 buildings on a 20 x 20 block grid of 150 m blocks,
840 road edges, 3 hospitals, 3 fire stations, 8 candidate sites,
36 planning units, an 8 x 8 DEM at 500 m and pipe lengths per unit.
A few buildings have no Vs30, one has no occupant count and a few
lanes carry a class ( |
Notes
Everything is synthetic, including the fault (see
SYNTHETIC_FAULT_SOURCE). The design levels and building types are
drawn at random to give a mixed stock; they do not represent any real
code history.
fetch_osm
¶
Download buildings, roads, hospitals, fire stations and parks from OpenStreetMap.
Network only. Uses osmnx (pip install 'quakecascade[demo]'); data
© OpenStreetMap contributors, ODbL 1.0. When the default Overpass server
is busy or unreachable, point osmnx at a mirror before calling, e.g.
osmnx.settings.overpass_url = "https://maps.mail.ru/osm/tools/overpass/api".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
place
|
str
|
Place name geocoded by Nominatim. |
None
|
bbox
|
(west, south, east, north)
|
Geographic bounding box in degrees (EPSG:4326). Exactly one of
|
None
|
network_type
|
str
|
osmnx network type for the road graph. |
'drive'
|
Returns:
| Type | Description |
|---|---|
dict
|
|
fetch_copernicus_dem
¶
Read the Copernicus DEM GLO-30 over a bounding box from the public AWS bucket.
Network only; needs rasterio (pip install 'quakecascade[raster]').
Copernicus DEM © DLR e.V. 2010-2014 and © Airbus Defence and Space GmbH
2014-2018, provided under COPERNICUS by the European Union and ESA; free
licence with attribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
(west, south, east, north)
|
Degrees (EPSG:4326). Must lie within one 1-degree tile. |
required |
Returns:
| Type | Description |
|---|---|
(ndarray, dict)
|
Elevation in metres (float, NaN for no-data) and a profile dict with
|
regrid_dem
¶
Average a DEM onto a square grid in a projected metric CRS.
The grid the cascade's liquefaction stage needs (CascadeInputs.dem and
dem_transform): row 0 at the top, cells of cell_size_m, NaN
for no-data. Each target cell is the mean of the source cells it covers
(rasterio.warp.reproject with average resampling), so a 30 m DEM
regridded to ~1 km gives the scale Zhu et al. (2015) were fitted on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(rows, cols) array
|
Elevations; |
required |
src_transform
|
Affine
|
Geotransform of |
required |
src_crs
|
CRS of |
required | |
dst_crs
|
CRS of |
required | |
cell_size_m
|
float
|
Target cell size (m). |
required |
bounds
|
(x_min, y_min, x_max, y_max)
|
Target extent in |
None
|
Returns:
| Type | Description |
|---|---|
(ndarray, tuple)
|
The regridded elevations and |
dem_grid
¶
Copernicus GLO-30 DEM over bbox averaged onto a metric grid, ready for the cascade.
Network only; needs rasterio. Combines fetch_copernicus_dem and
regrid_dem. bbox is (west, south, east, north) in degrees
within one 1-degree tile; crs is the run's metric CRS. The default
1 km cell is the input scale of Zhu et al. (2015).
Returns:
| Type | Description |
|---|---|
(ndarray, tuple)
|
|
fetch_gem_faults
¶
GEM Global Active Faults traces intersecting a bounding box.
Network only. Downloads GEM_FAULTS_URL (about 10 MB; CC BY-SA 4.0,
Styron & Pagani 2020, doi:10.1177/8755293020944182). cache keeps the
file for later calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
(west, south, east, north)
|
Degrees (EPSG:4326). |
required |
Returns:
| Type | Description |
|---|---|
GeoDataFrame (or list of GeoJSON features without geopandas)
|
Fault traces with their attributes ( |
gem_fault_geometry
¶
gem_fault_geometry(
record,
*,
dip_deg=None,
dip_azimuth_deg=None,
upper_depth_km=None,
lower_depth_km=None,
)
FaultGeometry from one GEM Global Active Faults record.
Reads the preferred values of average_dip, dip_dir,
upper_seis_depth and lower_seis_depth (GEM stores them as
(preferred, min, max) text). A keyword argument replaces the record's
value; a value that is missing from the record and not given raises
TypeError instead of being assumed. A vertical fault (dip 90) needs no
dip direction. The source string names the record and says, for each
number, whether it came from the record or from the caller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
mapping or Series
|
One row of |
required |
dip_deg
|
float
|
Values that replace or complete the record. |
None
|
dip_azimuth_deg
|
float
|
Values that replace or complete the record. |
None
|
upper_depth_km
|
float
|
Values that replace or complete the record. |
None
|
lower_depth_km
|
float
|
Values that replace or complete the record. |
None
|
Returns:
| Type | Description |
|---|---|
FaultGeometry
|
|