pro cg_Get_EUV_03_Lab_Calibration,e_wavelength,e_calibration,e_calibration_error,slit_width,input_spectrum,window_definition,bin_definition 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,'window_definition is a four element array that defines the four corners of the detector sub-array containing valid data' print,'default is full spectral-spatial window (0,0,1023,63)' 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 highresolution entrance slit ',slit_width ;if slit_width eq 1 then print,'** Calibration values forlow_resolution (0.20mm wide) spectrograph slit**' ;if slit_width eq 2 then print,'** Calibration values forhi_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**' ; window definition if n_params() lt 6 then window_definition=[0,0,1023,63] if n_elements(window_definition) ne 4 then begin window_definition=intarr(4) read,'******* input the column and row values of the upperleft corner of the window ',temp1,temp2 window_definition(0)=temp1 window_definition(1)=temp2 read,'******* input the column and row values of the lower right corner of the window ',temp1,temp2 window_definition(2)=temp1 window_definition(3)=temp2 end windef: if (window_definition(2) lt window_definition(0)) or (window_definition(2) lt window_definition(0)) then begin print,'******** faulty window definition try again' window_definition=intarr(4) read,'******* input the column and row values of the upperleft corner of the window ',temp1,temp2 window_definition(0)=temp1 window_definition(1)=temp2 read,'******* input the column and row values of the lower right corner of the window ',temp1,temp2 window_definition(2)=temp1 window_definition(3)=temp2 end if (window_definition(2) lt window_definition(0)) or (window_definition(2) lt window_definition(0)) then goto,windef ul_w=[window_definition(0),window_definition(1)] lr_w=[window_definition(2),window_definition(3)] Print,'** Upper Left Window Corner is',strtrim(string(ul_w(0)),2),' x ',strtrim(string(ul_w(1)),2),'**' Print,'** Lower Right Window Corner is ',strtrim(string(lr_w(0)),2),' x ',strtrim(string(lr_w(1)),2),'**' ; bin_definition if n_params() lt 7 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,' ' ;get size of unbinned window for later width=lr_w(0)-ul_w(0)+1 height=lr_w(1)-ul_w(1)+1 ; pad it out to integral multiples of the binning parameters width_pad=spectral_bin*ceil(1.*width/spectral_bin) height_pad=spatial_bin*ceil(1.*height/spatial_bin) ; get the size of the final returned array partial bins at the ends are included width_final=ceil(1.*width/spectral_bin) height_final=ceil(1.*height/spatial_bin) ;************************** ;read calibration data file get_lun,uu openr,uu,'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 ;we(1024) ;e_cal(1024,64) ;e_cal_error(1024,64) 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 ;extract the correct window padded out to integral binning ;wave_temp ;e_cal_temp(width_pad,height_pad) ;e_err_temp(width_pad,height_pad) wave_temp=fltarr(width_pad) e_cal_temp=fltarr(width_pad,height_pad) e_err_temp=fltarr(width_pad,height_pad) wave_temp(0:width-1)=we(ul_w(0):lr_w(0)) e_cal_temp(0:width-1,0:height-1)=e_cal(ul_w(0):lr_w(0),ul_w(1):lr_w(1)) e_err_temp(0:width-1,0:height-1)=e_cal_error(ul_w(0):lr_w(0),ul_w(1):lr_w(1)) e_wavelength=fltarr(width_final) e_calibration=fltarr(width_final,height_final) e_calibration_error=fltarr(width_final,height_final) for k=0,width_final-1 do e_wavelength(k)=mean(wave_temp(k*spectral_bin:(k+1)*spectral_bin-1)) for k=0,height_final-1 do for l=0,width_final-1 do begin e_calibration(l,k)=total(e_cal_temp(l*spectral_bin:(l+1)*spectral_bin-1,k*spatial_bin:(k+1)*spatial_bin-1)) e_calibration_error(l,k)=total(e_err_temp(l*spectral_bin:(l+1)*spectral_bin-1,k*spatial_bin:(k+1)*spatial_bin-1))/sqrt(spatial_bin*spectral_bin) end stop,'test1' 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