Skip to content

Incorporate the qFSP mask into InSAR mask#247

Open
xhuang-jpl wants to merge 39 commits intoisce-framework:developfrom
xhuang-jpl:update_insar_mask
Open

Incorporate the qFSP mask into InSAR mask#247
xhuang-jpl wants to merge 39 commits intoisce-framework:developfrom
xhuang-jpl:update_insar_mask

Conversation

@xhuang-jpl
Copy link
Copy Markdown
Contributor

@xhuang-jpl xhuang-jpl commented Apr 2, 2026

This PR is to incorporate the qFSP mask into the InSAR mask, where many places are updated including:

  1. Add the hasInputDataException to the identification group
  2. Incorporate the qSFP mask into mask in the InSAR dataset
  3. Update the geocode_insar.py
  4. Update the interpret_subswath_mask function

Xiaodong Huang added 30 commits September 19, 2023 20:40
@xhuang-jpl xhuang-jpl marked this pull request as draft April 2, 2026 18:10
@xhuang-jpl xhuang-jpl changed the title Incorporate the qFSB mask into InSAR mask Incorporate the qFSP mask into InSAR mask Apr 2, 2026
@xhuang-jpl xhuang-jpl marked this pull request as ready for review April 6, 2026 19:39
@xhuang-jpl xhuang-jpl added this to the R05.01.4 milestone Apr 6, 2026
@hfattahi
Copy link
Copy Markdown
Contributor

hfattahi commented Apr 8, 2026

We reviewed this PR in a PR review session. Overall it looks good pending testing and very minor comments provided offline.

Comment on lines +591 to +592
sec_i = int(int(i) + azimuth_off[0,int(j)] + 0.5)
sec_j = int(int(j) + range_off[0,int(j)] + 0.5)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Use round() function here

# The azimuth index is not in the radar grid meaning no subswath mask
else:
subswath_mask += [0] * len(rg_idx_arr)
mask += [0] * len(rg_idx_arr)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

may use the fillvalue (255) here

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! Thank you @xhuang-jpl for this addition. The PR looks good and I have extensively tested with real data. I do understand that we are making a change to an existing dataset in the InSAR products. We had two choices to make either add couple of extra mask datasets or modify the current mask. After detailed evaluation we decided to modify the existing mask in a largely backward compatible manner to ensure user convenience. We understand that users may need to slightly modify their InSAR readers to read mask but with this modification one can use one unified parser to parse mask dataset from both new and old products.

Here is an example code snippet for parsing RUNW mask from both old and new mask dataset.

def parse_mask(mask_value):
    """
    Decodes a RUNW/RIFG mask (8 bits or 32 bits).
    """
    # regardless if the mask_value is 8 or 32 bits, we convert to 32 bits
    mask_value = mask_value & 0xFFFFFFFF
    
    # Bits 0–7: Subswath encoding
    subswath_byte = mask_value & 0xFF
    
    ref_subswath = (subswath_byte // 10) % 10
    sec_subswath = subswath_byte % 10
    
    # Bits 8–15: Secondary RSLC anomaly flags
    sec_anomaly = (mask_value >> 8) & 0xFF

    # Bits 16–23: Reference RSLC anomaly flags
    ref_anomaly = (mask_value >> 16) & 0xFF

    # Bits 24–31: Reserved for future use
    reserved = (mask_value >> 24) & 0xFF

    return {
        "ref_subswath": ref_subswath,
        "sec_subswath": sec_subswath,
        "sec_anomaly_raw": sec_anomaly, # Binary string for bitwise flags
        "ref_anomaly_raw": ref_anomaly, # Binary string for bitwise flags
        "is_valid_subswath": (ref_subswath > 0) & (sec_subswath > 0),
        "anomaly_mask": (ref_anomaly == 0) & (sec_anomaly == 0)
    }

The code snippet requires small modification for GUNW which has extra water mask.
In a future PR we will add an ionospheric phase mask to 1 bit of the reserved bits.

Copy link
Copy Markdown
Contributor

@seongsujeong seongsujeong left a comment

Choose a reason for hiding this comment

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

LGTM.


"""
Generate the InSAR subswath 2d array mask
Generate the InSAR 2d array mask
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Generate the InSAR 2d array mask
Generate the InSAR 2d array mask

just a nit pick

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.

3 participants