In [41]:
platein = (4567, 7830)
plate = ravel(platein)

In [42]:
int(plate)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-42-c9f094e803b9> in <module>()
----> 1 int(plate)

TypeError: only length-1 arrays can be converted to Python scalars

In [39]:
print("What is this: {0:4d}".format(int(plate)))


What is this: 4567

In [50]:
spplate_hdunames = ('flux','invvar','andmask','ormask','disp','plugmap','sky','loglam', )
tryspplate_hdunames = ('flux','invvar','andmask','ormask','disp','plugmap','sky','lloglam', )

In [52]:
for thishdu in tryspplate_hdunames:
    print(thishdu, type(thishdu))
    print spplate_hdunames.index(thishdu)
    if type(thishdu) != str:
        raise TypeError("hdunames should be strings")
    if thishdu not in spplate_hdunames:
        raise ValueError("{0} is not in the hdu/loglam list: {1}".format(thishdu, spplate_hdunames))
    print spplate_hdunames.index(thishdu)


('flux', <type 'str'>)
0
0
('invvar', <type 'str'>)
1
1
('andmask', <type 'str'>)
2
2
('ormask', <type 'str'>)
3
3
('disp', <type 'str'>)
4
4
('plugmap', <type 'str'>)
5
5
('sky', <type 'str'>)
6
6
('lloglam', <type 'str'>)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-52-77ef0a0e4a51> in <module>()
      1 for thishdu in tryspplate_hdunames:
      2     print(thishdu, type(thishdu))
----> 3     print spplate_hdunames.index(thishdu)
      4     if type(thishdu) != str:
      5         raise TypeError("hdunames should be strings")

ValueError: tuple.index(x): x not in tuple

In [1]:
import sdssspec

In [14]:
output = ('loglam', 'flux',)
plate = 7319
mjd = 56962
fiber = array([30, 40, 50])
path = "/Users/Benjamin/AstroData/SDSS/v5_7_6"

In [15]:
results = sdssspec.read_spec(plate, mjd, fiber, path, output)


/Users/Benjamin/AstroData/SDSS/v5_7_6/spPlate-7319-56962.fits

In [16]:
flux = results['flux']
loglam = results['loglam']
flux.shape


Out[16]:
(1000, 4652)

In [13]:
plot(np.power(10., loglam), flux[7,:])


Out[13]:
[<matplotlib.lines.Line2D at 0x110fca2d0>]

In [68]:
c0 = hdr['coeff0']
c1 = hdr['coeff1']
npix = hdr['naxis1']


Out[68]:
1000

In [1]:
low_state = {'J': array(['1/2', '3/2', '5/2', '7/2', '9/2'])}
absorption = {'LOWJ': '3/2'}

In [12]:
jvalue = absorption['LOWJ']
ilevel = ((nonzero(low_state['J']==jvalue)))[0]

In [13]:
ilevel


Out[13]:
array([1])

In [14]:
weightMatrix = [{'A':0,'C':0,'G':0,'T':0} for k in range(10)]

In [21]:
weightMatrix[0] = {'A':1}

In [22]:
weightMatrix[0]


Out[22]:
{'A': 1}

In [24]:
def transition_dtype():
    out_dtype = [('XPOS', 'f4'),       
                 ('YPOS_TEXT', 'f4'),
                 ('LOWJ', 'S3'), 
                 ('HIGHJ', 'S3'), 
                 ('TEXT', 'S30')]
    return out_dtype

In [25]:
tran_dtype = transition_dtype()

In [26]:
emission = np.zeros(1, dtype=tran_dtype)

In [29]:
emission[0] = (0.23, 0.32, 1/2, '3/2', '2600.17   2.35E8   2.39E-1')

In [30]:
emission[0]


Out[30]:
(0.23000000417232513, 0.3199999928474426, '0', '3/2', '2600.17   2.35E8   2.39E-1')

In [3]:
import ebossspec

In [8]:
(outwave, fluxmedian, fluxmean, oiifluxmedian, oiifluxmean) = ebossspec.new_feiimgii_composite_bootstrap(nbootstrap=10)


Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave01800_03600A.fits.
Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave03600_07200A.fits.
(8620,)

In [7]:
reload(ebossspec)


Out[7]:
<module 'ebossspec' from 'ebossspec.py'>

In [9]:
print outwave.shape
print fluxmedian.shape


(2651,)
(2651, 10)

In [13]:
figsize(15,10)
for i in arange(10):
    plot(outwave, fluxmedian[:,i])
xlim(2200, 2900)


Out[13]:
(2200, 2900)

In [ ]: