diff --git a/StreamCat.py b/StreamCat.py index 0deec9e..7a581d4 100644 --- a/StreamCat.py +++ b/StreamCat.py @@ -154,6 +154,10 @@ cat = appendConnectors(cat, Connector, zone, inter_vpu) accum = np.load("accum_npy/bastards/accum_%s.npz" % zone) + cat.COMID = cat.COMID.astype(accum["comids"].dtype) + cat.set_index("COMID",inplace=True) + cat = cat.loc[accum["comids"]].reset_index().copy() + up = Accumulation( cat, accum["comids"], accum["lengths"], accum["upstream"], "Up" ) diff --git a/StreamCat_functions.py b/StreamCat_functions.py index 6319504..e13d03b 100644 --- a/StreamCat_functions.py +++ b/StreamCat_functions.py @@ -817,9 +817,8 @@ def Accumulation(tbl, comids, lengths, upstream, tbl_type, icol="COMID"): data[:, index] = values data = data[np.in1d(data[:, 0], coms), :] # Remove the extra comids outDF = pd.DataFrame(data) - outDF.columns = np.append( - icol, map(lambda x: x.replace("Cat", tbl_type), cols.values) - ) + prefix = "UpCat" if tbl_type == "Up" else "Ws" + outDF.columns = [icol] + [c.replace("Cat", prefix) for c in cols.tolist()] areaName = outDF.columns[outDF.columns.str.contains("Area")][0] # identifies that there is no area in catchment mask, # then NA values for everything past Area, covers upcats w. no area AND