# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>

# <codecell>

"""
Created on Wed Sep 24 15:12:45 2014

@author: chiaracasotto
"""
import numpy as np
from rmtk.vulnerability.NDP.fragility_process import fragility_process
import pandas as pd

dcm = np.matrix([[  30.,   16.,   54.],
        [  54.,   15.,   31.],
        [  59.,   10.,   31.],
        [  24.,   26.,   50.],
        [  58.,    5.,   37.],
        [ 100.,    0.,    0.],
        [  30.,   24.,   46.],
        [   7.,   35.,   58.],
        [   0.,    0.,  100.],
        [   0.,    5.,   95.],
        [   0.,    0.,  100.],
        [   0.,   12.,   88.],
        [   4.,   24.,   72.],
        [  76.,   16.,    8.],
        [  10.,   25.,   65.],
        [  40.,   17.,   43.],
        [  80.,    4.,   16.],
        [   4.,   37.,   59.],
        [  19.,   40.,   41.],
        [   1.,   39.,   60.],
        [  95.,    5.,    0.]])
totblg = 100
im = np.matrix([[  49.852 ],
        [  47.056 ],
        [  33.012 ],
        [  82.125 ],
        [  37.499 ],
        [   3.159 ],
        [  52.205 ],
        [  88.363 ],
        [ 290.11  ],
        [ 241.78  ],
        [ 273.37  ],
        [ 151.24  ],
        [  92.957 ],
        [  40.101 ],
        [  97.535 ],
        [  54.723 ],
        [  26.081 ],
        [ 105.61  ],
        [ 156.81  ],
        [  82.401 ],
        [  26.807 ]])
g = 981
noLS = 2

# <codecell>

[log_meanSa, log_stSa, FR, IML] = fragility_process(dcm,totblg,im,noLS, g)

# <codecell>

data = pd.DataFrame({'1.Sa50':np.exp(log_meanSa),'2.stdev':log_stSa},index = np.arange(len(log_meanSa)))     
data.to_csv('results/fragility_process.csv',header=True,index=True)

