hipspy / hips

Python library to handle HiPS
https://hips.readthedocs.io
13 stars 16 forks source link

Add function for HiPS to HEALPix conversion #132

Closed adl1995 closed 5 years ago

adl1995 commented 6 years ago

Following issue #120, this pull request adds a function for generating a HEALPix map from HiPS.

The function is replicated from this GitHub Gist by @tboch: https://gist.github.com/tboch/f68cd1bb1529d8ac12184b40e54ba692

@cdeil - Can you please suggest some test cases for this?

cdeil commented 6 years ago

@adonath - Did you start coding up this functionality already?

@adl1995 - I don't think @adonath did, but I'm not sure.

If you want to go ahead with this, you will have to more closely study the implementation and test case at #123 for the direction HEALPix -> HiPS, and then do the other direction HiPS -> HEALPix as similar as possible.

My understanding is that the hips_to_healpix_array you introduce here basically does the same thing as the existing hips_tile_healpix_ipix_array https://github.com/hipspy/hips/blob/0b52667f09fde5ea3d323b2ef7a6c2b0e064c2c8/hips/utils/healpix.py#L125 and you should use that one.

For the test case, one thing you could do is start with HEALPix, convert to HipS tiles (no need to write to disk) and convert back to HEALPix. The input and output should be identical.

cdeil commented 6 years ago

@adl1995 - I think @adonath only wanted to extend the HEALPix -> HipS direction to also work for PNG and JPEG, so most likely this PR doesn't overlap with that and you can just go ahead if you have time.

adl1995 commented 6 years ago

@cdeil - Sorry for getting back to this so late.

I have updated the hips_to_healpix function to generate the HEALPix map from a list of HiPS tiles. However, I'm not sure how to add a correct test case for this.

In the current test case test_hips_to_healpix there is initially a healpix_data array which contains numbers from 0 till 191. The returned healpix_map from hips_to_healpix function is of size 201326592, which is computed using hp.nside2npix(2 ** 12).

Should these two arrays be identical for the function to be considered correct? I think I'm missing out on a step in the conversion process. Do you know if the HiPS paper goes into detail about this conversion process?

cdeil commented 5 years ago

I'll start a new branch to develop this functionality.