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

norder limitation #25

Open
triple7 opened this issue Dec 26, 2021 · 24 comments
Open

norder limitation #25

triple7 opened this issue Dec 26, 2021 · 24 comments

Comments

@triple7
Copy link

triple7 commented Dec 26, 2021

Hi,

I'm using healpix for a different project, and have been looking around for implementations and came across yours which seems interesting. However, the limitation is at norder <= 15. Current norder doesn't allow high resolution images of nebulas for example when overlaying different frequency image survey maps (infrared, nir, xray etc). Can you tell me what the exact reason for this is? I might be able to help somehow.

I downloaded healpix 3.8 and the doc provides a healpix2 cpp that allows for much higher resolutions, which indicates that the norder can be increased?

Any pointers to the reasons of the limitations greatly appreciated as I can further investigate.

@michitaro
Copy link
Owner

The direct root of the limitation is here.

export function bit_combine(x: number, y: number) {

This function is for converting scheme from RING to NEST.

If the function could handle values of order > 16, the limitation can be eliminated.
(But, we have to care about the range of values being not bigger than Number.MAX_SAFE_INTEGER)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

@michitaro
Copy link
Owner

michitaro commented Dec 27, 2021

BTY, this library's license is MIT and HEALPix's license is GPL, so we cannot port HEALPix's implementation into this library.

@triple7
Copy link
Author

triple7 commented Dec 27, 2021 via email

@michitaro
Copy link
Owner

Sorry, I forgot there was a similar discussion. See this issue.
#8

JavaScript's bit-operation supports only 32bit integers, so bit_{,de}combine cannot handle large integers.
If the function could handle values without bit-operations, the limitation would be reduced.

@triple7
Copy link
Author

triple7 commented Dec 27, 2021 via email

@triple7
Copy link
Author

triple7 commented Dec 27, 2021 via email

@michitaro
Copy link
Owner

michitaro commented Dec 28, 2021

Have you considered breaking the bit to smaller parts? like taking the overflow bits and shifting them across to another 32-bit integer?

I think this is a good idea and more feasible than introducing BigInt.

I wonder introducing BigInt needs a lot of changes.

@triple7
Copy link
Author

triple7 commented Dec 28, 2021 via email

@michitaro
Copy link
Owner

The current test case generator generates only cases for norder <= 16, so tweak the file before your tests.
https://github.com/michitaro/healpix/blob/master/spec/generate-testcase.py
The case generator generates cases using random numbers, so the cases might not be comprehensive (edge cases might be missing). Keep in mind that.

I wonder BigInt and Newton Method bring some disadvantages on performance, so a flag to turn off BigInt mode will be helpful.

@triple7
Copy link
Author

triple7 commented Dec 28, 2021 via email

@michitaro
Copy link
Owner

I’m not sure if 12 million bigint operations a second would be an issue in applications that require healpix.

Wow, bigint operations are so fast? If so, they won't be bottleneck.

I’m writing a separate set of functions, wrapped into a HealpixIndex object.

😲

@triple7
Copy link
Author

triple7 commented Dec 28, 2021 via email

@triple7
Copy link
Author

triple7 commented Jan 1, 2022 via email

@triple7
Copy link
Author

triple7 commented Jan 1, 2022 via email

@triple7
Copy link
Author

triple7 commented Jan 2, 2022 via email

@michitaro
Copy link
Owner

Oh, sorry for the delayed response and Happy new year!
Wow! Super progress!

@michitaro
Copy link
Owner

If you can make a PR, I will tweak the test codes to suit your codes.

@triple7
Copy link
Author

triple7 commented Jan 6, 2022 via email

@michitaro
Copy link
Owner

query_disc_inclusive_nest does not return any list but accepts a callback function whose only parameter is ipix.
like this:

healpix.query_disc_inclusive_nest(nside, v, radius, ipix => {

This is to avoid allocating a large amount of memory when the resultant ipxs are too many.
If you want to get the list of ipxs, you can do something like this:

const a = []

for (const ipix of query_disc_inclusive_nest(...)) {
  a.push(ipix)
}

@michitaro
Copy link
Owner

How the example of healpix.query_disc_inclusive_nest work can be seen here.
https://michitaro.github.io/healpix/query_disc.html

@triple7
Copy link
Author

triple7 commented Jan 17, 2022 via email

@triple7
Copy link
Author

triple7 commented Jan 17, 2022 via email

@triple7
Copy link
Author

triple7 commented Jan 20, 2022 via email

@michitaro
Copy link
Owner

Hi,
Sorry for the delayed response.
Use hp.query_disc(nside=8, vec=[1, 0, 0], radius=0.008328107069661798, inclusive=True, nest=True) instead.
It also returns the same results.

import healpy

ipix = healpy.query_disc(nside=8, vec=[1, 0, 0], radius=0.008328107069661798, inclusive=True, nest=True)
print(ipix)
# [271 282 293 304]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants