-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwave_sol.py
27 lines (23 loc) · 1.22 KB
/
wave_sol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from astropy.io import fits
import os.path
import numpy as np
from constants import WCS_FILE, LEFT, RIGHT
def get_wavelengths(instrument, instrument_filter):
#Work in progress
if instrument == "MIRI":
with fits.open(WCS_FILE) as hdul:
#Subtraction is necessary because image is rotated
all_ys = np.arange(1024 - LEFT - 1, 1024 - RIGHT - 1, -1)
wavelengths = np.interp(all_ys,
(hdul[0].header["IMYSLTL"] + hdul[1].data["Y_CENTER"] - 1)[::-1],
hdul[1].data["WAVELENGTH"][::-1])
return wavelengths
if instrument == "NIRCAM":
print("WARNING: wavelength solution to be implemented. Using hard-coded wavelengths.")
script_dir = os.path.dirname(os.path.realpath(__file__))
wavelengths = np.load("{}/{}_wavelength_solution.npy".format(script_dir, instrument_filter))
if instrument == "NIRSPEC":
print("WARNING: wavelength solution to be implemented. Using hard-coded wavelengths.")
script_dir = os.path.dirname(os.path.realpath(__file__))
wavelengths = np.load("{}/prism_wavelength_solution.npy".format(script_dir))
return wavelengths