Extragalactic

Extragalactic#

A few functions that can also helpt to create extragalactic objects

import numpy as np
import matplotlib.pyplot as plt

from scopesim_templates.extragalactic import galaxy
/home/docs/checkouts/readthedocs.org/user_builds/scopesim-templates/envs/latest/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

The function galaxy will generate a sersic profile with user provided parameters. The function can accept any sed in the speXtra package.

It must be noted that the pixel scale is not related to the pixel scale of the final simulation but to the pixel scale (in arcsec) of the generated image. It is recommended to be fine enough to well sample the profile of the galaxy.

The SED and the selected filter must overlap but an error will be thrown if they don’t.

src = galaxy("kc96/s0", z=0.1, amplitude=17, filter_curve="g", pixel_scale=0.05, r_eff=2.5, n=4, ellip=0.5, theta=45, extend=3)

plt.imshow(np.log10(src.fields[0].data), origin="lower")
Downloading file 'libraries/kc96/index.yml' from 'https://scopesim.univie.ac.at/spextra/database/libraries/kc96/index.yml' to '/home/docs/.spextra_cache'.
  0%|                                              | 0.00/2.36k [00:00<?, ?B/s]
  0%|                                              | 0.00/2.36k [00:00<?, ?B/s]
100%|█████████████████████████████████████| 2.36k/2.36k [00:00<00:00, 1.79MB/s]
Downloading file 'libraries/kc96/s0.fits' from 'https://scopesim.univie.ac.at/spextra/database/libraries/kc96/s0.fits' to '/home/docs/.spextra_cache'.
  0%|                                              | 0.00/20.2k [00:00<?, ?B/s]
 36%|█████████████▏                       | 7.17k/20.2k [00:00<00:00, 62.0kB/s]
 71%|██████████████████████████▎          | 14.3k/20.2k [00:00<00:00, 61.3kB/s]
  0%|                                              | 0.00/20.2k [00:00<?, ?B/s]
100%|█████████████████████████████████████| 20.2k/20.2k [00:00<00:00, 20.1MB/s]

py.warnings - WARNING: /home/docs/checkouts/readthedocs.org/user_builds/scopesim-templates/envs/latest/lib/python3.11/site-packages/spextra/downloads.py:62: FutureWarning: The download_file function is deprecated and will be removed in v1.0. Please use retriever.fetch instead.
  download_file(origin, local_path)

Downloading data from 'http://svo2.cab.inta-csic.es/theory/fps3/fps.php?ID=SLOAN/SDSS.g' to file '/home/docs/.spextra_cache/svo_filters/SLOAN/SDSS.g'.
SHA256 hash of downloaded file: ea4dc3871f0c5dcd9ef276fcebe5e9bca6abd80cdb18abf055bba207a92fc119
Use this value as the 'known_hash' argument of 'pooch.retrieve' to ensure that the file hasn't changed if it is downloaded again in the future.
<matplotlib.image.AxesImage at 0x7a51ab4ae710>
../_images/0938cb9dc9b2d35b28250819cab690bcd3958252764b7928f4e80b33bf1b54d8.png

We can also visualize the spectrum

sp = src.spectra[0]
sp.plot()
../_images/97917583b93f8d3321116a72a191637f4a15736b0dd9dcb806750d7aac45624c.png

Finally there is much that can be done with the spectrum itself, like for example, obtaining the magnitude in a different filter

sp.get_magnitude(filter_curve="u", system_name="AB")
py.warnings - WARNING: /home/docs/checkouts/readthedocs.org/user_builds/scopesim-templates/envs/latest/lib/python3.11/site-packages/spextra/downloads.py:62: FutureWarning: The download_file function is deprecated and will be removed in v1.0. Please use retriever.fetch instead.
  download_file(origin, local_path)

Downloading data from 'http://svo2.cab.inta-csic.es/theory/fps3/fps.php?ID=SLOAN/SDSS.u' to file '/home/docs/.spextra_cache/svo_filters/SLOAN/SDSS.u'.
SHA256 hash of downloaded file: 84cad40e9f2ba403b2c815a3c2dc4218e4c3c3d16354be1e2b0f3cea960fb439
Use this value as the 'known_hash' argument of 'pooch.retrieve' to ensure that the file hasn't changed if it is downloaded again in the future.
\[18.824192 \; \mathrm{mag\left(AB\right)}\]

More can be found in the speXtra package.