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

Add WFC3 notebook 'wfc3_exception_report.ipynb' #102

Merged
merged 20 commits into from
Nov 21, 2023

Conversation

dulude
Copy link
Collaborator

@dulude dulude commented Oct 5, 2023

Relevant Tickets


This notebook checklist has been made available to us by the Notebooks For All team.
Its purpose is to serve as a guide for both the notebook author and the technical reviewer highlighting critical aspects to consider when striving to develop an accessible and effective notebook.

The First Cell

  • The title of the notebook in a first-level heading (eg. <h1> or # in markdown).
  • A brief description of the notebook.
  • A table of contents in an ordered list (1., 2., etc. in Markdown).
  • The author(s) and affiliation(s) (if relevant).
  • The date first published.
  • The date last edited (if relevant).
  • A link to the notebook's source(s) (if relevant).

The Rest of the Cells

  • There is only one H1 (# in Markdown) used in the notebook.
  • The notebook uses other heading tags in order (meaning it does not skip numbers).

Text

  • All link text is descriptive. It tells users where they will be taken if they open the link.
  • All acronyms are defined at least the first time they are used.
  • Field-specific/specialized terms are used when needed, but not excessively.

Code

  • Code sections are introduced and explained before they appear in the notebook. This can be fulfilled with a heading in a prior Markdown cell, a sentence preceding it, or a code comment in the code section.
  • Code has explanatory comments (if relevant). This is most important for long sections of code.
  • If the author has control over the syntax highlighting theme in the notebook, that theme has enough color contrast to be legible.
  • Code and code explanations focus on one task at a time. Unless comparison is the point of the notebook, only one method for completing the task is described at a time.

Images

  • All images (jpg, png, svgs) have an image description. This could be

    • Alt text (an alt property)
    • Empty alt text for decorative images/images meant to be skipped (an alt attribute with no value)
    • Captions
    • If no other options will work, the image is decribed in surrounding paragraphs.
  • Any text present in images exists in a text form outside of the image (this can be alt text, captions, or surrounding text.)

Visualizations

  • All visualizations have an image description. Review the previous section, Images, for more information on how to add it.

  • Visualization descriptions include

    • The type of visualization (like bar chart, scatter plot, etc.)
    • Title
    • Axis labels and range
    • Key or legend
    • An explanation of the visualization's significance to the notebook (like the trend, an outlier in the data, what the author learned from it, etc.)
  • All visualizations and their parts have enough color contrast (color contrast checker) to be legible. Remember that transparent colors have lower contrast than their opaque versions.

  • All visualizations convey information with more visual cues than color coding. Use text labels, patterns, or icons alongside color to achieve this.

  • All visualizations have an additional way for notebook readers to access the information. Linking to the original data, including a table of the data in the same notebook, or sonifying the plot are all options.

@dulude dulude added the WFC3 Wide Field Camera 3 label Oct 5, 2023
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

changes for PEP8 compliance
edits for PEP8 compliance
changes for PEP8 compiance
second markdown table in section 6.1 wasn't formatted correctly
removing the old environment installation instructions and replacing them with information about using the `requirements.txt` file
adding line breaks
@bjkuhn
Copy link
Contributor

bjkuhn commented Nov 14, 2023

@haticekaratay thank you for all your help. I've gotten everything taken care of and the notebook, readme, requirements, and docs under this branch (add_wfc3_exception_report_notebook) should be ready for final review. Please let me know if there's anything else I need to complete.

@@ -116,18 +116,21 @@
"source": [
Copy link
Collaborator

@haticekaratay haticekaratay Nov 20, 2023

Choose a reason for hiding this comment

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

Thanks for your work. I have a suggestion regarding the file paths. Replacing string concatenation with os.path.join would be more robust and platform-independent way to handle file paths.

I also suggest providing feedback to user instead of silently passing.

I had this when working you can test and try out if this suits:

Make sure to import shutils also.

# Loop through exposure id
for obsid in exp_ids: 
    # make new directory to hold fits files - named by exposure id
    newdir = os.path.join(os.getcwd(), obsid.lower())
    try:
        mkdir = os.mkdir(newdir)
        print(f'Making new directory {newdir}')
    except FileExistsError: 
        print(f'Directory {newdir} already exists.')
    
    # Loop through to get FLTs, JIFs, and JITs
    for file_type in file_types:
        print(f'Working on getting {file_type} files for Exposure ID {obsid}')
        obs_table = Observations.query_criteria(obs_id=obsid.lower())
        products = Observations.get_product_list(obs_table)
        filtered_products = Observations.filter_products(products, productSubGroupDescription=file_type, project='CALWF3')
        download_table = Observations.download_products(filtered_products, mrp_only=False)
    
        # For convenience move raws to cwd and remove empty download dir
        for file in download_table['Local Path']:
            filename = os.path.basename(file)
            new_file_path = os.path.join(newdir, filename)
            print(f'Moving {file} to {new_file_path}')
            os.rename(file, new_file_path)

            remove_dir = os.path.join('mastDownload', 'HST', filename[:9])      
            try:
                os.rmdir(remove_dir)
                print(f'Removing {remove_dir}')
            except (OSError, FileNotFoundError): 
                print(f'Error removing directory {remove_dir}')
                
    mast_dir = 'mastDownload'
    # Check and remove mastDownload directory
    if os.path.exists(mast_dir):
        print(f'Removing {mast_dir} directory')
        shutil.rmtree(mast_dir)
    else:
        print(f'{mast_dir} does not exist')



Reply via ReviewNB

@@ -116,18 +116,21 @@
"source": [
Copy link
Collaborator

@haticekaratay haticekaratay Nov 20, 2023

Choose a reason for hiding this comment

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

Hi! Thank you very much, @bjkuhn, for your work on the updates.

As a reader I would suggest we include a message for missing keywords. And also we can read header once per extension, which should make it more efficient.

for ext in range(1, numexts+1):
    print("JIF Header Ext Number:", ext)
    print('-'*80)
    header = fits.getheader(jif_file, ext)
    for keyword in keywords:
        # try to display keyword because it may not be present 
        details = header.get(keyword)
        if details is not None:
            print(f'{details}')
        else:
            print(f'Keyword {keyword} not found in extension {ext}')

Reply via ReviewNB

minor changes to make the code more robust and platform-independent
@bjkuhn
Copy link
Contributor

bjkuhn commented Nov 21, 2023

Thank you @haticekaratay! I have made the suggested changes. Please let me know if there's anything else I need to do for this notebook

i added shutil to the imports but forgot to describe it in the import markdown table
Copy link
Collaborator

@haticekaratay haticekaratay left a comment

Choose a reason for hiding this comment

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

Thank you for your work and for updating the notebook based on the reviews.

@haticekaratay haticekaratay merged commit 465c7e4 into main Nov 21, 2023
8 checks passed
@mgough-970 mgough-970 deleted the add_wfc3_exception_report_notebook branch December 6, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WFC3 Wide Field Camera 3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants