From 0e1a15f51e54833152782aa91610c75b9508aec7 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 24 Jun 2016 15:49:53 +0200 Subject: [PATCH] Add documentation --- inst/cta/test/README.md | 27 ++++++++++++++------------- inst/cta/test/dev/README.md | 72 ++++++++++++++++++++++++++++++++++++------------------------------------ test/README | 1 - test/README.md | 5 +++++ test/test_python.py | 42 ++++++++++++++++++++---------------------- 5 files changed, 75 insertions(+), 72 deletions(-) delete mode 100644 test/README create mode 100644 test/README.md diff --git a/inst/cta/test/README.md b/inst/cta/test/README.md index 5b7619e..e149332 100644 --- a/inst/cta/test/README.md +++ b/inst/cta/test/README.md @@ -3,19 +3,20 @@ CTA module unit tests This folder contains scripts and executables that are used for CTA module unit testing. -benchmark_irf_computing.py - This script performs a benchmark of the response computation for all - different analysis methods (unbinned, binned, stacked). Specifically it - compares the total number of modelled counts to the expected number from - Monte-Carlo simulations. This script is used to validate the absolute - normalization of the CTA response computations. +`benchmark_irf_computing.py` -benchmark_ml_fitting.py - This script performs a benchmark for maximum likelihood fitting of CTA - data. +> This script performs a benchmark of the response computation for all +> different analysis methods (unbinned, binned, stacked). Specifically it +> compares the total number of modelled counts to the expected number from +> Monte-Carlo simulations. This script is used to validate the absolute +> normalization of the CTA response computations. -test_CTA.cpp - Unit test C++ file for CTA specific GammaLib components. +`benchmark_ml_fitting.py` +> This script performs a benchmark for maximum likelihood fitting of CTA +> data. -test_CTA.py - Unit test Python script for CTA specific GammaLib components. +`test_CTA.cpp` +> Unit test C++ file for CTA specific GammaLib components. + +`test_CTA.py` +> Unit test Python script for CTA specific GammaLib components. diff --git a/inst/cta/test/dev/README.md b/inst/cta/test/dev/README.md index c8ae7af..a3595d6 100644 --- a/inst/cta/test/dev/README.md +++ b/inst/cta/test/dev/README.md @@ -5,51 +5,51 @@ during code development. None of the scripts actually needs to work, they may actually be outdated, but could still be useful for further testing if needed. -example_binned_ml_fit.py - Illustrates a binned maximum likelihood fit of CTA data. - This script implements a full analysis chain, and computes - also the TS statistics value that estimates the significance - of the source detection. +`example_binned_ml_fit.py` +> Illustrates a binned maximum likelihood fit of CTA data. +> This script implements a full analysis chain, and computes +> also the TS statistics value that estimates the significance +> of the source detection. -example_make_model.py - Illustrates how to make a model in counts space for a counts - map given a specific model in XML format. +`example_make_model.py` +> Illustrates how to make a model in counts space for a counts +> map given a specific model in XML format. -example_sim_photons.py - Illustrates how photons are simulated from a source model. If - matplotlib is installed, the simulated photons are shown as - a spectrum. +`example_sim_photons.py` +> Illustrates how photons are simulated from a source model. If +> matplotlib is installed, the simulated photons are shown as +> a spectrum. -test_gauss.py - Test Gaussian. +`test_gauss.py` +> Test Gaussian. -test_irf_offset.py - Creates images of source models for various offset angles. This - tests the IRF variation with offset angle. +`test_irf_offset.py` +> Creates images of source models for various offset angles. This +> tests the IRF variation with offset angle. -test_irf_trafo.py - Test coordinate transformations for IRF computation. +`test_irf_trafo.py` +> Test coordinate transformations for IRF computation. -test_model.py - Creates images of sources models convolved with the CTA instrument - response function. Also allows the creation of gradient images. +`test_model.py` +> Creates images of sources models convolved with the CTA instrument +> response function. Also allows the creation of gradient images. -test_npred_computation.py - Test the Npred computation of the CTA response. +`test_npred_computation.py` +> Test the Npred computation of the CTA response. -test_npred_integration.py - Compare numerical to analytical Npred computation for CTA response. +`test_npred_integration.py` +> Compare numerical to analytical Npred computation for CTA response. -test_radial_acceptance.py - Displays the various radial acceptance models. +`test_radial_acceptance.py` +> Displays the various radial acceptance models. -test_response_table.py - Display CTA response table. +`test_response_table.py` +> Display CTA response table. -test_sim_edisp.py - Compares energy dispersion simulation to energy dispersion - model. +`test_sim_edisp.py` +> Compares energy dispersion simulation to energy dispersion +> model. -test_sim_psf.py - Compares Point Spread function simulation to Point Spread function - model. +`test_sim_psf.py` +> Compares Point Spread function simulation to Point Spread function +> model. diff --git a/test/README b/test/README deleted file mode 100644 index 3f311c8..0000000 --- a/test/README +++ /dev/null @@ -1 +0,0 @@ -This folder contains files used for GammaLib unit testing. More unit tests files can be found in the instrument specific test folders inst/xxx/test. diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..3b19476 --- /dev/null +++ b/test/README.md @@ -0,0 +1,5 @@ +GammaLib unit tests +=================== + +This folder contains files used for GammaLib unit testing. More unit tests are +located in the instrument specific test folders inst//test. diff --git a/test/test_python.py b/test/test_python.py index 31ef3fd..fe043b6 100755 --- a/test/test_python.py +++ b/test/test_python.py @@ -73,7 +73,7 @@ def test(installed=False): Perform unit testing for Python interface. """ # Allocate test suites - suites = gammalib.GTestSuites("Python interface testing") + suites = gammalib.GTestSuites('Python interface testing') # Allocate test suites and append them to the container suite1 = test_GApplication.Test() @@ -131,7 +131,7 @@ def test(installed=False): suite_cta = test_CTA.Test() suite_cta.set() if installed: - suite_cta.caldb_path("cta/caldb") + suite_cta.caldb_path('cta/caldb') suites.append(suite_cta) # Optionally handle LAT suite @@ -161,43 +161,43 @@ def test(installed=False): head, tail = os.path.split(testdir) # Copy over test data - os.system("cp -r %s %s" % (head+"/data", "data")) - os.system("cp -r %s %s" % (head+"/cta", "cta")) + os.system('cp -r %s %s' % (head+'/data', 'data')) + os.system('cp -r %s %s' % (head+'/cta', 'cta')) # Special post processing for CTA files. This is needed because # the XML files contain absolute PATH information. This is a kluge # that works for now, but it's not a very maintainable way to # handle this if has_cta: - xml = gammalib.GXml("cta/data/irf_unbinned.xml") - elements = xml.element("observation_list").element("observation") + xml = gammalib.GXml('cta/data/irf_unbinned.xml') + elements = xml.element('observation_list').element('observation') for element in elements: - filename = element.attribute("file") + filename = element.attribute('file') head, tail = os.path.split(filename) head, dir = os.path.split(head) if len(dir) > 0: - filename = "cta/"+dir+"/"+tail - element.attribute("file", filename) - xml.save("cta/data/irf_unbinned.xml") - xml = gammalib.GXml("cta/data/irf_1dc.xml") - elements = xml.element("observation_list").element("observation") + filename = 'cta/'+dir+'/'+tail + element.attribute('file', filename) + xml.save('cta/data/irf_unbinned.xml') + xml = gammalib.GXml('cta/data/irf_1dc.xml') + elements = xml.element('observation_list').element('observation') for element in elements: - filename = element.attribute("file") + filename = element.attribute('file') head, tail = os.path.split(filename) head, dir = os.path.split(head) - if dir == "dc1": - dir = "caldb/dc1" + if dir == 'dc1': + dir = 'caldb/dc1' if len(dir) > 0: - filename = "cta/"+dir+"/"+tail - element.attribute("file", filename) - xml.save("cta/data/irf_1dc.xml") + filename = 'cta/'+dir+'/'+tail + element.attribute('file', filename) + xml.save('cta/data/irf_1dc.xml') # Run test suite success = suites.run() # If we have a non-installed version then save test results if not installed: - suites.save("reports/python.xml") + suites.save('reports/python.xml') # Set return code if success: @@ -213,8 +213,6 @@ def test(installed=False): # Main routine entry point # # ======================== # if __name__ == '__main__': - """ - Perform unit testing for Python interface. - """ + # Run tests test() -- libgit2 0.21.4