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

Feature/cache healpix nested grid #307

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _resolution(self):
pass

def first_axis_vals(self):
return self._final_transformation.first_axis_vals()
return self._final_transformation._first_axis_vals

def second_axis_vals(self, first_val):
return self._final_transformation.second_axis_vals(first_val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self, base_axis, mapped_axes, resolution, md5_hash=None, local_area
self.k = int(math.log2(self.Nside))
self.Npix = 12 * self.Nside * self.Nside
self.Ncap = (self.Nside * (self.Nside - 1)) << 1
self._cached_longitudes = {}
if md5_hash is not None:
self.md5_hash = md5_hash
else:
Expand Down Expand Up @@ -74,13 +75,19 @@ def HEALPix_nj(self, i):
return self.HEALPix_nj(ni - 1 - i)

def HEALPix_longitudes(self, i):
Nj = self.HEALPix_nj(i)
step = 360.0 / Nj
start = (
step / 2.0 if i < self._resolution or 3 * self._resolution - 1 < i or (i + self._resolution) % 2 else 0.0
)

longitudes = [start + n * step for n in range(Nj)]
if i in self._cached_longitudes:
return self._cached_longitudes[i]
else:
Nj = self.HEALPix_nj(i)
step = 360.0 / Nj
start = (
step / 2.0
if i < self._resolution or 3 * self._resolution - 1 < i or (i + self._resolution) % 2
else 0.0
)

longitudes = [start + n * step for n in range(Nj)]
self._cached_longitudes[i] = longitudes

return longitudes

Expand Down
Loading