pro nis_c_mirror, seq_in, seq_out, flag, sourcedir, verbose ; SUB-PROGRAM of nis_proc ; ; ABSTRACT ; Goes through sequence of NIS data spectra and corrects for scan mirror ; position ; ; INPUTS ; seq_in - temp & dark corrected data spectra from nis sequence ; slit - wide or narrow. Each has different correction ; sourcedir - source directory for NISCAL programs and data ; verbose - Toggle description of events std output. ; ; OUTPUTS ; seq_out - sequence1 with crosstalk correction ; flag - errors where actual scan mirror position does not match ; in the header and spectra ; USES ; nis_mirror_poly_coeffs_n.dat - data file for mirror coefficients. ; nis_mirror_poly_coeffs_w.dat - data file for mirror coefficients. ; Both calculated from large integrating shpere lab tests. ; ; HISTORY ; Created 9/23/97 by N. Izenberg ; Modified 12/02/97 (NRI)to extract mirror position from within spectra data. ; Modified 12/30/95 (NRI) v1.1 directory structure ; 01/19/98 (NRI) v1.2 directory structure ; 02/11/98 (NRI) v1.5 fix slit lookup ; 07/15/98 (NRI) v2.0 compliant - CNFF change slit to in-data lookup ; 07/22/01 (NRI) v5.0 Compliant (CNISF changes mostly) ; 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 ; IDL column 16 = actual scan mirror position for a given spectrum ; IDL column 15 = commanded mirror position ; IDL column 10 = slit out (0=yes, 1=no) ; IDL column 11 = slit in (0=yes, 1=no) ;------------------------------------------------------------------------------ ; Main sz=size(seq_in) if sz(0) eq 1 then sz(2)=1 slit=seq_in(11,*) ; 0 = slit is IN (Narrow) ;if verbose eq 1 then print," >>>> Polynomial mirror coefficients default" ; Extract mirror position from spectra data. There is an overall ; mirror position from the header, but this is not useful if the ; mirror scans during a given sequence. ;---------------------------------------------------------------- mirror_pos=seq_in(16,*) ; Load in table of coefficients from library. ; Coefficients are polynomial factors from 3rd to 5th order. ; fac is the scaling factor derived from mirror position for each ; detector ; Mirror position 188 gives a factor of 1.000, usually +/- .001 ;---------------------------------------------------------------- coefsn = fltarr(64,6) openr,unit,sourcedir+'lib_tables/nis_mirror_poly_coeffs_n.dat',/get_lun readf,unit,coefsn close,unit coefsw = fltarr(64,6) openr,unit,sourcedir+'lib_tables/nis_mirror_poly_coeffs_w.dat',/get_lun readf,unit,coefsw close,unit fac=fltarr(64) ; Go through spectra and multiply each by the mirror position correction factor ;------------------------------------------------------------------------------ flag = fltarr(sz(2)) seq_out = seq_in for j = 0, sz(2)-1 do begin if slit(j) eq 0 then coefs=coefsn else coefs=coefsw fac=coefs(*,0)+(coefs(*,1)*mirror_pos(j))+ $ (coefs(*,2)*mirror_pos(j)^2)+ $ (coefs(*,3)*mirror_pos(j)^3)+(coefs(*,4)*mirror_pos(j)^4)+ $ (coefs(*,5)*mirror_pos(j)^5) seq_out(131:194,j)=seq_in(131:194,j)*fac if seq_in(15,j) ne mirror_pos(j) then flag(j) = 1. ; check if mirror pos ; equals selected pos endfor if verbose eq 1 then begin case 1 of total(slit) eq 0:print,' >>>> Slit is Narrow' total(slit) eq sz(2):print,' >>>> Slit is Wide' else:print,' >>>> Slit state Varies' endcase print,' STEP 6: scan mirror position corrections applied' if total(flag) gt 0 then print,' >>>> FLAG: ',fix(total(flag)), $ ' deviant scan mirror flags detected. endif end