Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

If you've got an old version of Django running on your machine, do:

 

Code Block
languagebash
 $ pip install --updage django==1.10.0

 

 

1.Getting the code

Open a terminal and git clone the source code to your local directory.

Code Block
# https
$ git clone https://github.com/ucgmsim/seisfinder2.git
 
# SSH
$ git clone git@github.com:ucgmsim/seisfinder2.git
After clone is done, Do the following test:

 

Code Block
$cd seisfinder2
 
#if you're running locally:
/seisfinder2 $ python manage.py runserver 
 
# if you're running from the dev-01-quakecore serever,everything has been installed so you can just run the code
/seisfinder2 $ python manage.py runserver 132.181.39.127:8000
 

If you clone the files successfully, you should be able to see something similar to this:

Image Added

Open a browser and go to  http://127.0.0.1:8000/seisfinderapp/ (http://132.181.39.127:8000/seisfinderapp/ if on dev01-quakecore), you should be able to see 'Hello, world. You're at the polls index.'

2.Setting up the database

 To set up the seisfinder2 database in PostgreSQL. Open a terminal and do:

Code Block

...

Here you will describe the steps to put seisfinder2 on the machine. Describe the django 1.10 steps as well.

Database

What did you do to create the DB.

 

...

languagebash
# 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

Code Block
$cd seisfinder2
/seisfinder2$ python manage.py makemigraitons seisfinderapp
/seisfinder2$ python manage.py migrate seisfinderapp
/seisfinder2$ python manage.py migrate

To see if all the tables are correctly migrated, do:

Code Block
$ 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.

Image Added

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.

Code Block
# 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

Code Block
$cd seisfinder2
/seisfinder2 $ python manage.py runserver 

(2) Now the server is running, let's insert CSV data.

Open a browser, go to

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.

If the CSV data is inserted successfully, you'll see lots of text output in terminal and after about 9 minutes, console output: final result=ok. And you should get 11458  if performing the following sql command

Image Added

(3) Now let's insert hazard data. Doesn't matter if the Django is running or not.

Code Block
/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 successfyk, you should get 8534  when performing the following sql command

Image Added

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

Code Block
$cd seisfinder2/sqlsts
seisfinder2/sqlsts $ python hazard_search.py -q Cybershake17p8 -45.63 168.94

Output:

Image Added

(2)Test for event_search.py

Code Block
seisfinder2/sqlsts $ python event_hazard_search.py -q Kelly_m7pt25 -41.7483 171.4831 -r Kelly_HYP03-03_S1284

Output:

Image Added

Done !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!