Commit a9be6128 authored by Tara Evaz Zadeh's avatar Tara Evaz Zadeh
Browse files

edited Fragility_to_Dictionary.py on a call with Danijel

parent d3f59963
#!/usr/bin/env python
import csv
def Fragility_to_Dictionary2(gmDict,taxonomyConversionCsv,fragilities_path):
#OUTPUT:
#returns A dictionary with keys as first column
#of taxonomyConversionCsv(taxonomies)
#values as relative fragility names
#(2nd column of taxonomyConversionCsv) and
#ground-motion type and the respective
#column number of the gm-type
# INPUTS:
# gmDict: Dictionary with keys as gm-type and
# values as the relative column number
# taxonomyConversionCsv : A file with first column
# as taxonomies and the second column as the name of
# relative fragility function(type : _csv.reader matrix)
# fragilities_path: Path to the folder of fragility functions
# OUTPUT:
# This Function returns a dictionary with
# taxonomies as keys and their relative
# fragility names, the ground-motion-type based
# on which the fragility function is defind;
# and the specific gm-type column-number in
# the ground-motion-field file.
def Fragility_to_Dictionary(gmDict,taxonomyConversionCsv,fragilities_path):
#INPUTS:
#gmDict: Dictionary with keys as gm-type and
#values as the relative column number
#taxonomyConversionCsv : A file with first column
#as taxonomies and the second column as the name of
#relative fragility function(type : _csv.reader matrix)
#fragilities_path: Path to the folder of fragility functions
taxonomyConversionDict = {}
for row in taxonomyConversionCsv:
fragilityFileName = row[1] + ".csv"
data = list(csv.reader(open(fragilities_path+"/"+fragilityFileName)))
gm_type1=data[0][0]
columnNumber = gmDict[gm_type1]
key = row[0]
if key in taxonomyConversionDict:
# implement your duplicate row handling here
pass
dictValue = [row[1],gm_type1,columnNumber]
taxonomyConversionDict[key] = dictValue
return(taxonomyConversionDict)
taxonomyConversionDict = {}
for row in taxonomyConversionCsv:
fragilityFileName = row[1] + ".csv"
data = list(csv.reader(open(fragilities_path + "/" + fragilityFileName)))
gmType=data[0][0]
columnNumber = gmDict[gmType]
if row[0] in taxonomyConversionDict:
# implement your duplicate row handling here
pass
dictValue = [row[1],columnNumber]
taxonomyConversionDict[row[0]] = dictValue
return(taxonomyConversionDict,gmType)
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