Experiment with Pyspeckit

Try to get a handle of it to see if would be usefull in my scripts.

Only python 2.7 available


In [49]:
import numpy as np
import pyspeckit
from astropy.io import fits
import matplotlib.pyplot as plt

#% matplotlib.pyplot inlne

In [50]:
f_sum = "./test_crires.nod.ms.norm.sum.fits"
f_wavecal = "./test_crires.nod.ms.norm.sum.wavecal.fits"

In [51]:
data = fits.getdata(f_sum)
hdr = fits.getheader(f_sum)
print(data)

data_wavecal = fits.getdata(f_wavecal)
hdr_wavecal = fits.getheader(f_wavecal)
print(data_wavecal)
#data_wavecal.columns


wl = data_wavecal["Wavelength"]
flux = data_wavecal["Extracted_DRACS"]


[ 0.83280522  0.8855229   0.92419726 ...,  1.01128316  1.00921535
  1.02195954]
[(2111.8757, 0.83280522, 1.0) (2111.8872, 0.8855229, 2.0)
 (2111.8989, 0.92419726, 3.0) ..., (2123.5632, 1.0112832, 1022.0)
 (2123.5745, 1.0092154, 1023.0) (2123.5859, 1.0219595, 1024.0)]

In [65]:
# Test on data
xaxis = np.arange(len(data))
test_spec = pyspeckit.Spectrum(data=data, xarr=xaxis, unit='')
#                        xarrkwargs={'unit':'km/s'})
#sp = pyspeckit.Spectrum(data=data, error=error, xarr=xaxis,
#                        xarrkwargs={'unit':'km/s'},
#                        unit='erg/s/cm^2/AA')

test_spec.plotter()

In [67]:
test_spec.data
test_spec.unit


Out[67]:
''

In [69]:
# Test on wavelength calibtred data
test_spec2 = pyspeckit.Spectrum(data=flux, xarr=wl, xarrkwargs={'unit':'nm'}, unit='')
test_spec2.unit

test_spec.plotter()

In [ ]: