A web service for selecting and testing ground shaking models in Europe (eGSIM), developed in the framework of the Thematic Core Services for Seismology of EPOS-IP (European Plate Observing System-Implementation Phase)
Disclaimer: this is a temporary tutorial tested with MacOS (El Capitan) and Ubuntu 16.04.
Requirements (Ubuntu specific, in Mac should not be an issue, otherwise brew isntall
instead of apt-get install
):
brew doctor # pre-requisite
brew update # pre-requisite
brew install gcc
sudo apt-get install git python3-venv python3-pip python3-dev
Please use Python 3.7+. Check with python --version
: If it's Python2, then use python3 --version
. If it's not 3.7+, then you need to install Python3.7 along with (i.e., not replacing) the current default python3 installed on your computer.
From now on, each python
command refers to the path of the Python3.7 distribution you have (i.e., you might need to type e.g. /opt/lib/python3.7
or something similar, instead of python
or python3
)
[Pending: doc TBD] Three options:
- python-venv (for python>=3.5): Please use this option as it does not issues the 'matplotlib installed as a framework ...' problem
- python-virtualenv
- virtualenvwrapper (our choice)
FROM NOW ON virtualenv MUST be activated! EVERYTHING WILL BE INSTALLED ON YOUR "copy" of pyhton with no conflicts with the OS python distribution
pip install -U pip setuptools
git clone
and so on (see Github). From now on we assume you are inside the git repo (the local folder you clone the project into)
pip install -r ./requirements.dev.txt
Normal test (x=stop at first error, v*=increase verbosity):
pytest -xvvv --ds=egsim.settings_debug ./tests/
Test with coverage
pytest -xvvv --ds=egsim.settings_debug --cov=./egsim/ --cov-report=html ./tests/
This procedure should be executed for all flatfiles to be included in the application. For testing purposes, we will use ESM flatfile (2018) only. Download ESM flatfile from https://esm.mi.ingv.it//flatfile-2018/flatfile.php (ESM_flatfile_2018) Unzip it and from within the same directory, copy the file:
cp ESM_flatfile_2018/ESM_flatfile_SA.csv ./ESM_flatfile_2018_SA.csv
Called $FLATFILE_PATH the full path of the CSV file just copied, now parse it into the ESM database, the database will be a HDF5 file inside the /media/ directory of the egsim repository (git ignores that directory):
export DJANGO_SETTINGS_MODULE="egsim.settings_debug";python manage.py gmdb_esm $FLATFILE_PATH
From within the egsim folder (check that manage.py is therein):
export DJANGO_SETTINGS_MODULE="egsim.settings_debug";python manage.py migrate
From within the egsim folder (check that manage.py is therein):
export DJANGO_SETTINGS_MODULE="egsim.settings_debug";python manage.py initdb
export DJANGO_SETTINGS_MODULE="egsim.settings_debug";python manage.py runserver
and pen your browser (or use the API) at the URL address on the console
Please refer to 'deploy.html' (dynamic web page, open it in your browser of choice)