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

Rearrange photometry settings and add object for photometry options #272

Merged
merged 10 commits into from
Feb 11, 2024

Conversation

mwcraig
Copy link
Contributor

@mwcraig mwcraig commented Feb 8, 2024

This is another fairly big one. It does a few things:

  • Rearrange the order of keyword arguments in single_image_photometry and multi_image_photometry so the order is the same, with keywords specific to each function at the end of each signature.
  • Adds a PhotometryOptions object that includes shift_tolerance and all of the keyword options that were common to single_image_photometry and multi_image_photometry. Also adds tests of the new object.
  • Uses that object in place of shift_tolerance and the keyword options that were common to both.
  • Modifies tests as needed to accommodate the new arguments.
  • Fixes a few bugs where arguments in multi_image_photometry were not being passed through to single_image_photometry 😀

@JuanCab -- my step will be to use these to turn the photometry functions into a class. I'm going to start building that based on this, but can of course modify in response to suggestions here.

If you can review this one by early next week that would be great. The next one, "class"-ifying photometry, will be much less extensive than this I think.

Closes #149

@codecov-commenter
Copy link

codecov-commenter commented Feb 8, 2024

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (51be03a) 69.74% compared to head (f63f2cc) 70.22%.
Report is 7 commits behind head on main.

Files Patch % Lines
stellarphot/gui_tools/comparison_functions.py 64.28% 5 Missing ⚠️
stellarphot/photometry/photometry.py 88.23% 2 Missing ⚠️
stellarphot/gui_tools/seeing_profile_functions.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #272      +/-   ##
==========================================
+ Coverage   69.74%   70.22%   +0.47%     
==========================================
  Files          24       24              
  Lines        2938     2992      +54     
==========================================
+ Hits         2049     2101      +52     
- Misses        889      891       +2     

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

@JuanCab JuanCab self-requested a review February 9, 2024 00:49
Copy link
Contributor

@JuanCab JuanCab left a comment

Choose a reason for hiding this comment

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

Mostly good (like usual). I caught a couple of issues. Two big ones:

  1. Do we need more tests of PhotometryOptions class?
  2. Do we need to provide a function to the user to set the PhotometryOptions?

Other than that, it's all the small documentation issues I usually see. I do think we should be clearer to users when listing photometry_options as a parameter for the Single image and Multi-image photometry who the user can set those parameters. I would also consider listing them in the documentation for the photometry routines.

stellarphot/photometry/photometry.py Show resolved Hide resolved
Camera,
Observatory,
PhotometryApertures,
PhotometryOptions,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not here, but I looked up PhotometryOptions in settings/models.py and noticed a typo in line 424 of that file "constrols" --> "controls".

stellarphot/photometry/photometry.py Show resolved Hide resolved
noise for each observation. If ``False``, only the Poisson noise from
the source and the sky will be included.
photometry_options : `stellarphot.settings.PhotometryOptions`
Several options for the details of performing the photometry.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to clarify how a user should set those options in the docs here?

noise for each observation. If ``False``, only the Poisson noise from
the source and the sky will be included.
photometry_options : `stellarphot.settings.PhotometryOptions`
Several options for the details of performing the photometry.
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, do we want to clarify how a user should set those options in the docs here?

# use_coordinates="pixel". In the former case, the expected
# result is the test below. In the latter case, the expected
# result is that either obs_avg_net_cnts is nan or the difference
# is bigger than the expected_deviation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I misreading this? You say you expect the different is BIGGER than the expected_deviation, but below (line 556) you assert it is smaller, no?

Also, just for my sake, can you clarify why the noise will be different in sky coords versus pixel coord?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two things

  • I rearranged the comments to make clear what the passing condition is in each case.
  • I think there is a bug somewhere, either
    • In list_of_image or in the shifting stuff that calls. The reason I say that is I think we should be able to use either pixel or sky coordinates and have this pass. In practice, the image first image is fine but the second gets negative net counts and bad fwhms.
    • Maybe in multi_image_photometry since that treats the first image different than the rest.

I'll track down what exactly the error is later this morning, I hope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You say you expect the different is BIGGER than the expected_deviation, but below (line 556) you assert it is smaller, no?

oops, now fixed

stellarphot/settings/models.py Show resolved Hide resolved
@@ -288,6 +304,16 @@ def test_observatory_lat_long_as_float():
assert obs == Observatory(**DEFAULT_OBSERVATORY_SETTINGS)


def test_photometry_settings_negative_shift_tolerance():
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we test the other parameters of PhotometryOptions?

@mwcraig
Copy link
Contributor Author

mwcraig commented Feb 9, 2024

Mostly good (like usual).

Thanks 😀

Do we need more tests of PhotometryOptions class?

I don't think so because it gets all of the tests that are here in addition for the test for the one parameter that has a constraint.

Do we need to provide a function to the user to set the PhotometryOptions?

I'm adding an example of creating one to the PhotometryOptions documentation, and added a second link to those from the single/multi image docstrings.

@mwcraig
Copy link
Contributor Author

mwcraig commented Feb 9, 2024

This was a comment inline but I'm pulling it out here too so it doesn't get overlooked. It refers to this code.

  • I rearranged the comments to make clear what the passing condition is in each case.
  • I think there is a bug somewhere, either
    • In list_of_image or in the shifting stuff that calls. The reason I say that is I think we should be able to use either pixel or sky coordinates and have this pass. In practice, the image first image is fine but the second gets negative net counts and bad fwhms.
    • Maybe in multi_image_photometry since that treats the first image different than the rest.

I'll track down what exactly the error is later this morning, I hope.

@mwcraig mwcraig requested a review from JuanCab February 9, 2024 18:19
@mwcraig
Copy link
Contributor Author

mwcraig commented Feb 9, 2024

Good news, there is no bug. The reason the test in question doesn't find sources when use_coordinates="pixel" is that the pixel coordinates are set by the position of sources in the first image, but the rest of the test images are deliberately offset from those. I added something to that effect in the comments.

@mwcraig mwcraig force-pushed the rearrange-photometry-settings branch from 4ae2b25 to d7da0fb Compare February 9, 2024 18:22
Also fixed an import in a test.
@mwcraig mwcraig force-pushed the rearrange-photometry-settings branch from d7da0fb to f63f2cc Compare February 9, 2024 18:49
# see the line where found_sources is defined.
#
# However, the images are shifted with respect to each other by
# list_of_fakes, so there are no long stars at those positions in the
Copy link
Contributor

Choose a reason for hiding this comment

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

"no long" --> "no longer"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤣 I wish we could take care of collimation issues in the software! Will fix in the next batch of changes.

@mwcraig mwcraig merged commit e853dd7 into feder-observatory:main Feb 11, 2024
9 checks passed
@mwcraig mwcraig deleted the rearrange-photometry-settings branch February 11, 2024 15:35
@mwcraig mwcraig restored the rearrange-photometry-settings branch February 12, 2024 14:14
@mwcraig mwcraig deleted the rearrange-photometry-settings branch April 29, 2024 15:40
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.

Function signatures for photometry functions
3 participants