Skip to content

Conversation

@mwcraig
Copy link
Member

@mwcraig mwcraig commented Aug 3, 2019

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.

>>> # (everything above this was to make sample files)
>>>
>>> # Read our sample images
>>> science = fits.open(science_mef)
Copy link
Contributor

@MSeifert04 MSeifert04 Aug 3, 2019

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:

Copy link
Contributor

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).

Copy link
Member Author

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.

Copy link
Contributor

@MSeifert04 MSeifert04 Aug 4, 2019

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=False is 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.

with is probably preferable but added another level of indentation.

I agree but I think that's a worth-while level of indentation :)

@MSeifert04
Copy link
Contributor

MSeifert04 commented Aug 3, 2019

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.

@mwcraig
Copy link
Member Author

mwcraig commented Aug 3, 2019

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 tests directory in case we want it in the future.

Addressing the other comments on the next flight 😀

Copy link
Contributor

@MSeifert04 MSeifert04 left a 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.

@mwcraig mwcraig merged commit f2b4fcd into astropy:master Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserving WCS with CCDProc and MEF files

2 participants