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

Area-preserving bilinear interpolation for Healpix maps #89

Merged
merged 4 commits into from
Oct 8, 2022

Conversation

arahlin
Copy link
Member

@arahlin arahlin commented Oct 4, 2022

The weights computed for bilinear interpolation are computed in (theta, phi) coordinates, such that the effective sample location is shifted north or south compared to its actual location, with a shift amplitude that scales like 1/nside and is largest near the poles. This PR changes the GetInterpPixelsWeights method to compute weights in (z, phi) coordinates, so that the weights are area-preserving and calculated in the coordinates in which the Healpix pixel boundaries are defined.

Note that this means that HealpixSkyMap.get_interp_values() no longer produces the same results as healpy.get_interp_val().

Thank you to Eric Hivon for identifying the issue.

The weights computed for bilinear interpolation are computed in (theta, phi) coordinates.  This PR changes the GetInterpPixelsWeights method to compute weights in (z, phi) coordinates, so that the weights are area-preserving and calculated in the coordinates in which the Healpix pixel boundaries are defined.  With the original weighting scheme, the effective sample location is shifted north or south compared to its actual location, with a shift amplitude that scales like 1/nside and is largest near the poles.

Thank you to Eric Hivon for identifying the issue.
@arahlin arahlin requested a review from hivon October 4, 2022 19:57
@arahlin arahlin self-assigned this Oct 4, 2022
@arahlin arahlin requested a review from yomori October 4, 2022 19:58
Copy link

@hivon hivon left a comment

Choose a reason for hiding this comment

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

I see one problem with the new code, not affecting SPT (since it is for the southernmost ring): line 364 should be
double wz = (z - z1) / ( -1.0 - z1);

Copy link

@hivon hivon left a comment

Choose a reason for hiding this comment

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

Actually, there is similar problem at the north pole of Healpix: line 353 should read
double wz = (z - 1.0)/(z2 - 1.0)

@arahlin arahlin requested review from hivon and Wei-Q October 5, 2022 16:24
Copy link

@yomori yomori left a comment

Choose a reason for hiding this comment

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

Tried mock-observing and verified that the code works.

@arahlin arahlin merged commit 65d44ad into master Oct 8, 2022
@arahlin arahlin deleted the hpx_interp_fix branch October 8, 2022 03:21
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

Successfully merging this pull request may close these issues.

3 participants