Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nshm organisational refactor #4

Merged
merged 39 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1fff878
package and scriptify nshm db generator
lispandfound May 16, 2024
9daf496
add mypy type-checking
lispandfound May 16, 2024
48a669f
Add fault module
lispandfound May 16, 2024
de2663f
Add nshmdb interface
lispandfound May 16, 2024
60a2a10
add insert parent method
lispandfound May 16, 2024
229f299
add schema creation method
lispandfound May 16, 2024
a374553
fix segment reference
lispandfound May 16, 2024
1290224
begin script refactor
lispandfound May 16, 2024
da52082
s/segment/plane
lispandfound May 16, 2024
215fa67
fix type of tect_type
lispandfound May 16, 2024
f7ccabe
remove unused imports
lispandfound May 16, 2024
76ac658
fix function name
lispandfound May 16, 2024
7d52427
add comment to explain section casting
lispandfound May 16, 2024
f33d385
s/segment/plane & replace reuse sqlite connection
lispandfound May 17, 2024
38eaebb
speed up db gen
lispandfound May 17, 2024
c772631
add rupture plotting functionality
lispandfound May 20, 2024
11f83d6
Fix CLI scripts
lispandfound May 20, 2024
d00556e
update strike and dip_dir calculation for new api
lispandfound May 20, 2024
0f75bac
add docstring for NSHMDB.get_fault
lispandfound May 21, 2024
9b9e692
add docstring for NSHMDB.create
lispandfound May 21, 2024
c12f98d
raise error if db does not exist
lispandfound May 21, 2024
87f7b71
sensitivity tweaks for fault coordinates
lispandfound May 21, 2024
7be42c7
convert to nztm
lispandfound May 21, 2024
9c010a0
fix boundary case fault coord -> global coord bug
lispandfound May 22, 2024
90cf1e4
downgrade used version of python
lispandfound May 22, 2024
139318c
make _corners not private
lispandfound May 28, 2024
55deac6
improve docs
lispandfound May 28, 2024
8be0ace
add fault-level nztm corner calculations
lispandfound May 28, 2024
f1a56e4
write plot to file instead of fig.show
lispandfound May 28, 2024
142afb3
use requirements.txt
lispandfound May 28, 2024
e7190a4
remove unused variable
lispandfound May 28, 2024
23c560f
fix typo
lispandfound May 28, 2024
a6adcca
optimise imports
lispandfound May 28, 2024
aa9f1ff
update names and docstrings
lispandfound May 30, 2024
03d84c0
black
lispandfound May 30, 2024
48ba6a8
use optional
lispandfound May 31, 2024
debf646
update readme
lispandfound May 31, 2024
75ab5ff
spacing
lispandfound May 31, 2024
f2f4fbc
bold text
lispandfound May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading