Real galaxies (wcc_etc.galaxy)

Real galaxies as hosts: NGC images and spectra moved to any redshift.

Ported from slicersim (scene/sources/galaxy.py, M. Rigault). The data come from the lazuli_astrosim_data package: for each NGC galaxy an r-band thumbnail (PIXSCALE, REDSHIFT, XCENTER/YCENTER in the header) and a spectral template (WAVELENGTH in Angstrom, FLUX in flam).

  • render_galaxy() projects a thumbnail onto the detector grid at a redshift, keeping the galaxy’s physical size (angular-diameter-distance ratio), with an arcsec offset and a rotation. It is the "ngc" spatial model of wcc_etc.scene.SceneElement (profile="ngc0628").

  • load_galaxy_spectrum() is the galaxy’s own template, used when a scene element’s spectrum is an NGC name.

wcc_etc.galaxy.COSMOLOGY = FlatLambdaCDM(name='Planck18', H0=<Quantity 67.66 km / (Mpc s)>, Om0=0.30966, Tcmb0=<Quantity 2.7255 K>, Neff=3.046, m_nu=<Quantity [0.  , 0.  , 0.06] eV>, Ob0=0.04897)

Cosmology for distance moduli, kpc-to-arcsec and angular-size scaling.

class wcc_etc.galaxy.GalaxyImage(image, pixel_scale, redshift, center)[source]

Bases: object

A flux-normalised galaxy thumbnail with its sampling and distance.

image sums to 1; pixel_scale is arcsec/pixel; redshift is the galaxy’s own; center is the (x, y) 0-based pixel of the nucleus.

Parameters:
image: ndarray
pixel_scale: float
redshift: float
center: tuple
wcc_etc.galaxy.galaxy_filepath(name, which='spectrum')[source]

Path to the "spectrum" or "image" file of an NGC galaxy.

name is case insensitive and accepts "ngc0628", "NGC 0628", "ngc_0628". Raises FileNotFoundError for a galaxy not in the collection.

wcc_etc.galaxy.load_galaxy_spectrum(name)[source]

The galaxy’s spectral template as a synphot SourceSpectrum (flam).

Memoized per (lower-cased) name; the same object is returned every time.

wcc_etc.galaxy.load_galaxy_image(name)[source]

Load an NGC thumbnail as a GalaxyImage (memoized per name).

NaNs become 0 and negative sky residuals are clipped to 0 before the normalisation.

wcc_etc.galaxy.galaxy_pixel_scale(image_pixel_scale, galaxy_redshift, redshift, cosmology=FlatLambdaCDM(name='Planck18', H0=<Quantity 67.66 km / (Mpc s)>, Om0=0.30966, Tcmb0=<Quantity 2.7255 K>, Neff=3.046, m_nu=<Quantity [0., 0., 0.06] eV>, Ob0=0.04897))[source]

Thumbnail pixel scale (arcsec) once the galaxy is moved to redshift.

The physical size is kept, so the angular size scales with the ratio of angular diameter distances. redshift must exceed galaxy_redshift.

wcc_etc.galaxy.project_image(image, center, scale, shape, out_center, position=(0.0, 0.0), rotation=0.0, subsampling=8)[source]

Project image onto an (ny, nx) grid, conserving flux.

Each image pixel is split into k x k sub-pixels (k such that a sub-pixel is at most 1/subsampling of an output pixel) and each sub-pixel’s flux is added to the output pixel containing its centre. Light that lands off the grid is lost, not renormalised.

Parameters:
  • image (ndarray) – Source image, (ny_in, nx_in).

  • center ((float, float)) – (x, y) image pixel placed at out_center + position.

  • scale (float) – Size of one image pixel in output pixels.

  • shape ((int, int)) – Output (ny, nx).

  • out_center ((float, float)) – (x, y) output pixel the galaxy centre is measured from.

  • position ((float, float), optional) – (dx, dy) offset of the galaxy centre from out_center, in output pixels.

  • rotation (float, optional) – Rotation of the galaxy in degrees, counterclockwise.

  • subsampling (int, optional) – Minimum sub-pixels per output pixel. Default 8.

wcc_etc.galaxy.render_galaxy(name, redshift, plate_scale_arcsec, npix, dx=0.0, dy=0.0, pa=0.0, center=None, cosmology=FlatLambdaCDM(name='Planck18', H0=<Quantity 67.66 km / (Mpc s)>, Om0=0.30966, Tcmb0=<Quantity 2.7255 K>, Neff=3.046, m_nu=<Quantity [0., 0., 0.06] eV>, Ob0=0.04897))[source]

An NGC galaxy at redshift on an (npix, npix) detector grid.

Returns the fraction of the galaxy’s total flux in each pixel (light off the grid is lost). center is the (cx, cy) pixel the dx/dy offset (arcsec) is measured from; default is psfsim.grid_center, the convention every PSF render shares. pa rotates the galaxy in degrees counterclockwise.