simcado.image_plane_utils module

simcado.image_plane_utils.add_imagehdu_to_imagehdu(image_hdu, canvas_hdu, order=1, wcs_suffix='', conserve_flux=True)[source]

Re-project one fits.ImageHDU onto another fits.ImageHDU ..assumption:: of equal grid coordinate lengths Parameters ———- image_hdu : fits.ImageHDU

The ImageHDU which will be reprojected onto canvas_hdu

canvas_hdufits.ImageHDU

The ImageHDU onto which the table files should be projected. This must include a valid WCS

orderint, optional

Default is 1. The order of the spline interpolator used by the scipy.ndimage functions

wcs_suffixstr

To determine which WCS to use. “” for sky HDUs and “D” for ImagePlane HDUs

canvas_hdu : fits.ImageHDU

simcado.image_plane_utils.add_table_to_imagehdu(table, canvas_hdu, sub_pixel=True, wcs_suffix='')[source]

Add files from an astropy.Table to the image of an fits.ImageHDU Parameters ———- table : astropy.Table

Must contain the columns “x_mm”, “y_mm”, “flux” with the units in the column attribute .unit, or in the table.meta dictionary as “<colname>_unit”. Default units are mm and ph / s / pix

canvas_hdufits.ImageHDU

The ImageHDU onto which the table files should be projected. This must include a valid WCS

sub_pixelbool, optional

Default is True. If True, sub-pixel shifts of files will be taken into account when projecting onto the canvas pixel grid. This takes about 5x longer than ignoring the sub-pixel shifts

wcs_suffix : str, optional Returns ——- canvas_hdu : fits.ImageHDU

simcado.image_plane_utils.calc_footprint(header, wcs_suffix='')[source]

Returns the on sky-positions [deg] of the corners of a header WCS The on-sky positions returned correspond to the corners of the header’s image array, in this order:

(ra, dec) = (0,0), (w, 0), (w, h), (0, h)

where w, h are equal to NAXIS1 and NAXIS2 from the header. Parameters ———- header : fits.Header wcs_suffix : str

Letter suffix for the WCS keywords, e.g. CDELT1D for image-plane coords

xsky, yskyarrays of floats

[deg] xsky are the coordinates for pixels [0, w, w, 0] [deg] ysky are the coordinates for pixels [0, 0, h, h]

simcado.image_plane_utils.get_canvas_header(hdu_or_table_list, pixel_scale=<Quantity 1. arcsec>)[source]

Generate a fits.Header with a WCS that covers everything in the FOV Parameters ———- hdu_or_table_list : list

A list of Tables and/or ImageHDU py_objects

pixel_scaleastropy.Quantity

[arcsec] The pixel scale of the projection. Default in 1 arcsec

headerfits.Header

A Header containing a WCS and NAXISn values to build an ImageHDU

simcado.image_plane_utils.header_from_list_of_xy(x, y, pixel_scale, wcs_suffix='')[source]

Makes a header large enough to contain all x,y on-sky coordinates Parameters ———- x, y : list of floats

[deg, mm] List of sky coordinates to be bounded by the NAXISn keys

pixel_scalefloat

[deg, mm]

hdr : fits.Header

simcado.image_plane_utils.overlay_image(small_im, big_im, coords, mask=None, sub_pixel=False)[source]

Overlay small_im on top of big_im at the position specified by coords small_im will be centred at coords Adapted from: ``https://stackoverflow.com/questions/14063070/

overlay-a-smaller-image-on-a-larger-image-python-opencv``

simcado.image_plane_utils.pix2val(header, x, y, wcs_suffix='')[source]

Returns the real coordinates [deg, mm] for coordinates from a Header WCS Parameters ———- header : fits.Header x, y : float, list, array wcs_suffix : str Returns ——- a, b : float, array

[deg, mm] Real coordinates as given by the Header WCS

simcado.image_plane_utils.reorient_imagehdu(imagehdu, wcs_suffix='', conserve_flux=True, **kwargs)[source]

Rotates the .data array by the angle given in the PC matrix of the header Parameters ———- imagehdu : fits.ImageHDU wcs_suffix : str kwargs —— order : int

[1..5] Order of the spline interpolation used by scipy.ndimage.rotate

imagehdu : fits.ImageHDU

simcado.image_plane_utils.rescale_imagehdu(imagehdu, pixel_scale, wcs_suffix='', conserve_flux=True, **kwargs)[source]

Scales the .data array by the ratio of pixel_scale [deg] and CDELTn pixel_scale should NOT be passed as a Quantity! Parameters ———- imagehdu : fits.ImageHDU pixel_scale : float

[deg] NOT to be passed as a Quantity

wcs_suffix : str kwargs —— order : int

[1..5] Order of the spline interpolation used by scipy.ndimage.rotate

imagehdu : fits.ImageHDU

simcado.image_plane_utils.sub_pixel_fractions(x, y)[source]

Makes a list of pixel coordinates and weights to reflect sub-pixel shifts A point source which isn’t centred on a pixel can be modelled by a centred PSF convolved with a shifted delta function. A fraction of the delta function in moved into each of the adjoining pixels. For example, a star at (x,y)=(0.2, 0.2) would be represented by a following pixel weights:

---------------
| 0.16 | 0.04 |
---------------
| 0.64 | 0.16 |
---------------

where (0,0) is the centre of the bottom-left pixel Given (x,y) pixel coordinates, this function returns the fractions of flux that should go into the surrounding pixels, as well as the coordinates of those neighbouring pixels. Parameters ———- x, y : float Returns ——- x_pix, y_pix, fracs : list of (int, int, float)

The x and y pixel coordinates and their corresponding flux fraction

simcado.image_plane_utils.val2pix(header, a, b, wcs_suffix='')[source]

Returns the pixel coordinates for real coordinates [deg, mm] from a WCS Parameters ———- header : fits.Header a, b : float, list, array

[deg, mm]

x, yfloat, array

[pixel] Pixel coordinates as given by the Header WCS