-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from AstarVienna/dev_master
Merge dev_master into master for 0.4.3 release
- Loading branch information
Showing
11 changed files
with
143 additions
and
19 deletions.
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
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
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,60 @@ | ||
import numpy as np | ||
from astropy import units as u | ||
from scopesim import Source | ||
from synphot import BlackBody1D, SourceSpectrum, Empirical1D | ||
|
||
|
||
def pinhole_mask(x, y, waves, temperature=1500*u.K, sum_factor=1): | ||
""" | ||
Creates a Source object with point sources at coordinates (x, y) in the slit | ||
Parameters | ||
---------- | ||
x, y : array-like | ||
[arcsec] Coords relative to centre of FOV (i.e. optical axis) | ||
waves : array-like, u.Quantity | ||
[um] Array of wavelength values. | ||
temperature : float, u.Quantity, optional | ||
[deg K] Temperature of WCU blackbody spectrum. | ||
sum_factor : float, optional | ||
Rescale the spectrum to sum to this value | ||
Returns | ||
------- | ||
src : scopesim.Source | ||
Examples | ||
-------- | ||
Pin-holes every 0.5 arcsec along the MICADO long-slit | ||
:: | ||
x = np.arange(-1.5, 13.51, 0.5) | ||
y = np.zeros_like(x) | ||
waves = np.arange(0.7, 2.5, 0.001) * u.um | ||
src = pinhole_mask(x, y, waves, sum_factor=9001) | ||
A grid of pin-holes every 5 arcsec for the MICADO 4mas IMG mode | ||
:: | ||
dr = np.arange(-25, 26, 5) # [arcsec] | ||
x, y = np.meshgrid(dr, dr) | ||
x, y = x.flatten(), y.flatten() | ||
waves = np.arange(0.7, 2.5, 0.001) * u.um | ||
src = pinhole_mask(x, y, waves, sum_factor=9001) | ||
""" | ||
if not isinstance(waves, u.Quantity): | ||
waves *= u.um | ||
if not isinstance(temperature, u.Quantity): | ||
temperature *= u.K | ||
|
||
blackbody_spectrum = BlackBody1D(temperature=temperature) | ||
flux = blackbody_spectrum(waves.to(u.AA)) | ||
flux *= sum_factor / np.trapz(flux) | ||
spec = SourceSpectrum(Empirical1D, points=waves, lookup_table=flux) | ||
src = Source(x=x, y=y, ref=np.ones_like(x), weight=np.ones_like(x), | ||
spectra=[spec]) | ||
|
||
return src |
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
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,46 @@ | ||
"""Test for flatlamp.""" | ||
import numpy as np | ||
from astropy.table import Table | ||
from astropy import units as u | ||
from matplotlib import pyplot as plt | ||
from synphot import SourceSpectrum | ||
|
||
from scopesim import load_example_optical_train | ||
|
||
from scopesim_templates.micado.pinhole_masks import pinhole_mask | ||
from scopesim_templates.rc import Source | ||
|
||
PLOTS = False | ||
|
||
|
||
class TestPinholeMask: | ||
def test_pinhole_mask_returns_source_object(self): | ||
""" Example from pinhole_mask docstring""" | ||
dr = np.arange(-25, 26, 5) # [arcsec] | ||
x, y = np.meshgrid(dr, dr) | ||
x, y = x.flatten(), y.flatten() | ||
waves = np.arange(0.7, 2.5, 0.001) * u.um | ||
|
||
ph_mask = pinhole_mask(x, y, waves, sum_factor=9001) | ||
|
||
assert isinstance(ph_mask, Source) | ||
assert isinstance(ph_mask.spectra[0], SourceSpectrum) | ||
assert isinstance(ph_mask.fields[0], Table) | ||
|
||
def test_pinhole_with_basic_instrument(self): | ||
dr = np.arange(-25, 26, 5) # [arcsec] | ||
x, y = np.meshgrid(dr, dr) | ||
x, y = x.flatten(), y.flatten() | ||
waves = np.arange(0.7, 2.5, 0.001) * u.um | ||
|
||
src = pinhole_mask(x, y, waves, sum_factor=9001) | ||
opt = load_example_optical_train() | ||
opt.observe(src) | ||
|
||
im = opt.image_planes[0].data | ||
|
||
if PLOTS: | ||
plt.imshow(im) | ||
plt.show() | ||
|
||
assert np.max(im) > np.average(im) |
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