drizzle 1.15.3__cp311-cp311-win_amd64.whl → 2.0.0__cp311-cp311-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of drizzle might be problematic. Click here for more details.
- drizzle/__init__.py +2 -1
- drizzle/cdrizzle.cp311-win_amd64.pyd +0 -0
- drizzle/resample.py +702 -0
- drizzle/tests/test_cdrizzle.py +14 -9
- drizzle/tests/test_overlap_calc.py +2 -2
- drizzle/tests/test_resample.py +1437 -0
- drizzle/tests/test_utils.py +193 -0
- drizzle/util.py +17 -239
- drizzle/utils.py +239 -0
- {drizzle-1.15.3.dist-info → drizzle-2.0.0.dist-info}/METADATA +14 -176
- drizzle-2.0.0.dist-info/RECORD +15 -0
- {drizzle-1.15.3.dist-info → drizzle-2.0.0.dist-info}/WHEEL +1 -1
- drizzle/calc_pixmap.py +0 -52
- drizzle/doblot.py +0 -80
- drizzle/dodrizzle.py +0 -189
- drizzle/drizzle.py +0 -569
- drizzle/tests/test_drizzle.py +0 -834
- drizzle/tests/test_file_io.py +0 -173
- drizzle/tests/test_pixmap.py +0 -76
- drizzle-1.15.3.dist-info/RECORD +0 -18
- {drizzle-1.15.3.dist-info → drizzle-2.0.0.dist-info}/LICENSE.rst +0 -0
- {drizzle-1.15.3.dist-info → drizzle-2.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: drizzle
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: A package for combining dithered images into a single image
|
|
5
5
|
Author-email: STScI <help@stsci.edu>
|
|
6
6
|
License: Copyright (C) 2011,2014 Association of Universities for Research in
|
|
@@ -39,7 +39,7 @@ Project-URL: Homepage, https://github.com/spacetelescope/drizzle
|
|
|
39
39
|
Project-URL: Bug Tracker, https://github.com/spacetelescope/drizzle/issues
|
|
40
40
|
Project-URL: Documentation, http://spacetelescope.github.io/drizzle/
|
|
41
41
|
Project-URL: Source Code, https://github.com/spacetelescope/drizzle
|
|
42
|
-
Requires-Python:
|
|
42
|
+
Requires-Python: >=3.10
|
|
43
43
|
Description-Content-Type: text/x-rst
|
|
44
44
|
License-File: LICENSE.rst
|
|
45
45
|
Requires-Dist: numpy
|
|
@@ -49,15 +49,18 @@ Requires-Dist: sphinx ; extra == 'docs'
|
|
|
49
49
|
Requires-Dist: sphinx-automodapi ; extra == 'docs'
|
|
50
50
|
Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
|
|
51
51
|
Requires-Dist: matplotlib ; extra == 'docs'
|
|
52
|
+
Requires-Dist: pytest-doctestplus ; extra == 'docs'
|
|
52
53
|
Requires-Dist: tomli ; (python_version < "3.11") and extra == 'docs'
|
|
53
54
|
Provides-Extra: test
|
|
54
55
|
Requires-Dist: pytest ; extra == 'test'
|
|
56
|
+
Requires-Dist: pytest-cov ; extra == 'test'
|
|
57
|
+
Requires-Dist: pytest-doctestplus ; extra == 'test'
|
|
55
58
|
|
|
56
59
|
drizzle Documentation
|
|
57
60
|
=====================
|
|
58
61
|
|
|
59
|
-
.. image::
|
|
60
|
-
:target:
|
|
62
|
+
.. image:: https://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat
|
|
63
|
+
:target: https://www.astropy.org
|
|
61
64
|
:alt: Powered by Astropy Badge
|
|
62
65
|
|
|
63
66
|
.. image:: https://codecov.io/github/spacetelescope/drizzle/branch/main/graphs/badge.svg
|
|
@@ -76,6 +79,10 @@ drizzle Documentation
|
|
|
76
79
|
:target: https://pypi.org/project/drizzle
|
|
77
80
|
:alt: PyPI Status
|
|
78
81
|
|
|
82
|
+
.. image:: https://zenodo.org/badge/28100377.svg
|
|
83
|
+
:target: https://doi.org/10.5281/zenodo.10672889
|
|
84
|
+
:alt: Zenodo DOI
|
|
85
|
+
|
|
79
86
|
The ``drizzle`` library is a Python package for combining dithered images into a
|
|
80
87
|
single image. This library is derived from code used in DrizzlePac. Like
|
|
81
88
|
DrizzlePac, most of the code is implemented in the C language. The biggest
|
|
@@ -188,177 +195,8 @@ missing information.
|
|
|
188
195
|
The blot methods perform the inverse operation of drizzle. That is, blotting
|
|
189
196
|
performs the inverse mapping to transform the dithered median image back into
|
|
190
197
|
the coordinate system of the original input image. Blotting is primarily used
|
|
191
|
-
for identifying cosmic rays in the original image.
|
|
192
|
-
|
|
193
|
-
|
|
198
|
+
for identifying cosmic rays in the original image. Blot requires the user
|
|
199
|
+
to provide the world coordinate system (WCS)-based transformations in the
|
|
200
|
+
form of a pixel map array as input.
|
|
194
201
|
|
|
195
202
|
.. [Driz2012] Gonzaga, S., Hack, W., Fruchter, A., Mack, J., eds. 2012, The DrizzlePac Handbook. (Baltimore, STScI)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
The Drizzle Library
|
|
199
|
-
-------------------
|
|
200
|
-
|
|
201
|
-
The Drizzle library is object-oriented and you use it by first creating an object of
|
|
202
|
-
the ``Drizzle`` class. To create a new Drizzle output image, supply an Astropy
|
|
203
|
-
WCS object representing the coordinate system of the output image.
|
|
204
|
-
The other parameters are the linear pixel dimension described in the previous
|
|
205
|
-
section, the drizzle kernel used, how each input image is scaled (by exposure
|
|
206
|
-
time or time squared), and the pixel value set in the output image where the
|
|
207
|
-
input images do not overlap.
|
|
208
|
-
|
|
209
|
-
After creating a Drizzle object, you add one or more images by calling the
|
|
210
|
-
``add_fits_file`` method. The arguments are the name of the FITS file containing
|
|
211
|
-
the input image and optionally the name of a FITS file containing the pixel
|
|
212
|
-
weighting. Both file names can be followed by an extension name or number in
|
|
213
|
-
square brackets. Optionally you can pass the name of the header keywords
|
|
214
|
-
containing the exposure time and units. Two units are understood: counts and
|
|
215
|
-
cps (counts per second).
|
|
216
|
-
|
|
217
|
-
The following function is a demonstration of how you can create a new output
|
|
218
|
-
image::
|
|
219
|
-
|
|
220
|
-
def drizzle_demo_one(reference, outfile, infiles):
|
|
221
|
-
"""
|
|
222
|
-
First demonstration of drizzle
|
|
223
|
-
|
|
224
|
-
Parameters
|
|
225
|
-
==========
|
|
226
|
-
reference
|
|
227
|
-
A file containing the wcs of the output image
|
|
228
|
-
|
|
229
|
-
outfile
|
|
230
|
-
The name of the output image
|
|
231
|
-
|
|
232
|
-
infiles
|
|
233
|
-
The names of the input images to be combined
|
|
234
|
-
"""
|
|
235
|
-
# Get the WCS for the output image
|
|
236
|
-
hdulist = fits.open(reference)
|
|
237
|
-
reference_wcs = wcs.WCS(hdulist[1].header)
|
|
238
|
-
|
|
239
|
-
# Initialize the output with the WCS
|
|
240
|
-
driz = drizzle.drizzle.Drizzle(outwcs=reference_wcs)
|
|
241
|
-
|
|
242
|
-
# Combine the input images into on drizzle image
|
|
243
|
-
for infile in infiles:
|
|
244
|
-
driz.add_fits_file(infile)
|
|
245
|
-
|
|
246
|
-
# Write the drizzled image out
|
|
247
|
-
driz.write(outfile)
|
|
248
|
-
|
|
249
|
-
Optionally you can supply the input and weight images as Numpy arrays by using
|
|
250
|
-
the ``add_image`` method. If you use this method, you must supply the extra
|
|
251
|
-
information that would otherwise be read from the FITS image: The WCS
|
|
252
|
-
of the input image, the exposure time, and image units.
|
|
253
|
-
|
|
254
|
-
Here is an example of how you would call ``add_image``::
|
|
255
|
-
|
|
256
|
-
def drizzle_demo_two(reference, outfile, infiles):
|
|
257
|
-
"""
|
|
258
|
-
Demonstration of drizzle with add image.
|
|
259
|
-
|
|
260
|
-
Parameters
|
|
261
|
-
==========
|
|
262
|
-
reference
|
|
263
|
-
A file containing the wcs of the output image.
|
|
264
|
-
|
|
265
|
-
outfile
|
|
266
|
-
The name of the output image.
|
|
267
|
-
|
|
268
|
-
infiles
|
|
269
|
-
The names of the input images to be combined.
|
|
270
|
-
"""
|
|
271
|
-
# Get the WCS for the output image
|
|
272
|
-
reflist = fits.open(reference)
|
|
273
|
-
reference_wcs = wcs.WCS(reflist[1].header)
|
|
274
|
-
|
|
275
|
-
# Initialize the output with the WCS
|
|
276
|
-
driz = drizzle.drizzle.Drizzle(outwcs=reference_wcs)
|
|
277
|
-
|
|
278
|
-
# Combine the input images into on drizzle image
|
|
279
|
-
for infile in infiles:
|
|
280
|
-
# Open the file and read the image and wcs
|
|
281
|
-
# This is a contrived example, we would not do this
|
|
282
|
-
# unless the data came from another source
|
|
283
|
-
# than a FITS file
|
|
284
|
-
imlist = fits.open(reference)
|
|
285
|
-
image = imlist[1].data
|
|
286
|
-
image_wcs = wcs.WCS(imlist[1].header)
|
|
287
|
-
driz.add_image(image, image_wcs)
|
|
288
|
-
|
|
289
|
-
# Write the drizzled image out
|
|
290
|
-
driz.write(outfile)
|
|
291
|
-
|
|
292
|
-
After combining all the input images, you write the output image into a FITS
|
|
293
|
-
file with the ``write`` method. You must pass the name of the output image and
|
|
294
|
-
optionally the units. You can also supply a set of header cards to be added
|
|
295
|
-
to the primary header of the output FITS file.
|
|
296
|
-
|
|
297
|
-
You can also add more images to an existing Drizzle output file by creating
|
|
298
|
-
a new Drizzle object and passing the existing output file name as the new
|
|
299
|
-
object is created. In that case the output WCS and all
|
|
300
|
-
other parameters are read from the file.
|
|
301
|
-
|
|
302
|
-
Here is a demonstration of adding additional input images to a drizzled image::
|
|
303
|
-
|
|
304
|
-
def drizzle_demo_three(outfile, infiles):
|
|
305
|
-
"""
|
|
306
|
-
Demonstration of drizzle and adding to an existing output.
|
|
307
|
-
|
|
308
|
-
Parameters
|
|
309
|
-
==========
|
|
310
|
-
outfile
|
|
311
|
-
Name of output image that new files will be appended to.
|
|
312
|
-
|
|
313
|
-
infiles
|
|
314
|
-
The names of the input images to be added.
|
|
315
|
-
"""
|
|
316
|
-
# Re-open the output file
|
|
317
|
-
driz = drizzle.drizzle.Drizzle(infile=outfile)
|
|
318
|
-
|
|
319
|
-
# Add the input images to the existing output image
|
|
320
|
-
for infile in infiles:
|
|
321
|
-
driz.add_fits_file(infile)
|
|
322
|
-
|
|
323
|
-
# Write the modified drizzled image out
|
|
324
|
-
driz.write(outfile)
|
|
325
|
-
|
|
326
|
-
You can use the methods ``blot_fits_file`` and ``blot_image`` to transform the drizzled
|
|
327
|
-
output image into another WCS. Most usually this is the
|
|
328
|
-
coordinates of one of the input images and is used to identify cosmic rays or
|
|
329
|
-
other defects. The two methods ``blot_fits_file`` and ``blot_image`` allow you to
|
|
330
|
-
retrieve the WCS from the FITS file header or input it directly.
|
|
331
|
-
The optional parameter ``interp`` allows you to selct the method used to resample
|
|
332
|
-
the pixels on the new grid, and ``sincscl`` is used to scale the sinc function if one
|
|
333
|
-
of the sinc interpolation methods is used. This function demonstrates how both
|
|
334
|
-
methods are called::
|
|
335
|
-
|
|
336
|
-
def drizzle_demo_four(outfile, blotfile):
|
|
337
|
-
"""
|
|
338
|
-
Demonstration of blot methods.
|
|
339
|
-
|
|
340
|
-
Parameters
|
|
341
|
-
==========
|
|
342
|
-
outfile
|
|
343
|
-
Name of output image that will be converted.
|
|
344
|
-
|
|
345
|
-
blotfile
|
|
346
|
-
Name of image containing wcs to be transformed to.
|
|
347
|
-
"""
|
|
348
|
-
# Open drizzle using the output file
|
|
349
|
-
# Transform it to another coordinate system
|
|
350
|
-
driz = drizzle.drizzle.Drizzle(infile=outfile)
|
|
351
|
-
driz.blot_fits_file(blotfile)
|
|
352
|
-
driz.write(outfile)
|
|
353
|
-
|
|
354
|
-
# Read the WCS and transform using it instead
|
|
355
|
-
# This is a contrived example
|
|
356
|
-
blotlist = fits.open(blotfile)
|
|
357
|
-
blot_wcs = wcs.WCS(blotlist[1].header)
|
|
358
|
-
driz = drizzle.drizzle.Drizzle(infile=outfile)
|
|
359
|
-
driz.blot_image(blot_wcs)
|
|
360
|
-
driz.write(outfile)
|
|
361
|
-
|
|
362
|
-
The lower level function ``dodrizzle`` is present for backwards compatibility with
|
|
363
|
-
the existing STScI DrizzlePac code and should not be used unless you are also
|
|
364
|
-
concerned with this compatibility.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
drizzle/__init__.py,sha256=hMpqmjPhrUWTRU0eXNOcrpiqQFGp4lf9opY8FXqLLEQ,325
|
|
2
|
+
drizzle/cdrizzle.cp311-win_amd64.pyd,sha256=QC1vJU0jPGFFy7smjoUWtv8zYMW9_QvwlOlguYg8Y4A,100864
|
|
3
|
+
drizzle/resample.py,sha256=t6HCYNWwnz4-mKYtzIWDFIEkHOi84ZI5GD4x3L6Wp0k,28982
|
|
4
|
+
drizzle/util.py,sha256=os9wHm1JkKiG5jtnNCZAXG3vnnXxLHBpi8OTWsiPI7k,845
|
|
5
|
+
drizzle/utils.py,sha256=Mze8pASdCiSXEsIJNIGkTcLbqszpJrrE5U576AtkzeI,8776
|
|
6
|
+
drizzle/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
drizzle/tests/test_cdrizzle.py,sha256=utepqMiY8xtgQ8gBRBHwnlMhbBB1pq1xE4spf-wO7Kw,726
|
|
8
|
+
drizzle/tests/test_overlap_calc.py,sha256=ucwDL9fd8NVAxTdz-sWum_uobhm-TGkCr2yl69BKiC4,7062
|
|
9
|
+
drizzle/tests/test_resample.py,sha256=Xtov5vpVOEWOscKngGl8GkDyWSj_GpRNlceGIJ_Jdfg,41014
|
|
10
|
+
drizzle/tests/test_utils.py,sha256=rlRvd7JKo7YeVPIhYAYg4WgXLN7yge39Zkngv8jq4ds,5889
|
|
11
|
+
drizzle-2.0.0.dist-info/LICENSE.rst,sha256=sUXj5W73D9TcOw5ZXaDdcthYdY2b2dTJPsxBuZTOYWQ,1505
|
|
12
|
+
drizzle-2.0.0.dist-info/METADATA,sha256=dv6lr7uK6t4T5IzDF4UYvS5vYXBFhd0ZWQdTPdFMJ0Y,10850
|
|
13
|
+
drizzle-2.0.0.dist-info/WHEEL,sha256=tE2EWZPEv-G0fjAlUUz7IGM64246YKD9fpv4HcsDMkk,101
|
|
14
|
+
drizzle-2.0.0.dist-info/top_level.txt,sha256=MA5uqwTj1sJBi-hCeQj9v3-sZ9nVUTe6bd_zGWTKy5A,8
|
|
15
|
+
drizzle-2.0.0.dist-info/RECORD,,
|
drizzle/calc_pixmap.py
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def calc_pixmap(first_wcs, second_wcs):
|
|
5
|
-
"""
|
|
6
|
-
Calculate a mapping between the pixels of two images.
|
|
7
|
-
|
|
8
|
-
Parameters
|
|
9
|
-
----------
|
|
10
|
-
|
|
11
|
-
first_wcs : wcs
|
|
12
|
-
A WCS object representing the coordinate system you are
|
|
13
|
-
converting from
|
|
14
|
-
|
|
15
|
-
seond_wcs : wcs
|
|
16
|
-
A WCS object representing the coordinate system you are
|
|
17
|
-
converting to
|
|
18
|
-
|
|
19
|
-
Returns
|
|
20
|
-
-------
|
|
21
|
-
|
|
22
|
-
A three dimensional array representing the transformation between
|
|
23
|
-
the two. The last dimension is of length two and contains the x and
|
|
24
|
-
y coordinates of a pixel center, repectively. The other two coordinates
|
|
25
|
-
correspond to the two coordinates of the image the first WCS is from.
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
first_naxis1, first_naxis2 = first_wcs.pixel_shape
|
|
29
|
-
|
|
30
|
-
# We add one to the pixel co-ordinates before the transformation and subtract
|
|
31
|
-
# it afterwards because wcs co-ordinates are one based, while pixel co-ordinates
|
|
32
|
-
# are zero based, The result is the final values in pixmap give a tranformation
|
|
33
|
-
# between the pixel co-ordinates in the first image to pixel co-ordinates in the
|
|
34
|
-
# co-ordinate system of the second.
|
|
35
|
-
|
|
36
|
-
one = np.ones(2, dtype='float64')
|
|
37
|
-
idxmap = np.indices((first_naxis1, first_naxis2), dtype='float64')
|
|
38
|
-
idxmap = idxmap.transpose() + one
|
|
39
|
-
|
|
40
|
-
idxmap = idxmap.reshape(first_naxis2 * first_naxis1, 2)
|
|
41
|
-
|
|
42
|
-
worldmap = first_wcs.all_pix2world(idxmap, 1)
|
|
43
|
-
|
|
44
|
-
if second_wcs.sip is None:
|
|
45
|
-
pixmap = second_wcs.wcs_world2pix(worldmap, 1)
|
|
46
|
-
else:
|
|
47
|
-
pixmap = second_wcs.all_world2pix(worldmap, 1)
|
|
48
|
-
|
|
49
|
-
pixmap = pixmap.reshape(first_naxis2, first_naxis1, 2)
|
|
50
|
-
pixmap = pixmap - one
|
|
51
|
-
|
|
52
|
-
return pixmap
|
drizzle/doblot.py
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
STScI Python compatable blot module
|
|
3
|
-
"""
|
|
4
|
-
import numpy as np
|
|
5
|
-
|
|
6
|
-
from drizzle import calc_pixmap
|
|
7
|
-
from drizzle import cdrizzle
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def doblot(source, source_wcs, blot_wcs, exptime, coeffs=True,
|
|
11
|
-
interp='poly5', sinscl=1.0, stepsize=10, wcsmap=None):
|
|
12
|
-
"""
|
|
13
|
-
Low level routine for performing the 'blot' operation.
|
|
14
|
-
|
|
15
|
-
Create a single blotted image from a single source image. The
|
|
16
|
-
interface is compatible with STScI code. All distortion information
|
|
17
|
-
is assumed to be included in the WCS specification of the 'output'
|
|
18
|
-
blotted image given in 'blot_wcs'.
|
|
19
|
-
|
|
20
|
-
Parameters
|
|
21
|
-
----------
|
|
22
|
-
|
|
23
|
-
source : 2d array
|
|
24
|
-
Input numpy array of the source image in units of 'cps'.
|
|
25
|
-
|
|
26
|
-
source_wcs : wcs
|
|
27
|
-
The source image WCS.
|
|
28
|
-
|
|
29
|
-
blot_wcs : wcs
|
|
30
|
-
The blotted image WCS. The WCS that the source image will be
|
|
31
|
-
resampled to.
|
|
32
|
-
|
|
33
|
-
exptime : float
|
|
34
|
-
The exposure time of the input image.
|
|
35
|
-
|
|
36
|
-
interp : str, optional
|
|
37
|
-
The type of interpolation used in the blotting. The
|
|
38
|
-
possible values are "nearest" (nearest neighbor interpolation),
|
|
39
|
-
"linear" (bilinear interpolation), "poly3" (cubic polynomial
|
|
40
|
-
interpolation), "poly5" (quintic polynomial interpolation),
|
|
41
|
-
"sinc" (sinc interpolation), "lan3" (3rd order Lanczos
|
|
42
|
-
interpolation), and "lan5" (5th order Lanczos interpolation).
|
|
43
|
-
|
|
44
|
-
sincscl : float, optional
|
|
45
|
-
The scaling factor for sinc interpolation.
|
|
46
|
-
|
|
47
|
-
Returns
|
|
48
|
-
-------
|
|
49
|
-
|
|
50
|
-
A 2d numpy array with the blotted image
|
|
51
|
-
|
|
52
|
-
Other Parameters
|
|
53
|
-
----------------
|
|
54
|
-
|
|
55
|
-
coeffs : bool, optional
|
|
56
|
-
Not used. Only kept for backwards compatibility.
|
|
57
|
-
|
|
58
|
-
stepsize : float, optional
|
|
59
|
-
Was used when input to output mapping was computed
|
|
60
|
-
internally. Is no longer used and only here for backwards compatibility.
|
|
61
|
-
|
|
62
|
-
wcsmap : function, optional
|
|
63
|
-
Was used when input to output mapping was computed
|
|
64
|
-
internally. Is no longer used and only here for backwards compatibility.
|
|
65
|
-
"""
|
|
66
|
-
_outsci = np.zeros(blot_wcs.pixel_shape[::-1], dtype=np.float32)
|
|
67
|
-
|
|
68
|
-
# compute the undistorted 'natural' plate scale
|
|
69
|
-
blot_wcs.sip = None
|
|
70
|
-
blot_wcs.cpdis1 = None
|
|
71
|
-
blot_wcs.cpdis2 = None
|
|
72
|
-
blot_wcs.det2im = None
|
|
73
|
-
|
|
74
|
-
pixmap = calc_pixmap.calc_pixmap(blot_wcs, source_wcs)
|
|
75
|
-
pix_ratio = source_wcs.pscale / blot_wcs.pscale
|
|
76
|
-
|
|
77
|
-
cdrizzle.tblot(source, pixmap, _outsci, scale=pix_ratio, kscale=1.0,
|
|
78
|
-
interp=interp, exptime=exptime, misval=0.0, sinscl=sinscl)
|
|
79
|
-
|
|
80
|
-
return _outsci
|
drizzle/dodrizzle.py
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
STScI Python compatable drizzle module
|
|
3
|
-
"""
|
|
4
|
-
import numpy as np
|
|
5
|
-
|
|
6
|
-
from . import util
|
|
7
|
-
from . import calc_pixmap
|
|
8
|
-
from . import cdrizzle
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def dodrizzle(insci, input_wcs, inwht,
|
|
12
|
-
output_wcs, outsci, outwht, outcon,
|
|
13
|
-
expin, in_units, wt_scl,
|
|
14
|
-
wcslin_pscale=1.0, uniqid=1,
|
|
15
|
-
xmin=0, xmax=0, ymin=0, ymax=0,
|
|
16
|
-
pixfrac=1.0, kernel='square', fillval="INDEF"):
|
|
17
|
-
"""
|
|
18
|
-
Low level routine for performing 'drizzle' operation.on one image.
|
|
19
|
-
|
|
20
|
-
The interface is compatible with STScI code. All images are Python
|
|
21
|
-
ndarrays, instead of filenames. File handling (input and output) is
|
|
22
|
-
performed by the calling routine.
|
|
23
|
-
|
|
24
|
-
Parameters
|
|
25
|
-
----------
|
|
26
|
-
|
|
27
|
-
insci : 2d array
|
|
28
|
-
A 2d numpy array containing the input image to be drizzled.
|
|
29
|
-
it is an error to not supply an image.
|
|
30
|
-
|
|
31
|
-
input_wcs : 2d array
|
|
32
|
-
The world coordinate system of the input image.
|
|
33
|
-
|
|
34
|
-
inwht : 2d array
|
|
35
|
-
A 2d numpy array containing the pixel by pixel weighting.
|
|
36
|
-
Must have the same dimensions as insci. If none is supplied,
|
|
37
|
-
the weghting is set to one.
|
|
38
|
-
|
|
39
|
-
output_wcs : wcs
|
|
40
|
-
The world coordinate system of the output image.
|
|
41
|
-
|
|
42
|
-
outsci : 2d array
|
|
43
|
-
A 2d numpy array containing the output image produced by
|
|
44
|
-
drizzling. On the first call it should be set to zero.
|
|
45
|
-
Subsequent calls it will hold the intermediate results
|
|
46
|
-
|
|
47
|
-
outwht : 2d array
|
|
48
|
-
A 2d numpy array containing the output counts. On the first
|
|
49
|
-
call it should be set to zero. On subsequent calls it will
|
|
50
|
-
hold the intermediate results.
|
|
51
|
-
|
|
52
|
-
outcon : 2d or 3d array, optional
|
|
53
|
-
A 2d or 3d numpy array holding a bitmap of which image was an input
|
|
54
|
-
for each output pixel. Should be integer zero on first call.
|
|
55
|
-
Subsequent calls hold intermediate results.
|
|
56
|
-
|
|
57
|
-
expin : float
|
|
58
|
-
The exposure time of the input image, a positive number. The
|
|
59
|
-
exposure time is used to scale the image if the units are counts.
|
|
60
|
-
|
|
61
|
-
in_units : str
|
|
62
|
-
The units of the input image. The units can either be "counts"
|
|
63
|
-
or "cps" (counts per second.)
|
|
64
|
-
|
|
65
|
-
wt_scl : float
|
|
66
|
-
A scaling factor applied to the pixel by pixel weighting.
|
|
67
|
-
|
|
68
|
-
wcslin_pscale : float, optional
|
|
69
|
-
The pixel scale of the input image. Conceptually, this is the
|
|
70
|
-
linear dimension of a side of a pixel in the input image, but it
|
|
71
|
-
is not limited to this and can be set to change how the drizzling
|
|
72
|
-
algorithm operates.
|
|
73
|
-
|
|
74
|
-
uniqid : int, optional
|
|
75
|
-
The id number of the input image. Should be one the first time
|
|
76
|
-
this function is called and incremented by one on each subsequent
|
|
77
|
-
call.
|
|
78
|
-
|
|
79
|
-
xmin : float, optional
|
|
80
|
-
This and the following three parameters set a bounding rectangle
|
|
81
|
-
on the input image. Only pixels on the input image inside this
|
|
82
|
-
rectangle will have their flux added to the output image. Xmin
|
|
83
|
-
sets the minimum value of the x dimension. The x dimension is the
|
|
84
|
-
dimension that varies quickest on the image. If the value is zero,
|
|
85
|
-
no minimum will be set in the x dimension. All four parameters are
|
|
86
|
-
zero based, counting starts at zero.
|
|
87
|
-
|
|
88
|
-
xmax : float, optional
|
|
89
|
-
Sets the maximum value of the x dimension on the bounding box
|
|
90
|
-
of the input image. If the value is zero, no maximum will
|
|
91
|
-
be set in the x dimension, the full x dimension of the output
|
|
92
|
-
image is the bounding box.
|
|
93
|
-
|
|
94
|
-
ymin : float, optional
|
|
95
|
-
Sets the minimum value in the y dimension on the bounding box. The
|
|
96
|
-
y dimension varies less rapidly than the x and represents the line
|
|
97
|
-
index on the input image. If the value is zero, no minimum will be
|
|
98
|
-
set in the y dimension.
|
|
99
|
-
|
|
100
|
-
ymax : float, optional
|
|
101
|
-
Sets the maximum value in the y dimension. If the value is zero, no
|
|
102
|
-
maximum will be set in the y dimension, the full x dimension
|
|
103
|
-
of the output image is the bounding box.
|
|
104
|
-
|
|
105
|
-
pixfrac : float, optional
|
|
106
|
-
The fraction of a pixel that the pixel flux is confined to. The
|
|
107
|
-
default value of 1 has the pixel flux evenly spread across the image.
|
|
108
|
-
A value of 0.5 confines it to half a pixel in the linear dimension,
|
|
109
|
-
so the flux is confined to a quarter of the pixel area when the square
|
|
110
|
-
kernel is used.
|
|
111
|
-
|
|
112
|
-
kernel: str, optional
|
|
113
|
-
The name of the kernel used to combine the input. The choice of
|
|
114
|
-
kernel controls the distribution of flux over the kernel. The kernel
|
|
115
|
-
names are: "square", "turbo", "point", "gaussian", "lanczos2",
|
|
116
|
-
and "lanczos3".
|
|
117
|
-
|
|
118
|
-
.. warning::
|
|
119
|
-
The "gaussian" and "lanczos2/3" kernels **DO NOT** conserve flux.
|
|
120
|
-
|
|
121
|
-
fillval: str, optional
|
|
122
|
-
The value a pixel is set to in the output if the input image does
|
|
123
|
-
not overlap it. The default value of INDEF does not set a value.
|
|
124
|
-
|
|
125
|
-
Returns
|
|
126
|
-
-------
|
|
127
|
-
A tuple with three values: a version string, the number of pixels
|
|
128
|
-
on the input image that do not overlap the output image, and the
|
|
129
|
-
number of complete lines on the input image that do not overlap the
|
|
130
|
-
output input image.
|
|
131
|
-
|
|
132
|
-
"""
|
|
133
|
-
|
|
134
|
-
# Ensure that the fillval parameter gets properly interpreted
|
|
135
|
-
# for use with tdriz
|
|
136
|
-
if util.is_blank(fillval):
|
|
137
|
-
fillval = 'INDEF'
|
|
138
|
-
else:
|
|
139
|
-
fillval = str(fillval)
|
|
140
|
-
|
|
141
|
-
if in_units == 'cps':
|
|
142
|
-
expscale = 1.0
|
|
143
|
-
else:
|
|
144
|
-
expscale = expin
|
|
145
|
-
|
|
146
|
-
# Add input weight image if it was not passed in
|
|
147
|
-
|
|
148
|
-
if (insci.dtype > np.float32):
|
|
149
|
-
insci = insci.astype(np.float32)
|
|
150
|
-
|
|
151
|
-
if inwht is None:
|
|
152
|
-
inwht = np.ones_like(insci)
|
|
153
|
-
|
|
154
|
-
# Compute what plane of the context image this input would
|
|
155
|
-
# correspond to:
|
|
156
|
-
planeid = int((uniqid - 1) / 32)
|
|
157
|
-
|
|
158
|
-
# Check if the context image has this many planes
|
|
159
|
-
if outcon.ndim == 3:
|
|
160
|
-
nplanes = outcon.shape[0]
|
|
161
|
-
elif outcon.ndim == 2:
|
|
162
|
-
nplanes = 1
|
|
163
|
-
else:
|
|
164
|
-
nplanes = 0
|
|
165
|
-
|
|
166
|
-
if nplanes <= planeid:
|
|
167
|
-
raise IndexError("Not enough planes in drizzle context image")
|
|
168
|
-
|
|
169
|
-
# Alias context image to the requested plane if 3d
|
|
170
|
-
if outcon.ndim == 3:
|
|
171
|
-
outcon = outcon[planeid]
|
|
172
|
-
|
|
173
|
-
pix_ratio = output_wcs.pscale / wcslin_pscale
|
|
174
|
-
|
|
175
|
-
# Compute the mapping between the input and output pixel coordinates
|
|
176
|
-
pixmap = calc_pixmap.calc_pixmap(input_wcs, output_wcs)
|
|
177
|
-
|
|
178
|
-
#
|
|
179
|
-
# Call 'drizzle' to perform image combination
|
|
180
|
-
# This call to 'cdriz.tdriz' uses the new C syntax
|
|
181
|
-
#
|
|
182
|
-
_vers, nmiss, nskip = cdrizzle.tdriz(
|
|
183
|
-
insci, inwht, pixmap, outsci, outwht, outcon,
|
|
184
|
-
uniqid=uniqid, xmin=xmin, xmax=xmax,
|
|
185
|
-
ymin=ymin, ymax=ymax, scale=pix_ratio, pixfrac=pixfrac,
|
|
186
|
-
kernel=kernel, in_units=in_units, expscale=expscale,
|
|
187
|
-
wtscale=wt_scl, fillstr=fillval)
|
|
188
|
-
|
|
189
|
-
return _vers, nmiss, nskip
|