import pyslammer as slam
import numpy as np
import matplotlib.pyplot as plt
%matplotlib widget
histories = slam.sample_ground_motions()
ky_const = 0.15
motion = histories["Chi-Chi_1999_TCU068-090"]
# t_step = motion[0][1] - motion[0][0]
# input_acc = motion[1] / 9.80665
inputs = {
"ky":ky_const,
"a_in":motion.accel,
"dt":motion.dt,
"height":50.0,
"vs_slope":600.0,
"vs_base":600.0,
"damp_ratio":0.05,
"ref_strain":0.0005,
"target_pga":0.6,
"soil_model":"equivalent_linear"
}
da = slam.Decoupled(**inputs)
ca = slam.Coupled(**inputs)
ca.ground_accarray([-0.00694238, -0.00641323, -0.00555932, ..., -0.00087741,
-0.0012186 , -0.00133446], shape=(13102,))
da.ground_accarray([-0.00694238, -0.00641323, -0.00555932, ..., -0.00087741,
-0.0012186 , -0.00133446], shape=(13102,))
fig = ca.sliding_block_plot()fig2 = da.sliding_block_plot()#! python3
class WordListCollection:
# this will be treated as a class variable
List1 = []
def __init__(self, list_in):
# this will be treated as an instance variable
self.List2 = list_in
def AddWordsToList1(self, words):
for word in words:
self.List1.append(word)
def AddWordsToList2(self, words):
for word in words:
self.List2.append(word)
asdf = ["a", "s", "d", "f"]
WLC1 = WordListCollection(asdf)
WLC1.Name = "WordListCollection1"
WLC1.AddWordsToList1(["apple", "pear", "banana"])
WLC1.AddWordsToList2(["Ford", "Chevy", "Dodge"])
WLC2 = WordListCollection(asdf)
WLC2.Name = "WordListCollection2"
WLC2.AddWordsToList1(["peach", "cherry", "apricot"])
WLC2.AddWordsToList2(["Mercury", "Pontiac", "Jeep"])
print(WLC1.Name)
print("List1", WLC1.List1)
print("List2", WLC1.List2)
print("")
print("--------------")
print("")
print(WLC2.Name)
print("List1", WLC2.List1)
print("List2", WLC2.List2)WordListCollection1
List1 ['apple', 'pear', 'banana', 'peach', 'cherry', 'apricot']
List2 ['a', 's', 'd', 'f', 'Ford', 'Chevy', 'Dodge', 'Mercury', 'Pontiac', 'Jeep']
--------------
WordListCollection2
List1 ['apple', 'pear', 'banana', 'peach', 'cherry', 'apricot']
List2 ['a', 's', 'd', 'f', 'Ford', 'Chevy', 'Dodge', 'Mercury', 'Pontiac', 'Jeep']
import numpy as np
class MyClass:
def __init__(self, data_array):
self.data = data_array.copy() # Create a copy of the input array
def process_data(self):
# Example: Calculate the mean of the array
return np.mean(self.data)
# Example usage
my_array = np.array([1, 2, 3, 4, 5])
instance = MyClass(my_array)
mean_value = instance.process_data()
print(f"The mean of the array is: {mean_value}")The mean of the array is: 3.0
second = MyClass(my_array)second.dataarray([1, 2, 3, 4, 5])
second.data *= -1second.dataarray([-1, -2, -3, -4, -5])
instance.dataarray([1, 2, 3, 4, 5])