def sanity_ExampleTransmissionCurves(self): """ Checking example for 'TransmissionCurves' """ #from __future__ import print_function from PyAstronomy import pyasl import numpy as np import matplotlib.pylab as plt # Import six for Python 2/3 compatibility import six # Get transmission curve object tcs = pyasl.TransmissionCurves() # Add passbands from Spitzer IRAC tcs.addSpitzerIRACPassbands() print("Available bands: ", tcs.availableBands()) # Wavelength axis wvl = np.linspace(3000, 10000, 10000) # Plot transmission curves for Bessel b, v, and r bands for (b, c) in six.iteritems({"b":"b", "v":"k", "r":"r"}): tc = tcs.getTransCurve("Bessel " + b) trans = tc(wvl) plt.plot(wvl, trans, c+'-', label="Bessel " + b) # Plot transmission curves for Johnson U, B, and V bands for (b, c) in six.iteritems({"U":"m", "B":"b", "V":"k"}): tc = tcs.getTransCurve("Johnson " + b) trans = tc(wvl) plt.plot(wvl, trans, c+'--', label="Johnson " + b) plt.legend() plt.xlabel("Wavelength [$\AA$]") plt.ylabel("Transmission") #plt.show() # Create Planck spectrum ... wvl = np.arange(3000., 10000., 1.0) spec = pyasl.planck(T=5777., lam=wvl*1e-10) # ... and convolve with Johnson V band vbs = tcs.convolveWith(wvl, spec, "Johnson V") plt.plot(wvl, spec, 'b-', label='Input spectrum') plt.plot(wvl, vbs, 'r--', label='Convolution with Johnson V band') plt.legend() #plt.show()
def sanity_ExampleTransmissionCurves(self): """ Checking example for 'TransmissionCurves' """ #from __future__ import print_function from PyAstronomy import pyasl import numpy as np import matplotlib.pylab as plt # Import six for Python 2/3 compatibility import six # Get transmission curve object tcs = pyasl.TransmissionCurves() # Add passbands from Spitzer IRAC tcs.addSpitzerIRACPassbands() print("Available bands: ", tcs.availableBands()) # Wavelength axis wvl = np.linspace(3000, 10000, 10000) # Plot transmission curves for Bessel b, v, and r bands for (b, c) in six.iteritems({"b": "b", "v": "k", "r": "r"}): tc = tcs.getTransCurve("Bessel " + b) trans = tc(wvl) plt.plot(wvl, trans, c + '-', label="Bessel " + b) # Plot transmission curves for Johnson U, B, and V bands for (b, c) in six.iteritems({"U": "m", "B": "b", "V": "k"}): tc = tcs.getTransCurve("Johnson " + b) trans = tc(wvl) plt.plot(wvl, trans, c + '--', label="Johnson " + b) plt.legend() plt.xlabel("Wavelength [$\AA$]") plt.ylabel("Transmission") #plt.show() # Create Planck spectrum ... wvl = np.arange(3000., 10000., 1.0) spec = pyasl.planck(T=5777., lam=wvl * 1e-10) # ... and convolve with Johnson V band vbs = tcs.convolveWith(wvl, spec, "Johnson V") plt.plot(wvl, spec, 'b-', label='Input spectrum') plt.plot(wvl, vbs, 'r--', label='Convolution with Johnson V band') plt.legend()
def sanity_example(self): """ Check the example """ from PyAstronomy import pyasl import numpy as np import matplotlib.pylab as plt # Approximate a solar spectrum using a Planck # function with a temperature of 5778 K between # 3000 A and 8000 A. wvl = np.arange(3000., 8000., 1.0) flux = pyasl.planck(T=5778., lam=wvl*1e-10) # Deredden the spectrum assuming ebv=0.1 fluxUnred = pyasl.unred(wvl, flux, ebv=0.1, R_V=3.1) # Plot the result plt.title("Reddened flux (red) and dereddened flux (blue)") plt.plot(wvl, flux, 'r--') plt.plot(wvl, fluxUnred, 'b--')