Skip to content

Commit

Permalink
Code for combining fault source model with smoothed seismicity models
Browse files Browse the repository at this point in the history
  • Loading branch information
griffij committed Sep 27, 2017
1 parent b80be45 commit 7b92e95
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
58 changes: 58 additions & 0 deletions source_models/smoothed_seismicity/build_additive_ss_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""Script to build smoothed seismicity model that only uses the additive method (i.e.
has full weight of 1 for the model)
"""

import os, sys
import numpy as np
from NSHA2018.source_models.faults.shapefile2nrml import shapefile_2_simplefault, \
shapefile_2_simplefault_CE, shapefile_2_simplefault_MM, shp2nrml
from NSHA2018.source_models.logic_trees import logic_tree
from NSHA2018.source_models.utils.utils import largest_remainder
from NSHA2018.source_models.utils.area_sources import nrml2sourcelist, \
area2pt_source, weighted_pt_source
from NSHA2018.source_models.utils.pt2fault_distance import read_simplefault_source, \
pt2fault_distance, write_combined_faults_points, combine_pt_sources, read_pt_source
#from hmtk.parsers.source_model.nrml04_parser import nrmlSourceModelParser
from openquake.hazardlib.sourcewriter import write_source_model
from openquake.hazardlib.scalerel.leonard2014 import Leonard2014_SCR
from subprocess import call

from openquake.hazardlib.sourceconverter import SourceConverter, \
area_to_point_sources, SourceGroup



def build_model(combined_output_dir, pt_source_model, fsm,
source_model_name, fault_mesh_spacing):
"""Combine the fault and pt source model"""

# additive_pt_sources_filename = pt_source_model[:-4] + '_pts.xml'
print 'reading fault sources'
additive_pt_sources = read_pt_source(pt_source_model)
# Apply additive approach
if not os.path.exists(combined_output_dir):
os.makedirs(combined_output_dir)
print 'Writing full additive model'
outfile = os.path.join(combined_output_dir, source_model_name)
fault_sources = read_simplefault_source(fsm, rupture_mesh_spacing = fault_mesh_spacing)
write_combined_faults_points(additive_pt_sources, fault_sources,
outfile, source_model_name, nrml_version = '04')

if __name__ == "__main__":

fsm = '../faults/National_Fault_Source_Model_2018_Collapsed_NSHA13/National_Fault_Source_Model_2018_Collapsed_NSHA13_all_methods_collapsed_inc_cluster.xml'
fault_mesh_spacing = 2 #2 Fault source mesh
combined_output_dir = 'GA_adaptive_smoothing_collapsed_faults_K5'
ss_source_model = 'GA_adaptive_smoothing_collapsed/source_model_Australia_Adaptive_K5_merged_inc_b_mmax_uncert.xml'
source_model_name = 'GA_adaptive_smoothing_collapsed_faults_additive'
print 'Building Adaptive SS with faults'
build_model(combined_output_dir, ss_source_model, fsm,
source_model_name, fault_mesh_spacing)

combined_output_dir = 'GA_fixed_smoothing_collapsed'
pt_source_model = 'GA_fixed_smoothing_collapsed/source_model_smoothed_frankel_50_3_mmin_3.0_merged_inc_b_mmax_uncert.xml'
source_model_name = 'GA_fixed_smoothing_collapsed_faults_additive'
print 'Building Fixed SS with faults'
build_model(combined_output_dir, pt_source_model, fsm,
source_model_name, fault_mesh_spacing)

28 changes: 28 additions & 0 deletions source_models/smoothed_seismicity/run_build_add_model.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#PBS -P w84
#PBS -q normal
#PBS -l walltime=10:00:00
#PBS -l ncpus=1
#PBS -l mem=128GB
#PBS -l wd

module load intel-cc/12.1.9.293
module load intel-fc/12.1.9.293
module load geos/3.5.0
module load hdf5/1.8.10
#module load openmpi/1.6.3
module load gdal
module unload python
module load python/2.7.11
module load python/2.7.11-matplotlib

# To get rtree to run
export SPATIALINDEX_C_LIBRARY=/short/n74/jdg547/spatialindex-src-1.8.5/lib/libspatialindex_c.so.4
export LD_LIBRARY_PATH=/short/n74/jdg547/spatialindex-src-1.8.5/lib:$LD_LIBRARY_PATH
# Python paths for local openquake installs and dependencies
export PYTHONPATH=.:/home/547/jdg547/.local/lib/python2.7/site-packages:${PYTHONPATH}
export PYTHONPATH=.:/short/w84/NSHA18/sandpit/jdg547/oq-hazardlib:${PYTHONPATH}
export PYTHONPATH=.:/short/w84/NSHA18/sandpit/jdg547/oq-engine:${PYTHONPATH}
#export PYTHONPATH=.::/short/w84/NSHA18/sandpit/jdg547/NSHA2018/:${PYTHONPATH}
export PYTHONPATH=.::/short/w84/NSHA18/sandpit/jdg547/:${PYTHONPATH}

python build_additive_ss_models.py > build_additive_ss_models.log

0 comments on commit 7b92e95

Please sign in to comment.