Skip to content

RSLC: Fix broadcasting of subswath assignment in constant-PRF case#242

Merged
hfattahi merged 1 commit intoisce-framework:developfrom
bhawkins:fix_bboxes
Mar 23, 2026
Merged

RSLC: Fix broadcasting of subswath assignment in constant-PRF case#242
hfattahi merged 1 commit intoisce-framework:developfrom
bhawkins:fix_bboxes

Conversation

@bhawkins
Copy link
Copy Markdown
Contributor

A bug related to numpy broadcasting was introduced in #221 for fixed-PRF cases. For code like

reader = nisar.products.readers.Raw.open_rrsd(fn)
bboxes = reader.getSubSwathBboxes("A", "HH", num_ignore=25)

You might get an error like

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[6], line 1
----> 1 bboxes = reader.getSubSwathBboxes("A", "HH", num_ignore=25)
      2 bboxes

File ~/isce3-dev/packages/nisar/products/readers/Raw/Raw.py:939, in RawBase.getSubSwathBboxes(self, frequency, polarization, epoch, num_ignore)
    936         log.warning(f"Asked to ignore {num_ignore} pulses but there "
    937             f"are only {nt} total.")
    938         num_ignore = nt
--> 939     subswaths[:, -num_ignore:, :] = subswaths[:, -num_ignore, :]
    941 # For dithered replace subswaths (gap mask) with a single subswath
    942 # that merely tracks min[/max](https://nisar-adt-ondemand.jpl.nasa.gov/max) valid sample.  Note that gaps may still
    943 # interfere with min[/max](https://nisar-adt-ondemand.jpl.nasa.gov/max), though.
    944 if is_dithered:
    945     # Determine non-empty ranges.

ValueError: could not broadcast input array from shape (3,2) into shape (3,25,2)

I was surprised by this failure since the workflow unit test is fixed PRF. However, it didn't catch this case because it only has a single subswath, so numpy was able to figure out the broadcasting rule. The other data I tested with was all dithered PRF.

It's easy to fix just by leaving a singleton dimension so that numpy knows to broadcast over the other two.

@bhawkins bhawkins added the bug Something isn't working label Mar 23, 2026
Copy link
Copy Markdown
Contributor

@hfattahi hfattahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Copy Markdown
Contributor

@Tyler-g-hudson Tyler-g-hudson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hfattahi hfattahi merged commit 0837a2d into isce-framework:develop Mar 23, 2026
9 checks passed
@hfattahi hfattahi added this to the R05.01.3 milestone Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants