Exemple #1
0
from AstroObject.anaspec import InterpolatedSpectrum,GaussianSpectrum,FlatSpectrum,BlackBodySpectrum,UnitarySpectrum,Resolver
from AstroObject.spectra import SpectraStack
from AstroObject.util import npArrayInfo
from AstroObject.util.functions import get_resolution_spectrum

LOG = logging.getLogger('AstroObject')
LOG.configure_from_file('Examples/config.yml')
LOG.start()

WAVELENGTHS = ((np.arange(98)+1)/2.0 + 1.0) * 1e-7
HIGH_R =WAVELENGTHS[1:]/np.diff(WAVELENGTHS)
WAVELENGTHS_LOWR = ((np.arange(23)+0.25)*2.0 + 1.0) * 1e-7
LOWR = WAVELENGTHS_LOWR[1:]/np.diff(WAVELENGTHS_LOWR)/2
VALID = np.array([(np.arange(50) + 1.0) * 1e-7, np.sin(np.arange(50)/2.0)+2.0 + np.arange(50)/25.0])

OBJECT = SpectraStack()

OBJECT.read("Examples/SNIa.R1000.dat")
OBJECT["Interpolateable"] = InterpolatedSpectrum(OBJECT.d,"Interpolateable")
wl, rs = get_resolution_spectrum(np.min(OBJECT.f.wavelengths),np.max(OBJECT.f.wavelengths),200)
OBJECT["Raw Data"] = OBJECT.f(wavelengths = wl, resolution = rs, method = 'resample')
OBJECT.show()
wl, rs = get_resolution_spectrum(np.min(OBJECT.f.wavelengths),np.max(OBJECT.f.wavelengths),50)
OBJECT["Low Res Data"] = OBJECT["Interpolateable"](wavelengths = wl, resolution = rs, method = 'resample')
OBJECT.show()
for line in OBJECT.info():
    print line
print "Valid:",OBJECT.valid()
OBJECT["Raw Data"].logarize()
OBJECT["Logarized"] = OBJECT["Raw Data"]
for line in OBJECT.info():
from AstroObject.loggers import *
from AstroObject.anaspec import InterpolatedSpectrum,GaussianSpectrum,FlatSpectrum,BlackBodySpectrum,UnitarySpectrum,Resolver
from AstroObject.spectra import SpectraStack

LOG = logging.getLogger('AstroObject')
LOG.configure_from_file('Examples/config.yml')
LOG.start()

WAVELENGTHS = ((np.arange(98)+1)/2.0 + 1.0) * 1e-7
HIGH_R =WAVELENGTHS[1:]/np.diff(WAVELENGTHS)
WAVELENGTHS_LOWR = ((np.arange(23)+0.25)*2.0 + 1.0) * 1e-7
LOWR = WAVELENGTHS_LOWR[1:]/np.diff(WAVELENGTHS_LOWR)/2
VALID = np.array([(np.arange(50) + 1.0) * 1e-7, np.sin(np.arange(50)/2.0)+2.0 + np.arange(50)/25.0])

OBJECT = SpectraStack()

OBJECT["Raw Data"] = VALID
OBJECT.show()
OBJECT["Interpolated"] = InterpolatedSpectrum(VALID,label="Interpolated")
OBJECT.show()
OBJECT["Interpolation"] = OBJECT.frame()(wavelengths=WAVELENGTHS_LOWR)
OBJECT.show()
OBJECT["Resampled"] = OBJECT.frame("Interpolated")(wavelengths=WAVELENGTHS_LOWR[1:],resolution=LOWR,method='resample')
OBJECT.show()
plt.legend()
plt.title("Resample vs. Interpolation")
plt.figure(2)
OBJECT["Integrated"] = OBJECT.frame("Interpolated")(wavelengths=WAVELENGTHS[1:],resolution=HIGH_R,method='integrate')
OBJECT.show()
OBJECT["Integrated Quad"] = OBJECT.frame("Interpolated")(wavelengths=WAVELENGTHS[1:],resolution=HIGH_R,method='integrate_quad')