pro cg_Get_EUV_99_Lab_Calibration,e_wavelength,e_calibration,e_calibration_error,slit_width,input_spectrum,bin_definition,def_file_keep if n_params() le 0 then begin Print,'Pro Get_EUV_99_Lab_Calibration,e_wavelength,e_calibration,e_calibration_error,slit_width,input_spectrum,bin_definition' Print,'1999 EUV Channel Laboratory Calibration including adjustment to fit H2 model electron lamp spectrum' Print,' ' Print,'e_wavelength is the wavelength vector Print,' ' Print,'e_calibration is the data MULTIPLIER that converts couts/sec to kilorayleighs/pixel (or kilorayleighs/Angstrom)' Print,' ' Print,'e_calibration_error is the 1-sigma error in e_calibration' Print,' ' print,'slit_width selects ocultation (0), low_resolution (1), or high_resolution (2)' print,' print,'input_spectrum selects calibration for continuous spectra (1) or for discrete lines (2) ' print,' ' print,'bin_definition is a two element array that defines the spectralxspatial format' print,'for the wavelength scale and the calibration vector' return end ;print,' ' ;print,'*********************************************************************************************************' ;Print,'** 1999 EUV Channel Laboratory Calibration including adjustment to fit H2 model electron lamp spectrum **' ;********************************************* ;set up calibration matrix parameters and format ; slit width if n_params() lt 4 then slit_width=1 ;default is low resolution slit ;if (slit_width ne 1) and (slit_width ne 2) and (slit_width ne 0) then read,'******* Select occultation (0), low resolution (1), or high resolution entrance slit ',slit_width ;if slit_width eq 1 then print,'** Calibration values for low_resolution (0.20mm wide) spectrograph slit **' ;if slit_width eq 2 then print,'** Calibration values for hi_resolution (0.10mm wide) spectrograph slit **' ;if slit_width eq 0 then print,'** Calibration values for occultation (0.80mm wide) spectrograph slit **' if slit_width eq 0 then slit_width=1./4 ; input spectrum if n_params() lt 5 then input_spectrum=1 ;default is continuous ;if (input_spectrum ne 1) and (input_spectrum ne 2) then read,'******* Select either a continus input spectrum (1) or discrete line (2) ',input_spectrum ;if input_spectrum eq 2 then Print,'** Multiply the Data (counts/pixel/sec) by e_calibration to obtain kiloRayleighs/pixel **' ;if input_spectrum eq 1 then Print,'** Multiply the Data (counts/pixel/sec) by e_calibration to obtain kiloRayleighs/Angstrom **' ; bin_definition if n_params() lt 6 then bin_definition=[1,1] ;defalut is spectral & spatial binning=1 if n_elements(bin_definition) ne 2 then begin bin_definition=intarr(2) read,'******* input spectral binning parameter (1=no binning) ' ,temp bin_definition(0)=temp read,'******* input spatial binning parameter ((1=no binning) ' ,temp bin_definition(1)=temp end spectral_bin=bin_definition(0) spatial_bin=bin_definition(1) ;if (n_params() eq 6) and (n_elements(bin_definition) eq 2) then spectral_bin=bin_definition(0) ;if (n_params() eq 6) and (n_elements(bin_definition) eq 2) then spatial_bin=bin_definition(1) ;Print,'** Spectral x Spatial Binning is ', strtrim(string(spectral_bin),2),' x ',strtrim(string(spatial_bin),2),' **' ;print,'*********************************************************************************************************' ;print,' ' ;************************** ;read calibration data file path1=def_file_keep get_lun,uu openr,uu,path1 + 'EUV_1999_Lab_Cal.dat' x=' ' readf,uu,x dat=fltarr(14*3) readf,uu,dat free_lun,uu wcal=fltarr(14) ecalerror=wcal ecal=wcal for k=0,6 do wcal(k)=dat(k*6) for k=0,6 do ecal(k)=dat(k*6+1) for k=0,6 do ecalerror(k)=dat(k*6+2) for k=7,13 do wcal(k)=dat((k-7)*6+3) for k=7,13 do ecal(k)=dat((k-7)*6+4) for k=7,13 do ecalerror(k)=dat((k-7)*6+5) ;********************* ;generate calibration matrix cg_e_flight_wavelength,we e_cal=fltarr(1024,64) e_cal_error=fltarr(1024,64) ecal=interpol(ecal,wcal,we)/59. ecalerror=interpol(ecalerror,wcal,we)/59. for k=3,61 do e_cal(*,k)=ecal ; calibration per spatial pixel at the detector center row for k=3,61 do e_cal_error(*,k)=ecalerror ; error per spatial pixel at the detector center row ;apply slit width correction e_cal=e_cal/slit_width e_cal_error=e_cal_error/slit_width ;apply factor for continuous input spectrum if input_spectrum eq 1 then begin e_cal=e_cal*.605 e_cal_error=e_cal_error*.605 end ;perform spatial binning e_calibration_temp=fltarr(1024,64/spatial_bin) e_calibration_error_temp=fltarr(1024,64/spatial_bin) ;check for spatial binning if spatial_bin eq 1 then begin ; set up tempory binning vectors e_calibration_temp=e_cal e_calibration_error_temp=e_cal_error end if spatial_bin eq 64 then begin ; bin everything e_calibration_temp(*,0)=total(e_cal,2) e_calibration_error_temp(*,0)=total(e_cal_error,2) end if (spatial_bin eq 64) or (spatial_bin eq 1) then goto,spect_bin for k=0,64/spatial_bin-1 do begin e_calibration_temp(*,k)=total(e_cal(*,k*spatial_bin:(k+1)*spatial_bin-1),2) e_calibration_error_temp(*,k)=total(e_cal_error(*,k*spatial_bin:(k+1)*spatial_bin-1),2) end ;perform spectral binning spect_bin: e_wavelength=we ;define final vectors for binning in spatial dimension is 1 e_calibration=e_calibration_temp e_calibration_error=e_calibration_error_temp if spectral_bin eq 1 then goto,fin e_wavelength=fltarr(1024/spectral_bin) ;set up vectors for spectral binning e_calibration=fltarr(1024/spectral_bin,64/spatial_bin) e_calibration_error=fltarr(1024/spectral_bin,64/spatial_bin) if spectral_bin eq 1024 then begin ; bin everything in spectral dimension e_calibration(0,*)=total(e_calibration_temp,1) e_calibration_error(0,*)=total(e_calibration_error_temp,1) e_wavelength=total(we)/1024 end if (spectral_bin eq 1024) and (spatial_bin eq 64) then begin ;bin everything in both spatial and spectral dimensions e_calibration(0,0)=total(e_calibration_temp,1) e_calibration_error(0,0)=total(e_calibration_error_temp,1) e_wavelength=total(we)/1024 end if spectral_bin eq 1024 then goto,fin num=spectral_bin if spatial_bin eq 64 then begin ;bin in spectral when binning in spatial=64 for k=0,1024/num-1 do begin e_wavelength(k)=total(we(k*num:(k+1)*num-1))/num e_calibration(k)=total(e_calibration_temp(k*num:(k+1)*num-1)) e_calibration_error(k)=total(e_calibration_error_temp(k*num:(k+1)*num-1)) end end if spatial_bin eq 64 then goto,fin for k=0,1024/num-1 do e_wavelength(k)=total(we(k*num:(k+1)*num-1))/num ;bin in spectral when binning in spatial ne 64 or 1 for k=0,1024/num-1 do begin e_calibration(k,*)=total(e_calibration_temp(k*num:(k+1)*num-1,*),1) e_calibration_error(k,*)=total(e_calibration_error_temp(k*num:(k+1)*num-1,*),1) end fin: if n_elements(e_calibration eq 1) then begin e_calibration=1./e_calibration e_calibration_error=1./e_calibration_error return end cal_temp=(e_calibration eq 0)*1.e10+e_calibration err_temp=(e_calibration eq 0)*1.e10+e_calibration_error e_calibration=1./cal_temp e_calibration_error=err_temp/cal_temp/cal_temp e_calibration=(e_calibration gt 1.e-9)*e_calibration e_calibration_error=(e_calibration_error gt 1.e-9)*e_calibration_error end return end