Fiddling with Fluxing [v2]


In [1]:
%matplotlib notebook

In [64]:
# imports
import numpy as np
from matplotlib import pyplot as plt

from configobj import ConfigObj

from pypeit.par import util as putil
from pypeit.par import pypeitpar
from pypeit.spectrographs.util import load_spectrograph

In [3]:
path = '/home/xavier/scratch/FRB181112/FORS2/vlt_fors2_E/Science'

Load parameter file


In [65]:
spectro = load_spectrograph('shane_kast_blue')

In [68]:
spectrograph_def_par = spectro.default_pypeit_par()

In [69]:
lines = putil._read_pypeit_file_lines(path+'/fluxing.config')

In [70]:
cobj = ConfigObj(list(lines))
cobj


Out[70]:
ConfigObj({'fluxcalib': {'balm_mask_wid': '12.'}})

In [71]:
par = pypeitpar.PypeItPar.from_cfg_lines(cfg_lines=spectrograph_def_par.to_config(), merge_with=list(lines))

In [72]:
par['fluxcalib']


Out[72]:
Parameter      Value  Default  Type   Callable
----------------------------------------------
balm_mask_wid  12.0   5.0      float  False   
sensfunc       None   None     str    False   

In [52]:
cfg['fluxcalib']


Out[52]:
{'balm_mask_wid': '12.', 'sensfunc': 'None'}

In [55]:
cfg['rdx']['spectrograph'] = 'shane_kast_blue'

In [56]:
tmp_par = pypeitpar.PypeItPar.from_dict(cfg)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-56-8bbf3c69be9d> in <module>()
----> 1 tmp_par = pypeitpar.PypeItPar.from_dict(cfg)

~/local/Python/PypeIt/pypeit/par/pypeitpar.py in from_dict(cls, cfg)
   2338 
   2339         pk = 'rdx'
-> 2340         kwargs[pk] = ReducePar.from_dict(cfg[pk]) if pk in k else None
   2341 
   2342         pk = 'calibrations'

~/local/Python/PypeIt/pypeit/par/pypeitpar.py in from_dict(cls, cfg)
    926         for pk in parkeys:
    927             kwargs[pk] = cfg[pk] if pk in k else None
--> 928         return cls(**kwargs)
    929 
    930     @staticmethod

~/local/Python/PypeIt/pypeit/par/pypeitpar.py in __init__(self, spectrograph, detnum, sortroot, calwin, scidir, qadir, redux_path, ignore_bad_headers)
    913                                         options=list(options.values()),
    914                                         dtypes=list(dtypes.values()),
--> 915                                         descr=list(descr.values()))
    916         self.validate()
    917 

~/local/Python/PypeIt/pypeit/par/parset.py in __init__(self, pars, values, defaults, options, dtypes, can_call, descr, cfg_section, cfg_comment)
    193                 self.__setitem__(p, d)
    194                 continue
--> 195             self.__setitem__(p, v)
    196 
    197         # Save the configuration file section details

~/local/Python/PypeIt/pypeit/par/parset.py in __setitem__(self, key, value)
    245                 and not any([ isinstance(value, d) for d in self.dtype[key]]):
    246             raise TypeError('Input value for {0} has incorrect type: {1}.'.format(key, value) +
--> 247                             '\nValid types are: {0}'.format(self.dtype[key]))
    248 
    249         if self.can_call[key] and not callable(value):

TypeError: Input value for detnum has incorrect type: None.
Valid types are: [<class 'int'>, <class 'list'>]

Checking photometry


In [69]:
g = 18.45 # SDSS

In [72]:
f_nu_g = 10.**(-0.4*(g+48.6)) * u.erg/u.s/u.Hz/u.cm**2
f_nu_g


Out[72]:
$1.5135612 \times 10^{-27} \; \mathrm{\frac{erg}{Hz\,s\,cm^{2}}}$

In [76]:
f_lam_g = f_nu_g * const.c.cgs / (4000*u.AA)**2
f_lam_g.to('erg/s/cm**2/AA')


WARNING: UnitsWarning: 'erg/s/cm**2/AA' contains multiple slashes, which is discouraged by the FITS standard [astropy.units.format.generic]
Out[76]:
$2.835964 \times 10^{-16} \; \mathrm{\frac{erg}{\mathring{A}\,s\,cm^{2}}}$

In [77]:
200 * 1e-17


Out[77]:
2e-15

Tests and Misc


In [54]:
15 * 40.


Out[54]:
600.0

In [ ]: