summaryrefslogtreecommitdiff
path: root/python/atms-310/homework/hw3/homework3.py
blob: 8f5f61572b64ca762b2199dae3b79552a296cda5 (plain)
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
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])
    data = np.array(read(filelist[i]))
    for n in range (len(parameters)):
        operation = parameters[n]
        print(str(operation) + " " + np.operation(data))


#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.