Python is not getting me any error, but also not the results I want (therefore I also fail to find help in the forum). I am trying to get two new arrays F_h and F_n. If item in list data_WL is larger than 0.5 I would like to have F_n as a counter and F_h to store the values above 0.5. In an overall 9 years i want to have windows of 3 years.
data_WL = [0.4001, 0.3966472, 0.4365047, 0.4950109, 0.5348455, 0.5816008, 0.5816009, 0.09, -0.03]
one_year = 3
all_years= 9
data_WL1 = [float(x) for x in data_WL] # convert items to float
print data_WL1
F_h = []
F_n = []
for i in arange(0, all_years - 1 ,1):
flood = 0
F_h.append(data_WL[i])
for j in arange(0, one_year -1,1):
if data_WL1[j] >= 0.5:
flood = flood + 1
F_h.append(float(data_WL1[j]))
else:
flood = flood
print flood
F_n.append(flood)
print "Flood frequency"
print F_n
print "Flood magnitude"
print F_h
The results should therefore look as such:
Flood Frequency
[0,2,1]
Flood magnitude
[0.5348455, 0.5816008, 0.5816009]
I´d be happy about any clues of what I might be doing wrong here. Thank you!
Aucun commentaire:
Enregistrer un commentaire