Repository navigation
Fixes issue #3552: Mention Table interface in "Creating a New Table File" in FITS docs - #3558
vinayak-mehta wants to merge 3 commits into
Conversation
|
Thanks, this seems like a good start. Though I would probably write this differently, ultimately. I would want to move it closer to the top of the section and go through a more complete example (also with links to the Table docs). Perhaps showing how to create the same table using both the Table interface, and the old lower-level PyFITS interface, and also an explanation as to why the former should be preferred in most cases. |
|
@embray - Please point out the mistakes and help me refine it. |
|
@vortex-ape Thanks, this is looking good. I don't think there's much in the way of "mistakes" though I have a few other comments. I'll get back to it in a bit. But this is definitely on the right track for what I'm looking for. |
|
Thanks again for this, but I'm probably going to finish up this update to the docs myself, though I will include your example and make sure you're credited. I just want to go a little more in-depth, and actually refactor the docs altogether to emphasize this, and other simpler options for creating table HDUs. This is perfectly good work, but it's only a start. |
|
current fits maintaienrs @embray @MSeifert04 @pllim : I'm just looking through old, open PRs. Is there any reason this has not been merged yet? Yes, somebody could rework the docs more fully but that has not happened for the last two years, so I suggest merging this as is. |
pllim
left a comment
There was a problem hiding this comment.
The PR is so old that simply restarted the failed test wouldn't work. It needs to be rebased (despite no merge conflict).
Would also be nice to post a screenshot of rendered HTML of this change.
@vinayak-mehta , sorry for the long delay. Erik is no longer involved and I wasn't signed up as a "deputy" then. If you cannot follow-up on this, just let me know and I'll take over. Since this PR existed before "allow edits from maintainers" was introduced, I will need to take over via a new PR but credit you for your original commits.
| .. note:: | ||
|
|
||
| If you want to create a simple binary FITS table with no other HDUs, | ||
| you should use the Table_ interface in Astropy instead and then |
There was a problem hiding this comment.
It is simpler to just do
:class:`~astropy.table.Table`
This way, "stable" will properly link to the API in "stable", "latest" to "latest", and so on.
| write to FITS. | ||
|
|
||
| >>> from astropy.table import Table | ||
| >>> t = Table([[1,2],[4,5],[7,8]], names=('a','b','c')) |
There was a problem hiding this comment.
Wouldn't hurt to follow PEP8 here and add spaces after commas.
|
|
||
| When using "lower-level" FITS interface, it is not usually necessary to | ||
| create column object explicitly as long as the data is stored in a | ||
| `structured array <http://docs.scipy.org/doc/numpy/user/basics.rec.html>`_. |
|
|
||
| - Code complexity is decreased. | ||
|
|
||
| .. _Table: http://astropy.readthedocs.org/en/latest/api/astropy.table.Table.html#astropy.table.Table |
There was a problem hiding this comment.
This can be removed as per my suggestion above.
|
|
||
| Benefits: | ||
|
|
||
| - Code complexity is decreased. |
There was a problem hiding this comment.
Is it really necessary to make a bulleted list out of a single item like this?
| >>> t = Table([[1,2],[4,5],[7,8]], names=('a','b','c')) | ||
| >>> t.write('table.fits', format='fits') | ||
|
|
||
| Same code in PyFITS would look like this: |
There was a problem hiding this comment.
Now that you mention it, PyFITS's move to astropy.io.fits is so long ago now that we can probably replace PyFITS reference with astropy.io.fits. 🤔
There was a problem hiding this comment.
no "probably" about it. Please change it to astropy.io.fits. PyFITS has been deprecated for 3 years now (early 2014).
There was a problem hiding this comment.
And I vaguely remember previous PRs that got rid of similar mentions of pyfits both in code and docs.
| >>> t = pyfits.BinTableHDU.from_columns([ | ||
| ... pyfits.Column(name='a', array=c1), | ||
| ... pyfits.Column(name='b', array=c2), | ||
| ... pyfits.Column(name='c', array=c3)]) |
There was a problem hiding this comment.
This doesn't work, a format is required, something like fits.Column(name='a', array=[1,2], format='K').
|
@SaraOgaz , are you going to Katniss this one too? Or should I take over? 😂 |
|
@pllim depends on how early you want it, heh. Do we know that @vinayak-mehta won't get to it? Are they still around? |
|
I think code freeze for v2 is May-ish, so we have some time yet. |
|
But if you want people to know about this in |
|
In that case, sure. I'll try and get to that today. Might need some guidance to make sure @vinayak-mehta still get's the credit. |
|
@pllim @SaraOgaz - I always feel weird about these history hacks and credit amendments. What about cherry picking the original commit from here on top of the current master, and do the fixes in a separate commits? That case the first commit will be credited to @vinayak-mehta and will have the original date, too without any hacking involved. Any additional fix will be credited to the person taking up the stab and finishing the issue. |
|
@bsipocz , I never done that before but I like the suggestion. What are the incantations involved? Thanks! |
|
You can get a branch from this PR and continue to work on it (possibly squashing the commits in one): |
|
@pllim - The other option, start with a new branch on top of the current master, and pick the 3 commits from here. I agree with @saimn, that it would be then best to squash them together. |
|
hmm, in my solution you may need to add the fork of @vinayak-mehta as a remote to be able to see these commits (I usually have the forks of many people as remotes, so haven't tried this without it). |
|
I took over and moved it to #5893 . This will close when that one is merged. FYI. |
|
Thanks to everybody who contributed work on this PR and the discussion! You might hear from me again: I've decided to comb through all open PRs to find those that are still open while "almost but not quite finished". Some are really good ideas, but the longer we wait, the more extra work somebody has to put in to finish them (rebase etc.). So, I'll try to call out those that seem easy to finish (or do it myself if I know enough about the relevant sub-package). Also, the number of open PRs can be intimidating to newcomers. |
|
Sorry for not being able to address this, saw it just today. |
|
@vinayak-mehta , no worries! |
#3552