Here is a list of the software where we run SeisFinder and how to perform certain operations on it.
As of Jan 2018, we have the two following Virtual Machines (VMs):
- dev01-quakecore.canterbury.ac.nz (external web access via http://quakecoresoftdev.canterbury.ac.nz/seisfinder)
- Development machine.
- This machine has a mount for the RCC hard drive on /rcc/home. There is a lot of diskspace here, so we can probably put most of the CyberShake data here.
- ucquakecore1p.canterbury.ac.nz (external web access via http://quakecoresoft.canterbury.ac.nz/)
- Production machine.
- Reduced disk space. It would need to mount RCC storage to be able to serve SeisFinder v2. For the moment being, we will not use it.
User Management
Active Directory is up and running on those machines. This means that any UC user can be allowed to have access to the machines. In order to do so, any user with root access can perform the following command:
sudo realm permit $usercode
where $usercode is the UC code for the user (for example ykh22 for Jonney).
Installation of SeisFinder2
In a first instance, we have installed SeisFinder v2 on dev01-quakecore. This is the machine where our beta testers will use it.
Pre-requirements
The following version of software must be installed:
PostgresSQL 9.5.8
PostGIS 2.2.1
Python 2.7.12
Django 1.10.0
you have 7.5 hours
$ pip install --update django==1.10.0
1.Getting the code
Open a terminal and git clone the source code to your local directory.
# https $ git clone https://github.com/ucgmsim/seisfinder2.git # SSH $ git clone git@github.com:ucgmsim/seisfinder2.git
$cd seisfinder2 /seisfinder2 $ python manage.py runserver
If you clone the files successfully, you should be able to see something similar to this:
2.Setting up the database
To set up the seisfinder2 database in PostgreSQL. Open a terminal and do:
# open postgres $ sudo su - postgres postgres@user-desktop ~ $ psql # create database postgres=# CREATE DATABASE seisfinder2; # create user postgres=# CREATE USER www WITH PASSWORD 'seisfinder'; # Do the following alter regardless the user alreday exists or not postgres=# ALTER ROLE www SET client_encoding TO 'utf8'; postgres=# ALTER ROLE www SET default_transaction_isolation TO 'read committed'; postgres=# ALTER ROLE www SET timezone TO 'UTC'; # grant privilege postgres=# GRANT ALL PRIVILEGES ON DATABASE seisfinder2 TO www; # connect to the seisfinder2 database you just created postgres=# \c seisfinder2 # create postgis extension seisfinder2=# CREATE EXTENSION postgis; # exit seisfinder2=# \q postgres@user-desktop ~ $ exit
3.Migrate data structure from Django to database
$cd seisfinder2 /seisfinder2$ python manage.py makemigraitions seisfinderapp /seisfinder2$ python manage.py migrate seisfinderapp /seisfinder2$ python manage.py migrate
To see if all the tables are correctly migrated, do:
$ sudo su - postgres postgres@user-desktop ~ $ psql postgres=# \c seisfinder2 #list all the tables seisfinder2=# \d+
You should be able to see 44 rows if the migration is successful.
4.Getting the CSV and Hazard data files
Sample CSV and Hazard data for populating the database are located at username@dev01-quakecore:/var/www/seis2Data.
Type the following command and come back after lunch.
# scp -r username@remoteserver:remote_path_to_copy_files local_path_to_put_copied_files.eg scp -r gg999@dev01-quakecore:/var/www/seis2Data home/gg999/seisfinder2
5.Inserting the CSV and Hazard data to seisfinder2 database
(1)First, start the Django server
$cd seisfinder2 /seisfinder2 $ python manage.py runserver
(2) Now the server is running, let's insert CSV data.
Open a browser, go to the following address and the insertion will start automatically, you'll see lots of terminal output.
http://127.0.0.1:8000/seisfinderapp/insert?root_dir=home/gg999/seisfinder2/seis2Data/csv_data
The 'root_dir=' is the absolute path where you just put the copied data in step 4.
After about 9 minutes, if the CSV data is inserted successfully, terminal output: final result=OK.
And you should get 11458 if performing the following sql command in postgres
(3) Now let's insert hazard data. Doesn't matter if the Django server is running or not.
/seisfinder2 $ cd sqlsts #inserting hazard data.replace 'home/gg999/seisfinder2/seis2Data/hazard_data' with the absolute path that you put the copied data at in step 4.eg /seisfinder2/sqlsts $ python insert_hzd_paths.py home/gg999/seisfinder2/seis2Data/hazard_data
if the insertion of the hazard data is successful, you should get 8534 when performing the following sql command
6.Testing
Now you've finished all the installation steps. Let's do some test to see if the python scripts can run with the database smoothly:
(1)Test for hazard_search.py
$cd seisfinder2/sqlsts seisfinder2/sqlsts $ python hazard_search.py -q Cybershake17p8 -45.63 168.94
Output:
(2)Test for event_search.py
seisfinder2/sqlsts $ python event_hazard_search.py -q Kelly_m7pt25 -41.7483 171.4831 -r Kelly_HYP03-03_S1284
Output: