Skip to content

Commit

Permalink
reduce large comment block to easier to follow inline comments
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwilby committed Jan 8, 2025
1 parent 158b6dc commit 747f7dd
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions deepsensor/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,26 +940,20 @@ def stitch_clipped_predictions(
b_x1_min, b_x1_max = patch_overlap[0], patch_overlap[0]
b_x2_min, b_x2_max = patch_overlap[1], patch_overlap[1]

"""
Do not remove border for the patches along top and left of dataset and change overlap size for last patch in each row and column.
At end of row (when patch_x2_index = data_x2_index), to calculate the number of pixels to remove from left hand side of patch:
If x2 is ascending, subtract previous patch x2 max value from current patch x2 min value to get bespoke overlap in column pixels.
To account for the clipping done to the previous patch, then subtract patch_overlap value in pixels
to get the number of pixels to remove from left hand side of patch.
If x2 is descending. Subtract current patch max x2 value from previous patch min x2 value to get bespoke overlap in column pixels.
To account for the clipping done to the previous patch, then subtract patch_overlap value in pixels
to get the number of pixels to remove from left hand side of patch.
"""
# Do not remove border for the patches along top and left of dataset and change overlap size for last patch in each row and column.
if patch_x2_index[0] == data_x2_index[0]:
b_x2_min = 0
# TODO: Try to resolve this issue in data/loader.py by ensuring patches are perfectly square.
b_x2_max = b_x2_max

# At end of row (when patch_x2_index = data_x2_index), to calculate the number of pixels to remove from left hand side of patch:
elif patch_x2_index[1] == data_x2_index[1]:
b_x2_max = 0
patch_row_prev = preds[i - 1]

# If x2 is ascending, subtract previous patch x2 max value from current patch x2 min value to get bespoke overlap in column pixels.
# To account for the clipping done to the previous patch, then subtract patch_overlap value in pixels
# to get the number of pixels to remove from left hand side of patch.
if x2_ascend:
prev_patch_x2_max = get_index(
patch_row_prev[var_name].coords[orig_x2_name].max(),
Expand All @@ -968,6 +962,10 @@ def stitch_clipped_predictions(
b_x2_min = (
prev_patch_x2_max - patch_x2_index[0]
) - patch_overlap[1]

# If x2 is descending. Subtract current patch max x2 value from previous patch min x2 value to get bespoke overlap in column pixels.
# To account for the clipping done to the previous patch, then subtract patch_overlap value in pixels
# to get the number of pixels to remove from left hand side of patch.
else:
prev_patch_x2_min = get_index(
patch_row_prev[var_name].coords[orig_x2_name].min(),
Expand Down

0 comments on commit 747f7dd

Please sign in to comment.