Messing around with some of the initial spectra.
NGC1499 "California Nebula": these are diffuse enough that the "pick some random fibers as sky" for sframe doesn't work, so you'll want to subtract the fframe files from the on/off sequences to do sky subtraction
In [5]:
import os
import numpy as np
In [6]:
import desispec.io
import desimodel.io
import desimodel.io
In [7]:
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(context='talk', style='ticks', font_scale=1.1)
%matplotlib inline
In [8]:
fp = desimodel.io.load_focalplane()[0]
#fp
In [15]:
datadir = os.getenv('DESI_ROOT')+'/spectro/data'
reduxdir = os.getenv('DESI_ROOT')+'/spectro/redux/daily/exposures'
baileydir = os.getenv('DESI_ROOT')+'/spectro/redux/sjbailey/exposures'
In [20]:
def read_spec(cam='b', spectype='sframe', specid=3, night=20191022, expid=20095, bailey=False):
strexpid = '{:08d}'.format(expid)
if bailey:
ddir = baileydir
else:
ddir = reduxdir
specfile = os.path.join(ddir, str(night), strexpid, '{}-{}{:d}-{}.fits'.format(
spectype, cam, specid, strexpid))
print('Reading {}'.format(specfile))
sr = desispec.io.read_frame(specfile)
return sr
In [35]:
r_onspec = read_spec(cam='r', expid=19985, bailey=True)
r_offspec = read_spec(cam='r', expid=19988, bailey=True)
In [43]:
plt.plot(r_onspec.wave, r_onspec.flux[100, :])
Out[43]:
In [42]:
flux = r_onspec.flux# - offspec.flux
#ii = (3722 < r_onspec.wave) & (r_onspec.wave < 3735)
ii = (6540 < r_onspec.wave) & (r_onspec.wave < 6600)
keep = (fp['PETAL'] == 0) & (fp['DEVICE_TYPE'] == 'POS')
kfp = fp[keep]
kfp.sort('FIBER')
lineflux = flux[:, ii].sum(axis=1)
plt.hist(lineflux)
plt.figure(figsize=(3,5))
plt.scatter(kfp['OFFSET_X'], kfp['OFFSET_Y'], c=lineflux)
Out[42]:
In [19]:
ii = (3722 < onspec.wave) & (onspec.wave < 3735)
ii = (6540 < onspec.wave) & (onspec.wave < 6600)
ii = (6560 < onspec.wave) & (onspec.wave < 6570)
flux = onspec.flux - offspec.flux
print(flux.shape)
#plt.plot(onspec.wave, flux.mean(axis=0))
for ff in flux[:, ii]:
plt.plot(onspec.wave[ii], ff, alpha=0.7)
#plt.plot(onspec.wave[ii], flux[:, ii])#.mean(axis=0))
In [13]:
flux = onspec.flux - offspec.flux
ii = (3722 < onspec.wave) & (onspec.wave < 3735)
plt.plot(onspec.wave[ii], flux[:,ii].mean(axis=0))
keep = (fp['PETAL'] == 0) & (fp['DEVICE_TYPE'] == 'POS')
kfp = fp[keep]
kfp.sort('FIBER')
OIIflux = flux[:, ii].sum(axis=1)
plt.figure(figsize=(3,5))
plt.scatter(kfp['OFFSET_X'], kfp['OFFSET_Y'], c=OIIflux)
Out[13]:
In [ ]:
cam = 'r'
onspec, offspec = read_spec(cam=cam, expid=20095), read_spec(cam=cam, expid=20096)
In [23]:
def plot_spec(bcam, rcam, zcam, fiberid=307):
fig, ax = plt.subplots()
#ax.plot(bcam.wave, bcam.flux[fiberid, :])
#ax.plot(rcam.wave, rcam.flux[fiberid, :])
#ax.plot(zcam.wave, zcam.flux[fiberid, :])
ax.plot(bcam.wave, bthru.photons(bcam.wave, bcam.flux[fiberid, :]))
In [24]:
plot_spec(bcam, rcam, zcam, fiberid=307)
In [57]:
bcam.meta
Out[57]:
In [56]:
dir(bcam)
Out[56]:
In [53]:
def read_fibermap(night=20191116, expid=28818, fiberassignid=63064):
strexpid = '{:08d}'.format(expid)
strfiberassignid = '{:06d}'.format(fiberassignid)
fiberassignfile = os.path.join(datadir, str(night), strexpid, 'fiberassign-{}.fits'.format(
strfiberassignid))
sr = desispec.io.read_frame(specfile)
return sr
In [11]:
dir(bthru)
Out[11]:
In [26]:
help(bthru.thru)
In [ ]: