1 |
#!/usr/bin/env ruby |
2 |
# |
3 |
# kingparamemos.rb: |
4 |
# Construct ASCII data files with King-PSF model parameters as a function |
5 |
# of E [eV] and theta [rad]; there are two parameter rc [arcsec] (King |
6 |
# core radius) and alpha [] (King slope); rc+alpha are fitted to |
7 |
# linear function in E/theta in [1]; these functions are evaluated |
8 |
# on a rectangular E/theta grid; the produced output files |
9 |
# _fm1_king_params.dat/_fm2_king_params.dat are referred to in deceit |
10 |
# template emos_king.dct for creating the XPSF CCF constituent for |
11 |
# EMOS1/EMOS2. |
12 |
# |
13 |
# USAGE: |
14 |
# ./kingparamemos.rb |
15 |
# |
16 |
# REFERENCES: |
17 |
# [1]: "In Flight Calibration of the PSF for the MOS1 and MOS2 cameras", |
18 |
# S. Ghizzardi, EPIC-MCT-TN-011 |
19 |
# |
20 |
kingParam = [ [ [ 5.074, -0.236, 0.002, -0.0180 ], # rc EMOS1 |
21 |
[ 1.472, -0.010, -0.001, -0.0016 ] ], # alpha EMOS1 |
22 |
[ [ 4.759, -0.203, 0.014, -0.0229 ], # rc EMOS2 |
23 |
[ 1.411, -0.005, -0.001, -0.0002 ] ] ] # alpha EMOS2 |
24 |
|
25 |
class KingParam |
26 |
def initialize(parmvec) |
27 |
@pv = parmvec |
28 |
end |
29 |
|
30 |
def rc(e, theta) |
31 |
# e [keV] / theta ['] |
32 |
@pv[0][0] + @pv[0][1]*e + @pv[0][2]*theta + @pv[0][3]*e*theta |
33 |
end |
34 |
|
35 |
def alpha(e, theta) |
36 |
@pv[1][0] + @pv[1][1]*e + @pv[1][2]*theta + @pv[1][3]*e*theta |
37 |
end |
38 |
end |
39 |
|
40 |
2.times { |unit| |
41 |
kp = KingParam.new(kingParam[unit]) |
42 |
datFile = File.new("_fm" + (unit+1).to_s + "_king_params.dat", "w") |
43 |
datFile<<"# This data file was automatically generated by `#{File.basename($0)}'\n" |
44 |
datFile<<"# Do not edit - rerun script if needed!\n" |
45 |
[ 0, 100, 1500, 3000, 4500, 6000, 7500, 10000, 12000, 13500 ].each { |e| |
46 |
(0..7).each { |theta_half| |
47 |
datFile<<e<<" : " |
48 |
datFile<<2*theta_half/60.0*Math::PI/180.0<<" : " # [arcsec]->[rad] |
49 |
datFile<<kp.rc(e/1000.0, 2*theta_half)<<' ' |
50 |
datFile<<kp.alpha(e/1000.0, 2*theta_half)<<"\n" |
51 |
} |
52 |
} |
53 |
puts("Created #{datFile.path}") |
54 |
} |
55 |
|
56 |
|
57 |
|