function uly_spect_get, SignalIn, $
WAVERANGE=waverange, $
GOODPIX=goodpix, $
HDR=hdr, $
VALID=valid, $
MASK=mask, $
STATUS=status
if n_params() eq 0 then begin
message, 'Usage: uly_spect_get, SignalIn, <optional kw>', /INFO
status = 1
return, -1
endif
status = 0
valid = 1b
if size(SignalIn, /TYPE) ne 8 then valid = 0b
if valid eq 1 then if ptr_valid(SignalIn.data) eq 0 then valid = 0b
if valid eq 1 then if n_elements(*SignalIn.data) eq 0 then valid = 0b
if keyword_set(waverange) then begin
if not valid then begin
status = 1
return, -1
endif
if SignalIn.sampling eq 0 then return, SignalIn.start + $
[0d,((size(*SignalIn.data))[1]-1)*SignalIn.step]
if SignalIn.sampling eq 1 then return, exp(SignalIn.start + $
[0d,((size(*SignalIn.data))[1]-1)*SignalIn.step])
if SignalIn.sampling eq 2 then begin
if n_elements(*SignalIn.data) ne n_elements(*SignalIn.wavelen) then $
return, -1
return, [(*SignalIn.wavelen)[0], $
(*SignalIn.wavelen)[n_elements(*SignalIn.wavelen)-1]]
endif
endif
if keyword_set(goodpix) then begin
if not valid then begin
status = 1
return, -1
endif
if n_elements(*SignalIn.goodpix) ne 0 then $
goodpix = *SignalIn.goodpix else begin
npix = (size(*SignalIn.data, /DIM))[0]
goodpix = lindgen(npix)
endelse
return, goodpix
endif
if keyword_set(hdr) then begin
if not valid then begin
status = 1
return, -1
endif
hdr = ''
if tag_exist(SignalIn, 'hdr') then begin
if ptr_valid(SignalIn.hdr) then $
if n_elements(*SignalIn.hdr) gt 0 then hdr = *SignalIn.hdr
endif
return, hdr
endif
if keyword_set(mask) then begin
if not valid then begin
status = 1
return, -1
endif
msk = bytarr(n_elements(*SignalIn.data))
if n_elements(*SignalIn.goodpix) gt 0 then msk[*SignalIn.goodpix] = 1 $
else msk += 1B
msk = reform(msk, size(*SignalIn.data, /DIM))
return, msk
endif
return, valid
end
Part of