summaryrefslogtreecommitdiff
path: root/python/atms-310/homework/hw3/homework3.py
diff options
context:
space:
mode:
authorpants <niklasjo2004@gmail.com>2026-09-21 14:17:45 -0700
committerpants <niklasjo2004@gmail.com>2026-09-21 14:17:45 -0700
commita33d49ac4d1ce554c72770927957a089b4023bf1 (patch)
tree17ea036b5a0e8b488dc236f0ce48a275ecd80ef8 /python/atms-310/homework/hw3/homework3.py
Diffstat (limited to 'python/atms-310/homework/hw3/homework3.py')
-rwxr-xr-xpython/atms-310/homework/hw3/homework3.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/python/atms-310/homework/hw3/homework3.py b/python/atms-310/homework/hw3/homework3.py
new file mode 100755
index 0000000..31db6de
--- /dev/null
+++ b/python/atms-310/homework/hw3/homework3.py
@@ -0,0 +1,53 @@
+import numpy as np
+import scipy.stats as s
+import glob as glob # glob
+import pandas as pd
+
+filelist = glob.glob("hw3_*.txt")
+filelist.sort()
+
+def read(file):
+ fileobj = open(file, "r")
+ outputstr = fileobj.readlines()
+ fileobj.close()
+ outputarray = np.zeros(len(outputstr))
+ for i in np.arange(len(outputstr)):
+ outputarray[i] = float(outputstr[i])
+ return outputarray
+
+# parameters = ["mean", "median", "std", "iqr", "skew", "kurtosis"]
+
+# for i in range(len(filelist)):
+# print(filelist[i])
+# for n, param in enumerate(parameters):
+# np_function = getattr(np, param)
+# result = np_function(read(filelist[n]))
+# print(result)
+
+for n in range(len(filelist)):
+ print(filelist[n])
+ mean = np.mean(read(filelist[n]))
+ print("mean: " + str(mean))
+ median = np.median(read(filelist[n]))
+ print("median: " + str(median))
+ stddev = np.std(read(filelist[n]))
+ print("stddev: " + str(stddev))
+ iqr = s.iqr(read(filelist[n]))
+ print("iqr: " + str(iqr))
+ skew = s.skew(read(filelist[n]))
+ print("skew: " + str(skew))
+ kurtosis = s.kurtosis(read(filelist[n]))
+ print("kurtosis: " + str(kurtosis)+"\n")
+
+# the mean and median are similar for all files, indicating solid, outlier free data.
+# standard deviation is quite high for everything except wind shear, indicating either \
+# inconsistent readings for everything but wind shear, or more likely, smaller units and \
+# higher rates of change.
+# the difference between shr1's iqr and stddev is larger than that of shr2's (shr2's is \
+# quite close to its stddev), possibility of one minor outlier
+# none of the data is very skewed, the largest (absolute value) being 0.54896, and \
+# all of the data has negative kurtosis, meaning when distibuted, it will have a shallower \
+# peak than the bell curve (e^x^2)
+# the february and may datasets are similar in that their wind shears are similar, though \
+# mays is still larger. they are different in that mays SRH and CAPE are both much higher, \
+# so mays tornadoes are much stronger.