Commit 6662e9a91c6be50bf003a1a0330b485893bd2d1b
1 parent
bd318829
Do some minor documentation adjustments
Showing
4 changed files
with
105 additions
and
108 deletions
doc/source/users/index.rst
doc/source/users/tutorials/beyond/combining-observations.ipynb
| ... | ... | @@ -101,16 +101,14 @@ |
| 101 | 101 | }, |
| 102 | 102 | "outputs": [], |
| 103 | 103 | "source": [ |
| 104 | - "import xml.etree.cElementTree as ET\n", | |
| 105 | - "\n", | |
| 106 | - "obslist = ET.Element(\"observation_list\", title=\"observation library\")\n", | |
| 104 | + "xml = gammalib.GXml()\n", | |
| 105 | + "obslist = xml.append('observation_list title=\"observation library\"')\n", | |
| 107 | 106 | "\n", |
| 108 | 107 | "for i in range(2):\n", |
| 109 | - " obs = ET.SubElement(obslist, \"observation\", name=\"Crab\", id=\"{:02d}\".format(i+1), instrument=\"CTA\")\n", | |
| 110 | - " ET.SubElement(obs, \"parameter\", name=\"EventList\", file=\"events{}.fits\".format(i+1))\n", | |
| 108 | + " obs = obslist.append('observation name=\"Crab\" id=\"%02d\" instrument=\"CTA\"' % (i+1))\n", | |
| 109 | + " obs.append('parameter name=\"EventList\" file=\"events%d.fits\"' % (i+1))\n", | |
| 111 | 110 | "\n", |
| 112 | - "tree = ET.ElementTree(obslist)\n", | |
| 113 | - "tree.write(\"obs.xml\",xml_declaration=True,encoding='UTF-8')" | |
| 111 | + "xml.save('obs.xml')" | |
| 114 | 112 | ] |
| 115 | 113 | }, |
| 116 | 114 | { | ... | ... |
doc/source/users/tutorials/quickstart/butterfly.rst
| ... | ... | @@ -42,7 +42,6 @@ default is set to 100. Below an excerpt of the first lines of the |
| 42 | 42 | 110917.48152624 6.81370736945431e-15 6.62965024227895e-15 6.99776449662967e-15 |
| 43 | 43 | 118850.222743702 5.73964152654309e-15 5.58918876927557e-15 5.89009428381061e-15 |
| 44 | 44 | 127350.308101666 4.83488401643174e-15 4.71191629605204e-15 4.95785173681143e-15 |
| 45 | - | |
| 46 | 45 | ... |
| 47 | 46 | |
| 48 | 47 | A graphical display of the results is shown below: | ... | ... |
doc/source/users/tutorials/quickstart/onoff.rst
| ... | ... | @@ -40,20 +40,20 @@ excluded from the background computation. |
| 40 | 40 | |
| 41 | 41 | .. code-block:: bash |
| 42 | 42 | |
| 43 | - $ csphagen | |
| 44 | - Input event list or observation definition XML file [obs.xml] events_edisp.fits | |
| 45 | - Calibration database [prod2] | |
| 46 | - Instrument response function [South_0.5h] | |
| 47 | - Binning algorithm (LIN|LOG|FILE) [LOG] | |
| 48 | - Lower energy limit (TeV) [0.1] | |
| 49 | - Upper energy limit (TeV) [100.0] | |
| 50 | - Number of energy bins [120] 30 | |
| 51 | - Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL] | |
| 52 | - Right Ascension of source region centre (deg) (0-360) [83.63] | |
| 53 | - Declination of source region centre (deg) (-90-90) [22.01] | |
| 54 | - Radius of source region circle (deg) (0-180) [0.2] | |
| 55 | - Stack multiple observations into single PHA, ARF and RMF files? [no] | |
| 56 | - Output observation definition XML file [onoff_obs.xml] | |
| 43 | + $ csphagen | |
| 44 | + Input event list or observation definition XML file [obs.xml] events_edisp.fits | |
| 45 | + Calibration database [prod2] | |
| 46 | + Instrument response function [South_0.5h] | |
| 47 | + Binning algorithm (LIN|LOG|FILE) [LOG] | |
| 48 | + Lower energy limit (TeV) [0.1] | |
| 49 | + Upper energy limit (TeV) [100.0] | |
| 50 | + Number of energy bins [120] 30 | |
| 51 | + Coordinate system (CEL - celestial, GAL - galactic) (CEL|GAL) [CEL] | |
| 52 | + Right Ascension of source region centre (deg) (0-360) [83.63] | |
| 53 | + Declination of source region centre (deg) (-90-90) [22.01] | |
| 54 | + Radius of source region circle (deg) (0-180) [0.2] | |
| 55 | + Stack multiple observations into single PHA, ARF and RMF files? [no] | |
| 56 | + Output observation definition XML file [onoff_obs.xml] | |
| 57 | 57 | |
| 58 | 58 | .. note:: |
| 59 | 59 | |
| ... | ... | @@ -76,15 +76,15 @@ contains a single On/Off observation. |
| 76 | 76 | |
| 77 | 77 | .. code-block:: bash |
| 78 | 78 | |
| 79 | - <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
| 80 | - <observation_list title="observation list"> | |
| 81 | - <observation name="" id="" instrument="CTAOnOff" statistic="cstat"> | |
| 82 | - <parameter name="Pha_on" file="onoff_pha_on.fits" /> | |
| 83 | - <parameter name="Pha_off" file="onoff_pha_off.fits" /> | |
| 84 | - <parameter name="Arf" file="onoff_arf.fits" /> | |
| 85 | - <parameter name="Rmf" file="onoff_rmf.fits" /> | |
| 86 | - </observation> | |
| 87 | - </observation_list> | |
| 79 | + <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
| 80 | + <observation_list title="observation list"> | |
| 81 | + <observation name="" id="" instrument="CTAOnOff" statistic="cstat"> | |
| 82 | + <parameter name="Pha_on" file="onoff_pha_on.fits" /> | |
| 83 | + <parameter name="Pha_off" file="onoff_pha_off.fits" /> | |
| 84 | + <parameter name="Arf" file="onoff_arf.fits" /> | |
| 85 | + <parameter name="Rmf" file="onoff_rmf.fits" /> | |
| 86 | + </observation> | |
| 87 | + </observation_list> | |
| 88 | 88 | |
| 89 | 89 | The observation entails four FITS files. ``onoff_pha_on.fits`` and |
| 90 | 90 | ``onoff_pha_off.fits`` contain the On and Off spectra, respectively. |
| ... | ... | @@ -126,27 +126,27 @@ background component that we are dealing with a ``CTAOnOff`` analysis. |
| 126 | 126 | |
| 127 | 127 | .. code-block:: bash |
| 128 | 128 | |
| 129 | - <?xml version="1.0" standalone="no"?> | |
| 130 | - <source_library title="source library"> | |
| 131 | - <source name="Crab" type="PointSource"> | |
| 132 | - <spectrum type="PowerLaw"> | |
| 133 | - <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/> | |
| 134 | - <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/> | |
| 135 | - <parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/> | |
| 136 | - </spectrum> | |
| 137 | - <spatialModel type="PointSource"> | |
| 138 | - <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/> | |
| 139 | - <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/> | |
| 140 | - </spatialModel> | |
| 141 | - </source> | |
| 142 | - <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTAOnOff"> | |
| 143 | - <spectrum type="PowerLaw"> | |
| 144 | - <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/> | |
| 145 | - <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/> | |
| 146 | - <parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/> | |
| 147 | - </spectrum> | |
| 148 | - </source> | |
| 149 | - </source_library> | |
| 129 | + <?xml version="1.0" standalone="no"?> | |
| 130 | + <source_library title="source library"> | |
| 131 | + <source name="Crab" type="PointSource"> | |
| 132 | + <spectrum type="PowerLaw"> | |
| 133 | + <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/> | |
| 134 | + <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/> | |
| 135 | + <parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/> | |
| 136 | + </spectrum> | |
| 137 | + <spatialModel type="PointSource"> | |
| 138 | + <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="0"/> | |
| 139 | + <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="0"/> | |
| 140 | + </spatialModel> | |
| 141 | + </source> | |
| 142 | + <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTAOnOff"> | |
| 143 | + <spectrum type="PowerLaw"> | |
| 144 | + <parameter name="Prefactor" scale="1.0" value="1.0" min="1e-3" max="1e+3" free="1"/> | |
| 145 | + <parameter name="Index" scale="1.0" value="0.0" min="-5.0" max="+5.0" free="1"/> | |
| 146 | + <parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/> | |
| 147 | + </spectrum> | |
| 148 | + </source> | |
| 149 | + </source_library> | |
| 150 | 150 | |
| 151 | 151 | At this point we can run an On/Off analysis just by passing the On/Off |
| 152 | 152 | observation container to :ref:`ctlike`. |
| ... | ... | @@ -164,61 +164,61 @@ always be the case, especially if the background is not well known a priori. |
| 164 | 164 | |
| 165 | 165 | .. code-block:: bash |
| 166 | 166 | |
| 167 | - 2017-11-28T17:26:56: +=================================+ | |
| 168 | - 2017-11-28T17:26:56: | Maximum likelihood optimisation | | |
| 169 | - 2017-11-28T17:26:56: +=================================+ | |
| 170 | - 2017-11-28T17:26:56: >Iteration 0: -logL=-48350.908, Lambda=1.0e-03 | |
| 171 | - 2017-11-28T17:26:56: >Iteration 1: -logL=-48352.759, Lambda=1.0e-03, delta=1.852, step=1.0e+00, max(|grad|)=2.829489 [Index:7] | |
| 172 | - 2017-11-28T17:26:56: >Iteration 2: -logL=-48352.760, Lambda=1.0e-04, delta=0.000, step=1.0e+00, max(|grad|)=0.002408 [Index:3] | |
| 173 | - 2017-11-28T17:26:56: | |
| 174 | - 2017-11-28T17:26:56: +=========================================+ | |
| 175 | - 2017-11-28T17:26:56: | Maximum likelihood optimisation results | | |
| 176 | - 2017-11-28T17:26:56: +=========================================+ | |
| 177 | - 2017-11-28T17:26:56: === GOptimizerLM === | |
| 178 | - 2017-11-28T17:26:56: Optimized function value ..: -48352.760 | |
| 179 | - 2017-11-28T17:26:56: Absolute precision ........: 0.005 | |
| 180 | - 2017-11-28T17:26:56: Acceptable value decrease .: 2 | |
| 181 | - 2017-11-28T17:26:56: Optimization status .......: converged | |
| 182 | - 2017-11-28T17:26:56: Number of parameters ......: 10 | |
| 183 | - 2017-11-28T17:26:56: Number of free parameters .: 4 | |
| 184 | - 2017-11-28T17:26:56: Number of iterations ......: 2 | |
| 185 | - 2017-11-28T17:26:56: Lambda ....................: 1e-05 | |
| 186 | - 2017-11-28T17:26:56: Maximum log likelihood ....: 48352.760 | |
| 187 | - 2017-11-28T17:26:56: Observed events (Nobs) ...: 6656.000 | |
| 188 | - 2017-11-28T17:26:56: Predicted events (Npred) ..: 6655.663 (Nobs - Npred = 0.337440257160779) | |
| 189 | - 2017-11-28T17:26:56: === GModels === | |
| 190 | - 2017-11-28T17:26:56: Number of models ..........: 2 | |
| 191 | - 2017-11-28T17:26:56: Number of parameters ......: 10 | |
| 192 | - 2017-11-28T17:26:56: === GModelSky === | |
| 193 | - 2017-11-28T17:26:56: Name ......................: Crab | |
| 194 | - 2017-11-28T17:26:56: Instruments ...............: all | |
| 195 | - 2017-11-28T17:26:56: Instrument scale factors ..: unity | |
| 196 | - 2017-11-28T17:26:56: Observation identifiers ...: all | |
| 197 | - 2017-11-28T17:26:56: Model type ................: PointSource | |
| 198 | - 2017-11-28T17:26:56: Model components ..........: "PointSource" * "PowerLaw" * "Constant" | |
| 199 | - 2017-11-28T17:26:56: Number of parameters ......: 6 | |
| 200 | - 2017-11-28T17:26:56: Number of spatial par's ...: 2 | |
| 201 | - 2017-11-28T17:26:56: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1) | |
| 202 | - 2017-11-28T17:26:56: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1) | |
| 203 | - 2017-11-28T17:26:56: Number of spectral par's ..: 3 | |
| 204 | - 2017-11-28T17:26:56: Prefactor ................: 5.69533666063277e-16 +/- 7.77619410705106e-18 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient) | |
| 205 | - 2017-11-28T17:26:56: Index ....................: -2.47347083803876 +/- 0.0114544870463654 [-0,-5] (free,scale=-1,gradient) | |
| 206 | - 2017-11-28T17:26:56: PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 207 | - 2017-11-28T17:26:56: Number of temporal par's ..: 1 | |
| 208 | - 2017-11-28T17:26:56: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 209 | - 2017-11-28T17:26:56: === GCTAModelIrfBackground === | |
| 210 | - 2017-11-28T17:26:56: Name ......................: CTABackgroundModel | |
| 211 | - 2017-11-28T17:26:56: Instruments ...............: CTAOnOff | |
| 212 | - 2017-11-28T17:26:56: Instrument scale factors ..: unity | |
| 213 | - 2017-11-28T17:26:56: Observation identifiers ...: all | |
| 214 | - 2017-11-28T17:26:56: Model type ................: "PowerLaw" * "Constant" | |
| 215 | - 2017-11-28T17:26:56: Number of parameters ......: 4 | |
| 216 | - 2017-11-28T17:26:56: Number of spectral par's ..: 3 | |
| 217 | - 2017-11-28T17:26:56: Prefactor ................: 1.00017594707712 +/- 0.0373732914079376 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient) | |
| 218 | - 2017-11-28T17:26:56: Index ....................: 0.0190520959815092 +/- 0.0220805114253248 [-5,5] (free,scale=1,gradient) | |
| 219 | - 2017-11-28T17:26:56: PivotEnergy ..............: 1000000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 220 | - 2017-11-28T17:26:56: Number of temporal par's ..: 1 | |
| 221 | - 2017-11-28T17:26:56: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 167 | + 2017-11-28T17:26:56: +=================================+ | |
| 168 | + 2017-11-28T17:26:56: | Maximum likelihood optimisation | | |
| 169 | + 2017-11-28T17:26:56: +=================================+ | |
| 170 | + 2017-11-28T17:26:56: >Iteration 0: -logL=-48350.908, Lambda=1.0e-03 | |
| 171 | + 2017-11-28T17:26:56: >Iteration 1: -logL=-48352.759, Lambda=1.0e-03, delta=1.852, step=1.0e+00, max(|grad|)=2.829489 [Index:7] | |
| 172 | + 2017-11-28T17:26:56: >Iteration 2: -logL=-48352.760, Lambda=1.0e-04, delta=0.000, step=1.0e+00, max(|grad|)=0.002408 [Index:3] | |
| 173 | + 2017-11-28T17:26:56: | |
| 174 | + 2017-11-28T17:26:56: +=========================================+ | |
| 175 | + 2017-11-28T17:26:56: | Maximum likelihood optimisation results | | |
| 176 | + 2017-11-28T17:26:56: +=========================================+ | |
| 177 | + 2017-11-28T17:26:56: === GOptimizerLM === | |
| 178 | + 2017-11-28T17:26:56: Optimized function value ..: -48352.760 | |
| 179 | + 2017-11-28T17:26:56: Absolute precision ........: 0.005 | |
| 180 | + 2017-11-28T17:26:56: Acceptable value decrease .: 2 | |
| 181 | + 2017-11-28T17:26:56: Optimization status .......: converged | |
| 182 | + 2017-11-28T17:26:56: Number of parameters ......: 10 | |
| 183 | + 2017-11-28T17:26:56: Number of free parameters .: 4 | |
| 184 | + 2017-11-28T17:26:56: Number of iterations ......: 2 | |
| 185 | + 2017-11-28T17:26:56: Lambda ....................: 1e-05 | |
| 186 | + 2017-11-28T17:26:56: Maximum log likelihood ....: 48352.760 | |
| 187 | + 2017-11-28T17:26:56: Observed events (Nobs) ...: 6656.000 | |
| 188 | + 2017-11-28T17:26:56: Predicted events (Npred) ..: 6655.663 (Nobs - Npred = 0.337440257160779) | |
| 189 | + 2017-11-28T17:26:56: === GModels === | |
| 190 | + 2017-11-28T17:26:56: Number of models ..........: 2 | |
| 191 | + 2017-11-28T17:26:56: Number of parameters ......: 10 | |
| 192 | + 2017-11-28T17:26:56: === GModelSky === | |
| 193 | + 2017-11-28T17:26:56: Name ......................: Crab | |
| 194 | + 2017-11-28T17:26:56: Instruments ...............: all | |
| 195 | + 2017-11-28T17:26:56: Instrument scale factors ..: unity | |
| 196 | + 2017-11-28T17:26:56: Observation identifiers ...: all | |
| 197 | + 2017-11-28T17:26:56: Model type ................: PointSource | |
| 198 | + 2017-11-28T17:26:56: Model components ..........: "PointSource" * "PowerLaw" * "Constant" | |
| 199 | + 2017-11-28T17:26:56: Number of parameters ......: 6 | |
| 200 | + 2017-11-28T17:26:56: Number of spatial par's ...: 2 | |
| 201 | + 2017-11-28T17:26:56: RA .......................: 83.6331 [-360,360] deg (fixed,scale=1) | |
| 202 | + 2017-11-28T17:26:56: DEC ......................: 22.0145 [-90,90] deg (fixed,scale=1) | |
| 203 | + 2017-11-28T17:26:56: Number of spectral par's ..: 3 | |
| 204 | + 2017-11-28T17:26:56: Prefactor ................: 5.69533666063277e-16 +/- 7.77619410705106e-18 [1e-23,1e-13] ph/cm2/s/MeV (free,scale=1e-16,gradient) | |
| 205 | + 2017-11-28T17:26:56: Index ....................: -2.47347083803876 +/- 0.0114544870463654 [-0,-5] (free,scale=-1,gradient) | |
| 206 | + 2017-11-28T17:26:56: PivotEnergy ..............: 300000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 207 | + 2017-11-28T17:26:56: Number of temporal par's ..: 1 | |
| 208 | + 2017-11-28T17:26:56: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 209 | + 2017-11-28T17:26:56: === GCTAModelIrfBackground === | |
| 210 | + 2017-11-28T17:26:56: Name ......................: CTABackgroundModel | |
| 211 | + 2017-11-28T17:26:56: Instruments ...............: CTAOnOff | |
| 212 | + 2017-11-28T17:26:56: Instrument scale factors ..: unity | |
| 213 | + 2017-11-28T17:26:56: Observation identifiers ...: all | |
| 214 | + 2017-11-28T17:26:56: Model type ................: "PowerLaw" * "Constant" | |
| 215 | + 2017-11-28T17:26:56: Number of parameters ......: 4 | |
| 216 | + 2017-11-28T17:26:56: Number of spectral par's ..: 3 | |
| 217 | + 2017-11-28T17:26:56: Prefactor ................: 1.00017594707712 +/- 0.0373732914079376 [0.001,1000] ph/cm2/s/MeV (free,scale=1,gradient) | |
| 218 | + 2017-11-28T17:26:56: Index ....................: 0.0190520959815092 +/- 0.0220805114253248 [-5,5] (free,scale=1,gradient) | |
| 219 | + 2017-11-28T17:26:56: PivotEnergy ..............: 1000000 [10000,1000000000] MeV (fixed,scale=1000000,gradient) | |
| 220 | + 2017-11-28T17:26:56: Number of temporal par's ..: 1 | |
| 221 | + 2017-11-28T17:26:56: Normalization ............: 1 (relative value) (fixed,scale=1,gradient) | |
| 222 | 222 | |
| 223 | 223 | :ref:`ctlike` has a hidden parameter called ``statistic`` that sets the |
| 224 | 224 | statistic used for the fit. | ... | ... |