/
toy_disk.py
73 lines (58 loc) · 2.41 KB
/
toy_disk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
#
# Copyright (C) 2018, the ixpeobssim team.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
This is an extended source with the morphology of a uniform disk and a simple
power-law spectrum.
The most interesting feature of this toy model is possibly the fact that the
disk is larger than the field of view and therefore, if one runs a long-enough
simulation and creates a binned map out of the event file, the vignetting of
the optics and the footprint of the three focal-plane detector units become
evident.
.. image:: figures/obssim/toy_disk_count_map.png
"""
from __future__ import print_function, division
import numpy
from ixpeobssim.config import file_path_to_model_name
from ixpeobssim.utils.matplotlib_ import plt, setup_gca
from ixpeobssim.srcmodel.roi import xUniformDisk, xROIModel
from ixpeobssim.srcmodel.spectrum import power_law
from ixpeobssim.srcmodel.polarization import constant
from ixpeobssim.utils.units_ import arcmin_to_degrees
from ixpeobssim.utils.fmtaxis import fmtaxis
__model__ = file_path_to_model_name(__file__)
ra, dec = 45., 45.
radius = arcmin_to_degrees(10.)
pl_norm = 1.
pl_index = 2.
spec = power_law(pl_norm, pl_index)
pol_deg = constant(0.5)
pol_ang = constant(numpy.radians(65.))
src = xUniformDisk('Uniform disk', ra, dec, radius, spec, pol_deg, pol_ang)
ROI_MODEL = xROIModel(ra, dec, src)
def display(emin=1., emax=12.):
"""Display the source model.
"""
energy = numpy.linspace(emin, emax, 100)
# Energy spectrum
plt.figure('%s spectrum' % __model__)
plt.plot(energy, spec(energy))
setup_gca(xmin=emin, xmax=emax, ymin=spec(emax), logx=True, logy=True,
grids=True, **fmtaxis.spec)
if __name__ == '__main__':
from ixpeobssim.config import bootstrap_display
bootstrap_display()