diff --git a/teil22/.gitignore b/teil22/.gitignore new file mode 100644 index 0000000..1d82f2d --- /dev/null +++ b/teil22/.gitignore @@ -0,0 +1,4 @@ +# created by virtualenv automatically +__pycache__ +bin +lib diff --git a/teil22/StressFile.py b/teil22/StressFile.py new file mode 100644 index 0000000..612fe3c --- /dev/null +++ b/teil22/StressFile.py @@ -0,0 +1,18 @@ +import io +import numpy as np + +class StressFile: + def readOutFile(self,filename): + result = { + 'frequency': [], + 'temperatures': [] + } + with open(filename,'r') as f: + content = f.readlines() + print(f'conent= {content}') + + +sf = StressFile() + +sf.readOutFile('./kodos.out') + diff --git a/teil22/calc_array.py b/teil22/calc_array.py new file mode 100644 index 0000000..ed2bbd8 --- /dev/null +++ b/teil22/calc_array.py @@ -0,0 +1,42 @@ +import numpy as np + +# Array initialisieren +org = np.array([1,2,3,4,5,6]) + + +# Kopiert das int64 Array in ein float64 Array +def copy_to_float64(source): + liste = [] + + for i in range(source.shape[1]): + liste.append(float(source[i])) + + return np.array(liste,dtype=float64) + + +# Ein paar Kopien anlegen +copy_sum = org.copy() +copy_mult = org.copy() +copy_diff = org.copy() +copy_div = org.astype(np.float64).copy() + +# Zu allen Elementen 2 dazuzählen +copy_sum += 2 + +print(f'copy_sum={copy_sum}') + +# Alle Elemente mit 2 multiplizieren +copy_mult *= 2 + +print(f'copy_mult={copy_mult}') + + +# Von allen Elementen 1 abziehen +copy_diff -= 1 + +print(f'copy_diff={copy_diff}') + +copy_div /=2 + +print(f'copy_div={copy_div}') + diff --git a/teil22/copyarray.py b/teil22/copyarray.py new file mode 100644 index 0000000..221592a --- /dev/null +++ b/teil22/copyarray.py @@ -0,0 +1,20 @@ +import numpy as np + +org = np.array([1,2,3,4,5,6]) + +copy = org + +print(f'org= {org}') +print(f'copy={copy}') + +copy[2]= 7 + +print(f'org= {org}') +print(f'copy={copy}') + +copy2 = org.copy() + +copy2[2]= 3 + +print(f'org= {org}') +print(f'copy2={copy2}') diff --git a/teil22/reshape.py b/teil22/reshape.py new file mode 100644 index 0000000..652709c --- /dev/null +++ b/teil22/reshape.py @@ -0,0 +1,9 @@ +import numpy as np + +a = np.array([1,2,3,4,5,6,7,8,9,10]) + +print(f'orignal {a}') + +reshaped = a.reshape(2,5) + +print(f'reshaped {reshaped}') diff --git a/teil22/rndm.py b/teil22/rndm.py new file mode 100644 index 0000000..e6b729b --- /dev/null +++ b/teil22/rndm.py @@ -0,0 +1,7 @@ +import numpy as np + +#Erzeuge 1 Mio Zufallszahlen +random_np = np.random(100000) + +random_list = list(random_np) + diff --git a/teil22/shape.py b/teil22/shape.py new file mode 100644 index 0000000..525651d --- /dev/null +++ b/teil22/shape.py @@ -0,0 +1,6 @@ +import numpy as np + +twodim_array = np.array([[1,2,3,4,5],[1,4,9,16,25]]) + +print(f'shape is {twodim_array.shape}') + diff --git a/teil22/simplearray.py b/teil22/simplearray.py new file mode 100644 index 0000000..a9b4e83 --- /dev/null +++ b/teil22/simplearray.py @@ -0,0 +1,9 @@ +import numpy as np + + +simple_array = np.array([1,2,3,4,5,6]) + +print(f'simple_array={simple_array}') +print(f'ndim={simple_array.ndim}') +print(f'dtype={simple_array.dtype}') +print(f'shape is {simple_array.shape}') diff --git a/teil22/twodimarray.py b/teil22/twodimarray.py new file mode 100644 index 0000000..05d8433 --- /dev/null +++ b/teil22/twodimarray.py @@ -0,0 +1,9 @@ +import numpy as np + +twodim_array = np.array([[1,2,3,4,5],[1,4,9,16,25]],dtype='int32') + +print(f'twodim_array={twodim_array}') +print(f'ndim={twodim_array.ndim}') +print(f'dtype={twodim_array.dtype}') +print(f'shape is {twodim_array.shape}') +