The exposure to site tool is a short(ish) Python 3 module for constructing the SERA site amplification files for a given exposure model configuration. It supports several different workflows, depending on whether the user wishes to define the resulting site model from a regularly spaced grid, an existing exposure model or simply a shapefile of administative regions.
The exposure to site tool is a short(ish) Python 3 module for constructing the ESRM20 site amplification files for a given exposure model configuration. It supports several different workflows, depending on whether the user wishes to define the resulting site model from a regularly spaced grid, an existing exposure model or simply a shapefile of administative regions.
### Before you start
The tools require additional data files not included with the main code. These files contain the regional scale European site input data. More details can be found in the description below. The data files are distributed with a Createive Commons CC-By-4.0 license and are available for download from:
The tool requires as standard set of Python libraries that can be installed via most common Python package managers. A `setup.py` file is included to facilitate installation. We recommend using a Python virtual environment for installing and running the tools (<https://docs.python.org/3.6/tutorial/venv.html>).
The tool requires as standard set of Python libraries that can be installed via most common Python package managers. A `setup.py` file is included to facilitate installation. We recommend using a Python virtual environment for installing and running the tools (<https://docs.python.org/3.8/tutorial/venv.html>).
The required dependencies are:
(Required)
* Python >=3.
* h5py >=2.10, <2.11
* Numpy >=1.18, <1.20
* Scipy >=1.3, <1.7
* Pandas >=0.25 <1.3
* Shapely >=1.7, < 1.8
* Pyproj >=1.9
* matplotlib >=3.0
* geopandas >=0.9.0
* Python >=3.7
* h5py >=2.10
* Numpy >=1.18
* Scipy >=1.3
* Pandas >=0.25
* Shapely >=1.7, < 2.0
* Pyproj >=1.9
* matplotlib >=3.0
* geopandas >=0.9.0
(Additional)
...
...
@@ -68,9 +75,9 @@ pip install --update pip
```
Then run:
```bash
cd esrm20_sitemodel/exposure_site_tool/
pip install -e .
pip install -e esrm20_site_model/
```
This should install the dependencies and the `exposure2site` package. Additional packages to help run the code can be installed via
...
...
@@ -80,6 +87,12 @@ pip install ipython
pip install jupyter
```
<i><b>Note</b>: some installations may also require `pygeos`. If an error is raised indicating that it is not availablr then it can be installed via:</i>
```bash
pip install pygeos
```
##### Windows
...
...
@@ -90,7 +103,7 @@ For other users we suggest installing and running the toolkit using Anaconda. De
To create the virtual environment via `conda` run:
```bash
conda create --name exp2site python=3.7
conda create --name exp2site python=3.8
conda activate exp2site
```
...
...
@@ -109,10 +122,10 @@ pip install --update pip
Navigate to the `exposure_site_tool` and run the installation
```bash
cd esrm20_sitemodel\exposure_site_tool\
pip install -e .
pip install -e esrm20_site_model/
```
This should install the dependencies and the `exposure2site` package. Additional packages to help run the code can be installed via
```bash
...
...
@@ -125,7 +138,11 @@ pip install jupyter
## Required Datasets
In addition to the tools themselves, you will need several files containing pre-processed site data, which can be made available on request from the author (<graeme.weatherill@gfz-potsdam.de>). These should be stored in a subdirectory named `data`, and placed in the folder where the `exposure_to_site_tools.py` code is found.
In addition to the tools themselves, you will need several files containing pre-processed site data.
The zipped file containing all of the necessary data is available for download from here: <https://nextcloud.gfz-potsdam.de/s/93ZR4ky8D4mDXb9>
The downloaded data should be unzipped and stored in a directory named `site_data`, this directory should then be placed into the main code within the folder `exposure2site`.
The required datasets comprise 5 files:
...
...
@@ -173,10 +190,10 @@ Longitudes and latitudes in all 30 arc-second data sets refer to the locations o
# General Usage
The Ex2Site tool is mostly intended for command line usage (although Jupyter Notebooks illustrating how to call the functions directly are also provided). With the `exposure_to_site_tools.py` file in the current working directory, and the data files in the subdirectory `./data` the tool is run by:
The Ex2Site tool is mostly intended for command line usage (although Jupyter Notebooks illustrating how to call the functions directly are also provided). With the `exposure_to_site_tools.py` file in the current working directory, and the data files in the subdirectory `./site_data` the tool is run by:
@@ -269,7 +286,7 @@ The weighting approach described previously may be applicable for the case that
The following command would produce a 120 arc-second grid between 22˚E and 30˚E and 45˚N to 51.5˚N, clipping only to onshore sites, applying building density weighing and taking the resulting property as the maximum numerical value and modal geological category. The result will be exported to `example_site_model.csv`
@@ -297,7 +314,7 @@ All of the optional arguments specified for the `grid` option can be used here,
The following command will read the exposure model in the file `Exposure_Res_Dummy.csv`, whose geometry can be found in the file `Adm2_Dummy.shp` in the directory `Country_Shapefiles`. Weighting based on built density will be applied, this time with the value of the site property at the maximum weighted location. Geology will be determined from the modal geological category within the polygon. The result will be written to the output xml file `Dummy_Site_Model.xml`
@@ -357,7 +374,7 @@ The required input file can be any comma-separated text file, but the target sit
The following command will define the site model from a simple csv file of longitudes and latitudes (`./site_locations.csv`) and export the resulting model to `./example_point_site_model.csv`, clipping only to onshore sites
```bash
python exposure_to_site_tools.py --run point --output-file ./example_point_site_model.csv --input-file ./site_locations.csv --onshore-only True
exposure2site --run point --output-file ./example_point_site_model.csv --input-file ./site_locations.csv --onshore-only True
```
## `join`
...
...
@@ -377,7 +394,7 @@ One of either:
The following command joins together the site model in the file `site_model_countryA.csv` and the site model in the file `site_model_countryB.xml`, exporting them to `site_model_countriesAB.csv`: