Commit 76b181dc authored by Danijel Schorlemmer's avatar Danijel Schorlemmer

Merge branch 'Fragility2Dictionary' into 'master'

Fragility2 dictionary

See merge request !3
parents 54d30327 9746879a
import csv
def Taxonomy_to_Fragility(gmDict, taxonomyToFragilitySource, fragilityFileDir):
Creates an extended map of taxonomies to fragility function.
The input map 'taxonomyToFragilitySource' contains the mapping for each
taxonomy to a fragility function file from which the ground-motion type is
read to be written to the extended map 'taxonomyToFragilityMap'.
gmDict: dictionary (key: ground-motion type; value: column number in the
ground-motion field file)
taxonomyToFragilitySource: taxonomy to fragility-function file map,
following the format:
[taxonomy_string, fragility-function_filename, 'weight'], [...]
Example file extract:
['CR/LDUAL+CDM/HBET:6-/11.0', 'CR_LDUAL-DUM_H6', '1']
['CR/LDUAL+CDM/HBET:6-/5.0', 'CR_LDUAL-DUL_H6', '1']
['CR/LDUAL+CDM/HBET:6-/SOS/11.0', 'CR_LDUAL-DUL_H6', '1']
fragilityFileDir: directory of fragility-function files
Dictionary containing the taxonomy to fragility function map considering
the ground-motion types. It follows the format:
{taxonomy_string: [fragility-function_filename, column of
ground-motion_type in ground-motion_field file]}
Example extract:
{'CR/LDUAL+CDM/HBET:6-/11.0': ['CR_LDUAL-DUM_H6', 4],
'CR/LDUAL+CDM/HBET:6-/5.0': ['CR_LDUAL-DUL_H6', 'SA(0.6)', 4],
'CR/LDUAL+CDM/HBET:6-/SOS/11.0': ['CR_LDUAL-DUL_H6', 'SA(0.6)', 4], ... }
# Prepare return variable
taxonomyToFragilityMap = {}
# Loop through the taxonomy-to-fragility-function map
for mappingItem in taxonomyToFragilitySource:
# Open the fragility-function file corresponding to the taxonomy in
# 'mappingitem[1]'
fragilityFunction = list(csv.reader(open(fragilityFileDir + "/" + \
mappingItem[1] + ".csv")))
# Check if already one fragility function for a given GM type has been
# selected
if mappingItem[0] in taxonomyToFragilityMap:
# Ignore the additional fragility function to keep everything
# unambiguous
# Create the entry in the extended map with adding the type of ground
# motion 'fragilityFunction[0][0]'
taxonomyToFragilityMap[mappingItem[0]] = [mappingItem[1], \
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment