Skip to content

Commit 09c3bd3

Browse files
committed
Fix domdir thread assignement when tiled and all tiles empty.
1 parent 9625931 commit 09c3bd3

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

python/proj/mapthreads.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
"""
88

99
import so3g
10+
from .ranges import RangesMatrix
1011
import numpy as np
1112

13+
1214
def get_num_threads(n_threads=None):
1315
"""Utility function for computing n_threads. If n_threads is not
1416
None, it is returned directly. But if it is None, then the OpenMP
@@ -102,8 +104,18 @@ def get_threads_domdir(sight, fplane, shape, wcs, tile_shape=None,
102104
# Compute the scan angle, based on Q and U weights. This assumes
103105
# that +Q is parallel to map columns, and U increases along the
104106
# map diagonal.
105-
T, Q, U = np.sum([_m.reshape((3, -1)).sum(axis=-1)
106-
for _m in scan_maps if _m is not None], axis=0)
107+
if len(pmat.active_tiles) > 0:
108+
T, Q, U = np.sum([_m.reshape((3, -1)).sum(axis=-1)
109+
for _m in scan_maps if _m is not None], axis=0)
110+
else:
111+
T, Q, U = 0., 0., 0.
112+
113+
if T == 0:
114+
# No hits -- plan to do nothing, but use n_threads to avoid
115+
# needing a special test case.
116+
n_dets, n_samps = len(asm_full.dets), len(asm_full.Q)
117+
return [RangesMatrix.zeros(shape=(n_threads, n_dets, n_samps))]
118+
107119
phi = np.arctan2(U, Q) / 2
108120

109121
if plot_prefix:

0 commit comments

Comments
 (0)