pro nis_c_ecor, seq_in, seq_out, verbose, sourcedir, header,polflag ; SUB-PROGRAM of nis_proc ; ; ABSTRACT ; Applies empirical correction to NIS data. ; ; INPUTS ; seq_in - sequence of corrected spectra from nis_c_rad in ; radiance units ; sourcedir - source directory for NISCAL programs and data ; verbose - Toggle description of events std output. ; empcor - empirical correction factors from table derived from Eros and other ; NIS data ; - High frequency, channel to channel noise ; emperr - noise values for empcor ; Final derived correction accounts for a systematic and invariant ; high-frequencey (channel to channel) variation in nis spectra. The correction ; is believed to solve innaccuracies in the base DN to radiance conversion from ; the laboratory measurements. ; polcor/polerr - polarization correction for high-mirror-position spectra. ; polcor and polerr are the 64*# of spectra, populated by 1 ;.'s except where the correction is needed. ; ; OUTPUTS ; seq_in - spectra converted using empirical fit to known data. ; ; USES ; nis_ch2ch_emp_COR.dat ; nis_ch2ch_emp_ERR.dat ; eprop_mult for error porpagation ; ; HISTORY ; Created 10/01/97 by N. R. Izenberg ; Modified 12/30/97 (NRI) V1.1 directory structure ; 01/19/98 (NRI) V1.2 directory structure ; 07/15/98 (NRI) v2.0 compliant - CNFF format ; 02/28/00 (NRI) v4.0 Add ecor to make ground samples look like the ; real rocks they are. ; 08/15/00 (JFB/NRI) v5.0 derived correction ; 06/13/01 (NRI) v5.0 ecor is 2 parts - "high freq noise"(ch. to ch.) ; correction and polrization correction ; 06/22/01 (NRI) v5.0 Compliant (CNISF changes mostly) ; 07/22/01 (NRI) v5.01 combine metfind elements ; ; NOTES ; columns 2 and 3 define MET high and low word ; column 10 = shutter in/out (0 = in) ; columns 132-163 = 32 Ge detectors ; columns 164-195 = 32 InGas detectors ; columns 196-227 = 32 Ge derived noise ; columns 228-259 = 32 InGas derived noise ; ;------------------------------------------------------------------------------ ; Main ; Empirical correction is a single correction for all spectra ; load in Empirical (High frequency) correction ;---------------------------------------------------------------------- ; NISCAL 5.0 the high frequency empirical correction removes systematic ; non-varying channel to channel variations from the spectra. ; The correction is uniform for all Eros orbit data, and un-evaluated ; (but expected not to vary) for Flyby, Approach and Swingby data. ; Therefore the ecor table has a single entry for all METs ; empcorr error table is currently all 1.0 empcor=fltarr(1,64) openr,unit,sourcedir+'lib_tables/nis_ch2ch_emp_cor.dat',/get_lun readf,unit,empcor close,unit,/all emperr=fltarr(1,64) openr,unit,sourcedir+'lib_tables/nis_ch2ch_emp_err.dat',/get_lun readf,unit,emperr close,unit,/all ; Polariztion correction table also from step 1B ; Polarization correction is MET based and only for mirror postions above 150 NAX=sxpar(header,'NAXIS2') ; number of spectra sz=size(seq_in) if sz(2) ne NAX then NAX = sz(2) empcor=reform(empcor) ; Go through spectra and divide DN of each detector by DN/Radiance Unit. ; conversion. ;-------------------------------------------------------------------------- seq_out=seq_in if sz(0) eq 1 then sz(2)=1 if verbose eq 1 then begin print,' >>>> Empirical correction endif for j = 0, sz(2)-1 do begin seq_out(131:194,j)=seq_in(131:194,j)*empcor ;high freq correction ;------------------------------------------------------- emperr=empcor*.01 seq_out(195:258,j)=eprop_mult(seq_in(131:194,j), $ empcor,seq_in(195:258,j),emperr) ;Error for empirical correction is not determined as of archving. ;The above code creates an arbitrary 1% error term for the correction ;and propagates it. ;------------------------------------------------------- endfor ;Get METs ;-------------------------------------------------- mets=lonarr(sz(2)) for m=0,sz(2)-1 do begin met_hi=double(seq_in(1,m)) met_lo=double(seq_in(2,m)) if (met_lo lt 0) then met_lo=65536.d0+met_lo mets(m)=long(met_hi*65536.d0+met_lo) endfor ; Find polarization correction events and flag them ;---------------------------------------------------------------------- ; Read in heater event table, go through Spetra mets. ; If METS fall within heater events, then mark flag in data column ; Polarization errors are determined for Mirror positions above 150 ; if needed. ; Data table Columns are MET, ; mirror position, then 64 correction coefficients. Corrected spectrum ; = input spectrum * correction coefficients. ; Polarization correction is applied after _all_ other corrections. polflag=0 if (max(mets) le 125835719) or (min(mets) ge 125920101) then begin if verbose eq 1 then begin print,' >>>> MET range has no Polarization Correction' endif endif else begin if verbose eq 1 then begin print,' >>>> Data may have Polarization Correction' endif mirrec=3942 mirtab=dblarr(66,mirrec) ; MET list openr,unit,sourcedir+'lib_tables/nis_mirror_pol_cor.dat' readf,unit,mirtab close,unit,/all mirmet=mirtab(0,*) for k =0, sz(2)-1 do begin SMET=mets(k) polcor=fltarr(64)+1. polmatch=(where(mirmet eq SMET)) pm=polmatch(0) if pm ne -1 then polcor=polcor* (mirtab(2:*,pm)) seq_out(52,k) = pm ne -1 polflag=polflag+fix(pm ne -1) seq_out(131:194,k)=seq_out(131:194,k)*polcor ;Polarization correction ;------------------------------------------------------- polerr=polcor*.01 seq_out(195:258,k)=eprop_mult(seq_out(131:194,k), $ polcor,seq_out(195:258,k),polerr) ;Error for polarization correction is not determined as of archving. ;The above code creates an arbitrary 1% error term for the correction ;and propagates it. ;------------------------------------------------------- endfor endelse if verbose eq 1 then begin print,' STEP 10: Empirical/Polariz corrections applied' if polflag ne 0 then print, ' FLAG: Polarization Correction Used' endif end