Commit de69fbab0589793a28d26edd15e705cc18aa991c
1 parent
d85c22c6
Minor changes to quickstart.rst
Showing
1 changed file
with
40 additions
and
43 deletions
doc/source/quickstart.rst
| ... | ... | @@ -9,26 +9,24 @@ verify that the Python interfaces workes correctly. You do this by |
| 9 | 9 | typing:: |
| 10 | 10 | |
| 11 | 11 | >>> from gammalib import * |
| 12 | - >>> | |
| 13 | 12 | |
| 14 | 13 | If everything works fine you should just get a new Python prompt after |
| 15 | 14 | importing GammaLib. If you get an error message, make sure that you've |
| 16 | 15 | setup correctly the GammaLib environment. You basically need the |
| 17 | -PYTHONPATH variable set to GammaLib's Python site-package, and you also | |
| 16 | +``PYTHONPATH`` variable set to GammaLib's Python site-package, and you also | |
| 18 | 17 | have to make sure that GammaLib and any dependent library (cfitsio, |
| 19 | 18 | readline, ncurses) is in the library load path (eventually you may need |
| 20 | -to adjust LD\_LIBRARY\_PATH). This is all done automatically if you set | |
| 19 | +to adjust ``LD_LIBRARY_PATH``). This is all done automatically if you set | |
| 21 | 20 | up the environment as described |
| 22 | 21 | `here <installation.html#Setting_up_your_environment>`_. |
| 23 | 22 | |
| 24 | 23 | Now try:: |
| 25 | 24 | |
| 26 | - >>> models=GModels() | |
| 27 | - >>> print models | |
| 25 | + >>> models = GModels() | |
| 26 | + >>> print(models) | |
| 28 | 27 | === GModels === |
| 29 | 28 | Number of models ..........: 0 |
| 30 | 29 | Number of parameters ......: 0 |
| 31 | - >>> | |
| 32 | 30 | |
| 33 | 31 | You just alloacted your first GammaLib object, which is an empty model |
| 34 | 32 | container. |
| ... | ... | @@ -38,61 +36,61 @@ Now let's append a model to this container. For this, type:: |
| 38 | 36 | >>> pos = GSkyDir() |
| 39 | 37 | >>> pos.radec_deg(83.6331, 22.0145) |
| 40 | 38 | >>> spatial = GModelSpatialPointSource(pos) |
| 41 | - >>> spectral = GModelSpectralPlaw(1.0, -2.0) | |
| 39 | + >>> spectral = GModelSpectralPlaw(1.0, -2.0, GEnergy(100, 'MeV')) | |
| 42 | 40 | >>> model = GModelSky(spatial, spectral) |
| 43 | 41 | >>> models.append(model) |
| 44 | - >>> print models | |
| 42 | + >>> print(models) | |
| 45 | 43 | === GModels === |
| 46 | - Number of models ..........: 1 | |
| 47 | - Number of parameters ......: 6 | |
| 44 | + Number of models ..........: 1 | |
| 45 | + Number of parameters ......: 6 | |
| 48 | 46 | === GModelSky === |
| 49 | - Name ......................: | |
| 50 | - Instruments ...............: all | |
| 51 | - Model type ................: "SkyDirFunction" * "PowerLaw" * "Constant" | |
| 52 | - Number of parameters ......: 6 | |
| 53 | - Number of spatial par's ...: 2 | |
| 54 | - RA .......................: 83.6331 deg (fixed,scale=1) | |
| 55 | - DEC ......................: 22.0145 deg (fixed,scale=1) | |
| 56 | - Number of spectral par's ..: 3 | |
| 57 | - Prefactor ................: 1 +/- 0 [0,infty[ ph/cm2/s/MeV (free,scale=1,gradient) | |
| 58 | - Index ....................: -2 +/- 0 [-10,10] (free,scale=1,gradient) | |
| 59 | - PivotEnergy ..............: 100 MeV (fixed,scale=1,gradient) | |
| 60 | - Number of temporal par's ..: 1 | |
| 61 | - Constant .................: 1 (relative value) | |
| 62 | - (fixed,scale=1,gradient) | |
| 63 | - >>> | |
| 47 | + Name ......................: | |
| 48 | + Instruments ...............: all | |
| 49 | + Instrument scale factors ..: unity | |
| 50 | + Observation identifiers ...: all | |
| 51 | + Model type ................: PointSource | |
| 52 | + Model components ..........: "SkyDirFunction" * "PowerLaw" * "Constant" | |
| 53 | + Number of parameters ......: 6 | |
| 54 | + Number of spatial par's ...: 2 | |
| 55 | + RA .......................: 83.6331 deg (fixed,scale=1) | |
| 56 | + DEC ......................: 22.0145 deg (fixed,scale=1) | |
| 57 | + Number of spectral par's ..: 3 | |
| 58 | + Prefactor ................: 1 +/- 0 [0,infty[ ph/cm2/s/MeV (free,scale=1,gradient) | |
| 59 | + Index ....................: -2 +/- 0 [10,-10] (free,scale=-2,gradient) | |
| 60 | + PivotEnergy ..............: 100 MeV (fixed,scale=100,gradient) | |
| 61 | + Number of temporal par's ..: 1 | |
| 62 | + Constant .................: 1 (relative value) (fixed,scale=1,gradient) | |
| 64 | 63 | |
| 65 | 64 | With this sequence of commands you first defined a sky direction in |
| 66 | -celestial coordinates using GSkyDir. You may easily recognise that this | |
| 65 | +celestial coordinates using ``GSkyDir``. You may easily recognise that this | |
| 67 | 66 | is the position of the Crab. You then used this position to define the |
| 68 | -spatial component of a sky model using GModelSpatialPtsrc. As the name | |
| 67 | +spatial component of a sky model using ``GModelSpatialPointSource``. As the name | |
| 69 | 68 | suggests, the spatial component is a point source. Next, you defined the |
| 70 | -spectral component using GModelSpactralPlaw: a power law with | |
| 69 | +spectral component using ``GModelSpactralPlaw``: a power law with | |
| 71 | 70 | normalisation of 1 and index of -2. Then, you combined the spatial and |
| 72 | -spectral components in a point source model using GModelPointSource. And | |
| 71 | +spectral components in a point source model using ``GModelSky``. And | |
| 73 | 72 | finally you appended the point source to the model container allocated |
| 74 | 73 | previously using the append method. When you then print the model |
| 75 | 74 | container you see that is contains now one model with 6 parameters. |
| 76 | -Among them, you find the specified source position (parameters RA and | |
| 77 | -DEC), the power law normalisation (parameter Prefactor) and the spectral | |
| 78 | -index (parameter Index). In addition, the reference energy for the | |
| 79 | -normalisation has been set automatically to 100 MeV (parameter | |
| 80 | -PivotEnergy) and the temporal component has been set by default to a | |
| 81 | -constant (parameter Constant). | |
| 75 | +Among them, you find the specified source position (parameters ``RA`` and | |
| 76 | +``DEC``), the power law normalisation (parameter ``Prefactor``) and the spectral | |
| 77 | +index (parameter ``Index``). In addition, the reference energy for the | |
| 78 | +normalisation has been set to 100 MeV (parameter ``PivotEnergy``) | |
| 79 | +and the temporal component has been set by default to a constant (parameter ``Constant``). | |
| 82 | 80 | |
| 83 | 81 | Suppose you want to change one of these parameters, such as the |
| 84 | -PivotEnergy that you want to set to 1 TeV. This can be done using:: | |
| 82 | +``PivotEnergy`` that you want to set to 1 TeV. This can be done using:: | |
| 85 | 83 | |
| 86 | - >>> models[0]['PivotEnergy'].value(1.0e6) | |
| 87 | - >>> print models | |
| 84 | + >>> models[0]['PivotEnergy'].value(1e6) | |
| 85 | + >>> print(models) | |
| 88 | 86 | ... |
| 89 | - PivotEnergy ..............: 1e+06 MeV (fixed,scale=1,gradient) | |
| 87 | + PivotEnergy ..............: 1e+06 MeV (fixed,scale=100,gradient) | |
| 90 | 88 | ... |
| 91 | 89 | |
| 92 | 90 | As the units are MeV, we had to specify a value of 1e6 to set the |
| 93 | 91 | reference energy to 1 TeV. We did this by accessing the first model in |
| 94 | 92 | the container using ``models[0]`` (counting in GammaLib always starts from |
| 95 | -0). Then we addressed the PivotEnergy parameter by specifying | |
| 93 | +0). Then we addressed the ``PivotEnergy`` parameter by specifying | |
| 96 | 94 | ``['PivotEnergy']``. And finally we called the value method that sets the |
| 97 | 95 | value of a particular parameter. |
| 98 | 96 | |
| ... | ... | @@ -100,12 +98,11 @@ After all this hard work, you may save your model into a XML file by |
| 100 | 98 | typing:: |
| 101 | 99 | |
| 102 | 100 | >>> models.save('test.xml') |
| 103 | - >>> | |
| 104 | 101 | |
| 105 | 102 | and you can load it from an XML file in memory using:: |
| 106 | 103 | |
| 107 | - >>> newmodels=GModels('test.xml') | |
| 108 | - >>> print newmodels | |
| 104 | + >>> new_models = GModels('test.xml') | |
| 105 | + >>> print(new_models) | |
| 109 | 106 | |
| 110 | 107 | The last print command is to convince yourself that the models have been |
| 111 | 108 | loaded properly. | ... | ... |