;+ ; PROJECT: SPEX ; ; NAME: read_hirex_4_spex ; ; ; PURPOSE: general purpose data input proc. for SPEX ; ; ; CATEGORY: SPEX, analysis i/o ; ; CALLS: ; SPEC_SENSITIVITY, READ_CONT, READ_DISCSP, CONT_EDGES, FCHECK, CHECKVAR, ; F_DIV, DPRATE2SEC, LIMITS, AVE_CTS2, ANYTIM, GT_DP_MODE ; RESTORE_OVERFLOW CHKARG CLEAR_UTPLOT DET_COSINES EDGE_PRODUCTS FITS_SPECTRA ; GET_HXRBS_FITS HXT_CAL_FIX PRINTX RD_ROADMAP RD_SXS_PHA RD_WBS_PHA RD_XDA ; SHERS_LOAD SPEX_INTERVALS SXS_ECAL UTPLOT WBS_RESPONSE EXIST ATIME ; ; CALLING SEQUENCE: ; read_hirex_4_spex, dformat=dformat, files=files, $ ; start_time = start_time, end_time=end_time, title=title, command_out=command_out, $ ; det_id=det_id, id_style=id_style, p_read_data=p_read_data, _extra=_extra, $ ; flux=flux, eflux=eflux, ut=ut, units=units, area=area, ltime=ltime, edges=edges,$ ; id_use=id_use, auto=auto, noplot=noplot, mode=mode, wchan=wchan, delta_light=delta_light ; examples ; ; read_hirex_4_spex, dformat='', $ ; flux=flux, eflux=eflux, ut=ut, units=units, area=area, ltime=ltime, edges=edges ; ; ; INPUTS: ; dformat - dummy arg. ; files - only 1 file, dummy arg ; flare - dummy arg ; start_time - ; end_time - ; optional, read file between start_time and end_time, defaults ; are the start and end of the files, must be readable by ANYITM ; ; det_id - dummy ; id_style - NO MEANING ; _extra - keyword inheritance in version >3.1 ; /auto - dummy ; /noplot - dummy ; p_read_data - dummy ; OUTPUTS: ; flux - fltarr(nchan,nbins) - counts/cm2/sec/keV, overflow and livetime corrected ; eflux - fltarr(nchan,nbins) - sqrt(counts)/cm2/sec/keV ; ut - dblarr(2,nbins), seconds referenced to 79/1/1 ; units - e.g. 'cm!u-2!n s!u-1!n keV!u-1!n' ; area - detector area in cm2 ; ltime - fltarr(1,nbins) accumulation live time in interval, seconds ; changed to fltarr(nchan,nbins) - 20-oct-94 ; edges - fltarr(2,nchan) lo and hi edges in keV ; delta_light - fltarr(nchan), for BATSE SHER, channel width in pulse height ; see cal_sher and calibrate, and Band 1992 on SLED problem for ; discussion. ; id_use - actual detector id, to reference drm ; title - title string referencing instrument, data ; mode - special output for YOHKOH, mode=0 for non-flare, 1 for flare ; wchan - indices of allowed channels ; command_out - further instructions to SPEX, e.g. "read_drm", may also be used for input ; SIDE EFFECTS: ; none ; ; RESTRICTIONS: ; none ; ; PROCEDURE: ; This procedure provides a 1-stop shop for all YOHKOH data types readable through SPEX. ; The correct reader is identified for each data type, it is called for the input ; data file. The correct PHA edge generator is also called. Corrections are made ; to the data for livetime and overflow and all vectors by SPEX are returned. ; ; MODIFICATION HISTORY: ; Version 1 ; richard.schwartz@gsfc.nasa.gov, 26-sep-1997, extracted ; from read_4_spex ;- pro read_hirex_4_spex, dformat=dformat, files=files, $ start_time = start_time, end_time=end_time, flare=flare, $ det_id=det_id, id_style=id_style, p_read_data=p_read_data, $ flux=flux, eflux=eflux, ut=ut, units=units, area=area, cosines=cosines, $ ltime=ltime, edges=edges, delta_light=delta_light, wchan=wchan, id_use=id_use, title=title, $ auto=auto, noplot=noplot, mode=mode, error=error, $ command_out=command_out, efficiency = eff, _extra = _extra common read_spex_com, data, ut_data, data_file_read, read_start, read_end checkvar,data,0 checkvar,data_file_read,'' checkvar,read_start,'' checkvar,read_end,'' checkvar, command_out, '' if command_out(0) ne '' then com_param=command_out else com_param='' delta_light= 1.0 checkvar, units, ' s!u-1!n cm!u-2!n keV!u-1!n' command_out = 'build_drm,DIAGONAL!!background,null' fits_spectra, files(0), ut, flux_full, erate=eflux_full, livet=ltime, $ edges=edges_full, start_time=start_time, end_time=end_time, $ /printx ;data_units are defined XSPEC-OGIP style! area= 44.7 ;cm^2 ;Add a zero background interval prior to start - printx,['Reading in HIREX Balloon Data, data in photon units.',$ 'Already background subtracted. Already deconvolved.',$ 'Background flux set to zero. DRM is diagonalized. '] nbin = n_elements(ut(0,*)) title = 'HIREX BALLOON 27 JUNE 1980' ;Rebin the data to logarithmic bins nnew= [2+indgen(14), 16, 18, 20, 21, 23, 25, $ 28, 30, 32, 35, 38, 41, 44, 47, 51, 54, $ 58, 63, 67, 72, 77, 82, 88, 94, 100, 107, $ 114, 122, 130, 139, 148, 157, 168, 179, 190, 203, $ 216, 230, 244, 260, 277, 294, 313, 333, 354, 377, 400, 426, 453, 481, 511] nchan = n_elements(nnew)-1 wchan = indgen(nchan) flux = fltarr(nchan, nbin) eflux = fltarr(nchan, nbin) ; energy bins are equally spaced in edges_full!! for i=0,nchan-1 do begin flux(i,*) = rebin(flux_full(nnew(i):nnew(i+1),*),1,nbin) eflux(i,*)= sqrt(rebin(eflux_full(nnew(i):nnew(i+1),*)^2,1,nbin)) / $ sqrt( nnew(i+1)-nnew(i) ) endfor edges = [edges_full(0,nnew(0:nchan-1)),edges_full(1,nnew(1:nchan))] edge_products, edges, width=ww eff_oft = f_div( flux , eflux^2 ) / area for i=0,nbin-1 do eff_oft(*,i) = eff_oft(*,i) / ltime(i) /ww ;average eff_oft over time to get typical efficiency factor ;don't average over flux elements below zero eff = eff_oft(*,0) *0.0 for i=0,nchan-1 do begin wnz = where(flux(i,*) gt 0.0,nz) if nz ge 1 then eff(i) = avg( eff_oft(i,wnz)) endfor printx, string(/print,'These are the effective efficiencies:',eff) for i=0,nbin-1 do begin flux(*,i) = flux(*,i) * eff eflux(*,i)= eflux(*,i) * eff endfor end