hipspy / hips

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

Add property 'children' for creating four children tiles from parent tile #85

Closed adl1995 closed 7 years ago

adl1995 commented 7 years ago

As outlined in #83, I have added a property named children in HipsTile class, this splits the parent tile into four children tiles. I also added a some test cases for the first child.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.07%) to 96.847% when pulling 8de1614ecbb160a4149a6c69305af87a2bf15426 on adl1995:children_tiles into 438bbe4e396722bbf7da529447848f8f05fe4db4 on hipspy:master.

cdeil commented 7 years ago

The splitting isn't correct. For a tile of shape (512, 512), all the children should have shape (256, 256). You need to fix the implementation.

For the tests: please make a separate test_children method, don't mix the tests for the children property in with test_read.

Finally, even if the output shape of the children is correct, I guess it'll still not be clear whether their orientation is correct, or whether they are flipped in x or y or rotated. You could make a notebook drawing once the parent tile, and then the children, and show that the resulting sky image is (almost, apart from small distortiion correction) the same. I leave it up to you if you want to do this check now, or in the next PR where you use these children for drawing.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.07%) to 96.847% when pulling 8de1614ecbb160a4149a6c69305af87a2bf15426 on adl1995:children_tiles into 438bbe4e396722bbf7da529447848f8f05fe4db4 on hipspy:master.

adl1995 commented 7 years ago

@cdeil I have updated the implementation. Please check if it's correct now. For the Jupyter notebook, I would prefer to create it along with the next pull request.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.07%) to 96.854% when pulling 6a4517269c44a902303845de412ecf4286b11b19 on adl1995:children_tiles into 438bbe4e396722bbf7da529447848f8f05fe4db4 on hipspy:master.

cdeil commented 7 years ago

The implementation now splits into 4 parts with the correct shapes. But I still don't know if it's correct. You are putting the child with data[0: w, 0: w] to correspond to meta.ipix * 4 + 0, but that is just a guess, right? The correspondence which data sub-part goes with which HEALPIX ipix for the child is unclear and non-obvious (and thus probably incorrect).

My preference would be that you debug this here, because the next pull request will be even more complex, with changes to the painter, so debugging this utils function there in addition could take very long. Whereas this here is a very small pull request, and you will manage to understand, debug, fix and then document via a comment in the code the child tile order and orientation.

It's not so hard, it should be ~ 20 lines of code and take an hour: you just make a notebook where you draw a single tile, and then draw the four sub-tiles. Either the output images are correct, or you'll see that the children are in the wrong place or flipped and then adjust your code until it's correct.

--

For the test: remove all changes to the test_read() method. And change test_children to assert something about each of the four child tiles that establishes the current behaviour. Concretely I would assert on the ipix of each child, and the pixel value at pixel index (0, 255).

adl1995 commented 7 years ago

@cdeil I just tried displaying the found children tiles and compared it with the father tile, the result looks good to me. Link to notebook: https://github.com/adl1995/HIPS-to-Py/blob/master/examples/Tile%20distortion%20issue%20-%20Fix.ipynb

cdeil commented 7 years ago

Now project these tiles onto the sky image, and see if they land in the right place / with the right orientation. If it's not clear to you what to do here, let's chat on Slack.

adl1995 commented 7 years ago

@cdeil I updated the code according to your suggestions. The drawing code isn't updated yet, I will do that in the next PR.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.07%) to 96.854% when pulling e08ddcdf3c655021d5a0b96bb26ad50577e0e02a on adl1995:children_tiles into fe19120e1846aaaef4880e10669fdac2fd05aab2 on hipspy:master.

cdeil commented 7 years ago

Mui bien!