README.md 1.58 KB
Newer Older
Marius's avatar
Marius committed
1
# eGSIM Shakemap Service
2

Marius's avatar
Marius committed
3
The eGSIM shakemap is comprised of a backend service (`api.py`) and a front end response site (`front-end`).
4

Marius Kriegerowski's avatar
Marius Kriegerowski committed
5
6
7
8
9
10
# Docker

You can run the shakemap service in a docker container:

    docker-compose build
    docker-compose up
Marius's avatar
Marius committed
11

Marius Kriegerowski's avatar
Marius Kriegerowski committed
12
Note, that the front-end is not yet integrated in the `docker-compose.yml`. The service exposes port 8082.
Marius's avatar
Marius committed
13

Marius Kriegerowski's avatar
Marius Kriegerowski committed
14
15
16
17
# Dependencies

    apt install gmt libhdf5-dev pkg-config postgresql
    pip3 install -r requirements.txt
Marius's avatar
Marius committed
18

Marius's avatar
Marius committed
19
vs30 model available at [USGS](https://earthquake.usgs.gov/data/vs30/). Export an environment variable `VS30PATH` pointing to that file.
Marius's avatar
Marius committed
20
21
22
23
24
Shortcut: `wget https://earthquake.usgs.gov/static/lfs/data/global_vs30_grd.zip`

Furthermore, `npm` is required for the front-end, as well as the `vue` command line client. Install the latter with

    npm install -g @vue/cli@latest
Marius's avatar
Marius committed
25

Marius Kriegerowski's avatar
Marius Kriegerowski committed
26
## Start services manually
27

Marius Kriegerowski's avatar
Marius Kriegerowski committed
28
Spawning the service at port [8082](http://localhost:8082):
Marius's avatar
Marius committed
29

Marius Kriegerowski's avatar
Marius Kriegerowski committed
30
    python3 src/api.py
Marius's avatar
Marius committed
31
32
33

Starting the front end:

Marius's avatar
cleanup    
Marius committed
34
    cd front-end/shakemap
Marius's avatar
Marius committed
35
    npm install    # This needs to be done just once or if new dependencies were added
Marius's avatar
Marius committed
36
37
38
39
40
41
42
43
    npm run serve

Starting the API documentation:

    cd front-end/api_documentation
    git clone https://github.com/swagger-api/swagger-node
    npm start

Marius's avatar
Marius committed
44
45
46
47
Go to open http://localhost:8081/docs

## API

Marius's avatar
Marius committed
48
Either post request QuakeML formatted strings or use get requests on endpoint `/shakemap`. 
Marius Kriegerowski's avatar
Marius Kriegerowski committed
49
50
51
52
53

You can manually query the api with e.g. curl pointing a quakeml against the API:
```
curl -X POST -H "Content-Type: application/json" -d @coquimbo.quakeml http://localhost:8082/shakemap\?gmpe=BindiEtAl2014Rjb\&imt\=PGA
```