Package ivs :: Package sed :: Module filters
[hide private]
[frames] | no frames]

Module filters

source code

Functions relevant for photometric calibration

Table of contents:

  1. Available response functions
  2. Adding filters on the fly
  3. Adding filters permanently

Section 1. Available response functions

Short list of available systems:

>>> responses = list_response()
>>> systems = [response.split('.')[0] for response in responses]
>>> set_responses = sorted(set([response.split('.')[0] for response in systems]))
>>> for i,resp in enumerate(set_responses):
...    print '%10s (%3d filters)'%(resp,systems.count(resp))
     2MASS (  3 filters)
    ACSHRC ( 17 filters)
    ACSSBC (  6 filters)
    ACSWFC ( 12 filters)
     AKARI ( 13 filters)
       ANS (  6 filters)
      APEX (  1 filters)
     ARGUE (  3 filters)
    BESSEL (  6 filters)
   BESSELL (  6 filters)
     COROT (  2 filters)
   COUSINS (  3 filters)
       DDO (  7 filters)
     DENIS (  3 filters)
     DIRBE ( 10 filters)
   EEV4280 (  1 filters)
     ESOIR ( 10 filters)
      GAIA (  4 filters)
     GALEX (  2 filters)
    GENEVA (  7 filters)
 HIPPARCOS (  1 filters)
     IPHAS (  3 filters)
      IRAC (  4 filters)
      IRAS (  4 filters)
    ISOCAM ( 21 filters)
   JOHNSON ( 25 filters)
    KEPLER ( 43 filters)
      KRON (  2 filters)
   LANDOLT (  6 filters)
      MIPS (  3 filters)
      MOST (  1 filters)
       MSX (  6 filters)
    NARROW (  1 filters)
    NICMOS (  6 filters)
      OAO2 ( 12 filters)
      PACS (  3 filters)
      SAAO ( 13 filters)
     SCUBA (  6 filters)
      SDSS ( 10 filters)
     SLOAN (  2 filters)
     SPIRE (  3 filters)
  STEBBINS (  6 filters)
   STISCCD (  2 filters)
   STISFUV (  4 filters)
   STISNUV (  7 filters)
 STROMGREN (  6 filters)
       TD1 (  4 filters)
     TYCHO (  2 filters)
    TYCHO2 (  2 filters)
  ULTRACAM (  5 filters)
    USNOB1 (  2 filters)
      UVEX (  5 filters)
   VILNIUS (  7 filters)
     VISIR ( 13 filters)
  WALRAVEN (  5 filters)
     WFCAM (  5 filters)
     WFPC2 ( 21 filters)
      WISE (  4 filters)
      WOOD ( 12 filters)

Plots of all passbands of all systems:

]include figure]]ivs_sed_filters_2MASS.png]

]include figure]]ivs_sed_filters_ACSHRC.png]

]include figure]]ivs_sed_filters_ACSSBC.png]

]include figure]]ivs_sed_filters_ACSWFC.png]

]include figure]]ivs_sed_filters_AKARI.png]

]include figure]]ivs_sed_filters_ANS.png]

]include figure]]ivs_sed_filters_APEX.png]

]include figure]]ivs_sed_filters_ARGUE.png]

]include figure]]ivs_sed_filters_BESSEL.png]

]include figure]]ivs_sed_filters_BESSELL.png]

]include figure]]ivs_sed_filters_COROT.png]

]include figure]]ivs_sed_filters_COUSINS.png]

]include figure]]ivs_sed_filters_DDO.png]

]include figure]]ivs_sed_filters_DENIS.png]

]include figure]]ivs_sed_filters_DIRBE.png]

]include figure]]ivs_sed_filters_ESOIR.png]

]include figure]]ivs_sed_filters_EEV4280.png]

]include figure]]ivs_sed_filters_GAIA.png]

]include figure]]ivs_sed_filters_GALEX.png]

]include figure]]ivs_sed_filters_GENEVA.png]

]include figure]]ivs_sed_filters_HIPPARCOS.png]

]include figure]]ivs_sed_filters_IPHAS.png]

]include figure]]ivs_sed_filters_IRAC.png]

]include figure]]ivs_sed_filters_IRAS.png]

]include figure]]ivs_sed_filters_ISOCAM.png]

]include figure]]ivs_sed_filters_JOHNSON.png]

]include figure]]ivs_sed_filters_KEPLER.png]

]include figure]]ivs_sed_filters_KRON.png]

]include figure]]ivs_sed_filters_LANDOLT.png]

]include figure]]ivs_sed_filters_MIPS.png]

]include figure]]ivs_sed_filters_MOST.png]

]include figure]]ivs_sed_filters_MSX.png]

]include figure]]ivs_sed_filters_NARROW.png]

]include figure]]ivs_sed_filters_NICMOS.png]

]include figure]]ivs_sed_filters_OAO2.png]

]include figure]]ivs_sed_filters_PACS.png]

]include figure]]ivs_sed_filters_SAAO.png]

]include figure]]ivs_sed_filters_SCUBA.png]

]include figure]]ivs_sed_filters_SDSS.png]

]include figure]]ivs_sed_filters_SLOAN.png]

]include figure]]ivs_sed_filters_SPIRE.png]

]include figure]]ivs_sed_filters_STEBBINS.png]

]include figure]]ivs_sed_filters_STISCCD.png]

]include figure]]ivs_sed_filters_STISFUV.png]

]include figure]]ivs_sed_filters_STISNUV.png]

]include figure]]ivs_sed_filters_STROMGREN.png]

]include figure]]ivs_sed_filters_TD1.png]

]include figure]]ivs_sed_filters_TYCHO.png]

]include figure]]ivs_sed_filters_TYCHO2.png]

]include figure]]ivs_sed_filters_ULTRACAM.png]

]include figure]]ivs_sed_filters_USNOB1.png]

]include figure]]ivs_sed_filters_UVEX.png]

]include figure]]ivs_sed_filters_VILNIUS.png]

]include figure]]ivs_sed_filters_VISIR.png]

]include figure]]ivs_sed_filters_WALRAVEN.png]

]include figure]]ivs_sed_filters_WFPC2.png]

]include figure]]ivs_sed_filters_WISE.png]

]include figure]]ivs_sed_filters_WOOD.png]

Section 2: Adding filters on the fly

Section 2.1: Defining a new filter

You can add custom filters on the fly using add_custom_filter. In this example we add a weird-looking filter and check the definition of Flambda and Fnu and its relation to the effective wavelength of a passband:

Prerequisites: some modules that come in handy:

>>> from ivs.sigproc import funclib
>>> from ivs.sed import model
>>> from ivs.units import conversions

First, we'll define a double peakd Gaussian profile on the wavelength grid of the WISE.W3 response curve:

>>> wave = get_response('WISE.W3')[0]
>>> trans = funclib.evaluate('gauss',wave,[1.5,76000.,10000.,0.])
>>> trans+= funclib.evaluate('gauss',wave,[1.0,160000.,25000.,0.])

This is what it looks like:

>>> p = pl.figure()
>>> p = pl.plot(wave/1e4,trans,'k-')
>>> p = pl.xlabel("Wavelength [micron]")
>>> p = pl.ylabel("Transmission [arbitrary units]")

]include figure]]ivs_sed_filters_weird_trans.png]

We can add this filter to the list of predefined filters in the following way (for the doctests to work, we have to do a little work around and call filters via that module, this is not needed in a normal workflow):

>>> model.filters.add_custom_filter(wave,trans,photband='LAMBDA.CCD',type='CCD')
>>> model.filters.add_custom_filter(wave,trans,photband='LAMBDA.BOL',type='BOL')

Note that we add the filter twice, once assuming that it is mounted on a bolometer, and once on a CCD device. We'll call the filter LAMBDA.CCD and LAMBDA.BOL. From now on, they are available within functions as get_info and get_response. For example, what is the effective (actually pivot) wavelength?

>>> effwave_ccd = model.filters.eff_wave('LAMBDA.CCD')
>>> effwave_bol = model.filters.eff_wave('LAMBDA.BOL')
>>> print(effwave_ccd,effwave_bol)
(119263.54911400242, 102544.27931275869)

Let's do some synthetic photometry now. Suppose we have a black body atmosphere:

>>> bb = model.blackbody(wave,5777.)

We now calculate the synthetic flux, assuming the CCD and BOL device. We compute the synthetic flux both in Flambda and Fnu:

>>> flam_ccd,flam_bol = model.synthetic_flux(wave,bb,['LAMBDA.CCD','LAMBDA.BOL'])
>>> fnu_ccd,fnu_bol = model.synthetic_flux(wave,bb,['LAMBDA.CCD','LAMBDA.BOL'],units=['FNU','FNU'])

You can see that the fluxes can be quite different when you assume photon or energy counting devices!

>>> flam_ccd,flam_bol
(897.68536911320564, 1495.248213834755)
>>> fnu_ccd,fnu_bol
(4.2591095543803019e-06, 5.2446332430111098e-06)

Can we now readily convert Flambda to Fnu with assuming the pivot wavelength?

>>> fnu_fromflam_ccd = conversions.convert('erg/s/cm2/AA','erg/s/cm2/Hz',flam_ccd,wave=(effwave_ccd,'A'))
>>> fnu_fromflam_bol = conversions.convert('erg/s/cm2/AA','erg/s/cm2/Hz',flam_bol,wave=(effwave_bol,'A'))

Which is equivalent with:

>>> fnu_fromflam_ccd = conversions.convert('erg/s/cm2/AA','erg/s/cm2/Hz',flam_ccd,photband='LAMBDA.CCD')
>>> fnu_fromflam_bol = conversions.convert('erg/s/cm2/AA','erg/s/cm2/Hz',flam_bol,photband='LAMBDA.BOL')

Apparently, with the definition of pivot wavelength, you can safely convert from Fnu to Flambda:

>>> print(fnu_ccd,fnu_fromflam_ccd)
(4.2591095543803019e-06, 4.259110447428463e-06)
>>> print(fnu_bol,fnu_fromflam_bol)
(5.2446332430111098e-06, 5.2446373530017525e-06)

The slight difference you see is numerical.

Section 2.2: Temporarily modifying an existing filter

Under usual conditions, you are prohibited from overwriting an existing predefined response curve. That is, if you try to add_custom_filter with a photband that already exists as a file, a ValueError will be raised (this is not the case for a custom defined filter, which you can overwrite without problems!). If, for testing purposes, you want to use another definition of a predefined response curve, you need to set force=True in add_custom_filter, and then call

>>> set_prefer_file(False)

To reset and use the original definitions again, do

>>> set_prefer_file(True)

Section 3.: Adding filters permanently

Add a new response curve file to the ivs/sed/filters directory. The file should contain two columns, the first column is the wavelength in angstrom, the second column is the transmission curve. The units of the later are not important.

Then, call update_info. The contents of zeropoints.dat will automatically be updated. Make sure to add any additional information on the new filters manually in that file (e.g. is t a CCD or bolometer, what are the zeropoint magnitudes etc).

Functions [hide private]
    response curves
(array, array)
get_response(photband)
Retrieve the response curve of a photometric system 'SYSTEM.FILTER'
source code
ndarray
create_custom_filter(wave, peaks, range=(3000,4000), sigma=3.)
Create a custom filter as a sum of Gaussians.
source code
 
add_custom_filter(wave, response, **kwargs)
Add a custom filter to the set of predefined filters.
source code
 
set_prefer_file(prefer_file=True)
Set whether to prefer files or custom filters when both exist.
source code
 
add_spectrophotometric_filters(R=200., lambda0=950., lambdan=3350.) source code
list of str
list_response(name='*', wave_range=(-np.inf,+np.inf))
List available response curves.
source code
bool
is_color(photband)
Return true if the photometric passband is actually a color.
source code
tuple
get_color_photband(photband)
Retrieve the photometric bands from color
source code
tuple,callable
make_color(photband)
Make a color from a color name and fluxes.
source code
float or numpy array
eff_wave(photband, model=None, det_type=None)
Return the effective wavelength of a photometric passband.
source code
record array
get_info(photbands=None)
Return a record array containing all filter information.
source code
 
update_info(zp=None)
Update information in zeropoint file, e.g.
source code
Variables [hide private]
  basedir = os.path.dirname(__file__)
  logger = logging.getLogger("SED.FILT")
  custom_filters = {'_prefer_file': True}
Function Details [hide private]

get_response(photband)

source code 

Retrieve the response curve of a photometric system 'SYSTEM.FILTER'

OPEN.BOL represents a bolometric open filter.

Example usage:

>>> p = pl.figure()
>>> for band in ['J','H','KS']:
...    p = pl.plot(*get_response('2MASS.%s'%(band)))

If you defined a custom filter with the same name as an existing one and you want to use that one in the future, set prefer_file=False in the custom_filters module dictionary.

Parameters:
  • photband (str ('SYSTEM.FILTER')) - photometric passband
Returns: (array, array)
(wavelength [A], response)
Decorators:
  • @memoized

create_custom_filter(wave, peaks, range=(3000,4000), sigma=3.)

source code 

Create a custom filter as a sum of Gaussians.

Parameters:
  • wave (ndarray) - wavelength to evaluate the profile on
  • peaks (ndarray of length N, with N peaks) - heights of the peaks
  • range (tuple) - wavelength range of the peaks
  • sigma (float) - width of the peaks in units of (range/N)
Returns: ndarray
filter profile

add_custom_filter(wave, response, **kwargs)

source code 

Add a custom filter to the set of predefined filters.

Extra keywords are:
    'eff_wave', 'type',
    'vegamag', 'vegamag_lit',
    'ABmag', 'ABmag_lit',
    'STmag', 'STmag_lit',
    'Flam0', 'Flam0_units', 'Flam0_lit',
    'Fnu0', 'Fnu0_units', 'Fnu0_lit',
    'source'
    
default C{type} is 'CCD'.
default C{photband} is 'CUSTOM.FILTER'

@param wave: wavelength (angstrom)
@type wave: ndarray
@param response: response
@type response: ndarray
@param photband: photometric passband
@type photband: str ('SYSTEM.FILTER')

set_prefer_file(prefer_file=True)

source code 

Set whether to prefer files or custom filters when both exist.

Parameters:
  • prefer_file (bool) - boolean

list_response(name='*', wave_range=(-np.inf,+np.inf))

source code 

List available response curves.

Specify a glob string name and/or a wavelength range to make a selection of all available curves. If nothing is supplied, all curves will be returned.

Parameters:
  • name (str) - list all curves containing this string
  • wave_range ((float, float)) - list all curves within this wavelength range (A)
Returns: list of str
list of curve files

is_color(photband)

source code 

Return true if the photometric passband is actually a color.

Parameters:
  • photband (string) - name of the photometric passband
Returns: bool
True or False

get_color_photband(photband)

source code 

Retrieve the photometric bands from color

Parameters:
  • photband (string) - name of the photometric passband
Returns: tuple
tuple of strings

make_color(photband)

source code 

Make a color from a color name and fluxes.

You get two things: a list of photbands that are need to construct the color, and a function which you need to pass fluxes to compute the color.

>>> bands, func = make_color('JOHNSON.B-V')
>>> print(bands)
('JOHNSON.B', 'JOHNSON.V')
>>> print(func(2,3.))
0.666666666667
Returns: tuple,callable
photbands, function to construct color

eff_wave(photband, model=None, det_type=None)

source code 

Return the effective wavelength of a photometric passband.

The effective wavelength is defined as the average wavelength weighed with the response curve.

>>> eff_wave('2MASS.J')
12393.093155655277

If you give model fluxes as an extra argument, the wavelengths will take these into account to calculate the `true' effective wavelength (e.g., Van Der Bliek, 1996), eq 2.

Parameters:
  • photband (str ('SYSTEM.FILTER') or array/list of str) - photometric passband
  • model (tuple of 1D arrays (wave,flux)) - model wavelength and fluxes
Returns: float or numpy array
effective wavelength [A]

get_info(photbands=None)

source code 

Return a record array containing all filter information.

The record arrays contains following columns:

  • photband
  • eff_wave
  • type
  • vegamag, vegamag_lit
  • ABmag, ABmag_lit
  • STmag, STmag_lit
  • Flam0, Flam0_units, Flam0_lit
  • Fnu0, Fnu0_units, Fnu0_lit,
  • source
Parameters:
  • photbands (iterable container (list, tuple, 1Darray)) - list of photbands to get the information from. The input order is equal to the output order. If None, all filters are returned.
Returns: record array
record array containing all information on the requested photbands.
Decorators:
  • @memoized

update_info(zp=None)

source code 

Update information in zeropoint file, e.g. after calibration.

Call first ivs.sed.model.calibrate without arguments, and pass the output to this function.

Parameters:
  • zp (recarray) - updated contents from zeropoints.dat