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

Update seeing profile/aperture settings notebook to use new infrastructure #358

Merged
merged 19 commits into from
Jun 3, 2024

Conversation

mwcraig
Copy link
Contributor

@mwcraig mwcraig commented May 28, 2024

This PR does a few things:

  1. Changes some of the layout of the seeing profile/aperture settings notebook
  2. Adds a camera selector(fixes Notebook 01 needs to be modified to take a Camera #246)
  3. Adds an error console to that notebook to tell the user when they need to click on a star again.
  4. Saves aperture settings and camera to a partial photometry settings file.
  5. Does some internal variable renaming to make the names more meaningful.
  6. Adds a launcher entry for this notebook.

Some things to try:

  1. Hit the launcher to get a copy of this notebook.
  2. Load an image, zoom way in and shift-click far from a star. An error message should be displayed above the image.
  3. Next, shift-click on a star. You should get some plots, and some suggested aperture settings.
  4. Save the aperture settings and verify they appear properly in the json file created by this notebook.

@JuanCab
Copy link
Contributor

JuanCab commented May 28, 2024

To perform the initial review of the functionality of this PR, I entered the following commands on the command line:

conda create -n test-358 python=3.11 astroscrappy
conda activate test-358
pip install git+https://github.com/mwcraig/stellarphot.git@camera-nb-01
jupyter lab

Addressing some of your suggested "things to try:"

  1. Hit the launcher to get a copy of this notebook.

    This worked fine although you didn't clarify WHICH notebook to copy (there were two listed). I assumed it was the "Seeing Profile" from the context clues.

  2. Load an image, zoom way in and shift-click far from a star. An error message should be displayed above the image.
    Yep, "No star found at this location" error was displayed, but not when I "shift-clicked," I had to click without holding down the shift! One potential issue, if you click at several locations far from stars, multiple error messages show up and they actually push the image down the page.

  3. Next, shift-click on a star. You should get some plots, and some suggested aperture settings.
    Again, I had to just click and not shift-click, but yes, profiles showed up.

  4. Save the aperture settings and verify they appear properly in the json file created by this notebook.
    I saved the settings and the following (apparently proper JSON content) was saved:

    {
        "camera": {
            "name": "Testing",
            "data_unit": "adu",
            "gain": "10.0 electron / adu",
            "read_noise": "10.0 electron",
            "dark_current": "0.01 electron / s",
            "pixel_scale": "0.6 arcsec / pix",
            "max_data_value": "50000.0 adu"
        },
        "observatory": null,
        "passband_map": null,
        "photometry_apertures": {
            "radius": 8,
            "gap": 5,
            "annulus_width": 15,
            "fwhm": 5.650264631520387
        },
        "source_locations": null,
        "photometry_optional_settings": null,
        "logging_settings": null
    }

@mwcraig
Copy link
Contributor Author

mwcraig commented May 29, 2024

The broken test should be fixed now, @JuanCab. Not sure I like the fix, which was to save a camera if it is passed into the seeing profile widget and is not already saved...

Copy link

codecov bot commented May 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.42%. Comparing base (312fc0c) to head (e13ddc2).
Report is 308 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
+ Coverage   75.25%   76.42%   +1.17%     
==========================================
  Files          27       27              
  Lines        3601     3657      +56     
==========================================
+ Hits         2710     2795      +85     
+ Misses        891      862      -29     

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

@JuanCab
Copy link
Contributor

JuanCab commented May 29, 2024

I'll note again this issue (stated above): "if you click at several locations far from stars, multiple error messages show up and they actually push the image down the page."

@@ -256,6 +306,29 @@ def load_fits(self):
)
self.exposure = np.nan

def save(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this function/method is not tested according to codecov, I am seeing a bunch of warnings about that inline with the code review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

About to push a fix for this....

self.aperture_settings.savebuttonbar.unsaved_changes = True
def _set_save_box_title(self, _):
if self.aperture_settings.savebuttonbar.unsaved_changes:
self.ap_title.value = self._format_title(DEFAULT_SAVE_TITLE + " ❗️")
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for maintainability, couldn't these two lines that change the self.ap_title.value use the AP_SETTING_NEEDS_SAVE and AP_SETTING_SAVED constants you defined? Might even make the code more readable. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used, including in the incoming tests

Copy link
Contributor

@Tanner728 Tanner728 left a comment

Choose a reason for hiding this comment

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

Here is my review of the code mostly focusing on the UI/UX aspects and trying to break the notebook:

  1. Just a minor note but the waffle image does not show up for either notebook in the launcher, not sure if that is intended.
  2. In windows Shift-click has the same functionality as CRTL-Click
  3. We may want to include instructions of what right clicking does and how to restore the image to the default.
  4. As @JuanCab had noted above if you click repeatedly where there is no star the error message will move the image box. This does reset after 4 messages and the image box reverts back to its initial position.
  5. May want to adjust the wording of the Radius setting to be Aperture Radius or adjust the description of it. It confused me for a little bit.

image

Overall everything passed, I did try breaking the camera selector some again but it passed with blinding colors.

@mwcraig
Copy link
Contributor Author

mwcraig commented May 31, 2024

@JuanCab @Tanner728 -- I'll open a separate PR today to add the waffle image to the repo.

@mwcraig
Copy link
Contributor Author

mwcraig commented May 31, 2024

We may want to include instructions of what right clicking does and how to restore the image to the default.

Does right-click reset the zoom?

@Tanner728
Copy link
Contributor

Tanner728 commented May 31, 2024

We may want to include instructions of what right clicking does and how to restore the image to the default.

Does right-click reset the zoom?

holding right-click and dragging adjusts brightness and contrast of the image depending on which way you drag your cursor while holding right-click. Then I think its just right-click to reset contrast and brightness, it could be shift right-click as well. I forgot.

@mwcraig
Copy link
Contributor Author

mwcraig commented May 31, 2024

@JuanCab -- I think I've addressed all of the review comments except the one about the waffle logo and the one I opened #360 for.

@mwcraig mwcraig requested a review from JuanCab June 3, 2024 15:28
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.

Looks good, only suggested edit is my usual request for clearer comments, this time just explaining what a test is testing.



def test_seeing_profile_error_messages_no_star(tmp_path):
# Make sure the appropriate error message is displayed when a click happens on
Copy link
Contributor

Choose a reason for hiding this comment

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

Logic for this test seems sound.

@mwcraig mwcraig merged commit 468a836 into feder-observatory:main Jun 3, 2024
11 checks passed
@mwcraig mwcraig deleted the camera-nb-01 branch June 3, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notebook 01 needs to be modified to take a Camera
3 participants