desihub / speclite

Lightweight utilities for working with spectroscopic data
14 stars 19 forks source link

add sdss2010 filters which include the atmosphere #76

Closed moustakas closed 2 years ago

moustakas commented 2 years ago

This PR addresses #39 and #66 by adding SDSS filters which include the atmosphere at an airmass of 1.3. The group name nor the names of the individual filters are great, but let me know if you'd like something different @dkirkby.

This PR is a blocking factor for some of my other DESI work, so it'd be great if we could merge this within a day or two.

sdss2010atm filters

Screen Shot 2022-07-12 at 3 16 01 PM

sdss2010 filters

Screen Shot 2022-07-12 at 3 18 29 PM

For reference, this is the bit of code I wrote to parse the Doi et al. Table 4 (after mildly editing the file to only include the column names as a simple header):

#!/usr/bin/env python

import numpy as np
from astropy.table import Table

tt = Table.read('aj330387t4_ascii.txt', format='ascii.commented_header')

for band in ['u', 'g', 'r', 'i', 'z']:
    filt = tt[tt[band] != '...']['lambda', band, 'T13']
    filt['resp'] = filt[band].astype('f8') * filt['T13']
    I = np.where(filt['resp'] > 0)[0]
    with open('sdss2010atm-{}.ecsv'.format(band), 'w') as F:
        F.write('# %ECSV 1.0\n')
        F.write('# ---\n')
        F.write('# datatype:\n')
        F.write('# - {name: wavelength, unit: Angstrom, datatype: float64}\n')
        F.write('# - {name: response, datatype: float64}\n')
        F.write('# meta: !!omap\n')
        F.write("# - {url: 'http://dx.doi.org/10.1088/0004-6256/139/4/1628'}\n")
        F.write('# - {{band_name: {}}}\n'.format(band))
        F.write('# - {airmass: 1.3}\n')
        F.write("# - {{description: 'SDSS 2.5m telescope reference {}-band response function\n".format(band))
        F.write('#     (through airmass 1.3) from Table 4 of:\n')
        F.write('#\n')
        F.write('#     Values are the product of the {} and atmospheric transmission columns from Table\n'.format(band))
        F.write('#     4 of:\n')
        F.write('#\n')
        F.write('#     Doi et al, "Photometric Response Functions of the SDSS Imager",\n')
        F.write('#\n')
        F.write('#     The Astronomical Journal, Volume 139, Issue 4, pp. 1628-1648 (2010).\n')
        F.write('#\n')
        F.write("#     All response values outside the wavelength range covered here are zero.'}\n")
        F.write('# - {group_name: sdss2010atm}\n')
        F.write('wavelength response\n')
        F.write('{} 0.0\n'.format(filt['lambda'][I[0]]-1))
        for lam, resp in zip(filt['lambda'][I], filt['resp'][I]):
            F.write('{} {:.6g}\n'.format(lam, resp))
        F.write('{} 0.0\n'.format(filt['lambda'][I[-1]]+1))
sbailey commented 2 years ago

@dkirkby @moustakas as a heads up, I've added this to the DR1/Iron project to keep it on our radar for including in the code release for the Iron production.

dkirkby commented 2 years ago

This looks good, thanks! Can you also update docs/filters.rst to describe the changes?

Regarding the naming, any reason not to use sdss2010 and sdss2010noatm to be parallel with the existing decamDR1(noatm) names?

moustakas commented 2 years ago

Regarding the naming, any reason not to use sdss2010 and sdss2010noatm to be parallel with the existing decamDR1(noatm) names?

Thanks for the suggestion. My concern was the backwards-incompatibility: That if someone has been using the sdss2010 filters and applying the atmosphere themselves and we now make those the default, that it would cause issues. But if you're happy with making these the default (which is my preference) then I can make this change and also update the documentation.

dkirkby commented 2 years ago

I think this is the best solution overall since the docs always claimed sdss2010 included an atmosphere (so that hypothetical user presumably already knew they were wrong). Perhaps include a note in the doc page that this was wrong earlier?

moustakas commented 2 years ago

@dkirkby I think this is ready for final review and merging.