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

Remove isce dep #105

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Remove isce dep #105

wants to merge 5 commits into from

Conversation

mirzaees
Copy link
Collaborator

@mirzaees mirzaees commented Jan 29, 2025

This would remove isce2 dependency for tops data when loading them. There is still work to be done for stripmap
It also adds the correct number of looks for snaphu unwrapping

Summary by Sourcery

Remove ISCE dependency for TOPS data.

Enhancements:

  • Use meta_utils instead of isce_utils for TOPS data metadata extraction.

Tests:

  • Update tests to reflect the changes in metadata extraction and processing.

Copy link

sourcery-ai bot commented Jan 29, 2025

Reviewer's Guide by Sourcery

This pull request removes the isce2 dependency for loading TOPS data. It also adds the number of looks to the snaphu command.

Sequence diagram for TOPS metadata extraction process

sequenceDiagram
    participant C as Client
    participant M as MetaUtils
    participant X as XML Parser
    participant U as Utils
    C->>M: extract_tops_metadata(xml_file)
    M->>X: parse XML file
    X-->>M: return parsed data
    M->>U: interpolateHermite(state_vectors)
    U-->>M: return positions & velocities
    M->>U: xyz_to_llh(positions)
    U-->>M: return coordinates
    M->>U: enubasis(coordinates)
    U-->>M: return transformation matrices
    M-->>C: return metadata & frame info
Loading

Class diagram showing metadata extraction changes

classDiagram
    class MetaUtils {
        +extract_tops_metadata(xml_file)
        +extract_stripmap_metadata(xml_file)
        +extract_alosStack_metadata(xml_file)
    }
    class AstronomicalHandbook {
        +PlanetsData
        +SatellitesData
        +Constants
    }
    class Utils {
        +xyz_to_llh()
        +enubasis()
        +radiusOfCurvature()
        +interpolateHermite()
    }
    MetaUtils --> AstronomicalHandbook
    MetaUtils --> Utils
    note for MetaUtils "Replaces ISCE2 dependency"
Loading

File-Level Changes

Change Details Files
Removed the isce2 dependency for loading TOPS data.
  • Commented out the load_product function.
  • Modified extract_isce_metadata to use meta_utils.extract_tops_metadata instead of isce_utils.extract_tops_metadata for TOPS data.
  • The dependency on isce is only removed for tops, others need to be worked on
src/miaplpy/prep_slc_isce.py
Added the number of looks to the snaphu command.
  • Added nlooks to the run_unwrap function in miaplpyApp.py.
  • Added nlooks to the __init__ function in unwrap_ifgram.py.
  • Added NCORRLOOKS to the config file in unwrap_ifgram.py.
  • Added the -n argument to the unwrap_parser in arg_parser.py.
src/miaplpy/miaplpyApp.py
src/miaplpy/unwrap_ifgram.py
src/miaplpy/objects/arg_parser.py
Changed the data type of the date dataset to bytes.
  • Changed the dsDataType of the date dataset to np.bytes_ in crop_geo.py.
  • Changed the dsDataType of the date dataset to np.bytes_ in slcStack.py.
  • Changed the dtype of the dates array to np.bytes_ in ifgram_inversion_L1L2.py.
  • Changed the dtype of the data array to np.bytes_ in invert.pyx.
  • Changed the dsDataType of the date dataset to np.bytes_ in geometryStack.py.
  • Changed the dtype of the dates array to np.bytes_ in utils.py.
src/miaplpy/objects/crop_geo.py
src/miaplpy/objects/slcStack.py
src/miaplpy/dev/ifgram_inversion_L1L2.py
src/miaplpy/lib/invert.pyx
src/miaplpy/objects/geometryStack.py
src/miaplpy/objects/utils.py
Added a new file for astronomical constants and a new io utils file.
  • Added a new file AstronomicalHandBook.py containing astronomical constants.
  • Added a new file utils.py containing io utilities.
src/miaplpy/io/AstronomicalHandBook.py
src/miaplpy/io/utils.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @mirzaees - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding tests to verify the new TOPS metadata extraction produces identical results to the original ISCE2 version
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -364,6 +364,8 @@ def unwrap_parser():
help='Width of Reference .h5 file')
parser.add_argument('-sl', '--length', dest='ref_length', type=int, default=None,
help='Length of .h5 file')
parser.add_argument('-n', '--nlooks', dest='nlooks', type=int, default=200,
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Add validation for the nlooks parameter to ensure it's within reasonable bounds.

SNAPHU's correlation looks parameter should be positive and reasonably sized. Consider adding bounds checking to prevent invalid values.

Suggested implementation:

        def validate_nlooks(value):
            try:
                nlooks = int(value)
                if nlooks <= 0:
                    raise argparse.ArgumentTypeError("nlooks must be positive")
                if nlooks > 10000:  # reasonable upper bound for SNAPHU
                    raise argparse.ArgumentTypeError("nlooks value is unreasonably large (>10000)")
                return nlooks
            except ValueError:
                raise argparse.ArgumentTypeError("nlooks must be an integer")

        parser.add_argument('-n', '--nlooks', dest='nlooks', type=validate_nlooks, default=200,
                            help='The equivalent number of independent looks (positive integer, max 10000)')

You'll need to ensure that argparse is imported at the top of the file. If it's not already there, add:

import argparse

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