/
config.rst
463 lines (345 loc) · 12.8 KB
/
config.rst
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
.. _config:
Configuration
=============
This page describes the configuration management scheme used within
the Fermipy package and documents the configuration parameters
that can be set in the configuration file.
##################################
Class Configuration
##################################
Classes in the Fermipy package own a configuration state dictionary
that is initialized when the class instance is created. Elements of
the configuration dictionary can be scalars (str, int, float) or
dictionaries containing groups of parameters. The settings in this
dictionary are used to control the runtime behavior of the class.
When creating a class instance, the configuration is initialized by
passing either a configuration dictionary or configuration file path
to the class constructor. Keyword arguments can be passed to the
constructor to override configuration parameters in the input
dictionary. In the following example the *config* dictionary defines
values for the parameters *emin* and *emax*. By passing a dictionary
for the *selection* keyword argument, the value of *emax* in the
keyword argument (10000) overrides the value of *emax* in the input
dictionary.
.. code-block:: python
config = {
'selection' : { 'emin' : 100,
'emax' : 1000 }
}
gta = GTAnalysis(config,selection={'emax' : 10000})
The first argument can also be the path to a YAML configuration file
rather than a dictionary:
.. code-block:: python
gta = GTAnalysis('config.yaml',selection={'emax' : 10000})
##################################
Configuration File
##################################
Fermipy uses `YAML <http://yaml.org/>`_ files to read and write its
configuration in a persistent format. The configuration file has a
hierarchical structure that groups parameters into dictionaries that
are keyed to a section name (*data*, *binning*, etc.).
.. code-block:: yaml
:caption: Sample Configuration
data:
evfile : ft1.lst
scfile : ft2.fits
ltfile : ltcube.fits
binning:
roiwidth : 10.0
binsz : 0.1
binsperdec : 8
selection :
emin : 100
emax : 316227.76
zmax : 90
evclass : 128
evtype : 3
tmin : 239557414
tmax : 428903014
filter : null
target : 'mkn421'
gtlike:
edisp : True
irfs : 'P8R2_SOURCE_V6'
edisp_disable : ['isodiff','galdiff']
model:
src_roiwidth : 15.0
galdiff : '$FERMI_DIFFUSE_DIR/gll_iem_v06.fits'
isodiff : 'iso_P8R2_SOURCE_V6_v06.txt'
catalogs : ['3FGL']
The configuration file has the same structure as the configuration
dictionary such that one can read/write configurations using the
load/dump methods of the yaml module:
.. code-block:: python
import yaml
# Load a configuration
config = yaml.load(open('config.yaml'))
# Update a parameter and write a new configuration
config['selection']['emin'] = 1000.
yaml.dump(config, open('new_config.yaml','w'))
Most of the configuration parameters are optional and if not set
explicitly in the configuration file will be set to a default value.
The parameters that can be set in each section are described below.
.. _config_binning:
binning
-------
Options in the *binning* section control the spatial and spectral binning of the data.
.. code-block:: yaml
:caption: Sample *binning* Configuration
binning:
# Binning
roiwidth : 10.0
npix : null
binsz : 0.1 # spatial bin size in deg
binsperdec : 8 # nb energy bins per decade
projtype : WCS
.. csv-table:: *binning* Options
:header: Option, Default, Description
:file: config/binning.csv
:delim: tab
:widths: 10,10,80
.. _config_components:
components
----------
The *components* section can be used to define analysis configurations
for independent subselections of the data. Each subselection will
have its own binned likelihood instance that is combined in a global
likelihood function for the ROI (implemented with the SummedLikelihood
class in pyLikelihood). The *components* section is optional and when
set to null (the default) only a single likelihood component will be
created with the parameters of the root analysis configuration.
The component section is defined as a list of dictionaries where each
element sets analysis parameters for a different subcomponent of the
analysis. The component configurations follow the same structure and
accept the same parameters as the root analysis configuration.
Parameters not defined in a given element will default to the values
set in the root analysis configuration.
The following example illustrates how to define a Front/Back analysis
with two components. Files associated to each component will be given
a suffix according to their order in the list (e.g. file_00.fits,
file_01.fits, etc.).
.. code-block:: yaml
# Component section for Front/Back analysis
- { selection : { evtype : 1 } } # Front
- { selection : { evtype : 2 } } # Back
.. _config_data:
data
----
The *data* section defines the input data files for the analysis (FT1,
FT2, and livetime cube). ``evfile`` and ``scfile`` can either be
individual files or group of files. The optional ``ltcube`` option can
be used to choose a pre-generated livetime cube. If ``ltcube`` is
null a livetime cube will be generated at runtime with ``gtltcube``.
.. code-block:: yaml
:caption: Sample *data* Configuration
data :
evfile : ft1.lst
scfile : ft2.fits
ltcube : null
.. csv-table:: *data* Options
:header: Option, Default, Description
:file: config/data.csv
:delim: tab
:widths: 10,10,80
.. _config_extension:
extension
---------
The options in *extension* control the default behavior of the
`~fermipy.gtanalysis.GTAnalysis.extension` method. For more information
about using this method see the :ref:`extension` page.
.. csv-table:: *extension* Options
:header: Option, Default, Description
:file: config/extension.csv
:delim: tab
:widths: 10,10,80
.. _config_fileio:
fileio
------
The *fileio* section collects options related to file bookkeeping.
The ``outdir`` option sets the root directory of the analysis instance
where all output files will be written. If ``outdir`` is null then the
output directory will be automatically set to the directory in which
the configuration file is located. Enabling the ``usescratch`` option
will stage all output data files to a temporary scratch directory
created under ``scratchdir``.
.. code-block:: yaml
:caption: Sample *fileio* Configuration
fileio:
outdir : null
logfile : null
usescratch : False
scratchdir : '/scratch'
.. csv-table:: *fileio* Options
:header: Option, Default, Description
:file: config/fileio.csv
:delim: tab
:widths: 10,10,80
.. _config_gtlike:
gtlike
------
Options in the *gtlike* section control the setup of the likelihood
analysis include the IRF name (``irfs``).
.. csv-table:: *gtlike* Options
:header: Option, Default, Description
:file: config/gtlike.csv
:delim: tab
:widths: 10,10,80
.. _config_lightcurve:
lightcurve
----------
The options in *lightcurve* control the default behavior of the
`~fermipy.gtanalysis.GTAnalysis.lightcurve` method. For more information
about using this method see the :ref:`lightcurve` page.
.. csv-table:: *lightcurve* Options
:header: Option, Default, Description
:file: config/lightcurve.csv
:delim: tab
:widths: 10,10,80
.. _config_model:
model
-----
The *model* section collects options that control the inclusion of
point-source and diffuse components in the model. ``galdiff`` and
``isodiff`` set the templates for the Galactic IEM and isotropic
diffuse respectively. ``catalogs`` defines a list of catalogs that
will be merged to form a master analysis catalog from which sources
will be drawn. Valid entries in this list can be FITS files or XML
model files. ``sources`` can be used to insert additional
point-source or extended components beyond those defined in the master
catalog. ``src_radius`` and ``src_roiwidth`` set the maximum distance
from the ROI center at which sources in the master catalog will be
included in the ROI model.
.. code-block:: yaml
:caption: Sample *model* Configuration
model :
# Diffuse components
galdiff : '$FERMI_DIR/refdata/fermi/galdiffuse/gll_iem_v06.fits'
isodiff : '$FERMI_DIR/refdata/fermi/galdiffuse/iso_P8R2_SOURCE_V6_v06.txt'
# List of catalogs to be used in the model.
catalogs :
- '3FGL'
- 'extra_sources.xml'
sources :
- { 'name' : 'SourceA', 'ra' : 60.0, 'dec' : 30.0, 'SpectrumType' : PowerLaw }
- { 'name' : 'SourceB', 'ra' : 58.0, 'dec' : 35.0, 'SpectrumType' : PowerLaw }
# Include catalog sources within this distance from the ROI center
src_radius : null
# Include catalog sources within a box of width roisrc.
src_roiwidth : 15.0
.. csv-table:: *model* Options
:header: Option, Default, Description
:file: config/model.csv
:delim: tab
:widths: 10,10,80
.. _config_optimizer:
optimizer
---------
.. csv-table:: *optimizer* Options
:header: Option, Default, Description
:file: config/optimizer.csv
:delim: tab
:widths: 10,10,80
.. _config_plotting:
plotting
--------
.. csv-table:: *plotting* Options
:header: Option, Default, Description
:file: config/plotting.csv
:delim: tab
:widths: 10,10,80
.. _config_residmap:
residmap
--------
The options in *residmap* control the default behavior of the
`~fermipy.gtanalysis.GTAnalysis.residmap` method. For more
information about using this method see the :ref:`residmap` page.
.. csv-table:: *residmap* Options
:header: Option, Default, Description
:file: config/residmap.csv
:delim: tab
:widths: 10,10,80
.. _config_roiopt:
roiopt
------
The options in *roiopt* control the default behavior of the
`~fermipy.gtanalysis.GTAnalysis.optimize` method. For more
information about using this method see the :ref:`fitting` page.
.. csv-table:: *roiopt* Options
:header: Option, Default, Description
:file: config/roiopt.csv
:delim: tab
:widths: 10,10,80
.. _config_sed:
sed
---
The options in *sed* control the default behavior of the
`~fermipy.gtanalysis.GTAnalysis.sed` method. For more information
about using this method see the :ref:`sed` page.
.. csv-table:: *sed* Options
:header: Option, Default, Description
:file: config/sed.csv
:delim: tab
:widths: 10,10,80
.. _config_selection:
selection
---------
The *selection* section collects parameters related to the data
selection and target definition. The majority of the parameters in
this section are arguments to *gtselect* and *gtmktime*. The ROI
center can be set with the *target* parameter by providing the name of
a source defined in one of the input catalogs (defined in the *model*
section). Alternatively the ROI center can be defined by giving
explicit sky coordinates with *ra* and *dec* or *glon* and *glat*.
.. code-block:: yaml
selection:
# gtselect parameters
emin : 100
emax : 100000
zmax : 90
evclass : 128
evtype : 3
tmin : 239557414
tmax : 428903014
# gtmktime parameters
filter : 'DATA_QUAL>0 && LAT_CONFIG==1'
roicut : 'no'
# Set the ROI center to the coordinates of this source
target : 'mkn421'
.. csv-table:: *selection* Options
:header: Option, Default, Description
:file: config/selection.csv
:delim: tab
:widths: 10,10,80
.. _config_sourcefind:
sourcefind
----------
The options in *sourcefind* control the default behavior of the
`~fermipy.gtanalysis.GTAnalysis.find_sources` method. For more information
about using this method see the :ref:`findsources` page.
.. csv-table:: *sourcefind* Options
:header: Option, Default, Description
:file: config/sourcefind.csv
:delim: tab
:widths: 10,10,80
.. _config_tsmap:
tsmap
-----
The options in *tsmap* control the default behavior of the
`~fermipy.gtanalysis.GTAnalysis.tsmap` method. For more information
about using this method see the :ref:`tsmap` page.
.. csv-table:: *tsmap* Options
:header: Option, Default, Description
:file: config/tsmap.csv
:delim: tab
:widths: 10,10,80
.. _config_tscube:
tscube
------
The options in *tscube* control the default behavior of the
`~fermipy.gtanalysis.GTAnalysis.tscube` method. For more information
about using this method see the :ref:`tscube` page.
.. csv-table:: *tscube* Options
:header: Option, Default, Description
:file: config/tscube.csv
:delim: tab
:widths: 10,10,80