-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse_spectra_map.py
More file actions
80 lines (63 loc) · 2.36 KB
/
response_spectra_map.py
File metadata and controls
80 lines (63 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# /*
# ============================================================================
# Loads the plane displacement data to produce acceleration signals at each grid
# point, then generates a response spectra map of signals.
# Version: Sep 25, 2015.
# ============================================================================
# */
import numpy as np
import sys
sys.path.insert(0, '/Users/kelicheng/seismtools') # insert the path to seismtools to import stools program.
from stools import max_osc_response
from htools import plot, saveDat, dis_to_acc, show_progress, loadFile
from userInput import ResponseInput
np.seterr(divide='ignore', invalid='ignore')
def response_spectra_map(userInput):
compoDic = {'x':0, 'y':1, 'z':2}
typeDic = {'a':2, 'v':1, 'd':0}
fp = userInput.fp
dimensionX = userInput.dimensionX
dimensionY = userInput.dimensionY
spaceX = userInput.spaceX
spaceY = userInput.spaceY
outSpaceX = userInput.outspaceX
outSpaceY = userInput.outspaceY
simulationTime = userInput.simulationTime
deltaT = userInput.deltaT
period = userInput.period
component = userInput.component
responseType = userInput.plotType
colorMap = userInput.colorMap
numLayer = int(simulationTime/deltaT)
downDip = dimensionX/spaceX+1
alongStrike = dimensionY/spaceY+1
numGridX = int(dimensionX/outSpaceX)+1
numGridY = int(dimensionY/outSpaceY)+1
response = np.empty((numGridY, numGridX))
# iterate through each grid points
for i in range(0, numGridX):
for j in range(0, numGridY):
dis = np.array([],float)
# read the same grid point at different layer
for k in range(0, numLayer):
x_coor = i * (outSpaceX/spaceX)
y_coor = j * (outSpaceY/spaceY)
data = loadFile(fp, alongStrike, downDip, k, y_coor, x_coor, 1)
dis = np.append(dis, data[compoDic[component]])
acc = dis_to_acc(dis, deltaT)
# calculate response and put into the matrix
response[j][i] = max_osc_response(acc, deltaT, 0.05, period, 0, 0)[typeDic[responseType]]
show_progress(i, numGridX)
sys.stdout.write('\n')
if userInput.printDat:
saveDat(userInput.out_path, dimensionX, outSpaceX, outSpaceY, response)
# plot(response, colorMap)
plot(response, userInput)
# end of response_spectra_map
if __name__ == "__main__":
if len(sys.argv) > 1:
argument = tuple(sys.argv[1:])
userInput = ResponseInput(*argument)
else:
userInput = ResponseInput()
response_spectra_map(userInput)