howto_model_handling_python.ipynb
23.5 KB
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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to handle models from Python?"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"<div align=\"right\"><a href=\"../../../_downloads/howto_model_handling_python.ipynb\" download=\"howto_model_handling_python.ipynb\"><img src=\"../../../_static/download-notebook.jpg\" alt=\"Download Notebook\" height=\"40\"></a></div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this tutorial you will learn how to handle models from Python. This is done using the GammaLib classes `GModels`, `GModel`, `GModelSpatial`, `GModelSpectral`, and `GModelTemporal`. You can find all the information on the GammaLib classes in the [Doxygen documentation](http://cta.irap.omp.eu/gammalib-devel/doxygen/index.html).\n",
"\n",
"In GammaLib there are some conventions about units. If not otherwise specified:\n",
"\n",
"- energies are in MeV\n",
"\n",
"- photon fluxes are in photons/cm2/s\n",
"\n",
"- differential photon fluxes are in photons/cm2/s/MeV\n",
"\n",
"- energy fluxes are in erg/cm2/s\n",
"\n",
"To start we import the gammalib Python module."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import gammalib"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Reading and updating an existing XML model\n",
"\n",
"### Opening an XML model and parsing its content\n",
"\n",
"An existing XML model can be read into a model container (`GModels` class)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"container = gammalib.GModels('$CTOOLS/share/models/crab.xml')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The easiest way to inspect a model container is by using the function `print` that will display in the terminal its entire content."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"=== GModels ===\n",
" Number of models ..........: 2\n",
" Number of parameters ......: 10\n",
"=== GModelSky ===\n",
" Name ......................: Crab\n",
" Instruments ...............: all\n",
" Observation identifiers ...: all\n",
" Model type ................: PointSource\n",
" Model components ..........: \"PointSource\" * \"PowerLaw\" * \"Constant\"\n",
" Number of parameters ......: 6\n",
" Number of spatial par's ...: 2\n",
" RA .......................: 83.6331 [-360,360] deg (fixed,scale=1)\n",
" DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1)\n",
" Number of spectral par's ..: 3\n",
" Prefactor ................: 5.7e-16 +/- 0 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)\n",
" Index ....................: -2.48 +/- 0 [-0,-5] (free,scale=-1,gradient)\n",
" PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient)\n",
" Number of temporal par's ..: 1\n",
" Normalization ............: 1 (relative value) (fixed,scale=1,gradient)\n",
" Number of scale par's .....: 0\n",
"=== GCTAModelIrfBackground ===\n",
" Name ......................: CTABackgroundModel\n",
" Instruments ...............: CTA\n",
" Observation identifiers ...: all\n",
" Model type ................: \"PowerLaw\" * \"Constant\"\n",
" Number of parameters ......: 4\n",
" Number of spectral par's ..: 3\n",
" Prefactor ................: 1 +/- 0 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient)\n",
" Index ....................: 0 +/- 0 [-5,5] (free,scale=1,gradient)\n",
" PivotEnergy ..............: 1000000 [10000,1000000000] MeV (fixed,scale=1000000,gradient)\n",
" Number of temporal par's ..: 1\n",
" Normalization ............: 1 (relative value) (fixed,scale=1,gradient)\n"
]
}
],
"source": [
"print(container)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The model container contains two models, for a total of ten parameters. The first model is a sky model named `Crab`, the second a background model. Each model has a spatial, a spectral, and a temporal component. Each model component has parameters. For each parameter you have a value, an error (in our example it is always zero because no fit to the data was done yet), an allowed value range for fitting the parameter to data, and, whenever relevant, units. In the parenthesis you can se if the parameter is free or fixed, and some more technical information, i.e, if the model has an analytical gradient w.r.t. this parameter implemented (can be fit to data quickly under certain conditions), and if internally the parameter is scaled (parameters should be scaled so that value/scale is of order unity for a more efficient handling by the optimiser during a fit to the data). Furthemore each model can be restricted to a specific instrument or observation. In the example the only restriction is that the CTA background model is used only for CTA data (`Instruments ...............: CTA`).\n",
"\n",
"Model containers can be parsed using the model and parameter names if they are know to you. Below for example we directly access the properties of the Prefactor for the spectral model of the Crab source."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"value 5.7e-16\n",
"error 0.0\n",
"min value 1e-23\n",
"max value 1e-13\n",
"is free? True\n"
]
}
],
"source": [
"print('value', container['Crab']['Prefactor'].value())\n",
"print('error', container['Crab']['Prefactor'].error())\n",
"print('min value', container['Crab']['Prefactor'].min())\n",
"print('max value', container['Crab']['Prefactor'].max())\n",
"print('is free?', container['Crab']['Prefactor'].is_free())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can access specific model components through the `spatial`, `spectral`, and `temporal` methods, for example:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"=== GModelSpectralPlaw ===\n",
" Number of parameters ......: 3\n",
" Prefactor ................: 5.7e-16 +/- 0 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)\n",
" Index ....................: -2.48 +/- 0 [-0,-5] (free,scale=-1,gradient)\n",
" PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient)\n"
]
}
],
"source": [
"print(container['Crab'].spectral())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also blindly parse models and model parameters. Below we get names and values for the spectral parameters of all the models in the container."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"###### Name: Crab\n",
"Prefactor = 5.7e-16\n",
"Index = -2.48\n",
"PivotEnergy = 300000.0\n",
"###### Name: CTABackgroundModel\n",
"Prefactor = 1.0\n",
"Index = 0.0\n",
"PivotEnergy = 1000000.0\n"
]
}
],
"source": [
"for s in range(container.size()):\n",
" model = container[s]\n",
" print('###### Name:', model.name())\n",
" for i in range(model.spectral().size()):\n",
" param = model.spectral()[i]\n",
" print(param.name(),'=',param.value())\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally there are convenience methods to compute for a model component the flux and energy flux over an energy interval (spectral components), and the flux within a circular region (spatial models). "
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Crab photon flux: 1.8803968833520812e-11 cm-2 s-1\n",
"Crab energy flux: 6.426073324618545e-11 erg cm-2 s-1\n"
]
}
],
"source": [
"# calculate Crab spectral model flux in the 1-10 TeV energy range\n",
"\n",
"# define energy bounds\n",
"emin = gammalib.GEnergy(1.,'TeV')\n",
"emax = gammalib.GEnergy(10.,'TeV')\n",
"\n",
"# extract model from container'\n",
"crab = container['Crab']\n",
"\n",
"# photon flux (cm-2 s-1)\n",
"flux = crab.spectral().flux(emin,emax)\n",
"print('Crab photon flux:', flux, 'cm-2 s-1')\n",
"\n",
"# energy flux (cm-2 s-1)\n",
"eflux = crab.spectral().eflux(emin,emax)\n",
"print('Crab energy flux', eflux, 'erg cm-2 s-1')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Crab flux in region: 1.0 (relative value)\n"
]
}
],
"source": [
"# calculate Crab spatial model flux in 0.2 deg region centred on the source\n",
"\n",
"# region centre = source position\n",
"centre = crab.spatial().dir()\n",
"\n",
"# circular region\n",
"reg = gammalib.GSkyRegionCircle(centre,0.2)\n",
"\n",
"# flux in the circular region (relative value)\n",
"flux = crab.spatial().flux(reg)\n",
"print('Crab flux in region:',flux,'(relative value)')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Spatial models can be normalised to unity. This is always the case for analytical models including point sources. Therefore we do expect to have a spatial model flux of 1 for a region encompassing the source."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Updating a model\n",
"\n",
"Once you have a model container you can update its parameters, change model components and attributes, delete existing models or append new ones.\n",
"\n",
"In the first example we change the position of the Crab source by 0.1 deg toward positive R.A. and we free the spatial parameters, but we restrict the allowed range around the known position."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"=== GModelSky ===\n",
" Name ......................: Crab\n",
" Instruments ...............: all\n",
" Observation identifiers ...: all\n",
" Model type ................: PointSource\n",
" Model components ..........: \"PointSource\" * \"PowerLaw\" * \"Constant\"\n",
" Number of parameters ......: 6\n",
" Number of spatial par's ...: 2\n",
" RA .......................: 83.7331 +/- 0 [79,89] deg (free,scale=1)\n",
" DEC ......................: 22.0145 +/- 0 [21.5,22.5] deg (free,scale=1)\n",
" Number of spectral par's ..: 3\n",
" Prefactor ................: 5.7e-16 +/- 0 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient)\n",
" Index ....................: -2.48 +/- 0 [-0,-5] (free,scale=-1,gradient)\n",
" PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient)\n",
" Number of temporal par's ..: 1\n",
" Normalization ............: 1 (relative value) (fixed,scale=1,gradient)\n",
" Number of scale par's .....: 0\n"
]
}
],
"source": [
"# change R.A.\n",
"crab['RA'].value(crab['RA'].value() + .1)\n",
"# free spatial parameters\n",
"crab['RA'].free()\n",
"crab['DEC'].free()\n",
"# restric range\n",
"crab['RA'].min(79.)\n",
"crab['RA'].max(89.)\n",
"crab['DEC'].min(21.5)\n",
"crab['DEC'].max(22.5)\n",
"\n",
"# inspect model to verify changes\n",
"print(crab)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the second example we change the spectral model from a power law to an exponentially-cutoff power law, keeping the power law parameters to the original values, and adding a cutoff at 50 TeV."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"=== GModelSky ===\n",
" Name ......................: Crab\n",
" Instruments ...............: all\n",
" Observation identifiers ...: all\n",
" Model type ................: PointSource\n",
" Model components ..........: \"PointSource\" * \"ExponentialCutoffPowerLaw\" * \"Constant\"\n",
" Number of parameters ......: 7\n",
" Number of spatial par's ...: 2\n",
" RA .......................: 83.7331 +/- 0 [79,89] deg (free,scale=1)\n",
" DEC ......................: 22.0145 +/- 0 [21.5,22.5] deg (free,scale=1)\n",
" Number of spectral par's ..: 4\n",
" Prefactor ................: 5.7e-16 +/- 0 [0,infty[ ph/cm2/s/MeV (free,scale=1,gradient)\n",
" Index ....................: -2.48 +/- 0 [-10,10] (free,scale=1,gradient)\n",
" CutoffEnergy .............: 50000000 +/- 0 [0.1,infty[ MeV (free,scale=1,gradient)\n",
" PivotEnergy ..............: 300000 MeV (fixed,scale=1,gradient)\n",
" Number of temporal par's ..: 1\n",
" Normalization ............: 1 (relative value) (fixed,scale=1,gradient)\n",
" Number of scale par's .....: 0\n"
]
}
],
"source": [
"expplaw = gammalib.GModelSpectralExpPlaw()\n",
"expplaw['Prefactor'].value(crab['Prefactor'].value())\n",
"expplaw['Index'].value(crab['Index'].value())\n",
"expplaw['PivotEnergy'].value(crab['PivotEnergy'].value())\n",
"expplaw['CutoffEnergy'].value(50.e6) # value in MeV\n",
"crab.spectral(expplaw)\n",
"\n",
"# inspect model to verify changes\n",
"print(crab)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the last example we remove the IRF background model, and append a cube background model from another container."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"=== GModels ===\n",
" Number of models ..........: 2\n",
" Number of parameters ......: 11\n",
"=== GModelSky ===\n",
" Name ......................: Crab\n",
" Instruments ...............: all\n",
" Observation identifiers ...: all\n",
" Model type ................: PointSource\n",
" Model components ..........: \"PointSource\" * \"ExponentialCutoffPowerLaw\" * \"Constant\"\n",
" Number of parameters ......: 7\n",
" Number of spatial par's ...: 2\n",
" RA .......................: 83.7331 +/- 0 [79,89] deg (free,scale=1)\n",
" DEC ......................: 22.0145 +/- 0 [21.5,22.5] deg (free,scale=1)\n",
" Number of spectral par's ..: 4\n",
" Prefactor ................: 5.7e-16 +/- 0 [0,infty[ ph/cm2/s/MeV (free,scale=1,gradient)\n",
" Index ....................: -2.48 +/- 0 [-10,10] (free,scale=1,gradient)\n",
" CutoffEnergy .............: 50000000 +/- 0 [0.1,infty[ MeV (free,scale=1,gradient)\n",
" PivotEnergy ..............: 300000 MeV (fixed,scale=1,gradient)\n",
" Number of temporal par's ..: 1\n",
" Normalization ............: 1 (relative value) (fixed,scale=1,gradient)\n",
" Number of scale par's .....: 0\n",
"=== GCTAModelCubeBackground ===\n",
" Name ......................: Background\n",
" Instruments ...............: CTA\n",
" Observation identifiers ...: all\n",
" Model type ................: \"PowerLaw\" * \"Constant\"\n",
" Number of parameters ......: 4\n",
" Number of spectral par's ..: 3\n",
" Prefactor ................: 1 +/- 0 [0.01,100] ph/cm2/s/MeV (free,scale=1,gradient)\n",
" Index ....................: 0 +/- 0 [-5,5] (free,scale=1,gradient)\n",
" PivotEnergy ..............: 1000000 [10000,1000000000] MeV (fixed,scale=1000000,gradient)\n",
" Number of temporal par's ..: 1\n",
" Normalization ............: 1 (relative value) (fixed,scale=1,gradient)\n"
]
}
],
"source": [
"# remove existing background model\n",
"container.remove('CTABackgroundModel')\n",
"\n",
"# open example background cube model\n",
"bkgcube_container = gammalib.GModels('$CTOOLS/share/models/bkg_cube.xml')\n",
"\n",
"# append first model in new container to old container\n",
"container.append(bkgcube_container[0])\n",
"\n",
"# inspect model to verify changes\n",
"print(container)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Save model changes to an XML file\n",
"\n",
"You can use directly the model container in Python to pass it to ctools or cscripts, but you can also write it to an XML file."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"container.save('my_crab.xml')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Creating a new model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"New models can be created directly in Python. First, create a new empty model container."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"my_container = gammalib.GModels()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To create a new source we need to define at least spatial and spectral components (if not specified the temporal component is taken to be constants). Refer to the [Doxygen documentation](http://cta.irap.omp.eu/gammalib-devel/doxygen/index.html) for finding out all the models available in GammaLib and how to use them.\n",
"\n",
"We first create a Gaussian spatial component."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"# define source direction\n",
"srcdir = gammalib.GSkyDir()\n",
"# set R.A. and Dec\n",
"srcdir.radec_deg(54.,-19.)\n",
"\n",
"# Gaussian spatial component\n",
"spatial = gammalib.GModelSpatialRadialGauss(srcdir,0.5) # centre and radius in deg"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We create a power-law spectral component."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"# define pivot energy\n",
"pivot = gammalib.GEnergy(1,'TeV')\n",
"\n",
"# power law\n",
"spectral = gammalib.GModelSpectralPlaw(1.e-18,-2.5,pivot) # differential photon flux, index, pivot energy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We create the source and append it to the model container."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<gammalib.model.GModelSky; proxy of <Swig Object of type 'GModelSky *' at 0x11252dae0> >"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# create source\n",
"source = gammalib.GModelSky(spatial,spectral)\n",
"source.name('my_source')\n",
"\n",
"# append to container\n",
"my_container.append(source)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We also add a CTA IRF background model with power-law spectral correction."
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<gammalib.cta.GCTAModelIrfBackground; proxy of <Swig Object of type 'GCTAModelIrfBackground *' at 0x11252d960> >"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# spectral correction\n",
"spectral = gammalib.GModelSpectralPlaw(1, 0, gammalib.GEnergy(1, 'TeV'))\n",
"\n",
"# create background model\n",
"bkgmodel = gammalib.GCTAModelIrfBackground(spectral)\n",
"bkgmodel.name('Background')\n",
"bkgmodel.instruments('CTA')\n",
"\n",
"# append to container\n",
"my_container.append(bkgmodel)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We inspect the model we just created."
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"=== GModels ===\n",
" Number of models ..........: 2\n",
" Number of parameters ......: 11\n",
"=== GModelSky ===\n",
" Name ......................: my_source\n",
" Instruments ...............: all\n",
" Observation identifiers ...: all\n",
" Model type ................: ExtendedSource\n",
" Model components ..........: \"RadialGaussian\" * \"PowerLaw\" * \"Constant\"\n",
" Number of parameters ......: 7\n",
" Number of spatial par's ...: 3\n",
" RA .......................: 54 deg (fixed,scale=1)\n",
" DEC ......................: -19 deg (fixed,scale=1)\n",
" Sigma ....................: 0.5 +/- 0 [0.0002778,infty[ deg (free,scale=1)\n",
" Number of spectral par's ..: 3\n",
" Prefactor ................: 1e-18 +/- 0 [0,infty[ ph/cm2/s/MeV (free,scale=1e-18,gradient)\n",
" Index ....................: -2.5 +/- 0 [10,-10] (free,scale=-2.5,gradient)\n",
" PivotEnergy ..............: 1000000 MeV (fixed,scale=1000000,gradient)\n",
" Number of temporal par's ..: 1\n",
" Normalization ............: 1 (relative value) (fixed,scale=1,gradient)\n",
" Number of scale par's .....: 0\n",
"=== GCTAModelIrfBackground ===\n",
" Name ......................: Background\n",
" Instruments ...............: CTA\n",
" Observation identifiers ...: all\n",
" Model type ................: \"PowerLaw\" * \"Constant\"\n",
" Number of parameters ......: 4\n",
" Number of spectral par's ..: 3\n",
" Prefactor ................: 1 +/- 0 [0,infty[ ph/cm2/s/MeV (free,scale=1,gradient)\n",
" Index ....................: 0 +/- 0 [-10,10] (free,scale=1,gradient)\n",
" PivotEnergy ..............: 1000000 MeV (fixed,scale=1000000,gradient)\n",
" Number of temporal par's ..: 1\n",
" Normalization ............: 1 (relative value) (fixed,scale=1,gradient)\n"
]
}
],
"source": [
"print(my_container)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The container can be used in Python or written to disk in an XML file."
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"my_container.save('mymodel.xml')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}