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

HLA-1138: Exclude single filter images in the generation of the total detection image #1797

Merged
merged 3 commits into from
May 13, 2024

Conversation

mdlpstsci
Copy link
Collaborator

@mdlpstsci mdlpstsci commented May 13, 2024

Resolves [HLA-1138(https://jira.stsci.edu/browse/HLA-1138)

Closes #

This PR addresses ...
Exclude single filter images in the generation of the total detection
image to minimize cosmic ray contamination, unless there are only single filter images in the visit.

Checklist for maintainers

  • added entry in CHANGELOG.rst within the relevant release section
  • updated or added relevant tests
  • updated relevant documentation
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below.
    How to run regression tests on a PR

@mdlpstsci mdlpstsci added feature request Feature request jirahub-ignore Avoid linking to Jira labels May 13, 2024
@mdlpstsci mdlpstsci requested a review from rlwastro May 13, 2024 13:06
@mdlpstsci mdlpstsci self-assigned this May 13, 2024
@mdlpstsci mdlpstsci requested a review from a team as a code owner May 13, 2024 13:06
Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 31.45%. Comparing base (204588a) to head (02cce39).

Files Patch % Lines
drizzlepac/haputils/product.py 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1797      +/-   ##
==========================================
- Coverage   33.30%   31.45%   -1.85%     
==========================================
  Files         126      160      +34     
  Lines       31187    35166    +3979     
  Branches     5770        0    -5770     
==========================================
+ Hits        10386    11061     +675     
- Misses      19640    24105    +4465     
+ Partials     1161        0    -1161     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 667 to 675
set_of_filters = set([element.filters for element in self.edp_list])
count_dict = {key: [] for key in set_of_filters}

# Loop over the exposure objects to collect the exposures for each filter
for expo in self.edp_list:
for key in count_dict:
if key == expo.filters:
count_dict[key].append(expo.full_filename)
break
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
set_of_filters = set([element.filters for element in self.edp_list])
count_dict = {key: [] for key in set_of_filters}
# Loop over the exposure objects to collect the exposures for each filter
for expo in self.edp_list:
for key in count_dict:
if key == expo.filters:
count_dict[key].append(expo.full_filename)
break
count_dict = {}
# Loop over the exposure objects to collect the exposures for each filter
for expo in self.edp_list:
count_dict.set_default(expo.filters,[]).append(expo.full_filename))

I think the current code is much more complicated than it needs to be. I removed the set_of_filters variable because I think it is not used elsewhere. If I'm wrong about that, it can be computed from count_dict after the loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed. I am not very Pythonic in my thinking. Also, I forgot that by definition, a dictionary is comprised of a set of unique keys!

drizzlepac/haputils/product.py Show resolved Hide resolved
image to minimize cosmic ray contamination, unless there are only
single filter images in the visit.
added a log message as suggested during the code review.
Copy link
Collaborator

@rlwastro rlwastro left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@mdlpstsci mdlpstsci merged commit 8fc110f into spacetelescope:main May 13, 2024
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request jirahub-ignore Avoid linking to Jira
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants