pro nis_c_darkspace,seq_in, dark_mode, noise_mode, seq_out, head, verbose ; SUB-PROGRAM of nis_proc ; ; ABSTRACT ; Removes dark spectra from nis data. Most darks are interleaved with spectra. ; These are removed by nis_c_dark. Non-interleaved spectra sequences use ; nis_c_darksep for when sperate dark-only files are provided. For ; sequences that are dominated by looking into space with brief passes ; across the asteroid, Darks are determined by tracking the dark signal ; across the duration of the sequence, hacking out all the data, and ; fitting a line to the dark signals for each channel The resulting dark ; fit, based on looking into blank space is then subtracted from the ; signal. In some channels, notably InGaAs, space darks and shutter ; closed darks can differ by a significant number of DNs. For this ; reason, shutter-closed data are excised from consideration by the ; program. This procedure relies on nis_c_back.pro and associated programs ; developed by Ray Sterner at APL. ; ; INPUTS ; seq_in - sequence of averaged spectra from nis_c_div ; noise_mode - how spectra serror is determined ; 0 = error determined from average of all dark ; spectra in sequence (Default) ; 1 = initial error predetermined from file of 300 ; avergaged dark spectra ; sourcedir - source directory for NISCAL programs and data ; verbose - Toggle description of events std output ; ; OUTPUTS ; seq_out - array of data spectra with dark subtracted ; ; USES ; nis_c_back - Ray Sterner's procedures for getting dark background data. ; ; HISTORY ; Adapted 05/08/00 by N. R. Izenberg partly from nis_c_dark for NISCAL v4.1 ; 07/20/01 (NRI) v5.0 Compliant (mainly CNISF 5.0) ; ; NOTES ; From NIS sequence data: ; IDL columns 1 and 2 define MET high and low word ; CNISF 5.0 column 9 = shutter in/out (0 = in) ; CNISF 5.0 Data is 131:194 for Calibration ; CNISF 5.0 Data is 195:258 for Noise ;------------------------------------------------------------------------------ ; Main NAX=sxpar(head,'NAXIS2') seq_o=seq_in ; temporary output array place=0 for i=0,63 do begin ;Call Ray's procedure case dark_mode of 5 : if verbose eq 0 then nis_c_back,seq_in,getfit=fit,geterr=err, $ spcindex=131+i, dm=5 $ else nis_c_back,seq_in,getfit=fit,geterr=err, $ spcindex=131+i,dm=5,/splot 6 : if verbose eq 0 then nis_c_back_tight,seq_in,getfit=fit, $ geterr=err, spcindex=131+i, dm=6 $ else nis_c_back_tight,seq_in,getfit=fit,spcindex=131+i, $ geterr=err, dm=6,/splot 7 : if verbose eq 0 then nis_c_back,seq_in,getfit=fit,geterr=err, $ spcindex=131+i, dm=7 $ else nis_c_back,seq_in,getfit=fit,geterr=err, $ spcindex=131+i,dm=7,/splot ; Don't plot out output (,/splot) 8 : if verbose eq 0 then nis_c_back_tight,seq_in,getfit=fit, $ geterr=err, spcindex=131+i, dm=8 $ else nis_c_back_tight,seq_in,getfit=fit,spcindex=131+i, $ geterr=err, dm=8,/splot endcase seq_o(131+i,*)=seq_in(131+i,*)-reform(fit,1,NAX) if noise_mode eq 0 then seq_o(195+i,*)=fit*0.+err ; err is generated in nis_c_back or nis_c_back_tight by taking ; the stdev of the background using a 9-measurement rolling ; window. The 9 is hardcoded, but can be changed. This method ; was used to preserve local noise modifiers such as heater ; turn-ons. endfor ;Cleanup ;If darks are interleaved anyway, chop them out ;------------------------------------------------ sh=total(seq_in(6,*) gt 1) ; find number of sequencesthat have shutter ; closed (value = 2 or 3) if sh ne 0 then begin seq_out=fltarr(259,NAX-sh) ; make smaller array to eliminate dark ; interleave place=0 for j=0,NAX-1 do begin if seq_o(6,j) le 1 then begin seq_out(*,place) = seq_o(*,j) place=place+1 endif endfor endif else seq_out=seq_o if verbose eq 1 then print,' STEP 3: bounding space background removed' return end