Skip to content

Refactor create_binary_nisar_mask to be less aggressive - #527

Open
sssangha wants to merge 1 commit into
devfrom
nisar_msk
Open

Refactor create_binary_nisar_mask to be less aggressive#527
sssangha wants to merge 1 commit into
devfrom
nisar_msk

Conversation

@sssangha

Copy link
Copy Markdown
Collaborator

Updated the create_binary_nisar_mask function to clarify the conditions for valid and invalid data, and modified the binary mask creation logic to consider both reference and secondary swaths.

Updated the create_binary_nisar_mask function to clarify the conditions for valid and invalid data, and modified the binary mask creation logic to consider both reference and secondary swaths.
@sssangha

Copy link
Copy Markdown
Collaborator Author
  • The Issue: The create_binary_nisar_mask function in util/stitch.py was incorrectly masking out broad swaths of valid data along the azimuth. This occurred because modulo-10 arithmetic was being applied directly to the raw mask values. If NISAR packed higher-order flags into the bits above the base 3-digit code (Bit 8+), it corrupted the modulo calculation and falsely flagged pixels as invalid.
  • The Fix: * Applied a bitwise AND mask (& 0xFF) prior to digit extraction to safely strip out any higher-order bits.
    • Updated the validation logic to verify that both the reference and secondary subswaths contain valid data (> 0), bringing the base rigor in line with MintPy's handling.
    • The intentional pass-through of the water mask (hundreds digit) was preserved to maintain user control over water bodies.
  • Impact: Eliminates arbitrary data loss along the azimuth and ensures consistent, reliable mask generation.

IFGs before vs after this patch:
OG_T062_x05016_IFGs
T062_x05016_IFGs

@sssangha
sssangha requested review from dbekaert and mgovorcin June 23, 2026 08:25
@sssangha
sssangha marked this pull request as ready for review June 23, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant