Commit 17fc888cf3c27b8095591fb46d8a7e40f5c752f1

Authored by Christoph Deil
1 parent a9c1de33

Minor cleanup of Python docs

doc/source/user_manual/getting_started/python.rst
@@ -365,8 +365,7 @@ assumed that you have a ctlike object called 'like' which is setup and runs: @@ -365,8 +365,7 @@ assumed that you have a ctlike object called 'like' which is setup and runs:
365 import ctools 365 import ctools
366 like = ctools.ctlike(sim.obs()) 366 like = ctools.ctlike(sim.obs())
367 like.run() 367 like.run()
368 - ...  
369 - 368 +
370 * Best-fit parameters: 369 * Best-fit parameters:
371 370
372 The following command shows how to access the fit parameters and errors: 371 The following command shows how to access the fit parameters and errors:
@@ -376,31 +375,27 @@ assumed that you have a ctlike object called 'like' which is setup and runs: @@ -376,31 +375,27 @@ assumed that you have a ctlike object called 'like' which is setup and runs:
376 obs = like.obs() # Get observations object 375 obs = like.obs() # Get observations object
377 obs.models()["Crab"]["Prefactor"].value() # This returns the actual fit value 376 obs.models()["Crab"]["Prefactor"].value() # This returns the actual fit value
378 obs.models()["Crab"]["Prefactor"].error() # This returns the actual fit error 377 obs.models()["Crab"]["Prefactor"].error() # This returns the actual fit error
379 - ...  
380 378
381 * Open XML model file from python and print models on screen: 379 * Open XML model file from python and print models on screen:
382 380
383 .. code-block:: python 381 .. code-block:: python
384 382
385 models = gammalib.GModels("$CTOOLS/share/models/crab.xml") 383 models = gammalib.GModels("$CTOOLS/share/models/crab.xml")
386 - print models  
387 - ...  
388 - 384 + print(models)
  385 +
389 * Likelihood value 386 * Likelihood value
390 387
391 .. code-block:: python 388 .. code-block:: python
392 389
393 like.opt().value() # Returns likelihood value 390 like.opt().value() # Returns likelihood value
394 - ...  
395 - 391 +
396 * Covariance Matrix 392 * Covariance Matrix
397 393
398 .. code-block:: python 394 .. code-block:: python
399 395
400 covariance = like.opt().curvature().invert() # Return GMatrix object 396 covariance = like.opt().curvature().invert() # Return GMatrix object
401 - print covariance  
402 - ...  
403 - 397 + print(covariance)
  398 +
404 Modify and work on XML models 399 Modify and work on XML models
405 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 400 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406 401
@@ -409,52 +404,45 @@ Modify and work on XML models @@ -409,52 +404,45 @@ Modify and work on XML models
409 .. code-block:: python 404 .. code-block:: python
410 405
411 models["Crab"]["Prefactor"].fix() 406 models["Crab"]["Prefactor"].fix()
412 - ...  
413 - 407 +
414 * Release a certain parameter 408 * Release a certain parameter
415 409
416 .. code-block:: python 410 .. code-block:: python
417 411
418 models["Crab"]["Prefactor"].free() 412 models["Crab"]["Prefactor"].free()
419 - ...  
420 - 413 +
421 * Check if parameter is free 414 * Check if parameter is free
422 415
423 .. code-block:: python 416 .. code-block:: python
424 417
425 models["Crab"]["Prefactor"].is_free() 418 models["Crab"]["Prefactor"].is_free()
426 - ...  
427 - 419 +
428 * Set parameter value 420 * Set parameter value
429 421
430 .. code-block:: python 422 .. code-block:: python
431 423
432 models["Crab"]["Index"].value(-2.5) 424 models["Crab"]["Index"].value(-2.5)
433 - ...  
434 - 425 +
435 * Set parameter boundaries 426 * Set parameter boundaries
436 427
437 .. code-block:: python 428 .. code-block:: python
438 429
439 models["Crab"]["Index"].min(-5.0) 430 models["Crab"]["Index"].min(-5.0)
440 models["Crab"]["Index"].max(-1.0) 431 models["Crab"]["Index"].max(-1.0)
441 - ...  
442 - 432 +
443 * Loop over models and parameters (e.g. fix all parameters) 433 * Loop over models and parameters (e.g. fix all parameters)
444 434
445 - .. code-block:: python  
446 -  
447 - for model in models: # Loop over models  
448 - for par in model: # Loop over parameters  
449 - par.fix() # fix parameter  
450 - ...  
451 - 435 + .. code-block:: python
  436 +
  437 + for model in models: # Loop over models
  438 + for par in model: # Loop over parameters
  439 + par.fix() # fix parameter
  440 +
452 * Save modified XML model 441 * Save modified XML model
453 442
454 .. code-block:: python 443 .. code-block:: python
455 444
456 - models.save("myXMLmodel.xml")  
457 - ... 445 + models.save("my_model.xml")
458 446
459 447
460 Beyond the first steps 448 Beyond the first steps