dimage.combine package

Tools to combine a desired set of images onto a common footprint. Can use various resampling kernels; see documentation for dresample.

Notes and to-do:

  • Does not adjust for pixel area changes; keeps image in whatever units it was input in.
  • Uses simple TAN projection and square image; doesn’t yet take arbitrary WCS inputs.
  • Will fail on images which span > 180 deg in RA, due to simplistic handling of 0/360 boundary
dimage.combine.combine_apodize(nx, ny, edge=10)[source]

Create apodized weight image

Parameters:

nx, ny : int

dimensions of image

edge : int

pixel width of apodized edge (default 10)

Returns:

weight : np.float32

[nx, ny] ndarray weighted image

Notes

Uses a cos() function transition from zero to unity in each dimension along each edge.

dimage.combine.combine_wise(ra, dec, size, band, kernel='lanczos', dampsinc=2.47, lanczos=2.0, edge=10, pixscale=2.75, unmasked=False)[source]

Combine WISE images onto a desired footprint

Parameters:

ra, dec : fp.float64

center of image (J2000 deg)

size : float

size of square image (deg)

band : str

band name (‘W1’, ‘W2’, ‘W3’, ‘W4’)

edge : int

pixel width of apodized edge to use (default 10)

kernel, dampsinc, lanczos : parameters for dresample

pixscale : float

output pixel scale in arcsec/pixel (default 2.75)

unmasked : bool

if True, use unmasked coadds (default False)

Returns:

(image, ivar, wcs) : (np.float32, np.float32, WCS)

[nx, ny] image [nx, ny] image inverse variance WCS object

dimage.combine.dcombine(ra, dec, size, pixscale, image_files, ivar_files=None, kernel='lanczos', dampsinc=2.47, lanczos=2.0, edge=10)[source]

Combine a list of images onto a desired footprint

Parameters:

ra, dec : np.float64

center of image (J2000 deg)

size : float

size of square image (deg)

pixelscale : float

pixel scale (arcsec)

image_files : str

[N] list of image file names

ivar_files : str

[N] list of inverse variance file names (default none)

edge : int

pixel width of apodized edge to use (default 10)

kernel, dampsinc, lanczos :

parameters for dresample

Returns:

(image, ivar, wcs) : (float32, float32, WCS)

[nx, ny] image [nx, ny] image of estimated inverse variance WCS object

Notes

Uses a weighted combination with apodized edges of images to
ensure smooth transitions.
Uses inverse variance to estimate final inverse variance, but
doesn’t track covariance and doesn’t use inverse variance as a weight.

Calls dwcsproject for projection, which calls dresample. Assumes WCS for images and inverse variance files are identical;

otherwise unpredictable results!
dimage.combine.resample(image, x, y, kernel='dampsinc', dampsinc=2.47, lanczos=2.0)[source]

Resamples a two-dimensional ndarray image in x, y

Parameters:

image : np.float32

[nx, ny] 2-D ndarray

x, y : [N] locations for samples

kernel : Kernel to use in resampling (default ‘dampsinc’)

dampsinc : Gaussian scale used for ‘dampsinc’ (default 2.47)

lanczos : Lanczos scale parameter “a” (default 2)

Returns:

samples : [N] samples

Notes

Calls dresample.c in libdimage.so

dimage.combine.wcsgrid(wcs, nx, ny)[source]

Create grid of RA/Dec corresponding to WCS pixels

Parameters:

wcs : WCS object

nx, ny : size of image referred to in each dimension

Returns:

(ra, dec) : each member of tuple is [nx,ny] grid of

RA/Decs for each pixel

dimage.combine.wcsproject(image, weight, wcs, ra, dec, kernel='lanczos', dampsinc=2.47, lanczos=2.0)[source]

Resamples a two-dimensional ndarray image in RA, Dec

Parameters:

image : [nx, ny] 2-D ndarray

weight : [nx, ny] weight 2-D ndarray

wcs : WCS object

ra, dec : [N] locations for samples

kernel : Kernel to use in resampling (default ‘dampsinc’)

dampsinc : Gaussian scale used for ‘dampsinc’ (default 2.47)

lanczos : Lanczos scale parameter “a” (default 2)

Returns:

samples, weights, inbox : [M] samples, weights, and indices into ra,dec

Notes

Calls dresample. Will NOT work for very wide angle input images (180. deg or more), because

0/360 case checking is too simple.