Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

METIS WCU effects #494

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open

METIS WCU effects #494

wants to merge 45 commits into from

Conversation

oczoske
Copy link
Collaborator

@oczoske oczoske commented Nov 5, 2024

This pull request includes Scopesim functionality to describe the METIS warm calibration unit. The idea is to have an empty source (empty_sky, taken as the default of OpticalTrain.observe, cf. #483), and add the emission at the exit of the integrating sphere as (subclasses of) TERCurve (BlackBodySource and LaserSource). Further effects describe the aperture masks (including thermal emission from the opaque parts).

The computation of the integrating-sphere exit radiance follows Roy van Boekel's radiometric model described in E-REP-MPIA-1203.

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 72.05479% with 102 lines in your changes missing coverage. Please review.

Project coverage is 76.82%. Comparing base (a43ac16) to head (f105ae1).
Report is 34 commits behind head on main.

Files with missing lines Patch % Lines
scopesim/effects/metis_wcu/metis_wcu.py 72.03% 59 Missing ⚠️
scopesim/effects/ter_curves.py 43.90% 23 Missing ⚠️
scopesim/effects/metis_wcu/fpmask.py 83.82% 11 Missing ⚠️
scopesim/utils.py 66.66% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #494      +/-   ##
==========================================
- Coverage   77.00%   76.82%   -0.19%     
==========================================
  Files          66       69       +3     
  Lines        8216     8573     +357     
==========================================
+ Hits         6327     6586     +259     
- Misses       1889     1987      +98     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@teutoburg teutoburg added enhancement New feature or request instrument-specific effects Related to a ScopeSim effect labels Nov 5, 2024
@oczoske oczoske marked this pull request as ready for review January 14, 2025 20:36
@oczoske
Copy link
Collaborator Author

oczoske commented Jan 14, 2025

I open the branch for review, although I don't intend to merge just yet. There is a problem with the fits keywords -- it's looking for telescope keywords where there are none. I may have to merge the corresponding irdb branch AstarVienna/irdb#205 first.

@oczoske oczoske requested review from teutoburg and astronomyk and removed request for teutoburg January 14, 2025 20:44
@hugobuddel
Copy link
Collaborator

I open the branch for review, although I don't intend to merge just yet.

I was about to ask 🤓

There is a problem with the fits keywords -- it's looking for telescope keywords where there are none.

Oh yeah, these broken header keywords is to be expected. And I did.

The idea was/is to split up https://github.com/AstarVienna/irdb/blob/dev_master/METIS/headers/FITS_common_keywords.yaml into more yaml files, and include more ExtraFitsKeyword effects in other places. I did not split this up, because I was like, we can do that when we need it.

In this case, all the telescope-related header keywords should be in e.g. FITS_telescope_keywords.yaml, which is then used in a ExtraFitsKeyword effect that should be placed in a separate yaml file (ELT_keywords.yaml?) that is imported only when ELT.yaml is imported in AstarVienna/irdb#205 .

Unfortunately it is not possible to place these keywords in the ELT package, because other ELT instruments will want different keywords. So that means that there should be an extra yaml file in METIS that just includes a single ExtraFitsKeywords.

Other solutions are possible, like just ignore anything that cannot be found, but that can easily lead to mistakes, so I deliberately did not add such a feature.

@hugobuddel
Copy link
Collaborator

Unfortunately it is not possible to place these keywords in the ELT package

Or maybe we can put this ExtraFitsKeywords effect in the ELT package, and refer to the actual filename with the keywords in a similar way as we do for the ter-curve of the mirrors?

That is, have some default keywords provided by the ELT package itself (or an empty set of keywords as default) and then a mechanism to override that default with a keyword yaml file in METIS and MICADO?

That would be cleaner than a separate yaml file in METIS just to include the METIS-specific ExtraFitsKeywords effect.

@hugobuddel
Copy link
Collaborator

Oh I should read first. Or maybe just shut up at 22:00, because that FITS header discussion does not directly apply to these test failures. Nevertheless, a similar solution can be applied here too.

However, I would expect a similar problem to happen in AstarVienna/irdb#205 for the fits keywords in the TEL hierarchy. Strange that it doesn't. Maybe I'll look at it later

Copy link
Contributor

@teutoburg teutoburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that in general, you verified that this does what it's supposed to. My comments are mostly small unimportant suggestions on implementation details. But if nothing else, I'd like to avoid merging those three debug log configs 🙃

shift: tuple = (0, 0),
**kwargs
):
logger.debug("Initialising FPMask with {}".format(maskname))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.debug("Initialising FPMask with {}".format(maskname))
logger.debug("Initialising FPMask with %s", maskname)

(that way the formatting is only executed when debug logging is actually on)

Comment on lines +116 to +120
plt.plot(self.xpix, self.ypix, 'o')
plt.xlim(0, 2048)
plt.ylim(0, 2048)
plt.gca().set_aspect('equal')
plt.show()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps use utils.figure_factory() (and through that the "fig, ax" interface) instead? I'm always trying to not include direct script-like plt. calls anywhere, as those can result in plotting over other figures...

def __init__(self, **kwargs):
super().__init__(**kwargs)
params = {
"z_order": [113, 513],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

z_order is now a ClassVar in all effects. Please adapt to match the way this is now defined in the base class (TERCurve) on main...

self.meta.update(kwargs)
if 'config_file' in self.meta:
config_file = from_currsys(self.meta['config_file'], self.cmds)
with open(find_file(config_file)) as fd:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with open(find_file(config_file)) as fd:
with open(find_file(config_file), encoding="utf-8") as fd:


# Define surfaces (the IS surface is currently taken from parent class)
# we add another one here (TODO: make this nicer)
self.mask_surf = SpectralSurface(cmds = self.cmds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.mask_surf = SpectralSurface(cmds = self.cmds)
self.mask_surf = SpectralSurface(cmds=self.cmds)

Feel free to ignore my nitpicking here 😛 (or add it to a batched commit, but don't bother turning this into a separate commit...)

Comment on lines +231 to +232
logger.warning("bb_aperture value out of range [0, 1], clipping to {}"
.format(value))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.warning("bb_aperture value out of range [0, 1], clipping to {}"
.format(value))
logger.warning("bb_aperture value out of range [0, 1], clipping to %f",
value)

line_l = Gaussian1D(amplitude=amp, mean=lamc_l, stddev=sigma)
line_m = Gaussian1D(amplitude=amp, mean=lamc_m, stddev=sigma)
list_t = [Gaussian1D(amplitude=amp, mean=ll, stddev=sigma) for ll in lam_t]
line_t = sum(list_t[1:], start=list_t[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

self.mask_surf.meta.update(tbl.meta)


def is_multiplication(self, wavelength, nport=2):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I read that as a question. As in, "is this a multiplication?", expecting it to return a bool 😅

But yeah, I got it after 1 s and it's fine...

Comment on lines +969 to +970
tbl = Table(maskdict)
return tbl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tbl = Table(maskdict)
return tbl
return Table(maskdict)

just shorter...

Comment on lines -24 to +28
level: INFO
level: DEBUG
astar.scopesim.optics.image_plane_utils:
level: INFO
level: DEBUG
astar.scopesim.optics.surface:
level: INFO
level: DEBUG
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change those back to INFO before merging, otherwise we'll get log-spammed again...

@teutoburg teutoburg added the Pipeline dev. Technical target audience label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effects Related to a ScopeSim effect enhancement New feature or request instrument-specific Pipeline dev. Technical target audience
Projects
Status: 👀 Awaiting Review
Development

Successfully merging this pull request may close these issues.

3 participants