Skip to content
10 changes: 7 additions & 3 deletions AGILECalib_H/eff_area/AGILE_mksar_loop_H.pro
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
; 13/11/2013: selecting the /aref directory (V. Fioretti)
; 6/11/2015: loading the environment variable (V. Fioretti)
; 13/12/2015: new Fermi-style energy bands (A. Chen)
; 6/10/2023: T class added (V. Fioretti)

ae_path = GETENV('CALIB_AE_RSP')
ae_path = ae_path+'/aref'
Expand All @@ -42,7 +43,7 @@ for t=0, nthetas-1 do begin


;ener=[35,50,71,100,141,200,283,400,632,1000,1732,3000,5477,10000,20000]
ener=[10,35,50,71,100,173,300,548,1000,1732,3000,5477,10000,20000,100000]
ener=[10,35,50,71,100,173,300,548,1000,1732,3000,5477,10000,20000,100000]

;if theta eq 1 then str_theta='01' else str_theta=strtrim(theta,2)
;if phi eq 0 then str_phi='00' else str_phi=strtrim(phi,2)
Expand All @@ -52,15 +53,18 @@ ener=[10,35,50,71,100,173,300,548,1000,1732,3000,5477,10000,20000,100000]

openw,u,fileperandrew,width=1000,/get_lun
printf,u
printf,u,' E AeffG AeffL AeffS'
printf,u,' E AeffG AeffL AeffS AeffT'
printf,u

for i=0,n_elements(ener)-1 do begin
printf,u, ener[i], area_H(ae_path=ae_path, energ=ener[i], tip='G', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec), $
area_H(ae_path=ae_path, energ=ener[i], tip='L', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec), $
area_H(ae_path=ae_path, energ=ener[i], tip='S', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec)
area_H(ae_path=ae_path, energ=ener[i], tip='S', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec), $
area_H(ae_path=ae_path, energ=ener[i], tip='T', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec)

endfor


free_lun,u

endfor
Expand Down
85 changes: 85 additions & 0 deletions AGILECalib_H/eff_area/AGILE_write_all_sar_H0026.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; % AGILE_write_all_sar_H0026.pro %
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; Description:
; Effective area production - step 2
; Reading:
; - AG_GRID_G0017_S0001_H0007_template.sar.gz
; - <filter>_<theta>_<phi>.txt
; Calling:
; - readaeff_I0026.pro, interp_sar_I0026.pro, initheads.pro
; Output:
; AG_GRID_G0017_S${filter}${eventtype}_H0026.sar.gz
; ---------------------------------------
; Authors:
; A. Chen (INAF/IASF Mi)
; ---------------------------------------
; Modification history:
; 6/10/2023: copied from AGILE_write_all_sar_H0025.pro (V. Fioretti)
; 6/10/2023: H0026 and T class added (V. Fioretti)



@readaeff_I0026
@interp_sar_I0026

sar_path = GETENV('CALIB_AE_RSP')
sar_path = sar_path+'/sar'

; .sar.gz path keyword (0 = Default, 1 = enter new path)
sar_path_key = 0

read, sar_path_key, PROMPT = '% - .sar.gz directory [0 = $CALIB_AE_RSP/sar, 1 = new directory]:'
if sar_path_key EQ 1 then read, sar_path, PROMPT = '% - .sar.gz directory (e.g. /home):'

ae_path = GETENV('CALIB_AE_RSP')
ae_path = ae_path+'/aref'
; .ae path keyword (0 = Default, 1 = enter new path)
ae_path_key = 0

read, ae_path_key, PROMPT = '% - .ae directory [0 = $CALIB_AE_RSP/aref, 1 = new directory]:'
if ae_path_key EQ 1 then read, ae_path, PROMPT = '% - .ae directory (e.g. /home):'

template = sar_path+'/AG_GRID_G0017_S0001_H0007_template.sar.gz'

fileid = 'H0026'
factor = [[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]

table = mrdfits(template,0,head0)
flags = mrdfits(template,1,head1)
labels = mrdfits(template,2,head2)
initheads, head0, head1, head2, fileid

filters = ['F4','FM','FT3ab']
status = ['G','L','S', 'T']
thetas = ['01','30','35','45','50','60']
nthetas = n_elements(thetas)
phis = ['00','45']
nphis = n_elements(phis)

thetamap = intarr(n_elements(labels.polar_angle))
for itheta = 1, nthetas - 1 do thetamap = thetamap + (labels.polar_angle ge thetas[itheta])
thetamap = thetamap + (labels.polar_angle ge 70.0)

readaeff_I0025, ae_path, filters[0], thetas[0], phis[0], energies, areas
nenergies = n_elements(energies)
allareas = replicate(areas[0], nenergies, nthetas, nphis)

for ifilter = 0, n_elements(filters)-1 do $
for istatus = 0, n_elements(status)-1 do begin
stancon = 'S' + filters[ifilter] + status[istatus]
filename = sar_path+'/AG_GRID_G0017_' + stancon + '_' + fileid + '.sar'
sxaddpar, head0, 'STAN_CON', stancon
sxaddpar, head0, 'EXTEND', 'T'
for itheta = 0, nthetas - 1 do for iphi = 0, nphis - 1 do begin
readaeff_I0025, ae_path, filters[ifilter], thetas[itheta], phis[iphi], energies, areas
allareas[*, itheta, iphi] = areas
endfor
interp_sar_I0025, table, allareas, labels, energies, thetas, phis, istatus, factor = factor[*,ifilter]
mwrfits, table, filename, head0, /create
mwrfits, flags, filename, head1
mwrfits, labels, filename, head2
spawn, 'ftchecksum '+filename+' update=yes datasum=yes chatter=0'
spawn, 'gzip -f '+filename
endfor
end
3 changes: 2 additions & 1 deletion AGILECalib_H/eff_area/area_H.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
; Modification history:
; 13/11/2013: taking the /aref directory as input (V. Fioretti)
; 13/12/2015: new Fermi-style energy bands (A. Chen)

; 06/10/2023: T class added (V. Fioretti)


function area_H,ae_path=ae_path,theta=theta,phi=phi,energy=energy,tip=tip,spec=spec,filtro=filtro
Expand All @@ -41,6 +41,7 @@ energie=af(0,*)
if tip eq 'G' then aree=af(1,*)
if tip eq 'L' then aree=af(2,*)
if tip eq 'S' then aree=af(3,*)
if tip eq 'T' then aree=af(4,*)

;print,aree

Expand Down
38 changes: 38 additions & 0 deletions AGILECalib_H/eff_area/interp_sar_I0026.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; % interp_sar_I0026 %
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; ---------------------------------------
; Authors:
; A. Chen (INAF/IASF Mi)
; ---------------------------------------
; 6/10/2023: copied from interp_sar_I0025.pro (V. Fioretti)
; 6/10/2023: H0026 added (V. Fioretti)

pro interp_sar_I0026, table, allareas, labels, energies, thetas, phis, istatus, factor = factor

nthetas = n_elements(thetas)
nphis = n_elements(phis)
thetamap = intarr(n_elements(labels.polar_angle))
for itheta = 1, nthetas - 1 do thetamap = thetamap + (labels.polar_angle ge thetas[itheta])
thetamap = thetamap + (labels.polar_angle gt 90.0)
nenergies = n_elements(energies)
for ietab = 0, n_elements(labels.energy) - 1 do $
for ittab = 0, n_elements(labels.polar_angle) - 1 do $
for iaztab = 0, n_elements(labels.azimuth_angle) - 1 do begin
if thetamap[ittab] gt (nthetas - 1) then table[ietab, ittab, iaztab] = 0 $
else begin
t0 = 10.0d ^ interpol(alog10(allareas[*, thetamap[ittab], iaztab mod 2].(istatus)), alog10(energies), alog10(labels.energy[ietab]))
if thetamap[ittab]+1 gt (nthetas - 1) then begin
; print, t0
t1 = t0
endif else $
t1 = 10.0d ^ interpol(alog10(allareas[*, thetamap[ittab]+1, iaztab mod 2].(istatus)), alog10(energies), alog10(labels.energy[ietab]))
if (thetamap[ittab]+1 lt nthetas) then $
table[ietab, ittab, iaztab] = interpol([t0,t1], double(thetas[thetamap[ittab]:thetamap[ittab]+1]), labels.polar_angle[ittab]) $
else $
table[ietab, ittab, iaztab] = interpol([t0,t1], double([thetas[thetamap[ittab]],thetas[thetamap[ittab]]+40.0]), labels.polar_angle[ittab])
endelse
table[ietab, ittab, iaztab] = factor[ittab] * table[ietab, ittab, iaztab]
endfor

end
51 changes: 51 additions & 0 deletions AGILECalib_H/eff_area/readaeff_I0026.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; % readaeff_I0026.pro %
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; Description:
; Routine called by AGILE_write_all_sar_H0026.pro
; Reading:
; - <filter>_<theta>_<phi>.txt
; ---------------------------------------
; Authors:
; A. Chen (INAF/IASF Mi)
; ---------------------------------------
; Modification history:
; 6/10/2023: copied from readaeff_I0025.pro (V. Fioretti)
; 6/10/2023: H0026 and T class added (V. Fioretti)

pro readaeff_I0026, ae_path, filter, theta, phi, energies, area, directory = directory

if n_elements(directory) eq 0 then begin
directory=ae_path+'/'
filename = directory + filter + '_' + theta + '_' + phi + '_H.txt'
endif


e = 0.0d & ag = 0.0d & al = 0.0d & as = 0.0d & agls = 0.0d
earr = [0.0d,10.0d] & agarr = [0.0d,0.1d] & alarr = [0.0d,0.1d] & asarr = [0.0d,0.1d]& aglsarr = [0.0d,0.1d]
dummy = ''

openr, u, filename, /get_lun
for i = 0, 3 do readf, u, dummy
while not eof(u) do begin
readf, u, e, ag, al, as, agls
earr = [earr, e]
factor = 1.0
agarr = [agarr, ag / factor]
alarr = [alarr, al / factor]
asarr = [asarr, as / factor]
aglsarr = [aglsarr, agls / factor]
endwhile
free_lun, u
num = n_elements(earr)-1
energies = earr[1:num]
area = replicate({G: 0.0d, L:0.0d, S:0.0d, T: 0.0d}, num)
area.G = agarr[1:num]
area.L = alarr[1:num]
area.S = asarr[1:num]
area.T = aglsarr[1:num]


end


12 changes: 9 additions & 3 deletions AGILECalib_H/resp_ae_BAND/aeffi_H.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
; Modification history:
; 24/10/2013: JPG removed, saving output in postscript (V. Fioretti)
; 13/12/2015: new Fermi-style energy bands (A. Chen)
; 03/10/2023: T class added (V. Fioretti)

pro aeffi_H,ee, a, run, fil, inde, bol

Expand All @@ -36,11 +37,15 @@ pro aeffi_H,ee, a, run, fil, inde, bol
wg=where((ee.evstatus eq 'G') eq bol)
wl=where((ee.evstatus eq 'L') eq bol)
ws=where((ee.evstatus eq 'S') eq bol)
wgls = where(((ee.evstatus eq 'G') eq bol) or ((ee.evstatus eq 'L') eq bol) or ((ee.evstatus eq 'S') or bol))

;w31=where((ee31.evstatus eq tip) eq bol)

cag=canali_H(a(1,wg)*1000)
cal=canali_H(a(1,wl)*1000)
cas=canali_H(a(1,ws)*1000)
cagls=canali_H(a(1,wgls)*1000)

;ca31=canali(a31(1,w31)*1000)

;canal=[10.,35,50,71,100,141,200,283,400,632,1000,1732,3000,5477,10000,20000,100000]
Expand Down Expand Up @@ -69,20 +74,21 @@ TVLCT, 255 * RED, 255 * GREEN, 255 * BLUE

plot_oo,er,smooth(cag/ff,2) $
,psym=-3,yrange=[1,1000.],xrange=[10,100000.],xstyle=1,ystyle=1 $
,xtitle='Energy [MeV]',ytitle='Effective Area [cm!u2!n]',title='black:G, blue:L, red:S'
,xtitle='Energy [MeV]',ytitle='Effective Area [cm!u2!n]',title='black:G, blue:L, red:S, green:T'

oplot,er,smooth(cal/ff,2),psym=-3,color=1, thick=3
oplot,er,smooth(cas/ff,2),psym=-3,color=2, thick=3
;oplot,er,smooth(ca31/ff,2),psym=-6,color=verde
oplot,er,smooth(cag/ff,2),psym=-3,color=0, thick=3

oplot,er,smooth(cagls/ff,2),psym=-3,color=3, thick=3

;legend,['F4','F2','FT3-0','FT3-1'],color=[nero,blu,rosso,verde],linestyle=[0,0,0,0],/bot,/rig

fits_write,run+'_'+fil+'_H.ae',[ transpose(er[0:numchannels-1]), $
transpose(smooth(cag/ff,2)), $
transpose(smooth(cal/ff,2)), $
transpose(smooth(cas/ff,2)) ]
transpose(smooth(cas/ff,2)), $
transpose(smooth(cagls/ff,2)) ]



Expand Down
8 changes: 6 additions & 2 deletions AGILECalib_H/resp_ae_BAND/maris_H.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
; A. Giuliani, A. Chen (INAF/IASF Mi)
; ---------------------------------------
; 13/12/2015: new Fermi-style energy bands (A. Chen)

; 03/10/2023: T class added (V. Fioretti)



Expand All @@ -19,7 +19,7 @@ pro maris_H,ee,a,the,phi,run,fil


tipo=['G','L','S']
mmat=fltarr(3,14,14)
mmat=fltarr(4,14,14)

for j=0,2 do begin

Expand All @@ -29,6 +29,10 @@ for j=0,2 do begin

endfor

wc=where((ee.evstatus eq tipo(0)) or (ee.evstatus eq tipo(1)) or (ee.evstatus eq tipo(2)))
mat=matmake14(a(1,wc)*1000,ee(wc).energy)
mmat(3,*,*)=mat

;map,total(mmat(0,*,*),1),/scl

fits_write,run+'_'+fil+'_H.rsp',mmat
Expand Down
6 changes: 4 additions & 2 deletions eff_area/AGILE_mksar_loop.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
; Modification history:
; 13/11/2013: selecting the /aref directory (V. Fioretti)
; 6/11/2015: loading the environment variable (V. Fioretti)
; 6/10/2023: T class added (V. Fioretti)

ae_path = GETENV('CALIB_AE_RSP')
ae_path = ae_path+'/aref'
Expand Down Expand Up @@ -50,13 +51,14 @@ for t=0, nthetas-1 do begin

openw,u,fileperandrew,width=1000,/get_lun
printf,u
printf,u,' E AeffG AeffL AeffS'
printf,u,' E AeffG AeffL AeffS AeffT'
printf,u

for i=0,n_elements(ener)-1 do begin
printf,u, ener[i], area(ae_path=ae_path, energ=ener[i], tip='G', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec), $
area(ae_path=ae_path, energ=ener[i], tip='L', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec), $
area(ae_path=ae_path, energ=ener[i], tip='S', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec)
area(ae_path=ae_path, energ=ener[i], tip='S', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec), $
area(ae_path=ae_path, energ=ener[i], tip='T', theta=fix(str_theta[t]), phi=phi, filtro=filtro[f], spec=spec)

endfor
free_lun,u
Expand Down
Loading