How to use the extinction.calzetti00 function in extinction

To help you get started, we’ve selected a few extinction examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pynbody / pynbody / pynbody / plot / stars.py View on Github external
wavelength_avail = {'u':3571,'b':4378,'v':5466,'r':6695,'i':8565,'j':12101,
				   'h':16300,'k':21900,'U':3571,'B':4378,'V':5466,'R':6695,'I':8565,'J':12101,
				   'H':16300,'K':21900} #in Angstrom
		# effective wavelength taken from http://svo2.cab.inta-csic.es/svo/theory/fps3/index.php?mode=browse&gname=Generic&gname2=Johnson
		# and from https://en.wikipedia.org/wiki/Photometric_system for h, k
		
		lr,lg,lb = wavelength_avail[r_band],wavelength_avail[g_band],wavelength_avail[b_band] #in Angstrom
		wave = np.array([lb, lg, lr])

		ext_r = np.empty_like(r)
		ext_g = np.empty_like(g)
		ext_b = np.empty_like(b)
	
		for i in range(len(a_v)):
			for j in range(len(a_v[0])):
				ext = extinction.calzetti00(wave.astype(np.float), a_v[i][j].astype(np.float), 3.1, unit='aa', out=None)
				ext_r[i][j] = ext[2]
				ext_g[i][j] = ext[1]
				ext_b[i][j] = ext[0]

		r = r+ext_r
		g = g+ext_g
		b = b+ext_b

	#r,g,b = nw_scale_rgb(r,g,b)
	#r,g,b = nw_arcsinh_fit(r,g,b)

	if mag_range is None:
		rgbim, mag_max = combine(r, g, b, dynamic_range*2.5)
		mag_min = mag_max + 2.5*dynamic_range
	else:
		mag_max, mag_min = mag_range
github iancze / Starfish / Starfish / transforms.py View on Github external
:param law: the extinction law, one of {'ccm89', 'odonnell94', 'calzetti00',
        'fitzpatrick99', 'fm07'}
    :type law: str
    :param Av: The scaling total extinction value.
    :type Av: float
    :param Rv: The ratio of total to selective extinction. If using law 'fm07' you do
        not need to provide this (fixed 3.1).
    :type Rv: float

    :raises ValueError: If not using an expected law or ill-specifying Av or Rv
    """
    LAWS = {
        'ccm89': extinction.ccm89,
        'odonnell94': extinction.odonnell94,
        'calzetti00': extinction.calzetti00,
        'fitzpatrick99': extinction.fitzpatrick99,
        'fm07': extinction.fm07,
    }
    def __init__(self, law, Av, Rv=None):
        if not law in self.LAWS:
            raise ValueError('Need to specify a law from {}'.format(self.LAWS.keys()))
        if Av < 0:
            raise ValueError('Cannot have negative extinction')
        if Rv is None or Rv < 0 and law is not 'fm07':
            raise ValueError('Must provide positive r_v for law "{}"'.format(law))
        elif law is 'fm07':
            Rv = None
        self.law = self.LAWS[law]
        self.Av = Av
        self.Rv = Rv