Stellar Module¶
This module include general functions to work with stars
Stellar cluster¶
In the following example we generate a young star cluster with a core radius r_c=1 pc
, M=1000 Msun
and located in the LMC (d=50kpc
)
[1]:
import numpy as np
from scopesim_templates.stellar import cluster
src = cluster(mass=1E3, distance=50000, core_radius=1)
Lets have a look inside the object:
[2]:
src.fields[0]
[2]:
x | y | ref | weight | masses | spec_types |
---|---|---|---|---|---|
arcsec | arcsec | solMass | |||
float64 | float64 | int64 | float64 | float64 | str3 |
0.7047941071430335 | -0.34193400839906835 | 32 | 2.702228328228619e-19 | 0.023450818028910993 | M6V |
3.017163801660643 | -1.531947677274888 | 27 | 5.985543114133627e-12 | 0.5030213194041789 | M1V |
5.545342770168751 | -0.5059378004225308 | 24 | 4.961396135881094e-11 | 0.6887993545486397 | K5V |
0.04337484405135695 | 0.47394950595035895 | 31 | 9.301655464729025e-14 | 0.16592467519086804 | M5V |
-0.1695198026107141 | 2.689008599028229 | 27 | 5.728214836974918e-12 | 0.4981528843145076 | M1V |
2.903227971744357 | -0.42880293404815345 | 32 | 7.235335661968081e-19 | 0.030385458123976427 | M6V |
2.9147725521817955 | 1.4290979035892837 | 31 | 2.5344525453154387e-14 | 0.12048133658240405 | M5V |
2.1879322601012166 | 1.7393082707150282 | 29 | 1.1280665937633994e-12 | 0.33768446357534043 | M3V |
-0.5711617098260228 | -5.393018142881724 | 21 | 1.6102797118853998e-10 | 0.8167460590486888 | K2V |
-0.11710185806601776 | -5.100956140168292 | 32 | 1.5282472923135797e-14 | 0.11036638034546091 | M6V |
-2.146176289199411 | 4.292793390010554 | 29 | 6.746584693259497e-13 | 0.284529520314177 | M3V |
-6.516561394056243 | -0.8923876990270431 | 28 | 2.141385549412798e-12 | 0.4021587190742773 | M2V |
... | ... | ... | ... | ... | ... |
-4.679661612983974 | 2.5527643902258825 | 32 | 8.043671952122561e-16 | 0.0800771445221511 | M6V |
-1.6708993605568665 | 2.038654094696279 | 31 | 3.598973661189041e-14 | 0.13306765925503572 | M5V |
1.4678772515789662 | -0.17251949373959752 | 24 | 5.335448880937463e-11 | 0.6961978840502374 | K5V |
-2.9862656254225963 | 0.5421006937620638 | 31 | 2.702271491358672e-14 | 0.12278256100621125 | M5V |
3.157740384424968 | 3.0596228361838076 | 15 | 9.931528833544933e-10 | 1.1792543689064683 | F8V |
2.358628131504372 | -1.557299020469622 | 32 | 6.093043334547767e-20 | 0.012963210764621674 | M6V |
1.4521739653435157 | -0.851382522869428 | 32 | 2.1990614865733614e-14 | 0.117485467623293 | M6V |
-0.4565704589836154 | 0.18085670454520986 | 29 | 5.555250603467652e-13 | 0.26443896759352503 | M3V |
-4.2880207051930626 | 4.243801810096584 | 27 | 4.805552069892325e-12 | 0.48208630286109483 | M1V |
-1.0717398664268987 | 3.7082294509014195 | 32 | 1.471179396509044e-15 | 0.08623356844839875 | M6V |
2.1224836756915306 | 1.1488760649099696 | 32 | 4.0087183177773387e-17 | 0.05865254767345462 | M6V |
-4.886571147953505 | 1.7463696161882218 | 29 | 9.928282883555495e-13 | 0.3244795598952535 | M3V |
Here we can see the spatial information is in the form of an astropy.Table
.
The columns x
and y
show the position of each star in arcsec
relative to the centre of the field of view.
The column ref
connects each star in this table to a spectrum in the following list:
[3]:
src.spectra
[3]:
[<synphot.spectrum.SourceSpectrum object at 0x7fb8e6488b80>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8e6488760>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f47945e0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f4794790>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f463edf0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f465df10>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f463e910>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f466afd0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f477ff70>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f463ed00>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f46f8d90>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f4706a90>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f4706af0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f466a910>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f4717e20>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f465db50>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f4706610>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f4724e20>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f4730fd0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f47065b0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f47068b0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f46c2ca0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f4730df0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8fe602d00>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f47248b0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8e60c55e0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f47300a0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f46c2eb0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f46dea60>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f4730580>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f46dc2e0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f46b0d30>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f46dc040>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f46a3fd0>,
<synphot.spectrum.SourceSpectrum object at 0x7fb8f46deac0>]
When ScopeSim ingests this Source object, it will look primarily at these three columns.
Now for a graphical representation of the cluster as it will be seen by ScopeSim:
[4]:
import matplotlib.pyplot as plt
plt.figure(figsize=(8, 8))
plt.plot(src.fields[0]["x"], src.fields[0]["y"], '.')
plt.xlabel("X [arcsec]")
plt.ylabel("Y [arcsec]")
[4]:
Text(0, 0.5, 'Y [arcsec]')
Star Grid and Field¶
These are two functions that are good to test simulations quickly
[5]:
from scopesim_templates.stellar import star_field, star_grid
field = star_field(n=400, mmin=15, mmax=25, width=20, height=20, filter_name="Ks")
grid = star_grid(n=400, mmin=15, mmax=25, separation=1 , filter_name="Ks")
plt.figure(figsize=(14, 7))
plt.subplot(121)
size = np.log10(field.fields[0]["weight"])**2
plt.scatter(field.fields[0]["x"], field.fields[0]["y"], s=size, marker="o")
plt.subplot(122)
size = np.log10(grid.fields[0]["weight"])**2
plt.scatter(grid.fields[0]["x"], grid.fields[0]["y"], s=size, marker="o")
['A0V']
['A0V']
[5]:
<matplotlib.collections.PathCollection at 0x7fb8e090f460>
In both cases we generated 400 sources between magnitudes 15 (mmin
) and 25 (mmax
).
star_field
places the stars at random, whereas star_grid
place them in a regular partern controled by separation
distance.
The size of the simbols illustrate the magnitudes of the stars
Stars¶
The core of the stellar
module is however the star
function which can create any field according to the user needs
In this case we generate a stellar field following a 2D gaussian distribution with a star of every type in the pickles stellar library
[6]:
from scopesim_templates.stellar import stars
from spextra.database import SpecLibrary
[7]:
lib = SpecLibrary("pickles")
spectypes = lib.template_names
nstars = len(spectypes)
x = np.random.randn(nstars) * 10
y = np.random.randn(nstars) * 10
mags = np.linspace(10, 20, nstars)
src = stars(filter_name="J", amplitudes=mags, x=x, y=y, spec_types=spectypes, library="pickles")
[8]:
src.fields
[8]:
[<Table length=131>
x y ref weight spec_types
arcsec arcsec
float64 float64 int64 float64 str6
------------------- ------------------- ----- ------- ----------
2.007451224861396 0.1681071655341375 105 1.0 o5v
8.593728449012035 1.0022428226715767 106 1.0 o8iii
15.794690993340524 1.048888607243668 107 1.0 o9v
0.12354371714603121 2.9528383261426407 13 1.0 b0i
-0.4828399272073905 -1.8187067436493747 14 1.0 b0v
8.269207260479128 -3.4031373210003206 15 1.0 b12iii
8.302089462394221 -9.269016047589648 16 1.0 b1i
6.231844521598118 -6.148941889604722 17 1.0 b1v
-1.6268286899162279 18.51644268014349 18 1.0 b2ii
-0.3335389243832958 0.45403662143450824 19 1.0 b2iv
-6.112911809076027 8.548989247553019 20 1.0 b3i
-18.560993941068592 -2.7797644404218276 21 1.0 b3iii
... ... ... ... ...
14.288097551509324 5.393734390407308 94 1.0 m3iii
-3.4645252882727835 -7.660729789710751 95 1.0 m3v
11.695467015092449 -0.9015068233794685 96 1.0 m4iii
-3.8953999312417196 -3.202120466135513 97 1.0 m4v
21.966363419323997 -13.237923825721369 98 1.0 m5iii
-1.0680582531325613 -11.609390621966567 99 1.0 m5v
12.865638982994145 3.020365939546597 100 1.0 m6iii
6.38962463871831 -6.146996576751654 101 1.0 m6v
-16.111343878523737 11.306217143666768 102 1.0 m7iii
-4.618571067109303 10.398491786225657 103 1.0 m8iii
-0.4056773956303084 19.390809913922574 104 1.0 m9iii
13.552636359858983 -8.507559747977913 86 1.0 m10iii]