{ "cells": [ { "cell_type": "markdown", "id": "recreational-print", "metadata": {}, "source": [ "# Source : Point sources from arrays\n", "\n", "Collections of point sources can be initialised through either a collection of arrays, or an astropy Table" ] }, { "cell_type": "code", "execution_count": null, "id": "general-exploration", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import astropy.table as table\n", "from astropy import units as u\n", "\n", "import scopesim\n", "\n", "# how many stars\n", "n = 200\n", "\n", "# random coordinated in a 100 arcsec box\n", "x, y = 100 * np.random.random(size=(2, n)) - 50\n", "\n", "# All stars reference the Vega spectrum\n", "ref = np.zeros(n) \n", "# Each star is given a different weighting, i.e. magnitude\n", "weight = 10**(-0.4*np.linspace(10, 20, n))\n", "\n", "# Note: The Pyckles and SpeXtra libraries contain many more stellar and galactic spectra\n", "vega = scopesim.source.source_templates.vega_spectrum(mag=20)" ] }, { "cell_type": "markdown", "id": "cooked-robert", "metadata": {}, "source": [ "## astropy.Table" ] }, { "cell_type": "code", "execution_count": null, "id": "alive-renaissance", "metadata": {}, "outputs": [], "source": [ "tbl = table.Table(names=[\"x\", \"y\", \"ref\", \"weight\"],\n", " data= [x, y, ref, weight],\n", " units=[u.arcsec, u.arcsec, None, None])\n", "\n", "table_source = scopesim.Source(table=tbl, spectra=[vega])\n", "\n", "table_source.plot()" ] }, { "cell_type": "markdown", "id": "distributed-compilation", "metadata": {}, "source": [ "## From loose arrays" ] }, { "cell_type": "code", "execution_count": null, "id": "comprehensive-enlargement", "metadata": {}, "outputs": [], "source": [ "point_source = scopesim.Source(spectra=[vega], x=x, y=y, ref=ref, weight=weight)\n", "\n", "point_source.plot()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.16" } }, "nbformat": 4, "nbformat_minor": 5 }