{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Deriving the A_lambda/E(B-V) coefficients needed for dereddening
\n", "This notebook shows a quick demo of how to calculate the A_lambda/E(B-V) coefficients needed to remove Galactic dust from the DC2 catalogs.
\n", "\n", "In DC2, the CCM model (https://ui.adsabs.harvard.edu/abs/1989ApJ...345..245C/abstract) was assumed when calculating the dust model, we will use the lsst.sims.photUtils package to compute the effective wavelengths for the filters, and then set up the CCM model and calculate Alambda/E(B-V) for each of the LSST filters.
" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "import GCRCatalogs\n", "import pandas as pd\n", "import numpy as np\n", "import scipy.interpolate\n", "from lsst.sims import photUtils\n", "from lsst.sims.photUtils import BandpassSet" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This function grabs the \"LSST_THROUGHPUTS_BASELINE\" filters as currently specified in the photUtils package, then computes both lambda_eff and A_lambda/E(B-V) for each of the six LSST filters:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def compute_alambda_over_ebv(filterset='ugrizy',basepath=None):\n", " \"\"\"\n", " compute the effective wavelengths and alambda/E(B-V) values for a set of filters\n", " We will grab the flat SED from the SIMS library to calculate the CCM dust model \n", " that was assumed for DC2, and then grab the baseline ugrizy filters and calculate \n", " their effective wavelengths, and evaluate the CCM alam_over_ebv value at those\n", " wavelengths\n", " inputs: filterset:\n", " vector of filters (limited to ugrizy present for the baseline LSST filterset)\n", " returns:\n", " lam_eff_list: \n", " np 1d array of filter effective wavelengths for the filters\n", " alam_over_ebv_list:\n", " np 1d array of alam_over_ebv values for the filters\n", " \"\"\"\n", " lam_eff_list = []\n", " alam_over_ebv_list = []\n", " sed_file = os.path.join(os.environ['SIMS_SED_LIBRARY_DIR'],'flatSED','sed_flat.txt.gz')\n", " sed = photUtils.Sed()\n", " sed.readSED_flambda(sed_file)\n", " ax,bx = sed.setupCCM_ab()\n", " ccm_model = 3.1*ax+bx\n", " wl = sed.wavelen\n", " ccm_spline = scipy.interpolate.interp1d(wl,ccm_model,bounds_error=True)\n", " alam_over_ebv = 3.1*ax+bx\n", " for filt in filterset:\n", " if basepath is None:\n", " bp_file = os.path.join(os.environ['LSST_THROUGHPUTS_BASELINE'],'',f'total_{filt}.dat')\n", " else:\n", " bp_file = os.path.join(basepath,f'total_{filt}.dat')\n", " bandpass = photUtils.Bandpass()\n", " bandpass.readThroughput(bp_file)\n", " _,leff = bandpass.calcEffWavelen()\n", " lam_eff_list.append(leff)\n", " alam = ccm_spline(leff)\n", " alam_over_ebv_list.append(alam)\n", " return np.array(lam_eff_list),np.array(alam_over_ebv_list)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's do a quick check that we are getting the results that we expect. For DC2 we should get the following for the effective wavelengths and A_lam/E(B-V) values:
\n", "u 367.07 nm A_lambda/EBV = 4.812
\n", "g 482.69 nm A_lambda/EBV = 3.643
\n", "r 622.32 nm A_lambda/EBV = 2.699
\n", "i 754.60 nm A_lambda/EBV = 2.063
\n", "z 869.01 nm A_lambda/EBV = 1.578
\n", "y 971.03 nm A_lambda/EBV = 1.313
\n", "If these values do not match those in the next cell, check that the Baseline filter definitions have not changed!" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "filter u lam_eff: 368.48nm alam/E(B-V): 4.802\n", "filter g lam_eff: 480.20nm alam/E(B-V): 3.668\n", "filter r lam_eff: 623.12nm alam/E(B-V): 2.695\n", "filter i lam_eff: 754.17nm alam/E(B-V): 2.065\n", "filter z lam_eff: 869.05nm alam/E(B-V): 1.578\n", "filter y lam_eff: 973.64nm alam/E(B-V): 1.307\n" ] } ], "source": [ "filterlist = ['u','g','r','i','z','y']\n", "leff_list,alamebv_list = compute_alambda_over_ebv(filterlist)\n", "for filt,leff, alamebv in zip(filterlist,leff_list,alamebv_list):\n", " print(f\"filter {filt} lam_eff: {leff:.2f}nm alam/E(B-V): {alamebv:.3f}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These numbers do *not* match, there are very slight differences, as the filters were updated in mid 2019. The filter curves used for DC2 are released as v1.4 cosmoDC2:\n", "https://github.com/lsst/throughputs/releases/tag/1.4. For convenience, we have saved a copy of these filters in the data/dc2_throughputs subdirectory. So, we can calculate the lambda_eff and A_lambda/E(B-V) for these filters:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "filter u lam_eff: 367.07nm alam/E(B-V): 4.812\n", "filter g lam_eff: 482.69nm alam/E(B-V): 3.643\n", "filter r lam_eff: 622.32nm alam/E(B-V): 2.699\n", "filter i lam_eff: 754.60nm alam/E(B-V): 2.063\n", "filter z lam_eff: 869.09nm alam/E(B-V): 1.578\n", "filter y lam_eff: 971.03nm alam/E(B-V): 1.313\n" ] } ], "source": [ "leff_list,alamebv_list = compute_alambda_over_ebv(filterlist,basepath=\"data/dc2_throughputs\")\n", "for filt,leff, alamebv in zip(filterlist,leff_list,alamebv_list):\n", " print(f\"filter {filt} lam_eff: {leff:.2f}nm alam/E(B-V): {alamebv:.3f}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Yes, these numbers do agree. So, if need A/E(B-V) coefficients for a different filter set, you can use this procedure to derive them." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "desc-stack-weekly", "language": "python", "name": "desc-stack-weekly" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }