rubix.telescope package#
Subpackages#
Submodules#
rubix.telescope.apertures module#
This class defines the aperture mask for the observation of a galaxy.
- rubix.telescope.apertures.CIRCULAR_APERTURE(sbin: int64) Float[Array, '...'] [source]#
Creates a circular aperture mask for the observation of a galaxy.
- Parameters:
sbin (int) – The size of the spatial bin in each direction for the aperture mask.
- Returns:
A jnp.ndarray 1D array of the aperture mask.
- rubix.telescope.apertures.HEXAGONAL_APERTURE(sbin: int64) Float[Array, '...'] [source]#
Creates a hexagonal aperture mask for the observation of a galaxy.
- Parameters:
sbin (int) – The size of the spatial bin in each direction for the aperture mask.
- Returns:
A jnp.ndarray 1D array of the aperture mask.
rubix.telescope.base module#
- class rubix.telescope.base.BaseTelescope(fov: float | int, spatial_res: float | int, wave_range: List[float], wave_res: float | int, lsf_fwhm: float | int, signal_to_noise: float | None, sbin: int64, aperture_region: Float[Array, '...'] | Int[Array, '...'], pixel_type: str, wave_seq: Float[Array, '...'], wave_edges: Float[Array, '...'])[source]#
Bases:
Module
Base class for the telescope module. This class contains the base parameters for the telescope module.
- Parameters:
fov (float) – The field of view of the telescope.
spatial_res (float) – The spatial resolution of the telescope.
wave_range (list) – The wavelength range of the telescope.
wave_res (float) – The wavelength resolution of the telescope.
lsf_fwhm (float) – The full width at half maximum of the line spread function.
signal_to_noise (float) – The signal to noise ratio of the telescope.
sbin (int) – The size of the spatial bin in each direction for the aperture mask.
aperture_region (jnp.ndarray) – The aperture region of the telescope.
pixel_type (str) – The type of pixel used in the telescope.
wave_seq (jnp.ndarray) – The wavelength sequence of the telescope.
wave_edges (jnp.ndarray) – The wavelength edges of the telescope.
- aperture_region: Float[Array, '...'] | Int[Array, '...']#
- fov: float | int#
- lsf_fwhm: float | int#
- pixel_type: str#
- sbin: int64#
- signal_to_noise: float | None#
- spatial_res: float | int#
- wave_edges: Float[Array, '...']#
- wave_range: List[float]#
- wave_res: float | int#
- wave_seq: Float[Array, '...']#
rubix.telescope.factory module#
- class rubix.telescope.factory.TelescopeFactory(telescopes_config: dict | str | None = None)[source]#
Bases:
object
- create_telescope(name: str) BaseTelescope [source]#
Function to create a telescope object from the given configuration.
- Parameters:
name (str) – The name of the telescope to create.
- Returns:
The telescope object as BaseTelescope.
Example 1 (Uses the defined telescope configuration)#
>>> from rubix.telescope import TelescopeFactory >>> telescope_config = { ... "MUSE": { ... "fov": 5, ... "spatial_res": 0.2, ... "wave_range": [4700.15, 9351.4], ... "wave_res": 1.25, ... "lsf_fwhm": 2.51, ... "signal_to_noise": None, ... "wave_centre": 6975.775, ... "aperture_type": "square", ... "pixel_type": "square" ... } ... } >>> factory = TelescopeFactory(telescope_config) >>> telescope = factory.create_telescope("MUSE") >>> print(telescope)
Example 2 (Uses the default telescope configuration)#
>>> from rubix.telescope import TelescopeFactory >>> factory = TelescopeFactory() >>> telescope = factory.create_telescope("MUSE") >>> print(telescope)
rubix.telescope.utils module#
- rubix.telescope.utils.calculate_spatial_bin_edges(fov: float, spatial_bins: int64, dist_z: float, cosmology: BaseCosmology) Tuple[Float[Array, '...'], Float[Array, '...']] [source]#
Calculate the bin edges for the spatial bins.
- Parameters:
fov (float) – field of view of the telescope.
spatial_bins (float) – number of spatial bins.
dist_z (float) – redshift of the galaxy.
cosmology (BaseCosmology) – cosmology object.
- Returns:
The bin edges for the spatial bins and the spatial bin size as jnp.array.
- rubix.telescope.utils.calculate_wave_edges(wave_bin_edges: Float[Array, '...'], wave_res: float) Float[Array, '...'] [source]#
Calculate the bin edges for the wavelength bins.
- Parameters:
wave_bin_edges (jnp.array) – The bin edges for the wavelength bins.
wave_res (float) – The resolution of the wavelength bins.
- Returns:
The bin edges for the wavelength bins as jnp.array.
- rubix.telescope.utils.calculate_wave_seq(wave_range: List[float], wave_res: float) Float[Array, '...'] [source]#
Calculate the wavelength sequence for the wavelength bins.
- Parameters:
wave_range (Tuple[float, float]) – The range of the wavelength bins.
wave_res (float) – The resolution of the wavelength bins.
- Returns:
The bin edges for the wavelength bins as jnp.array.
- rubix.telescope.utils.mask_particles_outside_aperture(coords: Float[Array, '* 3'], spatial_bin_edges: Float[Array, '...']) Bool[Array, '...'] [source]#
Mask the particles that are outside the aperture.
- Parameters:
coords (jnp.array) – The particle coordinates.
spatial_bin_edges (jnp.array) – The bin edges for the spatial bins.
- Returns:
A boolean mask as jnp.array that is True for particles that are inside the aperture and False for particles that are outside the aperture.
- rubix.telescope.utils.square_spaxel_assignment(coords: Float[Array, '...'], spatial_bin_edges: Float[Array, '...']) Int[Array, '...'] [source]#
Bin the particle coordinates into a 2D image with the given bin edges for square pixels.
This function takes the particle coordinates and bins them into a 2D image with the given bin edges. The binning is done by digitizing the x and y coordinates of the particles and then calculating the flat indices of the 2D image.
The returned indexes are the pixel assignments of the particles. Indexing starts at 0.
- Parameters:
coords (jnp.array) – The particle coordinates.
spatial_bin_edges (jnp.array) – The bin edges for the spatial bins.
- Returns:
The flat pixel assignments of the particles as jnp.array. Indexing starts at 0.
Example (Assing two particles to the spatial matching bins)#
>>> from rubix.telescope.utils import square_spaxel_assignment >>> import matplotlib.pyplot as plt >>> from matplotlib.colors import ListedColormap >>> from jaxtyping import Float, Array >>> import jax.numpy as jnp >>> import numpy as np
>>> # Define the particle coordinates >>> coords = np.array([[0.5, 1.5], [2.5, 3.5]]) >>> # Define the spatial bin edges >>> spatial_bin_edges = np.array([0, 1, 2, 3, 4])
>>> # Compute the pixel assignments >>> pixel_assignments = square_spaxel_assignment(coords, spatial_bin_edges)
>>> # Plot the results ... plt.figure(figsize=(10, 5)) ... # Plotting the particles with labels ... plt.subplot(1, 2, 1) ... scatter = plt.scatter(coords[:, 0], coords[:, 1]) ... plt.colorbar(scatter, ticks=np.arange(0, max_assignment + 1)) ... plt.title('Particle Coordinates and Pixel Assignments') ... plt.xlabel('X Coordinate') ... plt.ylabel('Y Coordinate') ... plt.xlim(spatial_bin_edges[0], spatial_bin_edges[-1]) ... plt.ylim(spatial_bin_edges[0], spatial_bin_edges[-1]) ... # Label each point with its pixel index ... for i, (x, y) in enumerate(coords[:, :2]): ... plt.text(x, y, str(pixel_assignments[i]), color='red', fontsize=8) ... #create the bins ... for edge in spatial_bin_edges: ... plt.axvline(edge, color='k', linestyle='--') ... plt.axhline(edge, color='k', linestyle='--') ... plt.tight_layout() ... plt.show()