astrofrog / sedfitter

Python version of the SED fitter from Robitaille et al., 2007, ApJS 169 328
http://sedfitter.readthedocs.org
BSD 2-Clause "Simplified" License
20 stars 22 forks source link

Convolving new filters: WISE #50

Open silcicho opened 7 years ago

silcicho commented 7 years ago

Hi, I need to use WISE data in the SED fitting and I do not know how to add it. I am not familiar with phyton, I am just trying to learn it to use the sedfitter tool. Up to now I found out that I have to add

f=Filter() f.name=WISE1 f.central_wavelength =3.3526 * u.micron

to add the filter response I just found a txt file http://wise2.ipac.caltech.edu/docs/release/prelim/expsup/figures/RSR-W1.txt

should I use it? if yes, how ? I’d appreciate any help! thanks! Silvina

AwakNess commented 7 years ago

Hi,

I also tried to add the WISE filters as well as Sloan riz for my project, but it did not work correctly. The problem might be that I fed in the response in the wrong way. The documentation said you should take into account the assumptions about whether the response is given in response per photon or energy. The WISE response ( http://wise2.ipac.caltech.edu/docs/release/allsky/expsup/sec4_4h.html ; below Figure 5a ) is given in response per photon, but I had no idea how to take that into account and simply used the original data. My attempt:


model_dir = '.../Models/models_r06' extinction = Extinction.from_file('.../Extinction/kmh94text', columns=[0, 3], wav_unit=u.micron, chi_unit=u.cm**2 / u.g)

WISE1 = Filter() WISE1.name = "WISE1" WISE1.central_wavelength = 3.353 u.micron WISE1_wl, WISE1_rsr = np.loadtxt('.../Response/RSR-W1.txt', usecols=(0, 1), unpack=True) WISE1.nu = 3.0e14 u.Hz * WISE1_wl WISE1.response = WISE1_rsr / np.max(WISE1_rsr) WISE1.normalize()

WISE2 = Filter() WISE2.name = "WISE2" WISE2.central_wavelength = 4.603 u.micron WISE2_wl, WISE2_rsr = np.loadtxt('.../Response/RSR-W2.txt', usecols=(0, 1), unpack=True) WISE2.nu = 3.0e14 u.Hz * WISE2_wl WISE2.response = WISE2_rsr / np.max(WISE2_rsr) WISE2.normalize()

WISE3 = Filter() WISE3.name = "WISE3" WISE3.central_wavelength = 11.561 u.micron WISE3_wl, WISE3_rsr = np.loadtxt('.../Response/RSR-W3.txt', usecols=(0, 1), unpack=True) WISE3.nu = 3.0e14 u.Hz * WISE3_wl WISE3.response = WISE3_rsr / np.max(WISE3_rsr) WISE3.normalize()

WISE4 = Filter() WISE4.name = "WISE4" WISE4.central_wavelength = 22.088 u.micron WISE4_wl, WISE4_rsr = np.loadtxt('.../Response/RSR-W4.txt', usecols=(0, 1), unpack=True) WISE4.nu = 3.0e14 u.Hz * WISE4_wl WISE4.response = WISE4_rsr / np.max(WISE4_rsr) WISE4.normalize()

convolve_model_dir('.../Models/models_r06', [WISE1, WISE2, WISE3, WISE4])


I would be really thankful for any help! :)

Best wishes Awak

sergiovelascom commented 6 years ago

Hi, I am having the same issue, has anyone solved it? Thanks!

pboley commented 6 years ago

Note that the newer Hyperion 2017 models (https://zenodo.org/record/166732) are already convolved with the WISE filters, where they are called WISE1, WISE2, WISE3, WISE4. Note, however, that the IRAS filters are no longer included. So if you want to also use IRAS you will anyway have to convolve the models.

Anto9605 commented 1 year ago

Hi, I know it's been quite a while since this issue was raised and that it was probably already solved, but I wanted to write here how I solved it just so that it could maybe help. Firstly, I downloaded the WISE response curves from the following site: http://svo2.cab.inta-csic.es/theory/fps/ After this, I changed the files' format to .txt and added a header line to each file containing the central wavelength in um (# wav = put central wavel. in um here). To actually define the filters I wrote this piece of code: (example for WISE1)

w1 = Filter() w1.name = 'WISE1'

w1.central_wavelength = float(open('C:/Users/asus/anaconda3/Lib/site-packages/sedfitter/filter/tests/data/WISE_RESPONSE/W1_response.txt', 'r').readline().split('=')[1]) u.micron wave1 = np.loadtxt('C:/Users/asus/anaconda3/Lib/site-packages/sedfitter/filter/tests/data/WISE_RESPONSE/W1_response.txt', usecols=[0], dtype=float) wave1 = np.flip(wave1) u.AA w1.nu = wave1.to(u.Hz, equivalencies = u.spectral()) w1.response = np.loadtxt('C:/Users/asus/anaconda3/Lib/site-packages/sedfitter/filter/tests/data/WISE_RESPONSE/W1_response.txt', usecols=[1], dtype=float) w1.response = np.flip(w1.response) w1.normalize()

The files downloaded from the site have the wavelengths in Angstroms, so that is reflected here. Now for the reasons to use np.flip: looking at the repository "filters" in sedfitter one can find an "examples" repository with some .txt files containing the response of some filters. Looking closely, one can see that the data in the file is in descending order of wavelength! Due to this, once I load the data, I immediatly flip the resulting arrays and, after convolving the r06 models with these filters and performing the fit I can say that it works!

Hope this helps :)