-
Notifications
You must be signed in to change notification settings - Fork 10
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
oczoske
wants to merge
45
commits into
main
Choose a base branch
from
oc/metis_wcu
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
METIS WCU effects #494
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
05411f8
start with BlackBodySource
oczoske 5fed12a
reinstate utils.seq, with tests
oczoske 3c2fc2d
add emission to BlackBodySource
oczoske fb84570
update test, add more
oczoske 0f5337d
debug messages
oczoske 3495999
Merge branch 'main' into oc/metis_wcu
oczoske af05978
One more debug message
oczoske 8171ac9
Hack to let NAXIS=3 wcses pass
oczoske e5e3379
BlackBodySource interface with tests
oczoske c46081b
allow int; do not allow negative temp
oczoske f0f2239
test for emission v temperature
oczoske 1425562
shorter
oczoske 237c727
Merge main
oczoske eb4e0ad
integrating sphere output intensity
oczoske de97413
correction to background intensity
oczoske c392f59
First attempt to make FP mask
oczoske 5b81a24
make background_source a list - needed for METIS_WCU
oczoske 0dca38a
add config_file
oczoske a1480fa
consistency between two definitions of background source
oczoske 17d0e8c
clean up pixarea multiplication
oczoske 5c0a141
user config file; apply pinhole size
oczoske 4725735
PupilMaskWheel
oczoske 5a729fe
start laser lamp
oczoske 65ad6f4
Update tests
oczoske 6c68867
fix tests
oczoske 723e48c
one more test for lss
oczoske aaf544e
clean up
oczoske 4d27c49
Merge branch 'main' into oc/metis_wcu
oczoske 8f401b5
Add second laser
oczoske 1e4740a
tunable laser
oczoske 5cd1cbe
Start FPMask class
oczoske 7ddeb45
Complete fpmask; instantiation in metis_wcu still open
oczoske 1eb6bba
Find mask definition files
oczoske 552243e
reject holes outside of field
oczoske 8624664
do not check against pre-installed masks
oczoske 8588b3c
flux-controlling aperture
oczoske 1b97d52
Put bb_aperture in the right place
oczoske 01a6e90
test for bb_aperture
oczoske c66a8a6
appease pylint in test
oczoske 7d5be2a
remove debug action
oczoske f093d48
TEL.area now set to 1 by default
oczoske cc4f167
let find_file not raise an error
oczoske c3faa7f
revert previous commit, protect test otherwise
oczoske 3097763
Move FPMask around
oczoske f105ae1
pinholes placed to subpixel accuracy
oczoske File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,6 @@ | |
|
||
from .rotation import * | ||
|
||
from .metis_wcu import * | ||
|
||
# from . import effects_utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Effects for METIS Warm Calibration Unit | ||
|
||
Classes: | ||
- | ||
- | ||
""" | ||
|
||
from ...utils import get_logger | ||
|
||
logger = get_logger(__name__) | ||
|
||
from .metis_wcu import WCUSource | ||
from .fpmask import FPMask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
"""A class for the METIS WCU focal-plane mask""" | ||
|
||
from pathlib import Path | ||
import numpy as np | ||
from matplotlib import pyplot as plt | ||
from astropy.io import fits | ||
from astropy import units as u | ||
from ..data_container import DataContainer | ||
from ...utils import find_file, from_currsys, get_logger | ||
from ...optics.image_plane_utils import sub_pixel_fractions | ||
|
||
logger = get_logger(__name__) | ||
|
||
class FPMask: | ||
"""Focal-plane mask for the METIS WCU | ||
|
||
Parameters | ||
---------- | ||
See :class:`DataContainer` for input parameters | ||
|
||
""" | ||
hdr = {"BG_SRC": True, | ||
"BG_SURF": "WCU focal plane mask", # TODO more specific? | ||
"CTYPE1": "LINEAR", | ||
"CTYPE2": "LINEAR", | ||
"CRPIX1": 1024.5, | ||
"CRPIX2": 1024.5, | ||
"CRVAL1": 0., | ||
"CRVAL2": 0., | ||
"CUNIT1": "arcsec", | ||
"CUNIT2": "arcsec", | ||
"CDELT1": 0.00547, | ||
"CDELT2": 0.00547, | ||
"BUNIT": "PHOTLAM arcsec-2", | ||
"SOLIDANG": "arcsec-2"} | ||
|
||
def __init__(self, | ||
maskname: Path | str | None = None, | ||
fpmask_filename_format: str | None = None, | ||
angle: float = 0, | ||
shift: tuple = (0, 0), | ||
**kwargs | ||
): | ||
logger.debug("Initialising FPMask with {}".format(maskname)) | ||
self.name = maskname | ||
self.angle = angle | ||
self.shift = shift | ||
self.xpix = [] | ||
self.ypix = [] | ||
if maskname == "open": | ||
self.holehdu = fits.ImageHDU() | ||
self.holehdu.header.update(self.hdr) | ||
self.opaquehdu = None | ||
else: | ||
# Try to find the file as a path | ||
if find_file(maskname, silent=True) is None: | ||
file_format = from_currsys(fpmask_filename_format) | ||
self.filename = file_format.format(maskname) | ||
else: | ||
self.filename = maskname | ||
|
||
self.data_container = DataContainer(filename=self.filename, **kwargs) | ||
self.pixarea = (self.hdr['CDELT1'] * u.Unit(self.hdr['CUNIT1']) | ||
* self.hdr['CDELT2'] * u.Unit(self.hdr['CUNIT2'])) | ||
self.make_hdus(header=self.hdr) | ||
|
||
|
||
def make_hdus(self, header): | ||
"""Create an hdu for the holes in fpmask | ||
|
||
The holes are assumed to be unresolved. They therefore cover one pixel and have | ||
a value corresponding to the actual solid angle covered by the hole. | ||
""" | ||
holehdu = fits.ImageHDU() | ||
holehdu.header.update(header) | ||
holehdu.data = np.zeros((2047, 2047)) | ||
|
||
opaquehdu = fits.ImageHDU() | ||
opaquehdu.header.update(header) | ||
opaquehdu.data = np.ones((2047, 2047)) * self.pixarea.value | ||
|
||
# Hole locations | ||
tab = self.data_container.table | ||
xhole = tab['x'].data | ||
yhole = tab['y'].data | ||
diam = tab['diam'].data | ||
|
||
if self.angle != 0: | ||
rangle = np.deg2rad(self.angle) | ||
xtmp = xhole * np.cos(rangle) - yhole * np.sin(rangle) | ||
ytmp = xhole * np.sin(rangle) + yhole * np.cos(rangle) | ||
xhole = xtmp | ||
yhole = ytmp | ||
|
||
xhole += self.shift[0] | ||
yhole += self.shift[1] | ||
|
||
xpix = (xhole - header['CRVAL1']) / header['CDELT1'] + header['CRPIX1'] - 1 | ||
ypix = (yhole - header['CRVAL2']) / header['CDELT2'] + header['CRPIX2'] - 1 | ||
in_field = (xpix > 0) * (xpix < 2047) * (ypix > 0) * (ypix < 2047) | ||
|
||
|
||
for x, y, d in zip(xpix[in_field], ypix[in_field], diam[in_field]): | ||
holearea = (d/2)**2 * np.pi | ||
xint, yint, fracs = sub_pixel_fractions(x, y) | ||
holehdu.data[yint, xint] = np.array(fracs) * holearea | ||
opaquehdu.data[yint, xint] = 0 | ||
self.xpix = xpix | ||
self.ypix = ypix | ||
self.holehdu = holehdu | ||
self.opaquehdu = opaquehdu | ||
|
||
|
||
def plot(self): | ||
"""Plot the location of the holes""" | ||
plt.plot(self.xpix, self.ypix, 'o') | ||
plt.xlim(0, 2048) | ||
plt.ylim(0, 2048) | ||
plt.gca().set_aspect('equal') | ||
plt.show() | ||
Comment on lines
+116
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps use |
||
|
||
def __str__(self) -> str: | ||
return f"""{self.__class__.__name__}: "{self.name}" | ||
Angle: {self.angle} deg | ||
Shift: {self.shift} arcsec""" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(that way the formatting is only executed when debug logging is actually on)