Skip to content

Commit 4e1a0af

Browse files
committed
Run full dtw/hrs algorithm
1 parent 68ca108 commit 4e1a0af

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

utils/Wetlands.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def indicator_wets_only(self, make_new=False):
7777

7878
else:
7979
print ('Finding optimum criteria; will take a bit')
80-
dtw_tests = np.arange(0, 1, 0.1)
80+
dtw_tests = np.arange(0, 1, 0.01)
8181
hrs_tests = range(3000, self.mat_dtw.shape[1])
8282
mat_all = np.zeros([len(dtw_tests) * len(hrs_tests), 7])
8383

@@ -93,15 +93,17 @@ def indicator_wets_only(self, make_new=False):
9393
mat_good = mat_all[mat_all[:,2]>0]
9494
mat_good[:, 3] = mat_good[:,2]/float(mat_wet_dtw.shape[0])
9595
mat_best = mat_good[mat_good[:,4] >= 0.90]
96-
mat_best[:, 5] = 1 - ((mat_best[:,4]) / float(mat_dry_dtw.shape[0]))
97-
mat_best[:, 6] = mat_best[:,3] / (mat_best[:,5])
96+
mat_best[:, 5] = mat_best[:,4] / float(mat_dry_dtw.shape[0])
97+
mat_best[:, 6] = mat_best[:,3] / (1 - (mat_best[:,5]))
9898
colnames = ['dtw_thresh', 'hrs_thresh', 'n_wet', 'perWet', 'n_dry', 'perDry', 'perRatio']
99-
df_all = pd.DataFrame(mat_best, columns=colnames).sort_values(by='perRatio')
99+
df_all = pd.DataFrame(mat_best, columns=colnames).sort_values(by='perRatio', ascending=False)
100100

101101
np.save(op.join(self.path_data, 'dtw_hrs_wet_dry.npy'), mat_best)
102102
df_all.to_pickle(op.join(self.path_data, 'dtw_hrs_wet_dry.df'))
103103

104-
print (df_all.head(10))
104+
## do some cropping
105+
df_new = df_all[df_all.hrs_thresh > 7000]
106+
BB.print_all (df_new.head(250))
105107

106108
return mat_all, df_all
107109

0 commit comments

Comments
 (0)