Filter curves#
This notebook shows how you can apply different filters to your rubix IFU cube and create photometric images of your mock-data.
# NBVAL_SKIP
from rubix.telescope.filters import load_filter, print_filter_list, print_filter_list_info, print_filter_property
2024-12-04 09:07:21,286 - rubix - INFO -
___ __ _____ _____ __
/ _ \/ / / / _ )/ _/ |/_/
/ , _/ /_/ / _ |/ /_> <
/_/|_|\____/____/___/_/|_|
2024-12-04 09:07:21,288 - rubix - INFO - Rubix version: 0.0.post138+g67c52e2.d20241203
Information about the filters#
We can have a look, which different filters are availible for a given facility or instrument. A list of all availible filters can be found here: http://svo2.cab.inta-csic.es/theory/fps/index.php
As an example, we print the different filters for SLOAN.
# NBVAL_SKIP
print_filter_list("SLOAN")
filterID
------------------------
SLOAN/SDSS.uprime_filter
SLOAN/SDSS.u
SLOAN/SDSS.g
SLOAN/SDSS.gprime_filter
SLOAN/SDSS.r
SLOAN/SDSS.rprime_filter
SLOAN/SDSS.i
SLOAN/SDSS.iprime_filter
SLOAN/SDSS.z
SLOAN/SDSS.zprime_filter
We can also print some more details about the filters. print_filter_list_info()
prints the filter name, the dtype and the unit.
# NBVAL_SKIP
print_filter_list_info("SLOAN")
<Table length=10>
name dtype unit
-------------------- ------- ---------------
FilterProfileService object
filterID object
WavelengthUnit object
WavelengthUCD object
PhotSystem object
DetectorType object
Band object
Instrument object
Facility object
ProfileReference object
CalibrationReference object
Description object
Comments object
WavelengthRef float64 AA
WavelengthMean float64 AA
WavelengthEff float64 AA
WavelengthMin float64 AA
WavelengthMax float64 AA
WidthEff float64 AA
WavelengthCen float64 AA
WavelengthPivot float64 AA
WavelengthPeak float64 AA
WavelengthPhot float64 AA
FWHM float64 AA
Fsun float64 erg / (A s cm2)
PhotCalID object
MagSys object
ZeroPoint float64 Jy
ZeroPointUnit object
Mag0 float64
ZeroPointType object
AsinhSoft float64
TrasmissionCurve object
The most detaield information about a filter can be obtained by using the print_filter_property()
function.
# NBVAL_SKIP
print_filter_property("SLOAN", "SDSS.u")
FilterProfileService filterID WavelengthUnit WavelengthUCD PhotSystem DetectorType Band Instrument Facility ProfileReference CalibrationReference Description Comments WavelengthRef WavelengthMean WavelengthEff WavelengthMin WavelengthMax WidthEff WavelengthCen WavelengthPivot WavelengthPeak WavelengthPhot FWHM Fsun PhotCalID MagSys ZeroPoint ZeroPointUnit Mag0 ZeroPointType AsinhSoft TrasmissionCurve
AA AA AA AA AA AA AA AA AA AA AA erg / (A s cm2) Jy
-------------------- ------------ -------------- ------------- ---------- ------------ ---- ---------- -------- ----------------------------------------------------- ----------------------------------------------- ------------------------ -------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- -------------- --------------- --------------- --------------- ----------------- ------ -------------- ------------- ---- ------------- --------- ----------------------------------------------------------------
ivo://svo/fps SLOAN/SDSS.u Angstrom em.wl SDSS 1 SLOAN http://www.sdss.org/dr7/instruments/imager/index.html http://www.sdss.org/DR2/algorithms/fluxcal.html SDSS u full transmission 3556.5239668607 3572.1824003193 3608.0403153219 3055.1091291961 4030.6399499061 540.97112586776 3578.0271197298 3556.5239668607 3680.0 3619.6973042374 565.79845192387 103.21344236463 SLOAN/SDSS.u/Vega Vega 1582.537065543 Jy 0.0 Pogson 0.0 http://svo2.cab.inta-csic.es//theory/fps/fps.php?ID=SLOAN/SDSS.u
FilterProfileService | filterID | WavelengthUnit | WavelengthUCD | PhotSystem | DetectorType | Band | Instrument | Facility | ProfileReference | CalibrationReference | Description | Comments | WavelengthRef | WavelengthMean | WavelengthEff | WavelengthMin | WavelengthMax | WidthEff | WavelengthCen | WavelengthPivot | WavelengthPeak | WavelengthPhot | FWHM | Fsun | PhotCalID | MagSys | ZeroPoint | ZeroPointUnit | Mag0 | ZeroPointType | AsinhSoft | TrasmissionCurve |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AA | AA | AA | AA | AA | AA | AA | AA | AA | AA | AA | erg / (A s cm2) | Jy | ||||||||||||||||||||
object | object | object | object | object | object | object | object | object | object | object | object | object | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | object | object | float64 | object | float64 | object | float64 | object |
ivo://svo/fps | SLOAN/SDSS.u | Angstrom | em.wl | SDSS | 1 | SLOAN | http://www.sdss.org/dr7/instruments/imager/index.html | http://www.sdss.org/DR2/algorithms/fluxcal.html | SDSS u full transmission | 3556.5239668607 | 3572.1824003193 | 3608.0403153219 | 3055.1091291961 | 4030.6399499061 | 540.97112586776 | 3578.0271197298 | 3556.5239668607 | 3680.0 | 3619.6973042374 | 565.79845192387 | 103.21344236463 | SLOAN/SDSS.u/Vega | Vega | 1582.537065543 | Jy | 0.0 | Pogson | 0.0 | http://svo2.cab.inta-csic.es//theory/fps/fps.php?ID=SLOAN/SDSS.u |
# NBVAL_SKIP
print_filter_property("JWST", "F070W", "NIRCam")
FilterProfileService filterID WavelengthUnit WavelengthUCD PhotSystem DetectorType Band Instrument Facility ProfileReference CalibrationReference Description Comments WavelengthRef WavelengthMean WavelengthEff WavelengthMin WavelengthMax WidthEff WavelengthCen WavelengthPivot WavelengthPeak WavelengthPhot FWHM Fsun PhotCalID MagSys ZeroPoint ZeroPointUnit Mag0 ZeroPointType AsinhSoft TrasmissionCurve
AA AA AA AA AA AA AA AA AA AA AA erg / (A s cm2) Jy
-------------------- ----------------- -------------- ------------- ---------- ------------ ---- ---------- -------- ------------------------------------------------------ -------------------- ------------------- ------------------------------------------------------------------ --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- -------------- -------------- --------------- --------------- ---------------------- ------ --------------- ------------- ---- ------------- --------- ---------------------------------------------------------------------
ivo://svo/fps JWST/NIRCam.F070W Angstrom em.wl NIRCam 1 NIRCam JWST https://jwst-docs.stsci.edu/display/JTI/NIRCam+Filters NIRCam F070W filter includes NIRCam optics, DBS, QE and JWST Optical Telescope Element 7039.1194650654 7088.3009369996 6988.4272768359 6048.1970523246 7927.0738659178 1212.8399166581 7099.1873443748 7039.1194650654 7691.5 7022.060805287 1430.8105961315 140.01772043307 JWST/NIRCam.F070W/Vega Vega 2768.4045696982 Jy 0.0 Pogson 0.0 http://svo2.cab.inta-csic.es//theory/fps/fps.php?ID=JWST/NIRCam.F070W
FilterProfileService | filterID | WavelengthUnit | WavelengthUCD | PhotSystem | DetectorType | Band | Instrument | Facility | ProfileReference | CalibrationReference | Description | Comments | WavelengthRef | WavelengthMean | WavelengthEff | WavelengthMin | WavelengthMax | WidthEff | WavelengthCen | WavelengthPivot | WavelengthPeak | WavelengthPhot | FWHM | Fsun | PhotCalID | MagSys | ZeroPoint | ZeroPointUnit | Mag0 | ZeroPointType | AsinhSoft | TrasmissionCurve |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AA | AA | AA | AA | AA | AA | AA | AA | AA | AA | AA | erg / (A s cm2) | Jy | ||||||||||||||||||||
object | object | object | object | object | object | object | object | object | object | object | object | object | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | object | object | float64 | object | float64 | object | float64 | object |
ivo://svo/fps | JWST/NIRCam.F070W | Angstrom | em.wl | NIRCam | 1 | NIRCam | JWST | https://jwst-docs.stsci.edu/display/JTI/NIRCam+Filters | NIRCam F070W filter | includes NIRCam optics, DBS, QE and JWST Optical Telescope Element | 7039.1194650654 | 7088.3009369996 | 6988.4272768359 | 6048.1970523246 | 7927.0738659178 | 1212.8399166581 | 7099.1873443748 | 7039.1194650654 | 7691.5 | 7022.060805287 | 1430.8105961315 | 140.01772043307 | JWST/NIRCam.F070W/Vega | Vega | 2768.4045696982 | Jy | 0.0 | Pogson | 0.0 | http://svo2.cab.inta-csic.es//theory/fps/fps.php?ID=JWST/NIRCam.F070W |
Loading filters#
Now we can load and plot our selected filters, in our example case "SLOAN"
.
If you want to know more about filters and which ones are supported by RUBIX please visit the SVO Filter Profile Service. RUBIX supports all standard filters for all instruments of all facilities listed there.
# NBVAL_SKIP
# load all fliter curves for SLOAN
curves = load_filter("SLOAN")
2024-12-04 09:07:22,315 - rubix - INFO - Filters directory not found: /home/annalena/rubix/rubix/telescope/filters/data/SLOAN
2024-12-04 09:07:22,317 - rubix - INFO - Start downloading telescope filter files for SLOAN.
2024-12-04 09:07:22,318 - rubix - INFO - Downloading telescope filter files for SLOAN.
2024-12-04 09:07:22,986 - rubix - INFO - Filter files for SLOAN successfully downloaded!
2024-12-04 09:07:22,987 - rubix - INFO - File SDSS.zprime_filter saved to /home/annalena/rubix/rubix/telescope/filters/data/SLOAN.
# NBVAL_SKIP
curves.filters
[SLOAN/SDSS.uprime_filter,
SLOAN/SDSS.u,
SLOAN/SDSS.g,
SLOAN/SDSS.gprime_filter,
SLOAN/SDSS.r,
SLOAN/SDSS.rprime_filter,
SLOAN/SDSS.i,
SLOAN/SDSS.iprime_filter,
SLOAN/SDSS.z,
SLOAN/SDSS.zprime_filter]
# NBVAL_SKIP
curves.plot()
# NBVAL_SKIP
filter = curves[1]
filter.plot()
Applying filters to mock-IFUs#
After getting the information about different filters and loading the filter curves for "SLOAN"
, we want to apply these filter curves to a mock-IFU cube to get photometric images of the mock-IFU cube.
The first step is to create our mock-IFU cube. We have taken care of this already and run RUBIX with default config
for a tiny mock MUSE cube on an example Ilustris TNG galaxy. For more details see rubix_pipeline_single_function.ipynb
or rubix_pipeline_stepwise.ipynb
. Below we load the dummy datacube using the library h5py
.
#NBVAL_SKIP
import h5py
import numpy as np
with h5py.File('./data/dummy_datacube.h5', 'r') as hf2:
print(hf2.keys())
datacube = np.array(hf2.get('datacube'))
wave = np.array(hf2.get('wave'))
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[10], line 4
2 import h5py
3 import numpy as np
----> 4 with h5py.File('./data/dummy_datacube.h5', 'r') as hf2:
5 print(hf2.keys())
6 datacube = np.array(hf2.get('datacube'))
File ~/miniconda3/envs/rubix/lib/python3.10/site-packages/h5py/_hl/files.py:561, in File.__init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, fs_strategy, fs_persist, fs_threshold, fs_page_size, page_buf_size, min_meta_keep, min_raw_keep, locking, alignment_threshold, alignment_interval, meta_block_size, **kwds)
552 fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0,
553 locking, page_buf_size, min_meta_keep, min_raw_keep,
554 alignment_threshold=alignment_threshold,
555 alignment_interval=alignment_interval,
556 meta_block_size=meta_block_size,
557 **kwds)
558 fcpl = make_fcpl(track_order=track_order, fs_strategy=fs_strategy,
559 fs_persist=fs_persist, fs_threshold=fs_threshold,
560 fs_page_size=fs_page_size)
--> 561 fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
563 if isinstance(libver, tuple):
564 self._libver = libver
File ~/miniconda3/envs/rubix/lib/python3.10/site-packages/h5py/_hl/files.py:235, in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
233 if swmr and swmr_support:
234 flags |= h5f.ACC_SWMR_READ
--> 235 fid = h5f.open(name, flags, fapl=fapl)
236 elif mode == 'r+':
237 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()
File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()
File h5py/h5f.pyx:102, in h5py.h5f.open()
FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = './data/dummy_datacube.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
Our dummy datacube has 25x25 pixels and 3721 spectral bins.
# NBVAL_SKIP
datacube.shape
Now, we have our mock-IFU datacube and we have selected and loaded a filter. The next step is to apply the filter to the datacube, which is done with a convolution. And then we obtain our photometric image of the galaxy. For the filter, choosen in this example, you may wonder, why the image is zerro everywhere. You have to keep in mind that our dummy datacube is created for a MUSE observation and in the default telescopes.yaml
we defined the wavelength to be in the range [4700.15, 9351.4]
and the filter is in the range [3000, 4000]
. So this result should be expected for the choice of this mock-data convolved with the SLOAN/SDSS.u
filter.
# NBVAL_SKIP
from rubix.telescope.filters import convolve_filter_with_spectra
import matplotlib.pyplot as plt
# NBVAL_SKIP
filter = curves[1]
# NBVAL_SKIP
convolved = convolve_filter_with_spectra(filter, datacube, wave)
print(convolved.shape)
# NBVAL_SKIP
import matplotlib.pyplot as plt
plt.imshow(convolved)
plt.colorbar()
If we now look at other filters from SLOAN/SDSS
that match the wavelengthrange of our mock-datacube, we get photometric images of our galaxy.
# NBVAL_SKIP
for filter in curves:
convolved = convolve_filter_with_spectra(filter, datacube, wave)
plt.figure()
plt.imshow(convolved)
plt.colorbar()
plt.title(filter.name)
# NBVAL_SKIP
filters,images =curves.apply_filter_curves(datacube, wave).values()
# NBVAL_SKIP
filters
# NBVAL_SKIP
for i,name in zip(images, filters):
plt.figure()
plt.imshow(i)
plt.colorbar()
plt.title(name)
To create false color images (RGB images), we have to normalize the individual photometric images from three different filters and stack them.
# NBVAL_SKIP
# Create an RGB image
# Normalize the images
import numpy as np
def normalize(image):
image_min = image.min()
image_max = image.max()
return (image - image_min) / (image_max - image_min)
r = images[1]
g = images[2]
b = images[3]
rgb = np.stack([r,g,b], axis=-1)
rgb = normalize(rgb)
plt.imshow(rgb)