diff --git a/METIS/LIST_METIS_mirrors_wcu.dat b/METIS/LIST_METIS_mirrors_wcu.dat new file mode 100644 index 0000000..178bde9 --- /dev/null +++ b/METIS/LIST_METIS_mirrors_wcu.dat @@ -0,0 +1,21 @@ +# author : Oliver Czoske +# source : E-REP-UZK-MET-1008_3-0 +# date_created : 2024-09-09 +# date_modified : 2024-09-09 +# status : FDR design +# type : mirror:list +# outer_unit : m +# inner_unit : m +# angle_unit : degree +# temperature_unit : deg_C +# changes: +# - 2024-09-09 (OC) created +# +name outer inner angle temperature action filename +WCU_table_fold_1 0.217 0.0 45 !WCU.temperature reflection TER_mirror_gold.dat +WCU_table_fold_2 0.271 0.0 45 !WCU.temperature reflection TER_mirror_gold.dat +WCU_CM1 0.274 0.0 0 !WCU.temperature reflection TER_mirror_gold.dat +WCU_CM2 0.100 0.0 0 !WCU.temperature reflection TER_mirror_gold.dat +WCU_CM3 0.196 0.0 0 !WCU.temperature reflection TER_mirror_gold.dat +WCU_fold_down 0.184 0.0 45 !WCU.temperature reflection TER_mirror_gold.dat +WCU_periscopic_feed 0.217 0.0 45 !WCU.temperature reflection TER_mirror_gold.dat diff --git a/METIS/METIS_WCU.yaml b/METIS/METIS_WCU.yaml new file mode 100644 index 0000000..dfd2721 --- /dev/null +++ b/METIS/METIS_WCU.yaml @@ -0,0 +1,46 @@ +--- +### METIS Warm Calibration Unit effects + +object: warm calibration unit +alias : WCU +name: METIS_WCU +description: base configuration for METIS/WCU +date_modified: 2024-11-25 +changes: + - 2024-09-03 (OC) file created + - 2024-11-06 (OC) add BlackBodySource + - 2024-11-25 (OC) config file, test TEL.area + - 2024-11-26 (OC) rename to WCUSource + +properties: + temperature: 15 # Celsius! needed for relay optics + config_file: "metis_wcu_config.yaml" + +effects: + - name: wcu_source + description: Source of the WCU + class: WCUSource + kwargs: + config_file: "!WCU.config_file" + + - name: wcu_relay_optics + description: surface list for METIS WCU relay optics + class: SurfaceList + kwargs: + filename: LIST_METIS_mirrors_wcu.dat + + - name: pupil_masks + description: pupil masks (transmission only) + class: PupilMaskWheel + kwargs: + pupil_masks: + names: [APP-LMS, APP-LM, CLS-LMS, CLS-LM, CLS-N, PPS-LMS, PPS-LM, PPS-N, PPS-CFO2, RLS-LMS, RLS-LM, SPM-LMS, SPM-LM, SPM-N, open] + transmissions: [0.6098, 0.6312, 0.5879, 0.6073, 0.5795, 0.7342, 0.7509, 0.7429, 0.6170, 0.4362, 0.4476, 0.6098, 0.6312, 0.6076, 0.8201] + current_mask: "open" + +--- +# Required parameters to replace telescope +alias: TEL +properties: + #area: 975.23478998 + area: 1354.593 #### TEST, needed to agree with RvB's calculation diff --git a/METIS/code/wcu_bb_to_is_throughput.py b/METIS/code/wcu_bb_to_is_throughput.py new file mode 100644 index 0000000..45a5e46 --- /dev/null +++ b/METIS/code/wcu_bb_to_is_throughput.py @@ -0,0 +1,98 @@ +"""Utility functions for the WCU radiometry + +These functions create lookup tables that are stored in the irdb. +""" +import os +from datetime import datetime +import numpy as np +from astropy.table import Table +from astropy.io import fits +from scopesim.utils import seq + +def bb_to_is_throughput(rho_tube, **kwargs): + """Compute the effective transmission through the tube between BB source + and integrating-sphere entrance port + + + """ + diam = 25.4 # diameter of the tube [mm]. + height = 28.2 # height of the tube [mm] + drad = 0.1 # grid step in radius [mm] + dalpha = 0.01 # grid step in "zenith angle" [rad] + dphi = 0.02 # grid step in azimuthal angle [rad] + + alpha = seq(dalpha/2, (np.pi - dalpha)/2, dalpha) + rad = seq(drad/2, (diam - drad)/2, drad) + phi = seq(dphi/2, np.pi - dphi/2, dphi) + + nalpha = len(alpha) + nrad = len(rad) + nphi = len(phi) + + # expand to grid + xyz = np.array(np.meshgrid(alpha, rad, phi)).reshape((3, nalpha * nrad * nphi)) + alpha = xyz[0,] + rad = xyz[1,] + phi = xyz[2,] + if "special" in kwargs: + nref = n_reflections(alpha, 0, phi, diam, height) + else: + nref = n_reflections(alpha, rad, phi, diam, height) + + result = np.zeros_like(rho_tube) + for i, rho in enumerate(rho_tube): + integrand = rho**nref * 0.5 * np.sin(2 * alpha) * rad * drad * dalpha * dphi + result[i] = np.sum(integrand) + return result * 16 / (np.pi * diam**2) + + + +def n_reflections(alpha, rad, phi, diam, height): + """Compute number of reflections of a photon emitted at radius r in direction alpha,phi""" + + beta = np.arcsin(2 * rad /diam * np.sin(phi)) + + numerator = height - diam * np.sin(phi + beta)/(2 * np.sin(phi)) * np.tan(np.pi/2 - alpha) + denominator = diam * np.cos(beta) * np.tan(np.pi/2 - alpha) + return (np.floor(1 + numerator/denominator)).astype(int) + + +#def integrating_sphere(wavelength): +# """Compute the magnification factor due to the integrating sphere""" + + +def make_pri_hdu(): + """Create primary header with meta data""" + pri_hdu = fits.PrimaryHDU() + + meta = {"author": "Oliver Czoske", + "descript": "METIS WCU, throughput from Blackbody to integrating sphere", + "source": "E-REP-MPIA-MET-1203", + "date-cre": "2024-11-19", + "date-mod": datetime.today().strftime("%Y-%m-%d"), + "status": "model", + "code": os.path.basename(__file__) + } + pri_hdu.header.update(meta) + return pri_hdu + +def do_main(): + """Create and write out lookup table for BB to IS transfer""" + rho_tube = seq(0, 1, 0.02) + t_general_no_gap = bb_to_is_throughput(rho_tube) + t_special_no_gap = bb_to_is_throughput(rho_tube, special=True) + + arr = {"rho_tube": rho_tube, + "t_gen_no_gap": t_general_no_gap, + "t_spec_no_gap": t_special_no_gap} + tab = Table(arr) + table_hdu = fits.table_to_hdu(tab) + table_hdu.header["EXTNAME"] = "BB_to_IS_throughput" + pri_hdu = make_pri_hdu() + hdul = fits.HDUList([pri_hdu, table_hdu]) + hdul.writeto("WCU_BB_to_IS_throughput.fits", overwrite=True) + + + +if __name__ == "__main__": + do_main() diff --git a/METIS/default.yaml b/METIS/default.yaml index 57523c2..cbc381d 100644 --- a/METIS/default.yaml +++ b/METIS/default.yaml @@ -6,7 +6,7 @@ alias: OBS name: METIS_default_configuration description: default parameters needed for a METIS simulation status: development -date_modified: 2022-03-14 +date_modified: 2024-09-04 changes: - 2021-12-16 (OC) chopnod defaults to perpendicular - 2021-12-16 (OC) default slits renamed @@ -16,16 +16,17 @@ changes: - 2022-02-20 (OC) pupil_transmission now an OBS parameter - 2022-02-21 (OC) linear interpolation, cosmetics - 2022-03-14 (OC) use single PSF file + - 2024-09-04 (OC) rearrange to include WCU modes packages: - Armazones - ELT - METIS -yamls: - - Armazones.yaml - - ELT.yaml # overrides below - - METIS.yaml +#yamls: +# - Armazones.yaml +# - ELT.yaml # overrides below +# - METIS.yaml properties: instrument: "METIS" @@ -67,6 +68,9 @@ mode_yamls: description: "METIS LM-band imaging" status: development yamls: + - Armazones.yaml + - ELT.yaml + - METIS.yaml - METIS_IMG_LM.yaml - METIS_DET_IMG_LM.yaml properties: @@ -83,6 +87,9 @@ mode_yamls: description: "METIS N-band imaging" status: development yamls: + - Armazones.yaml + - ELT.yaml + - METIS.yaml - METIS_IMG_N.yaml - METIS_DET_IMG_N_GeoSnap.yaml properties: @@ -101,6 +108,9 @@ mode_yamls: description: "METIS L-band slit spectroscopy" status: development yamls: + - Armazones.yaml + - ELT.yaml + - METIS.yaml - METIS_IMG_LM.yaml - METIS_LSS.yaml - METIS_DET_IMG_LM.yaml @@ -120,6 +130,9 @@ mode_yamls: description: "METIS M-band slit spectroscopy" status: development yamls: + - Armazones.yaml + - ELT.yaml + - METIS.yaml - METIS_IMG_LM.yaml - METIS_LSS.yaml - METIS_DET_IMG_LM.yaml @@ -139,6 +152,9 @@ mode_yamls: description: "METIS N-band slit spectroscopy" status: development yamls: + - Armazones.yaml + - ELT.yaml + - METIS.yaml - METIS_IMG_N.yaml - METIS_LSS.yaml - METIS_DET_IMG_N_GeoSnap.yaml @@ -158,6 +174,9 @@ mode_yamls: description: "METIS LM-band integral-field spectroscopy, nominal mode" status: experimental yamls: + - Armazones.yaml + - ELT.yaml + - METIS.yaml - METIS_LMS.yaml - METIS_DET_IFU.yaml properties: @@ -174,6 +193,136 @@ mode_yamls: description: "METIS LM-band integral-field spectroscopy, extended mode" status: experimental yamls: + - Armazones.yaml + - ELT.yaml + - METIS.yaml + - METIS_LMS_EXT.yaml + - METIS_DET_IFU.yaml + properties: + slit: false + adc: false + detector_readout_mode: slow + + - object: observation + alias: OBS + name: wcu_img_lm + description: "METIS LM-band imaging with WCU" + yamls: + - METIS_WCU.yaml + - METIS.yaml + - METIS_IMG_LM.yaml + - METIS_DET_IMG_LM.yaml + properties: + psf_file: PSF_SCAO_9mag_06seeing.fits # REPLACE! + filter_name: Lp + nd_filter_name: open + slit: false + adc: false + detector_readout_mode: fast + + - object: observation + alias: OBS + name: wcu_img_n + description: "METIS N-band imaging" + yamls: + - METIS_WCU.yaml + - METIS.yaml + - METIS_IMG_N.yaml + - METIS_DET_IMG_N_GeoSnap.yaml + properties: + psf_file: PSF_SCAO_9mag_06seeing.fits # REPLACE! + filter_name: N2 + nd_filter_name: open + slit: false + adc: false + chop_offsets: [3, 0] # perpendicular chopping and nodding + nod_offsets: [0, 3] + detector_readout_mode: high_capacity + + - object: observation + alias: OBS + name: wcu_lss_l + description: "METIS L-band slit spectroscopy" + yamls: + - METIS_WCU.yaml + - METIS.yaml + - METIS_IMG_LM.yaml + - METIS_LSS.yaml + - METIS_DET_IMG_LM.yaml + properties: + psf_file: PSF_LM_9mag_06seeing.fits # REPLACE! + trace_file: TRACE_LSS_L.fits + efficiency_file: TER_grating_L.fits + slit: C-38_1 + adc: const_90 + filter_name: L_spec + nd_filter_name: open + detector_readout_mode: slow + + - object: observation + alias: OBS + name: wcu_lss_m + description: "METIS M-band slit spectroscopy" + yamls: + - METIS_WCU.yaml + - METIS.yaml + - METIS_IMG_LM.yaml + - METIS_LSS.yaml + - METIS_DET_IMG_LM.yaml + properties: + psf_file: PSF_LM_9mag_06seeing.fits # REPLACE! + trace_file: TRACE_LSS_M.fits + efficiency_file: TER_grating_M.fits + slit: C-38_1 + adc: const_90 + filter_name: M_spec + nd_filter_name: open + detector_readout_mode: slow + + - object: observation + alias: OBS + name: wcu_lss_n + description: "METIS N-band slit spectroscopy" + yamls: + - METIS_WCU.yaml + - METIS.yaml + - METIS_IMG_N.yaml + - METIS_LSS.yaml + - METIS_DET_IMG_N_GeoSnap.yaml + properties: + psf_file: PSF_N_9mag_06seeing.fits # REPLACE! + trace_file: TRACE_LSS_N.fits + efficiency_file: TER_grating_N.fits + slit: D-57_1 + adc: false + filter_name: N_spec + nd_filter_name: open + detector_readout_mode: low_capacity + + - object: observation + alias: OBS + name: wcu_lms + description: "METIS LM-band integral-field spectroscopy, nominal mode" + yamls: + - METIS_WCU.yaml + - METIS.yaml + - METIS_LMS.yaml + - METIS_DET_IFU.yaml + properties: + psf_file: PSF_LM_9mag_06seeing.fits # REPLACE! + slit: false + adc: false + trace_file: TRACE_LMS.fits + wavelen: 4.2 + detector_readout_mode: slow + + - object: observation # is this a separate mode from nominal LMS? + alias: OBS + name: wcu_lms_extended + description: "METIS LM-band integral-field spectroscopy, extended mode" + yamls: + - METIS_WCU.yaml + - METIS.yaml - METIS_LMS_EXT.yaml - METIS_DET_IFU.yaml properties: diff --git a/METIS/metis_wcu_config.yaml b/METIS/metis_wcu_config.yaml new file mode 100644 index 0000000..1d09dda --- /dev/null +++ b/METIS/metis_wcu_config.yaml @@ -0,0 +1,25 @@ +# ------------- User-settable parameters +lamps: ["bb", "laser", "none"] # available lamps +current_lamp: "bb" # the lamp currently in use +bb_temp: 1000 # [K] temperature of BB source # Kelvin! +is_temp: 300 # [K] temperature of the integratig sphere +wcu_temp: 300 # [K] ambient temperature in the WCU +bb_aperture: 1.0 # aperture of flux-controlling mask +fpmasks: ["open", "pinhole_lm", "pinhole_n", "grid_lm"] +fpmask_filename_format: "wcu/fp_mask_{}.dat" +current_fpmask: "open" +fpmask_angle: 0 +fpmask_shift: (0, 0) + +# ------------- Data needed to describe the WCU +bb_to_is: "wcu/WCU_BB_to_IS_throughput.fits" +is_reflect: "wcu/WCU_IS_reflectivity.dat" +tube_reflect: "wcu/WCU_tube_reflectivity.dat" +mask_reflect: "wcu/WCU_mask_reflectivity.dat" +emiss_bb: 0.98 # E-REP-MPIA-MET-1203 +diam_is_in: 25.4 # [mm] diameter of integrating sphere entrance port +diam_is: 250 # [mm] diameter of integrating sphere +diam_is_out: 100 # [mm] diameter if integrating sphere output port +rho_is: 0.95 # [] reflectivity of integrating sphere +rho_tube: 0.95 # [] reflectivity of tube between BB and IS +rho_mask: 0.95 # [] reflectivity of focal-plane mask diff --git a/METIS/tests/test_modes.py b/METIS/tests/test_modes.py new file mode 100644 index 0000000..9843083 --- /dev/null +++ b/METIS/tests/test_modes.py @@ -0,0 +1,38 @@ +"""Tests for ELT vs. WCU modes + +These tests check that the yamls for the ELT/Armazones and METIS_WCU are loaded for the +modes where they belong (and not loaded where they do not belong). This is done by +checking the "elements" in the effects list of the OpticalTrain objects. +""" +# pylint: disable=missing-class-docstring +# pylint: disable=missing-function-docstring + +import os +import pytest + +import scopesim +PKGS_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) +scopesim.rc.__config__["!SIM.file.local_packages_path"] = PKGS_DIR + +ELT_MODES = ["img_lm", "img_n", "lss_l", "lss_m", "lss_n", "lms", "lms_extended"] +# Generate WCU_MODES automatically to ensure that each elt mode has a corresponding wcu mode +WCU_MODES = [("wcu_" + mode) for mode in ELT_MODES] + +class TestModes: + @pytest.mark.parametrize("themode", ELT_MODES) + def test_elt_modes_include_elt_effects(self, themode): + cmd = scopesim.UserCommands(use_instrument="METIS", + set_modes=[themode]) + metis = scopesim.OpticalTrain(cmd) + assert "ELT" in metis.effects["element"] + assert "armazones" in metis.effects["element"] + assert "METIS_WCU" not in metis.effects["element"] + + @pytest.mark.parametrize("themode", WCU_MODES) + def test_wcu_modes_include_wcu_effects(self, themode): + cmd = scopesim.UserCommands(use_instrument="METIS", + set_modes=[themode]) + metis = scopesim.OpticalTrain(cmd) + assert "ELT" not in metis.effects["element"] + assert "armazones" not in metis.effects["element"] + assert "METIS_WCU" in metis.effects["element"] diff --git a/METIS/wcu/WCU_BB_to_IS_throughput.fits b/METIS/wcu/WCU_BB_to_IS_throughput.fits new file mode 100644 index 0000000..c087a89 Binary files /dev/null and b/METIS/wcu/WCU_BB_to_IS_throughput.fits differ diff --git a/METIS/wcu/fp_mask_grid_lm.dat b/METIS/wcu/fp_mask_grid_lm.dat new file mode 100644 index 0000000..91e6504 --- /dev/null +++ b/METIS/wcu/fp_mask_grid_lm.dat @@ -0,0 +1,88 @@ +# description : WCU focal plane mask, grid LM +# name : WCU FP mask #5 +# author : Oliver Czoske +# source : E-SPE-UZK-MET-1015_2-0; E-REP-UZK-MET-1008_3-0, Table 10-8 +# date_created : 2025-01-13 +# date_modified : 2025-01-13 +# status : FDR +# type : aperture:aperture_mask +# x_unit : arcsec +# y_unit : arcsec +# diam_unit : arcsec +# notes: diam 25 um at 3.319 mm/arcsec +# changes : +# + x y diam + 1.36 1.36 0.007532 + 0.00 1.36 0.007532 +-1.36 1.36 0.007532 + 1.36 0.00 0.007532 + 0.00 0.00 0.007532 +-1.36 0.00 0.007532 + 1.36 -1.36 0.007532 + 0.00 -1.36 0.007532 +-1.36 -1.36 0.007532 + +-6.44 6.44 0.007532 +-4.29 6.44 0.007532 +-2.15 6.44 0.007532 + 0.00 6.44 0.007532 + 2.15 6.44 0.007532 + 4.29 6.44 0.007532 + +-6.44 4.29 0.007532 +-4.29 4.29 0.007532 +-2.15 4.29 0.007532 + 0.00 4.29 0.007532 + 2.15 4.29 0.007532 + 4.29 4.29 0.007532 + 6.44 4.29 0.007532 + +-6.44 2.15 0.007532 +-4.29 2.15 0.007532 + 4.29 2.15 0.007532 + 6.44 2.15 0.007532 + +-6.44 0.00 0.007532 +-4.29 0.00 0.007532 + 4.29 0.00 0.007532 + 6.44 0.00 0.007532 + +-6.44 -2.15 0.007532 +-4.29 -2.15 0.007532 + 4.29 -2.15 0.007532 + 6.44 -2.15 0.007532 + +-6.44 -4.29 0.007532 +-4.29 -4.29 0.007532 +-2.15 -4.29 0.007532 + 0.00 -4.29 0.007532 + 2.15 -4.29 0.007532 + 4.29 -4.29 0.007532 + 6.44 -4.29 0.007532 + +-6.44 -6.44 0.007532 +-4.29 -6.44 0.007532 +-2.15 -6.44 0.007532 + 0.00 -6.44 0.007532 + 2.15 -6.44 0.007532 + 4.29 -6.44 0.007532 + 6.44 -6.44 0.007532 + +-8.79 0.00 0.007532 + 8.79 0.00 0.007532 + +-12.88 0.00 0.007532 + 12.88 0.00 0.007532 + +-7.93 9.78 0.007532 +-3.96 9.78 0.007532 + 0.00 9.78 0.007532 + 3.96 9.78 0.007532 + 7.93 9.78 0.007532 + +-7.93 -9.78 0.007532 +-3.96 -9.78 0.007532 + 0.00 -9.78 0.007532 + 3.96 -9.78 0.007532 + 7.93 -9.78 0.007532 diff --git a/METIS/wcu/fp_mask_pinhole_lm.dat b/METIS/wcu/fp_mask_pinhole_lm.dat new file mode 100644 index 0000000..a64139f --- /dev/null +++ b/METIS/wcu/fp_mask_pinhole_lm.dat @@ -0,0 +1,16 @@ +# description : WCU focal plane mask, pinhole LM +# name : WCU FP mask #1 +# author : Oliver Czoske +# source : E-SPE-UZK-MET-1015_2-0; E-REP-UZK-MET-1008_3-0, Table 10-8 +# date_created : 2025-01-13 +# date_modified : 2025-01-13 +# status : FDR +# type : aperture:aperture_mask +# x_unit : arcsec +# y_unit : arcsec +# diam_unit : arcsec +# notes: diam 25 um at 3.319 mm/arcsec +# changes : +# + x y diam + 0 0 0.007532 diff --git a/METIS/wcu/fp_mask_pinhole_n.dat b/METIS/wcu/fp_mask_pinhole_n.dat new file mode 100644 index 0000000..b8b2ecf --- /dev/null +++ b/METIS/wcu/fp_mask_pinhole_n.dat @@ -0,0 +1,16 @@ +# description : WCU focal plane mask, pinhole N +# name : WCU FP mask #2 +# author : Oliver Czoske +# source : E-SPE-UZK-MET-1015_2-0; E-REP-UZK-MET-1008_3-0, Table 10-8 +# date_created : 2025-01-13 +# date_modified : 2025-01-13 +# status : FDR +# type : aperture:aperture_mask +# x_unit : arcsec +# y_unit : arcsec +# diam_unit : arcsec +# notes: diam 66 um at 3.319 mm/arcsec +# changes : +# + x y diam + 0 0 0.01988551