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

DM-18036: Use Tables to read FITS #183

Merged
merged 1 commit into from Oct 30, 2019
Merged

DM-18036: Use Tables to read FITS #183

merged 1 commit into from Oct 30, 2019

Conversation

SimonKrughoff
Copy link
Contributor

This also includes fixing the unit tests.
Using astropy.table.Table also solves issues dealing with endianness of values coming from FITS files.

Copy link
Contributor

@erykoff erykoff left a comment

Choose a reason for hiding this comment

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

A couple of things. First, have you tested the relative speed of the Table version vs the fits version? If there's a difference, it might be fine, but I think we should know. Second, I'm confused about the string handling. Why are the strings not either true-strings or bags-o-bytes, and why is there a bunch of if/else blocks to test for this?


def testHDU2(self):
"""Test reading HDU 2 with original order"""
config = ReadFitsCatalogTask.ConfigClass()
config.hdu = 2
task = ReadFitsCatalogTask(config=config)
arr = task.run(FitsPath)
self.assertTrue(np.array_equal(arr, self.arr2))
for name in self.arr1.dtype.names:
# Table form disk ends up being bytes and in memory is unicode
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be "from disk". But I'm confused why there are these two options below? Why isn't it one or the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix the typo.

I don't know why it does this, but the array constructed from a Table read from a fits file on disk has the strings as type bytes. If the array comes from a Table constructed from a FITS object in memory, they are unicode even if I try to force them to be bytes.

I didn't want to try to figure out if it was a bug or not, so just handle the one string like column separately. I know that's not particularly satisfying, but I'd prefer to figure out the difference without the pressure of the release blockage. I'll file a ticket if that's ok with you.

Copy link
Contributor

Choose a reason for hiding this comment

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

At least put that in the comments, though is it possible that this could bite a user?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hold on ... what ticket is this associated with? It should be in the PR name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gah. Very sorry about that. I was in a rush to make the PRs. This is DM-18036.

@SimonKrughoff SimonKrughoff changed the title Use Tables to read FITS DM-18036: Use Tables to read FITS Oct 30, 2019
This also includes fixing the unit tests.
Using astropy.table.Table also solves issues dealing with endianness of values coming from FITS files.
@SimonKrughoff
Copy link
Contributor Author

@erykoff I know you already approved, but I simplified the test greatly. Feel free to have another look if you wish.

@SimonKrughoff SimonKrughoff merged commit 7b93ca0 into master Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants