Last active
April 2, 2024 02:25
-
-
Save terjehaukaas/b407aa1853d83a51afd53af0d2774cc7 to your computer and use it in GitHub Desktop.
Half Sine Wave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------------ | |
# The following Python code is implemented by Professor Terje Haukaas at | |
# the University of British Columbia in Vancouver, Canada. It is made | |
# freely available online at terje.civil.ubc.ca together with notes, | |
# examples, and additional Python code. Please be cautious when using | |
# this code; it may contain bugs and comes without warranty of any kind. | |
# ------------------------------------------------------------------------ | |
import numpy as np | |
def createHalfSineWave(T, numHalfSineWaves, dt, amplitudeINg, fileName): | |
omega = 2 * np.pi / T | |
duration = T/2.0*numHalfSineWaves | |
t = np.arange(0, duration, dt) | |
groundMotion = np.array(amplitudeINg * (np.sin(omega * t))) | |
with open(fileName, 'w') as file: | |
for i in range(len(t)): | |
file.write("%.5f " % groundMotion[i]) | |
if (i+1) % 8 == 0 and i != 0: | |
file.write('\n') | |
file.close() | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment