8
8
except NameError : basestring = str
9
9
10
10
def thumbnails (imap , coords , r = 5 * utils .arcmin , res = None , proj = None , apod = 2 * utils .arcmin ,
11
- order = 3 , oversample = 4 , pol = None , oshape = None , owcs = None , extensive = False , verbose = False ,
12
- filter = None ,pixwin = False ,pixwin_order = 0 ):
11
+ method = "mixed" , order = 3 , oversample = 4 , pol = None , oshape = None , owcs = None ,
12
+ extensive = False , verbose = False , filter = None ,pixwin = False ,pixwin_order = 0 ):
13
13
"""Given an enmap [...,ny,nx] and a set of coordinates in a numpy array
14
14
coords with shape (n,2) and ordering [n,{dec,ra}], extract a set
15
15
of thumbnail images [n,...,thumby,thumbx] centered on each set of
@@ -73,7 +73,7 @@ def thumbnails(imap, coords, r=5*utils.arcmin, res=None, proj=None, apod=2*utils
73
73
# Define our output maps, which we will fill below
74
74
omaps = enmap .zeros ((nsrc ,)+ imap .shape [:- 2 ]+ oshape , owcs , imap .dtype )
75
75
for si , pixbox in enumerate (pixboxes ):
76
- if oversample > 1 :
76
+ if method == "nufft" or method == "mixed" and oversample > 1 :
77
77
# Make the pixbox fft-friendly
78
78
for i in range (2 ):
79
79
pixbox [1 ,i ] = pixbox [0 ,i ] + fft .fft_len (pixbox [1 ,i ]- pixbox [0 ,i ], direction = "above" , factors = [2 ,3 ,5 ])
@@ -86,13 +86,16 @@ def thumbnails(imap, coords, r=5*utils.arcmin, res=None, proj=None, apod=2*utils
86
86
print ("%4d/%d %6.2f %6.2f %8.2f %dx%d" % (si + 1 , nsrc , coords [si ,0 ]/ utils .degree , coords [si ,1 ]/ utils .degree , np .max (ithumb ), ithumb .shape [- 2 ], ithumb .shape [- 1 ]))
87
87
# Oversample using fourier if requested. We do this because fourier
88
88
# interpolation is better than spline interpolation overall
89
- if oversample > 1 :
89
+ if method == "mixed" and oversample > 1 :
90
90
fshape = utils .nint (np .array (oshape [- 2 :])* oversample )
91
91
ithumb = ithumb .resample (fshape , method = "fft" )
92
- # I apologize for the syntax. There should be a better way of doing this
92
+ # I apologize for the syntax. There should be a better way to do this
93
93
ipos = coordinates .transform ("cel" , ["cel" ,[[0 ,0 ,coords [si ,1 ],coords [si ,0 ]],False ]], opos [::- 1 ], pol = pol )
94
94
ipos , rest = ipos [1 ::- 1 ], ipos [2 :]
95
- omaps [si ] = ithumb .at (ipos , mode = "spline" , order = order )
95
+ if method in ["spline" , "mixed" ]: ipol_mode = "spline"
96
+ elif method in ["nufft" ]: ipol_mode = "nufft"
97
+ else : raise ValueError ("Unrecognized method '%s'" % (str (method )))
98
+ omaps [si ] = ithumb .at (ipos , mode = ipol_mode , order = order )
96
99
# Apply the polarization rotation. The sign is flipped because we computed the
97
100
# rotation from the output to the input
98
101
if pol : omaps [si ] = enmap .rotate_pol (omaps [si ], - rest [0 ])
0 commit comments