Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
earosenberg committed Mar 11, 2024
1 parent dff0d99 commit 96cd43f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion python/proj/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,16 @@ def tiling(self):

@classmethod
def for_healpix(cls, shape, pixRangeMaxes, interpol=None):
""" Construct a Projectionist for Healpix maps.
The last dimension of shape should be a valid npix in HEALPIX
pixRangeMaxes is a list of pixel ranges for thread distribution.
Should be len(nthread+1), first element 0, last element npix
"""
self=cls()
self.naxis = np.array(shape[-2:], dtype=int) # naxis[1] should hold npix
self.wcs = None
self.proj_name = 'HP'
if interpol is not None and interpol != 'nearest':
if interpol is not None and (interpol not in ['nearest', 'nn']):
raise NotImplementedError("Only 'nearest' interpolation is supported for Healpix")
self.interpol = 'nearest'
self.q_celestial_to_native = quat.quat(1,0,0,0)
Expand Down
7 changes: 6 additions & 1 deletion src/Projection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,20 @@ void Pointer<ProjCAR>::GetCoords(int i_det, int i_time,
//! Pixelizors
//
class Pixelizor_Healpix {
// Make [1, npix] full-sky maps in HEALPIX RING ordering
// int32 for pixel indexes will work up to NSIDE=8192. Assuming int is int32
public:
static const int index_count = 2;
static const int interp_count = 1;
Pixelizor_Healpix(int npix){
nside = npix2nside(npix);
naxis[0] = 1;
naxis[0] = 1; // keep 2d array for compatibility, first axis always len 1
naxis[1] = npix;
};
Pixelizor_Healpix() : naxis{1,1} {};
Pixelizor_Healpix(bp::object args) {
// args[0]: int npix
// args[1]: list<int>[nthreads+1] max pixel id for each domain for threading
bp::tuple args_tuple = bp::extract<bp::tuple>(args);
int npix = bp::extract<int>(args_tuple[0])();
bp::list pixRangeMaxes_bp = bp::extract<bp::list>(args_tuple[1])();
Expand Down Expand Up @@ -510,6 +513,8 @@ class Pixelizor_Healpix {
mapbuf->strides[3]*pixel_index[1]);
}
int stripe(const int pixel_index[], int thread_count) {
// Assign ith thread to ith pixel bin as given in externally defined pixRangeMaxes param
// Assumes pixRangeMaxes is ordered, contiguous bins, first element 0 and last element npix
for (int ii=0; ii<thread_count; ii++){
if ((pixel_index[1] >= pixRangeMaxes[ii]) && (pixel_index[1] < pixRangeMaxes[ii+1]))
return ii;
Expand Down

0 comments on commit 96cd43f

Please sign in to comment.