astropy / specreduce

Tools for the reduction of spectroscopic observations from Optical and NIR instruments
https://specreduce.readthedocs.io
58 stars 38 forks source link

flux calibration of the spectra #10

Closed crawfordsm closed 4 years ago

crawfordsm commented 6 years ago
kakirastern commented 5 years ago

Hi @crawfordsm! I really would like to contribute to this issue by a pull request, but will need additional help regarding some reliable references, some pointers, and perhaps some directions. I am in need of this functionality for my thesis work, so I was thinking I might as well make myself useful. Please let me know if you have any tips.

kakirastern commented 5 years ago

I was using IRAF noao package's standard-sensfunc-calibrate task-combo before, but something didn't seem right with the calibrated 1D spectra... An astropy-based solution would be beneficial for double checking. Anyway, reckon it is time for me to move away from IRAF, the specreduce package seems to be what I will need.

kakirastern commented 5 years ago

Actually, I just figured out how to do flux calibration on my own using several different packages, and think maybe I can port those functionalities to this repo later if no one has started working on this yet. I have used the Gemini version of IRAF to determine the bandpass throughput/response function, then PyNeb for calculating the extinction curve needed. And finally I have used synphot to convert the units into flux properly given a known telescope collecting area. And I was able to check my work with some published data from an independent research group. Hopefully I (or someone else) will be able to open some PR soon.

kakirastern commented 5 years ago

Hi @crawfordsm How do you feel about porting the noao.onedspec.standard, noao.onedspec.sensfunc, and noao.onedspec.calibrate as is from the Gemini IRAF/PyRAF directly to here, with some minor changes?

kakirastern commented 5 years ago

As per conversation with @crawfordsm on Slack, am starting work on this.

kakirastern commented 5 years ago

Work on the flux calibration utility is currently being carried out here: https://github.com/kakirastern/specreduce/tree/add-fluxcal

jehturner commented 4 years ago

Gemini now has a draft pipeline "primitive" called calculateSensitivity in https://github.com/GeminiDRSoftware/DRAGONS/blob/spectroscopy/geminidr/core/primitives_spect.py. It looks pretty straightforward with the tools available, though I see this is currently using flux tables from IRAF. It would be good to get them from specreduce...

kakirastern commented 4 years ago

I will see if I can adapt this Gemini draft calculateSensitivity to this package (and call it something like sensfunc as a legacy/convention from IRAF) and get the flux tables from specreduce instead... was unable to work much for a while due to job change, but things have improved of late.

kakirastern commented 4 years ago

@jehturner Do you think it is a good idea to port Gemini's work with some tweaking to here while obtaining the flux tables from IRAF? I am thinking my original intention of porting the flux calibration functionalities directly from IRAF might have been a bit naive in hindsight. In other words, how may I carry out the suggestion you have made in the most effective manner?

kakirastern commented 4 years ago

Found this recently: https://pydis.readthedocs.io/stepbystep.html#flux-calibration But that seems to be designed specifically for DIS data only.

Will investigate further to see if it works for or generalized to other datasets. But it does say in the docs that "So far PyDIS has also been successfully used (with hacking/modification) on data from MMT and DCT."

kakirastern commented 4 years ago

Updated pipeline "primitive" URL: https://github.com/GeminiDRSoftware/DRAGONS/blob/master/geminidr/core/primitives_spect.py in reference to https://github.com/astropy/specreduce/issues/10#issuecomment-565670254

kakirastern commented 4 years ago

The calculateSensitivity function in L140 of primitives_spect.py appears to be tailored for data acquired with GEMINI... Will need to generalize it for the case where the data can be acquired from any telescope using standard and basic (or minimum) set of FITS header keywords for calculating the sensitivity function instead.

Also, may need to use some Astropy alternatives for the following as contained therein:

from geminidr import PrimitivesBASE
from geminidr.gemini.lookups import DQ_definitions as DQ
from gempy.gemini import gemini_tools as gt
from gempy.library import astromodels, matching, tracing
from gempy.library import transform
from gempy.library.astrotools import array_from_list
from gempy.library.nddops import NDStacker
from gempy.library.spectral import Spek1D
from recipe_system.utils.decorators import parameter_override
from . import parameters_spect