Commit 789dbfc4 authored by Hugo Buddelmeijer's avatar Hugo Buddelmeijer
Browse files

Upload minimal MICADO example to simulate a cluster

parent 7429ec2a
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import scopesim
import scopesim_templates as sim_tp
# In[2]:
get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib.pyplot as plt
# In[373]:
import numpy
from pprint import pprint
import copy
# In[4]:
scopesim.server.download_package("telescopes/LFOA")
scopesim.server.download_package("telescopes/ELT")
scopesim.server.download_package("instrumnents/MICADO")
scopesim.server.download_package("instrumnents/MAORY")
scopesim.server.download_package("locations/Armazones")
# In[5]:
#my_cluster = sim_tp.basic.stars.cluster(mass=10000, distance=2000, core_radius=1)
my_cluster = sim_tp.basic.stars.cluster(mass=10000, distance=2000, core_radius=.1)
# In[ ]:
# In[407]:
yamls = [
{'object': 'configuration',
'alias': 'OBS',
'name': 'MICADO_default_configuration',
'description': 'default parameters needed for a MICADO simulation',
'packages': ['Armazones', 'ELT', 'MAORY', 'MICADO'],
'properties': {
# 'modes': ['SCAO', 'IMG_4mas'],
'airmass': 1.2,
'declination': -30,
'hour_angle': 0,
'pupil_angle': 0,
'dit': 60,
'ndit': 1,
# Deciding what detectors to use is not necessary in minimal example
# 'use_full_detector': False,
# 'use_window_detector': True,
# filter_name added from IMG4_mas below
'filter_name': 'Ks',
},
# 'mode_yamls': [
# {'name': 'SCAO',
# 'description': 'SCAO optical system',
# 'alias': 'OBS',
# 'yamls': ['MICADO_Standalone_RO.yaml']},
# # {'name': 'MCAO',
# # 'description': 'MCAO optical system',
# # 'alias': 'OBS',
# # 'yamls': ['MAORY.yaml']},
# {'name': 'IMG_4mas',
# 'description': 'wide-field imager : 4mas/pix',
# 'alias': 'OBS',
# 'yamls': ['MICADO_IMG_wide.yaml'],
# 'properties': {'filter_name': 'Ks'}},
# # {'name': 'IMG_1.5mas',
# # 'description': 'high resolution imager : 1.5mas/pix',
# # 'alias': 'OBS',
# # 'yamls': ['MICADO_IMG_zoom.yaml'],
# # 'properties': {'filter_name': 'Ks'}},
# # {'name': 'IMG_HCI',
# # 'description': 'High contrast imaging',
# # 'alias': 'OBS',
# # 'yamls': ['MICADO_IMG_HCI.yaml']},
# # {'name': 'SPEC_15000x50',
# # 'description': 'spectrograph : slit size 15000x50mas',
# # 'alias': 'OBS',
# # 'yamls': ['MICADO_SPEC.yaml'],
# # 'properties': {'trace_file': 'TRACE_15arcsec.fits',
# # 'slit_file': 'MASK_slit_15000x50.dat',
# # 'filter_name': 'Spec_HK'}},
# # {'name': 'SPEC_3000x50',
# # 'description': 'spectrograph : slit size 3000x50mas',
# # 'alias': 'OBS',
# # 'yamls': ['MICADO_SPEC.yaml'],
# # 'properties': {'trace_file': 'TRACE_3arcsec.fits',
# # 'slit_file': 'MASK_slit_3000x50.dat',
# # 'filter_name': 'Spec_HK'}},
# # {'name': 'SPEC_3000x20',
# # 'description': 'spectrograph : slit size 3000x20mas',
# # 'alias': 'OBS',
# # 'yamls': ['MICADO_SPEC.yaml'],
# # 'properties': {'trace_file': 'TRACE_3arcsec.fits',
# # 'slit_file': 'MASK_slit_3000x20.dat',
# # 'filter_name': 'Spec_HK'}}
# ]
},
# OBS is necessary because it defines the filter
# Added to configuration above
# {'name': 'IMG_4mas',
# 'description': 'wide-field imager : 4mas/pix',
# 'alias': 'OBS',
# 'properties': {'filter_name': 'Ks'}},
# {'object': 'atmosphere',
# 'alias': 'ATMO',
# 'name': 'armazones',
# 'description': 'Atmosphere and location details for Cerro Armazones',
# 'properties': {'altitude': 3060,
# 'longitude': -70.1918,
# 'latitude': -24.5899,
# 'temperature': 7,
# 'humidity': 0.1,
# 'pressure': 0.755,
# 'pwv': 2.5,
# 'airmass': '!OBS.airmass',
# 'pupil_angle': '!OBS.pupil_angle',
# 'pixel_scale': '!INST.pixel_scale',
# 'element_name': 'armazones'},
# 'effects': [{'name': 'armazones_atmo_default_ter_curve',
# 'description': 'atmospheric emission and transmission',
# 'class': 'AtmosphericTERCurve',
# 'include': True,
# 'kwargs': {'filename': 'TER_armazones_default_NIR_IMG.dat'}},
# {'name': 'armazones_atmo_dispersion',
# 'description': 'atmospheric dispersion',
# 'class': 'AtmosphericDispersion'},
# # {'name': 'armazones_atmo_skycalc_ter_curve',
# # 'description': 'atmospheric spectra pulled from the skycalc server',
# # 'class': 'SkycalcTERCurve',
# # 'include': False,
# # 'kwargs': {'observatory': 'armazones',
# # 'wmin': '!SIM.spectral.wave_min',
# # 'wmax': '!SIM.spectral.wave_max',
# # 'wunit': 'um',
# # 'wdelta': '!SIM.spectral.spectral_resolution'}}
# ]},
# A Telescope is not strictly necessary
# {'object': 'telescope',
# 'alias': 'TEL',
# 'name': 'ELT',
# 'description': 'The extremely large telescope',
# # 'properties': {'temperature': '!ATMO.temperature', 'element_name': 'ELT'},
# 'properties': {
# 'temperature': 10.0,
# # 'element_name': 'ELT'
# },
# 'effects': [
# # {'name': 'scope_surface_list',
# # 'description': 'list of ELT surfaces',
# # 'class': 'SurfaceList',
# # 'kwargs': {'filename': 'LIST_mirrors_ELT.tbl'}},
# # {'name': 'scope_vibration',
# # 'description': 'residual vibration of telescope',
# # 'class': 'Vibration',
# # 'kwargs': {'fwhm': 0.001, 'pixel_scale': '!INST.pixel_scale'}},
# # {'name': 'eso_combined_reflection',
# # 'description': 'single combined reflection curve for clean ELT 5 mirror combination',
# # 'class': 'TERCurve',
# # 'include': False,
# # 'kwargs': {'filename': 'TER_ELT_System_20190611.dat'}}
# ]},
# MICADO also contains info from MICADO_IMG_RL
{'object': 'instrument',
'alias': 'INST',
'name': 'MICADO',
'description': 'base configuration for MICADO',
'properties': {
'temperature': -190,
'pixel_scale': 0.004,
'plate_scale': 0.26666666666,
# 'element_name': 'MICADO',
},
'effects': [
# {'name': 'micado_static_surfaces',
# 'description': 'surfaces list for wide field optics',
# 'class': 'SurfaceList',
# 'kwargs': {'filename': 'LIST_MICADO_mirrors_static.dat'}},
{'name': 'micado_filter',
'description': 'transmission curve for filter',
'class': 'FilterCurve',
'kwargs': {'filter_name': '!OBS.filter_name',
'filename_format': 'filters/TC_filter_{}.dat',
'minimum_throughput': 0.000101,
'outer': 0.2,
'outer_unit': 'm'}},
# {'name': 'micado_ncpas_psf',
# 'description': 'Effective NCPA induced PSF kernel',
# 'class': 'NonCommonPathAberration',
# 'kwargs': {'pixel_scale': '!INST.pixel_scale',
# 'filename': 'INST_MICADO_wavefront_error_budget.dat'}}
]},
{'object': 'detector',
'alias': 'DET',
'name': 'micado_detector_array',
'description': 'A set of 9 (or 1) H4RG detectors',
'properties': {
'image_plane_id': 0,
'temperature': -230,
'dit': '!OBS.dit',
'ndit': '!OBS.ndit',
# 'element_name': 'micado_detector_array'
},
'effects': [
# Exclude full detector array for minimal example
# {'name': 'full_detector_array',
# 'description': 'MICADO detector array list',
# 'class': 'DetectorList',
# 'include': '!OBS.use_full_detector',
# 'kwargs': {'filename': 'FPA_array_layout.dat', 'active_detectors': 'all'}},
{'name': 'detector_window',
'class': 'DetectorList',
# 'include': '!OBS.use_window_detector',
'kwargs': {'image_plane_id': 0,
'array_dict': {
'id': [1],
'pixsize': [0.015],
'angle': [0.0],
'gain': [1.0],
'x_cen': [0.0],
'y_cen': [0.0],
'xhw': [7.68],
'yhw': [7.68]},
'x_cen_unit': 'mm',
'y_cen_unit': 'mm',
'xhw_unit': 'mm',
'yhw_unit': 'mm',
'pixsize_unit': 'mm',
'angle_unit': 'deg',
'gain_unit': 'electron/adu'}},
# QE curve is not necessary, but moves the mean flux from 0 to +3000, while
# the std stays at 3. So requires fine tuning of the plot limits to see anything.
# {'name': 'qe_curve',
# 'description': 'Quantum efficiency curves for each detector',
# 'class': 'QuantumEfficiencyCurve',
# 'kwargs': {'filename': 'QE_detector_H2RG.dat'}},
# {'name': 'exposure_action',
# 'description': 'Summing up sky signal for all DITs and NDITs',
# 'class': 'SummedExposure'},
# {'name': 'dark_current',
# 'description': 'MICADO dark current',
# 'class': 'DarkCurrent',
# 'kwargs': {'value': 0.1}},
# Detector linearity is necessary as well.. No it is not, must plot logarithmically though
# {'name': 'detector_linearity',
# 'description': 'Linearity characteristics of H4RG chips',
# 'class': 'LinearityCurve',
# 'kwargs': {'filename': 'FPA_linearity.dat'}},
# {'name': 'shot_noise',
# 'description': 'apply poisson shot noise to images',
# 'class': 'ShotNoise'},
# {'name': 'readout_noise',
# 'description': 'Readout noise frames',
# 'class': 'BasicReadoutNoise',
# 'kwargs': {'noise_std': 12, 'n_channels': 64}}
]},
# A PSF is necessary because otherwise there are only point sources,
# making it impossible to see anything.
# {'name': 'SCAO', 'description': 'SCAO optical system', 'alias': 'OBS'},
{'object': 'relay_optics',
'alias': 'RO',
'name': 'default_ro',
'description': 'Simple stand-alone relay optics module',
# 'properties': {'temperature': '!ATMO.temperature', 'element_name': 'default_ro'},
'properties': {
'temperature': 10.0,
# 'element_name': 'default_ro'
},
'effects': [
# relay_psf is necessary, otherwise nothing is shown.
{'name': 'relay_psf',
'description': 'SCAO PSF',
'class': 'FieldConstantPSF',
'kwargs': {
'filename': 'PSF_SCAO_ConstPSF_0_5off.fits',
# 'warning': 'Default PSF is NOT field varying. See documentation.'
}},
# {'name': 'relay_surface_list',
# 'description': 'list of surfaces in the relay optics',
# 'class': 'SurfaceList',
# 'kwargs': {'filename': 'LIST_RO_SCAO_mirrors.dat'}}
]},
# MICADO_IMG_LR can be incorporated in just MICADO, at least w/o effects
# {'object': 'instrument',
# 'alias': 'INST',
# 'name': 'MICADO_IMG_LR',
# 'description': 'additional effects for the wide-field imaging mode',
# 'properties': {
# 'pixel_scale': 0.004,
# 'plate_scale': 0.26666666666,
# # 'element_name': 'MICADO_IMG_LR',
# },
# 'effects': [
# # {'name': 'micado_wide_field_mirror_list',
# # 'description': 'list of extra mirrors needed for the wide field mode',
# # 'class': 'SurfaceList',
# # 'kwargs': {'filename': 'LIST_MICADO_mirrors_wide.dat'}},
# # {'name': 'micado_adc_3D_shift',
# # 'description': 'atmospheric disperson corrector',
# # 'class': 'AtmosphericDispersionCorrection',
# # 'kwargs': {'altitude': '!ATMO.altitude',
# # 'longitude': '!ATMO.longitude',
# # 'latitude': '!ATMO.latitude',
# # 'airmass': '!OBS.airmass',
# # 'temperature': '!ATMO.temperature',
# # 'humidity': '!ATMO.humidity',
# # 'pressure': '!ATMO.pressure',
# # 'pupil_angle': '!OBS.pupil_angle',
# # 'efficiency': 1,
# # 'wave_mid': '!SIM.spectral.wave_mid',
# # 'quick_adc': True}}
# ]
# },
# SIM is necessary because it defines some properties used by ADC and ATMO
# {'object': 'simulation',
# 'alias': 'SIM',
# 'name': 'MICADO_simulation_paramters',
# 'description': 'RC simulation paramters which need to change for a MICADO run',
# 'properties': {'random': {'seed': 9001},
# 'spectral': {'wave_min': 0.7, 'wave_mid': 1.6, 'wave_max': 2.5},
# 'computing': {'preload_field_of_view': True}}}
]
# In[408]:
cmds = scopesim.UserCommands(yamls=yamls)
opt = scopesim.OpticalTrain(cmds=cmds)
# In[409]:
opt.observe(my_cluster)
hdulists = opt.readout(filename="TEST.fits")
# In[410]:
from matplotlib.colors import LogNorm
hdu = hdulists[0][1]
dmin, dmax, dmean, dmed, dstd = hdu.data.min(), hdu.data.max(), hdu.data.mean(), numpy.median(hdu.data), hdu.data.std()
fig, ax = plt.subplots()
im = ax.imshow(hdu.data, norm=LogNorm(vmin=dmed , vmax=dmed + 0.1 * dstd))
# im = ax.imshow(hdu.data, norm=LogNorm(vmin=hdu.data.min(), vmax=hdu.data.max()))
# im = ax.imshow(hdu.data)
fig.colorbar(im)
fig.show()
# In[403]:
print(dmin, dmax, dmean, dmed, dstd)
# In[411]:
for y in yamls:
print(f"{y['alias']:10} {y.get('object', 'None'):20} {y['name']:10}")
# In[414]:
opt.effects
# In[ ]:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment