2: Observing the same object with multiple telescopes¶
A brief introduction into using ScopeSim to observe a cluster in the LMC using the 39m ELT and the 1.5m LFOA
This is a step-by-step guide. The complete script can be found at the bottom of this page/notebook.
First set up all relevant imports:
[1]:
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
%matplotlib inline
import scopesim as sim
import scopesim_templates as sim_tp
Scopesim works by using so-called instrument packages, which have to be downloaded separately. For normal use, you would set the package directory (a local folder path, local_package_folder
in this example), download the required packages once, and then remove the download command.
[2]:
local_package_folder = "./inst_pkgs"
However, to be able to run this example on the Readthedocs page, we need to include a temporary directory.
Do not copy and run this code locally, it is only needed to set things up for Readthedocs!
[3]:
from tempfile import TemporaryDirectory
local_package_folder = TemporaryDirectory().name
Download the packages for MICADO at the ELT and the viennese 1.5m telescope at the LFOA
Again, you would only need to do this once, not every time you run the rest of the script, assuming you set a (permanent) instrument package folder.
[4]:
sim.rc.__config__["!SIM.file.local_packages_path"] = local_package_folder
sim.download_packages(["Armazones", "ELT", "MICADO", "MORFEO", "LFOA"])
astar.scopesim.server.database - Gathering information from server ...
astar.scopesim.server.database - Connection successful, starting download ...
Downloading Armazones: 100%|██████████| 74.3k/74.3k [00:00<00:00, 635kB/s]
Extracting Armazones: 100%|██████████| 10/10 [00:00<00:00, 3123.55it/s]
Downloading ELT : 100%|██████████| 53.4k/53.4k [00:00<00:00, 26.4MB/s]
Extracting ELT : 100%|██████████| 16/16 [00:00<00:00, 5467.56it/s]
Downloading MICADO : 100%|██████████| 14.4M/14.4M [00:27<00:00, 549kB/s]
Extracting MICADO : 100%|██████████| 121/121 [00:00<00:00, 850.59it/s]
Downloading MORFEO : 100%|██████████| 1.38M/1.38M [00:02<00:00, 561kB/s]
Extracting MORFEO : 100%|██████████| 12/12 [00:00<00:00, 926.34it/s]
Downloading LFOA : 100%|██████████| 409k/409k [00:00<00:00, 594kB/s]
Extracting LFOA : 100%|██████████| 45/45 [00:00<00:00, 3549.28it/s]
[4]:
[PosixPath('/tmp/tmpoiweq4ub/Armazones.zip'),
PosixPath('/tmp/tmpoiweq4ub/ELT.zip'),
PosixPath('/tmp/tmpoiweq4ub/MICADO.zip'),
PosixPath('/tmp/tmpoiweq4ub/MORFEO.zip'),
PosixPath('/tmp/tmpoiweq4ub/LFOA.zip')]
Create a star cluster Source
object¶
Now, create a star cluster using the scopesim_templates package. You can ignore the output that is sometimes printed. The seed argument is used to control the random number generation that creates the stars in the cluster. If this number is kept the same, the output will be consistent with each run, otherwise the position and brightness of the stars is randomised every time.
[5]:
cluster = sim_tp.stellar.clusters.cluster(mass=10000, # Msun
distance=50000, # parsec
core_radius=2, # parsec
seed=9001) # random seed
imf - sample_imf: Setting maximum allowed mass to 10000
imf - sample_imf: Loop 0 added 1.01e+04 Msun to previous total of 0.00e+00 Msun
Observe with the 1.5m telescope at the LFOA¶
|4831a5faf2784c3baf0cac64a9a213cd|
[6]:
lfoa = sim.OpticalTrain("LFOA")
lfoa.observe(cluster,
properties={"!OBS.ndit": 10, "!OBS.ndit": 360},
update=True)
hdus_lfoa = lfoa.readout()
FOVs: 0%| | 0/1 [00:00<?, ?it/s]
FOV effects: 0%| | 0/1 [00:00<?, ?it/s]
FOV effects: 100%|██████████| 1/1 [00:00<00:00, 1.80it/s]
FOVs: 100%|██████████| 1/1 [00:00<00:00, 1.09it/s]
Image Plane effects: 0it [00:00, ?it/s]
astar.scopesim.detector.detector_array - Extracting from 1 detectors...
astar.scopesim.optics.optical_train - ERROR: Header update failed, data will be saved with incomplete header. See stack trace for details.
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/scopesim/checkouts/latest/scopesim/optics/optical_train.py", line 386, in readout
hdul = self.write_header(hdul)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/docs/checkouts/readthedocs.org/user_builds/scopesim/checkouts/latest/scopesim/optics/optical_train.py", line 408, in write_header
pheader["INSTRUME"] = from_currsys("!OBS.instrument", self.cmds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/docs/checkouts/readthedocs.org/user_builds/scopesim/checkouts/latest/scopesim/utils.py", line 542, in from_currsys
raise ValueError(f"{item} was not found in rc.__currsys__")
ValueError: !OBS.instrument was not found in rc.__currsys__
Observe the same Source
with MICADO at the ELT¶
[7]:
micado = sim.OpticalTrain("MICADO")
micado.cmds["!OBS.dit"] = 10
micado.cmds["!OBS.ndit"] = 360
micado.update()
micado.observe(cluster)
hdus_micado = micado.readout()
FOVs: 0%| | 0/1 [00:00<?, ?it/s]
FOV effects: 0%| | 0/2 [00:00<?, ?it/s]
FOV effects: 50%|█████ | 1/2 [00:00<00:00, 7.30it/s]
FOV effects: 100%|██████████| 2/2 [00:00<00:00, 8.09it/s]
FOVs: 100%|██████████| 1/1 [00:00<00:00, 2.06it/s]
Image Plane effects: 100%|██████████| 1/1 [00:00<00:00, 5329.48it/s]
astar.scopesim.detector.detector_array - Extracting from 1 detectors...
Plot up the results
[8]:
plt.figure(figsize=(12,5))
plt.subplot(121)
plt.imshow(hdus_lfoa[0][1].data[345:385, 525:565], norm=LogNorm(), origin="lower")
plt.colorbar()
plt.title("1.5m LFOA")
plt.subplot(122)
plt.imshow(hdus_micado[0][1].data, norm=LogNorm(vmax=1E6, vmin=1e5), origin="lower")
plt.colorbar()
plt.title("39m ELT")
[8]:
Text(0.5, 1.0, '39m ELT')
Complete script¶
Included below is the complete script for convenience, including the downloads, but not including the plotting.
[9]:
import scopesim as sim
import scopesim_templates as sim_tp
# sim.download_packages(["Armazones", "ELT", "MICADO", "MORFEO", "LFOA"])
cluster = sim_tp.stellar.clusters.cluster(mass=10000, # Msun
distance=50000, # parsec
core_radius=2, # parsec
seed=9001) # random seed
lfoa = sim.OpticalTrain("LFOA")
lfoa.observe(cluster,
properties={"!OBS.ndit": 10, "!OBS.ndit": 360},
update=True)
hdus_lfoa = lfoa.readout()
micado = sim.OpticalTrain("MICADO")
micado.cmds["!OBS.dit"] = 10
micado.cmds["!OBS.ndit"] = 360
micado.update()
micado.observe(cluster)
hdus_micado = micado.readout()
imf - sample_imf: Setting maximum allowed mass to 10000
imf - sample_imf: Loop 0 added 1.01e+04 Msun to previous total of 0.00e+00 Msun
FOVs: 0%| | 0/1 [00:00<?, ?it/s]
FOV effects: 0%| | 0/1 [00:00<?, ?it/s]
FOV effects: 100%|██████████| 1/1 [00:00<00:00, 1.89it/s]
FOVs: 100%|██████████| 1/1 [00:00<00:00, 1.16it/s]
Image Plane effects: 0it [00:00, ?it/s]
astar.scopesim.detector.detector_array - Extracting from 1 detectors...
astar.scopesim.optics.optical_train - ERROR: Header update failed, data will be saved with incomplete header. See stack trace for details.
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/scopesim/checkouts/latest/scopesim/optics/optical_train.py", line 386, in readout
hdul = self.write_header(hdul)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/docs/checkouts/readthedocs.org/user_builds/scopesim/checkouts/latest/scopesim/optics/optical_train.py", line 408, in write_header
pheader["INSTRUME"] = from_currsys("!OBS.instrument", self.cmds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/docs/checkouts/readthedocs.org/user_builds/scopesim/checkouts/latest/scopesim/utils.py", line 542, in from_currsys
raise ValueError(f"{item} was not found in rc.__currsys__")
ValueError: !OBS.instrument was not found in rc.__currsys__
FOVs: 0%| | 0/1 [00:00<?, ?it/s]
FOV effects: 0%| | 0/2 [00:00<?, ?it/s]
FOV effects: 50%|█████ | 1/2 [00:00<00:00, 7.51it/s]
FOV effects: 100%|██████████| 2/2 [00:00<00:00, 8.31it/s]
FOVs: 100%|██████████| 1/1 [00:00<00:00, 2.09it/s]
Image Plane effects: 100%|██████████| 1/1 [00:00<00:00, 5041.23it/s]
astar.scopesim.detector.detector_array - Extracting from 1 detectors...
[ ]: