Skip to content

Commit

Permalink
Merge pull request #4 from ucgmsim/nshm_organisational_refactor
Browse files Browse the repository at this point in the history
Nshm organisational refactor
  • Loading branch information
lispandfound authored Jun 6, 2024
2 parents 0027cc4 + f2f4fbc commit eb10cbe
Show file tree
Hide file tree
Showing 10 changed files with 1,006 additions and 341 deletions.
70 changes: 5 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,70 +63,10 @@ To integrate with PyCharm (if you use it) see [PyCharm's Documentation](https://
│   └── sub_seismo_on_fault_mfds.csv
└── WARNING.md
```
2. Copy the `fault_sections.geojson` and `fast_indices.csv` file into the directory contaning the script.
3. For some reason (pandas shenanigans?) the `fast_indices.csv` which maps between rupture ids and fault segment ids uses ints for the ruptures and *floats* for the fault segment ids. Run the following in the command line to turn the floats into integers.
```bash
$ sed -i 's/\.0//' fast_indices.csv
```
4. Creating an empty `nshm2022.db` database file.
```bash
$ sqlite3 nshm2022.db < schema.db
```
5. Populate the database using the `nshm_geojson_fault_parser.py` script.
```bash
$ python nshm_geojson_fault_parser.py
```
This step will take some time.

# Database Schema
```mermaid
erDiagram
fault {
fault_id INT PK
name TEXT
parent_id INT FK
tect_type INT
}
**YOU DO NOT NEED TO EXTRACT THIS FILE ANYWHERE**

parent_fault {
parent_id INT PK
name TEXT
}
fault_segment {
segment_id INT PK
strike REAL
rake REAL
dip REAL
dtop REAL
dbottom REAL
length REAL
width REAL
dip_dir REAL
clon REAL
clat REAL
}
rupture {
rupture_id INT PK
}
rupture_faults {
rupture_fault_id INT PK
rupture_id INT FK
fault_id INT FK
}
magnitude_frequency_distribution {
entry_id INT PK
fault_id INT FK
magnitude REAL
rate REAL
}
rupture }o--o{ rupture_faults : "has many"
fault }o--o{ rupture_faults : "belonging to many"
fault ||--o{ fault_segment : "containing many"
parent_fault ||--o{ fault : "are groups of"
fault ||--o{ magnitude_frequency_distribution : "erupts with annual rate at given magnitude"
2. After cloning this repository and installing the depedencies, run the following
```bash
python nshmdb/scripts/nshm_db_generator.py <PATH_TO_CRU_FAULT_ZIP> nshmdb.db
```
This will take some time.
237 changes: 0 additions & 237 deletions nshm_geojson_fault_parser.py

This file was deleted.

Empty file added nshmdb/__init__.py
Empty file.
Loading

0 comments on commit eb10cbe

Please sign in to comment.