Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper rounding of the x/y values #305

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pysteps/feature/tstorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ def get_profile(areas, binary, ref, loc_max, time, minref):
maxref = np.nanmax(ref[cells_id.y[n], cells_id.x[n]])
contours = skime.find_contours(cell_unique, 0.8)
cells_id.cont.iloc[n] = contours
cells_id.cen_x.iloc[n] = int(np.nanmean(cells_id.x[n])) # int(x[0])
cells_id.cen_y.iloc[n] = int(np.nanmean(cells_id.y[n])) # int(y[0])
cells_id.cen_x.iloc[n] = np.round(np.nanmean(cells_id.x[n])).astype(int)
cells_id.cen_y.iloc[n] = np.round(np.nanmean(cells_id.y[n])).astype(int)
cells_id.max_ref.iloc[n] = maxref
cells_id.area.iloc[n] = len(cells_id.x.iloc[n])
labels[cells == cell_labels[n]] = ID
Expand Down
4 changes: 2 additions & 2 deletions pysteps/tracking/tdating.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ def advect(cells_id, labels, V1):
for ID, cell in cells_id.iterrows():
if cell.ID == 0 or np.isnan(cell.ID):
continue
ad_x = int(np.nanmean(V1[0, cell.y, cell.x]))
ad_y = int(np.nanmean(V1[1, cell.y, cell.x]))
ad_x = np.round(np.nanmean(V1[0, cell.y, cell.x])).astype(int)
ad_y = np.round(np.nanmean(V1[1, cell.y, cell.x])).astype(int)
new_x = cell.x + ad_x
new_y = cell.y + ad_y
new_x[new_x > labels.shape[1] - 1] = labels.shape[1] - 1
Expand Down