- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 89
Add example of processing a MEF file and a little tinkering with section headings #694
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
Conversation
        
          
                docs/reduction_toolbox.rst
              
                Outdated
          
        
      | >>> # (everything above this was to make sample files) | ||
| >>> | ||
| >>> # Read our sample images | ||
| >>> science = fits.open(science_mef) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will leave the files open and we probably should avoid these in official "examples". One could use the double with here:
with fits.open(science_mef) as science, fits.open(flat_mef) as flat:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe even use memmap=False because we're in the global scope so the file-handle will be kept alive even if the context closes (in a function the dropping of the reference would finally close the file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added explicit .close calls at the end of the example. I agree it is bad to leave them open. I think in this case memmap=False is a bad idea because may well copy/paste the code. with is probably preferable but added another level of indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this case
memmap=Falseis a bad idea because may well copy/paste the code.
The memmap is actually because people may copy/paste the code. Closing the memmap'd file just closes the file and doesn't close the memmap if the variables referencing the memmap aren't disposed of. So in global scope I always use memmap to make sure the file and mmaps are closed properly when the context ends.
withis probably preferable but added another level of indentation.
I agree but I think that's a worth-while level of indentation :)
| Thanks Matt, I think the example and cleanup is very impressive. However I wonder if we shouldn't drop the "creation"-part of the example and just provide the two files via the repo because it somewhat distracts (especially because of the length) from the actual CCDData and ccdproc related part. | 
| 
 Good idea; I'll move the MEF-generating code into a function in the  Addressing the other comments on the next flight 😀 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good now.
The other comments can also be changed if we wanted later.
This fixes #673 by adding an example in the documentation of processing a multi-extension fits file.
While I was looking at the documentation again I fleshed out some of the section headings and rearranged a couple to make it easier for users to find what they are looking for.
@katherinebruce529, can you take a quick look? The rendered documentation is at http://physics.mnstate.edu/craig/apy20/
@MSeifert04 or @crawfordsm, if you could also take a look that would be great.