CMX Spectra

Messing around with some of the initial spectra.

M33 (press release data)

California Nebula

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

  • 20191022 / 00020095 - on 
  • 20191022 / 00020096 - off
  • 20191022 / 00020097 - on
  • 20191022 / 00020098 - off
  • 20191022 / 00020099 - on
  • 20191022 / 00020100 - off

Dither Data

  • 20191206 / 00030951 - fibers positioned on stars + SDSS Main galaxies

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

Find the data


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

M33


In [35]:
r_onspec = read_spec(cam='r', expid=19985, bailey=True)
r_offspec = read_spec(cam='r', expid=19988, bailey=True)


Reading /global/project/projectdirs/desi/spectro/redux/sjbailey/exposures/20191022/00019985/sframe-r3-00019985.fits
Reading /global/project/projectdirs/desi/spectro/redux/sjbailey/exposures/20191022/00019988/sframe-r3-00019988.fits

In [43]:
plt.plot(r_onspec.wave, r_onspec.flux[100, :])


Out[43]:
[<matplotlib.lines.Line2D at 0x2aaae29c7080>]

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]:
<matplotlib.collections.PathCollection at 0x2aaae2b57048>

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))


(500, 2326)

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]:
<matplotlib.collections.PathCollection at 0x2aaae3288390>

California Nebula


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]:
SIMPLE  =                    T / conforms to FITS standard                      
BITPIX  =                  -32 / array data type                                
NAXIS   =                    2 / number of array dimensions                     
NAXIS1  =                 2751                                                  
NAXIS2  =                  500                                                  
EXTEND  =                    T                                                  
EXTNAME = 'FLUX    '                                                            
INSTRUME= 'DESI    '           / Instrument name                                
PROCTYPE= 'RAW     '           / Data processing level                          
PRODTYPE= 'image   '           / Data product type                              
PROGRAM = 'Dither tile_id 63064 (0.5,7.5)' / Program name                       
EXPID   =                29181 / Exposure number                                
EXPFRAME=                    0 / Frame number                                   
FILENAME= '/exposures/desi/specs/20191117/00029181/sp4-00029181.fits.fz' / Name 
FLAVOR  = 'science '           / Observation type                               
REQTIME =                  60. / [s] Requested exposure time                    
EXPTIME =                  60. / [s] Actual exposure time                       
OBSID   = 'kp4m20191118t072516' / Unique observation identifier                 
TIMESYS = 'UTC     '           / Time system used for date-obs                  
NIGHT   = '20191117'           / Observing night                                
DATE-OBS= '2019-11-18T07:25:16.177745' / [UTC] Observation data and start time  
TIME-OBS= '07:25:16.177745'    / [UTC] Observation start time                   
MJD-OBS =       58805.30921502 / Modified Julian Date of observation            
ST      = '03:47:05.170'       / Local Sidereal time at observation start (HH:MM
DELTARA =                   0. / [arcsec] Offset], right ascension, observer inp
DELTADEC=                   0. / [arcsec] Offset], declination, observer input  
SPECGRPH=                    3 / Spectrograph logical name (SP)                 
SPECID  =                    6 / Spectrograph serial number (SM)                
DETECTOR= 'sn22797 '           / Detector (ccd) identification                  
CAMERA  = 'b3      '           / Camera name                                    
CCDNAME = 'CCDS3B  '           / CCD name                                       
CCDPREP = 'purge,clear'        / CCD prep actions                               
CCDSIZE = '4162,4232'          / CCD size in pixels (rows, columns)             
CCDTEMP =                 850. / [deg C] CCD controller CCD temperature         
CPUTEMP =              56.0097 / [deg C] CCD controller CPU temperature         
CASETEMP=              56.2458 / [deg C] CCD controller case temperature        
CCDTMING= 'default_sta_timing_20180905.txt' / CCD timing file                   
CCDCFG  = 'default_sta_20190717.cfg' / CCD configuration file                   
SETTINGS= 'detectors_20190717.json' / Name of DESI CCD settings file            
VESSEL  =                   15 / Cryostat serial number                         
FEEVER  = 'v20160312'          / CCD Controller version                         
FEEBOX  = 'lbnl081 '           / CCD Controller serial number                   
PRESECA = '[1:4, 2:2049]'      / Prescan section for quadrant A                 
PRRSECA = '[5:2052, 1:1]'      / Row prescan section for quadrant A             
DATASECA= '[5:2052, 2:2049]'   / Data section for quadrant A                    
TRIMSECA= '[5:2052, 2:2049]'   / Trim section for quadrant A                    
BIASSECA= '[2053:2116, 2:2049]' / Bias section for quadrant A                   
ORSECA  = '[5:2052, 2050:2081]' / Row overscan section for quadrant A           
CCDSECA = '[1:2048, 1:2048]'   / CCD section for quadrant A                     
DETSECA = '[1:2048, 1:2048]'   / Detector section for quadrant A                
AMPSECA = '[1:2048, 1:2048]'   / AMP section for quadrant A                     
PRESECB = '[4229:4232, 2:2049]' / Prescan section for quadrant B                
PRRSECB = '[2181:4228, 1:1]'   / Row prescan section for quadrant B             
DATASECB= '[2181:4228, 2:2049]' / Data section for quadrant B                   
TRIMSECB= '[2181:4228, 2:2049]' / Trim section for quadrant B                   
BIASSECB= '[2117:2180, 2:2049]' / Bias section for quadrant B                   
ORSECB  = '[2181:4228, 2050:2081]' / Row overscan section for quadrant B        
CCDSECB = '[2049:4096, 1:2048]' / CCD section for quadrant B                    
DETSECB = '[2049:4096, 1:2048]' / Detector section for quadrant B               
AMPSECB = '[2049:4096, 2048:1]' / AMP section for quadrant B                    
PRESECC = '[1:4, 2114:4161]'   / Prescan section for quadrant C                 
PRRSECC = '[5:2052, 4162:4162]' / Row prescan section for quadrant C            
DATASECC= '[5:2052, 2114:4161]' / Data section for quadrant C                   
TRIMSECC= '[5:2052, 2114:4161]' / Trim section for quadrant C                   
BIASSECC= '[2053:2116, 2114:4161]' / Bias section for quadrant C                
ORSECC  = '[5:2052, 2082:2113]' / Row overscan section for quadrant C           
CCDSECC = '[1:2048, 2049:4096]' / CCD section for quadrant C                    
DETSECC = '[1:2048, 2049:4096]' / Detector section for quadrant C               
AMPSECC = '[2048:1, 2049:4096]' / AMP section for quadrant C                    
PRESECD = '[4229:4232, 2114:4161]' / Prescan section for quadrant D             
PRRSECD = '[2181:4228, 4162:4162]' / Row prescan section for quadrant D         
DATASECD= '[2181:4228, 2114:4161]' / Data section for quadrant D                
TRIMSECD= '[2181:4228, 2114:4161]' / Trim section for quadrant D                
BIASSECD= '[2117:2180, 2114:4161]' / Bias section for quadrant D                
ORSECD  = '[2181:4228, 2082:2113]' / Row bias section for quadrant D            
CCDSECD = '[2049:4096, 2049:4096]' / CCD section for quadrant D                 
DETSECD = '[2049:4096, 2049:4096]' / Detector section for quadrant D            
AMPSECD = '[4096:2049, 4096:2049]' / AMP section for quadrant D                 
DAC0    = '15.9998,15.965'     / [V] set value, measured value                  
DAC1    = '15.9998,15.8105'    / [V] set value, measured value                  
DAC2    = '15.9998,15.8105'    / [V] set value, measured value                  
DAC3    = '15.9998,15.9547'    / [V] set value, measured value                  
DAC4    = '0.0,0.0053'         / [V] set value, measured value                  
DAC5    = '0.0,0.0105'         / [V] set value, measured value                  
DAC6    = '0.0,0.0158'         / [V] set value, measured value                  
DAC7    = '0.0,0.0053'         / [V] set value, measured value                  
DAC8    = '26.9998,26.6081'    / [V] set value, measured value                  
DAC9    = '26.9998,26.9346'    / [V] set value, measured value                  
DAC10   = '26.9998,26.8752'    / [V] set value, measured value                  
DAC11   = '26.9998,26.9049'    / [V] set value, measured value                  
DAC12   = '4.9997,22.62'       / [V] set value, measured value                  
DAC13   = '-5.0006,-4.9816'    / [V] set value, measured value                  
DAC14   = '0.0,0.8216'         / [V] set value, measured value                  
DAC15   = '19.9997,20.0616'    / [V] set value, measured value                  
DAC16   = '0.0,64.9572'        / [V] set value, measured value                  
DAC17   = '-0.0,0.0366'        / [V] set value, measured value                  
CLOCK0  = '3.9999,-4.0002'     / [V] high rail, low rail                        
CLOCK1  = '3.9999,-4.0002'     / [V] high rail, low rail                        
CLOCK2  = '3.9999,-4.0002'     / [V] high rail, low rail                        
CLOCK3  = '6.9999,-2.0001'     / [V] high rail, low rail                        
CLOCK4  = '3.9999,-4.0002'     / [V] high rail, low rail                        
CLOCK5  = '3.9999,-4.0002'     / [V] high rail, low rail                        
CLOCK6  = '3.9999,-4.0002'     / [V] high rail, low rail                        
CLOCK7  = '6.9999,-2.0001'     / [V] high rail, low rail                        
CLOCK8  = '3.0,-7.0002'        / [V] high rail, low rail                        
CLOCK9  = '3.0,-7.0002'        / [V] high rail, low rail                        
CLOCK10 = '3.0,-7.0002'        / [V] high rail, low rail                        
CLOCK11 = '0.0,0.0 '           / [V] high rail, low rail                        
CLOCK12 = '3.0,-7.0002'        / [V] high rail, low rail                        
CLOCK13 = '3.0,-7.0002'        / [V] high rail, low rail                        
CLOCK14 = '3.0,-7.0002'        / [V] high rail, low rail                        
CLOCK15 = '0.0,0.0 '           / [V] high rail, low rail                        
CLOCK16 = '0.0,0.0 '           / [V] high rail, low rail                        
CLOCK17 = '3.9999,-4.0002'     / [V] high rail, low rail                        
CLOCK18 = '3.9999,-4.0002'     / [V] high rail, low rail                        
OFFSET0 = '-1.5,15.9547'       / [V] set value, measured value                  
OFFSET1 = '-1.5,15.8311'       / [V] set value, measured value                  
OFFSET2 = '-1.5,15.8208'       / [V] set value, measured value                  
OFFSET3 = '-1.5,15.965'        / [V] set value, measured value                  
OFFSET4 = '-1.100000023841858,0.0053' / [V] set value, measured value           
OFFSET5 = '-1.100000023841858,0.0105' / [V] set value, measured value           
OFFSET6 = '-1.100000023841858,0.0158' / [V] set value, measured value           
OFFSET7 = '-1.100000023841858,0.0105' / [V] set value, measured value           
DELAYS  = '13, 13, 25, 25, 8, 3000, 7, 7, 7, 7' / [10] Delay settings           
CDSPARMS= '400, 400, 8, 1000'  / CDS parameters                                 
PGAGAIN =                    5 / Controller gain                                
OCSVER  =                  1.2 / OCS software version                           
DOSVER  = 'current '           / DOS software version                           
CONSTVER= 'DESI:CURRENT'       / Constants version                              
BLDTIME =               0.3495 / [s] Time to build image                        
DIGITIME=              46.0835 / [s] Time to digitize image                     
CHECKSUM= 'SdAiTaAhSaAhSaAh'   / HDU checksum updated 2019-11-18T00:13:15       
DATASUM = '2531195875'         / data unit checksum updated 2019-11-18T00:13:15 
OVERSCNA=    1198.787177931188 / ADUs (gain not applied)                        
OBSRDNA =    4.094511730689728 / electrons (gain is applied)                    
GAINA   =                1.133 / e/ADU (gain applied to image)                  
OVERSCNB=    1198.072404983086 / ADUs (gain not applied)                        
OBSRDNB =    3.199362629719445 / electrons (gain is applied)                    
GAINB   =                1.117 / e/ADU (gain applied to image)                  
OVERSCNC=    1190.468828039591 / ADUs (gain not applied)                        
OBSRDNC =    3.679787770489328 / electrons (gain is applied)                    
GAINC   =                1.122 / e/ADU (gain applied to image)                  
OVERSCND=     1180.74669961941 / ADUs (gain not applied)                        
OBSRDND =    3.811509408401009 / electrons (gain is applied)                    
GAIND   =                1.122 / e/ADU (gain applied to image)                  
DEPNAM00= 'python  '                                                            
DEPVER00= '3.6.6   '                                                            
DEPNAM01= 'numpy   '                                                            
DEPVER01= '1.16.4  '                                                            
DEPNAM02= 'scipy   '                                                            
DEPVER02= '1.3.0   '                                                            
DEPNAM03= 'astropy '                                                            
DEPVER03= '2.0.14  '                                                            
DEPNAM04= 'yaml    '                                                            
DEPVER04= '5.1.1   '                                                            
DEPNAM05= 'desiutil'                                                            
DEPVER05= '2.0.1.dev757'                                                        
DEPNAM06= 'desispec'                                                            
DEPVER06= '0.31.0.dev3623'                                                      
DEPNAM07= 'desimodel'                                                           
DEPVER07= '0.10.2.dev552'                                                       
DEPNAM08= 'specter '                                                            
DEPVER08= '0.9.1.dev568'                                                        
DEPNAM09= 'speclite'                                                            
DEPVER09= '0.9dev514'                                                           
NSPEC   =                  500 / Number of spectra                              
WAVEMIN =               3600.0 / First wavelength [Angstroms]                   
WAVEMAX =               5800.0 / Last wavelength [Angstroms]                    
WAVESTEP=                  0.8 / Wavelength step size [Angstroms]               
SPECTER = '0.9.1.dev568'       / https://github.com/desihub/specter             
IN_PSF  = '...s/20191117/00029181/psf-b3-00029181.fits' / Input spectral PSF    
IN_IMG  = '...191117/00029181/preproc-b3-00029181.fits' / Input image           
FIBERMIN=                    0                                                  
BUNIT   = 'count/Angstrom'                                                      
DEPNAM10= 'fitsio  '                                                            
DEPVER10= '0.9.11  '                                                            
DEPNAM11= 'mpi4py  '                                                            
DEPVER11= '3.0.1   '                                                            
DEPNAM12= 'desitarget'                                                          
DEPVER12= '0.34.0.dev3626'                                                      

In [56]:
dir(bcam)


Out[56]:
['R',
 '__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getitem__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 'chi2pix',
 'fibermap',
 'fibers',
 'flux',
 'ivar',
 'mask',
 'meta',
 'ndiag',
 'nspec',
 'nwave',
 'resolution_data',
 'scores',
 'scores_comments',
 'spectrograph',
 'vet',
 'wave',
 'wsigma']

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]:
['__call__',
 '__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_extinction',
 '_fiberinput',
 '_hc',
 '_throughput',
 '_thru',
 '_wave',
 'apply_throughput',
 'area',
 'atmospheric_throughput',
 'exptime',
 'extinction',
 'fiberarea',
 'fiberdia',
 'fiberinput_throughput',
 'hardware_throughput',
 'photons',
 'thru',
 'wavemax',
 'wavemin']

In [26]:
help(bthru.thru)


Help on method thru in module specter.throughput:

thru(*args, **kwargs) method of specter.throughput.Throughput instance
    same as calling self(*args, **kwargs)


In [ ]: