Skip to content

Commit

Permalink
user config file; apply pinhole size
Browse files Browse the repository at this point in the history
  • Loading branch information
oczoske committed Nov 25, 2024
1 parent 17d0e8c commit 5c0a141
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions scopesim/effects/metis_wcu/metis_wcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from ..ter_curves import TERCurve
from ...utils import get_logger, seq, find_file,\
convert_table_comments_to_dict
convert_table_comments_to_dict, from_currsys
from ...source.source import Source
from ...optics.surface import SpectralSurface
from ...optics.surface_utils import make_emission_from_array
Expand All @@ -27,6 +27,26 @@ class BlackBodySource(TERCurve):
- coupling into the integrating sphere
- integrating sphere magnification factor
- thermal emission from the integrating sphere
Configuration file
------------------
The default configuration file for the METIS WCU is provided in the irdb.
To modify the configuration, copy the file <irdb>/METIS/metis_wcu_config.yaml
to the working directory and edit it there. To use the file do e.g.
>>> cmds = sim.UserCommands(use_instrument="METIS", set_modes=["wcu_img_lm"]
>>> cmds["!WCU.config_file"] = "my_wcu_config.yaml"
>>> metis = sim.OpticalTrain(cmds)
Changing important parameters
-----------------------------
The temperatures of the black-body source, the integrating sphere as well as the
ambient temperature of the WCU (which is the temperature of the focal-plane mask)
can be set by calling
>>> metis['bb_source'].set_temperature(bb_temp=1200*u.K, is_temp=320*u.K,
wcu_temp=295*u.K)
The focal-plane mask can be changed by calling
>>> metis['bb_source'].set_mask("pinhole")
"""

def __init__(self, **kwargs):
Expand All @@ -39,7 +59,8 @@ def __init__(self, **kwargs):
self.meta.update(params)
self.meta.update(kwargs)
if 'config_file' in self.meta:
with open(find_file(self.meta['config_file'])) as fd:
config_file = from_currsys(self.meta['config_file'], self.cmds)
with open(find_file(config_file)) as fd:
config = yaml.safe_load(fd)
self.meta.update(config)

Check warning on line 65 in scopesim/effects/metis_wcu/metis_wcu.py

View check run for this annotation

Codecov / codecov/patch

scopesim/effects/metis_wcu/metis_wcu.py#L59-L65

Added lines #L59 - L65 were not covered by tests

Expand Down Expand Up @@ -99,6 +120,9 @@ def background_source(self):
bg_hdu.header.update(hdr)
self._background_source.append(Source(image_hdu=bg_hdu, spectra=bb_flux))

Check warning on line 121 in scopesim/effects/metis_wcu/metis_wcu.py

View check run for this annotation

Codecov / codecov/patch

scopesim/effects/metis_wcu/metis_wcu.py#L118-L121

Added lines #L118 - L121 were not covered by tests
else: # TODO: properly define masks
holearea = 4.45610478e-05 * u.arcsec**2 # LM: 25 um

Check warning on line 123 in scopesim/effects/metis_wcu/metis_wcu.py

View check run for this annotation

Codecov / codecov/patch

scopesim/effects/metis_wcu/metis_wcu.py#L123

Added line #L123 was not covered by tests
# holearea = 0.00031057 * u.arcsec**2 # N: 66 um

bg_hdu = fits.ImageHDU()
bg_hdu.header.update(hdr)
bg_hdu.data = np.zeros((2048, 2048))
Expand All @@ -108,10 +132,11 @@ def background_source(self):
# area (arcsec2). For a true backgroud field, this is taken care of by
# fov._calc_area_factor, but this is not applied to image data, so we
# have to do it here.
bg_hdu.data = bg_hdu.data * holearea # Should actually be the size of the hole
self._background_source.append(Source(image_hdu=bg_hdu, spectra=bb_flux))

Check warning on line 136 in scopesim/effects/metis_wcu/metis_wcu.py

View check run for this annotation

Codecov / codecov/patch

scopesim/effects/metis_wcu/metis_wcu.py#L135-L136

Added lines #L135 - L136 were not covered by tests

pixarea = (hdr['CDELT1'] * u.Unit(hdr['CUNIT1'])

Check warning on line 138 in scopesim/effects/metis_wcu/metis_wcu.py

View check run for this annotation

Codecov / codecov/patch

scopesim/effects/metis_wcu/metis_wcu.py#L138

Added line #L138 was not covered by tests
* hdr['CDELT2'] * u.Unit(hdr['CUNIT2']))
bg_hdu.data = bg_hdu.data #* pixarea # Should actually be the size of the hole
self._background_source.append(Source(image_hdu=bg_hdu, spectra=bb_flux))

bg2_hdu = fits.ImageHDU()
bg2_hdu.header.update(hdr)
Expand Down

0 comments on commit 5c0a141

Please sign in to comment.