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 ofwcc_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:
objectA flux-normalised galaxy thumbnail with its sampling and distance.
imagesums to 1;pixel_scaleis arcsec/pixel;redshiftis the galaxy’s own;centeris the (x, y) 0-based pixel of the nucleus.
- wcc_etc.galaxy.galaxy_filepath(name, which='spectrum')[source]
Path to the
"spectrum"or"image"file of an NGC galaxy.nameis 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.
redshiftmust exceedgalaxy_redshift.
- wcc_etc.galaxy.project_image(image, center, scale, shape, out_center, position=(0.0, 0.0), rotation=0.0, subsampling=8)[source]
Project
imageonto 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/
subsamplingof 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.
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
redshifton an(npix, npix)detector grid.Returns the fraction of the galaxy’s total flux in each pixel (light off the grid is lost).
centeris the (cx, cy) pixel thedx/dyoffset (arcsec) is measured from; default ispsfsim.grid_center, the convention every PSF render shares.parotates the galaxy in degrees counterclockwise.