Skip to content

Add function for interpreting quality flag#350

Merged
wtbarnes merged 3 commits intoLM-SAL:mainfrom
wtbarnes:decode-quality-flag
Feb 12, 2025
Merged

Add function for interpreting quality flag#350
wtbarnes merged 3 commits intoLM-SAL:mainfrom
wtbarnes:decode-quality-flag

Conversation

@wtbarnes
Copy link
Contributor

@wtbarnes wtbarnes commented Feb 11, 2025

The QUALITY keyword in the AIA headers is a 32-bit integer that denotes the quality of an observation. Flags associated with the observation quality are encoded bit-wise, with a different message associated with each bit flag. See section 7.7.6 of the SDO user guide for more details.

This PR adds a function that takes in the value of the QUALITY key and returns a list of messages associated with any quality flags that are set.

A few questions:

  1. Are these the standard messages associated with these flags?
  2. Should this function take a map (and pull out the quality key) rather than just an integer?
  3. Is util the right place for it to live?

Summary by Sourcery

Add a function to interpret the AIA observation QUALITY flag.

New Features:

  • Added check_quality_flag() to interpret the QUALITY keyword in AIA image headers, which is a bitmask indicating the status of the observation (e.g., nominal, calibration, eclipse).

Tests:

  • Added tests for the new check_quality_flag() function.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 11, 2025

Reviewer's Guide by Sourcery

This PR introduces a new utility function for interpreting the 32-bit QUALITY flag from AIA observation headers and returns a list of messages for the set flag bits. The implementation includes a bitwise evaluation of the QUALITY value and uses a predefined mapping of flag bits to their associated messages. Additionally, parameterized tests are added to verify the function's correctness.

Updated class diagram for aiapy/util/util.py

classDiagram
    class util_Module {
      <<module>>
      +check_quality_flag(quality: int): list
      +sdo_location(time)
      +telescope_number
      - _QUALITY_FLAG_MESSAGES: dict
    }
Loading

File-Level Changes

Change Details Files
Added a new function to decode the QUALITY flag into human-readable messages using bitwise operations.
  • Defined a mapping dictionary for quality flag bits and their corresponding messages.
  • Implemented the check_quality_flag function which returns relevant messages for set flags or ‘nominal’ if no flags are set.
  • Updated the module's public API (all) to include the new function.
aiapy/util/util.py
Added parameterized tests for the new quality flag interpretation function.
  • Created a new test function (test_check_quality_flag) to test various scenarios by constructing quality values with different flag configurations.
  • Asserted that the function returns the correct list of messages for the given bit settings.
aiapy/util/tests/test_util.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
Contributor

@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 @wtbarnes - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a named tuple or dataclass instead of a dictionary for _QUALITY_FLAG_MESSAGES.
  • The docstring could be improved by including an example of how to use the function.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 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.

@nabobalis
Copy link
Member

  • Are these the standard messages associated with these flags?

If that is what the guide says, I guess we can ask the JSOC?

  • Should this function take a map (and pull out the quality key) rather than just an integer?

I feel like that would be nice. Would kind of be nice if an AIA Map .quality returned both the value and message but thats probs not feasible.

  • Is util the right place for it to live?

Sure.

@wtbarnes wtbarnes merged commit c049ab5 into LM-SAL:main Feb 12, 2025
17 checks passed
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.

2 participants