Commit 5303e49b6f1bfbe6d702b56ada7c582232e8b19c
1 parent
9f0f5511
Reorganise CTA test scripts
Showing
10 changed files
with
84 additions
and
70 deletions
.gitignore
| ... | ... | @@ -11,6 +11,7 @@ examples/python/*.fits |
| 11 | 11 | inst/cta/test/*.xml |
| 12 | 12 | inst/cta/test/*.fits |
| 13 | 13 | inst/cta/test/*.fits.gz |
| 14 | +inst/cta/test/dev/*.fits | |
| 14 | 15 | inst/spi/test/data/*.xml |
| 15 | 16 | |
| 16 | 17 | # Generated files |
| ... | ... | @@ -88,6 +89,8 @@ test/region.reg |
| 88 | 89 | test/test_python.sh |
| 89 | 90 | test/test_examples.sh |
| 90 | 91 | test/test_csv*.dat |
| 92 | +test/dev/*.fits | |
| 93 | +test/dev/*.xml | |
| 91 | 94 | |
| 92 | 95 | examples/python/*.xml |
| 93 | 96 | examples/python/*.html | ... | ... |
inst/cta/test/README.md
0 → 100644
| 1 | +CTA module unit tests | |
| 2 | +===================== | |
| 3 | +This folder contains scripts and executables that are used for CTA | |
| 4 | +module unit testing. | |
| 5 | + | |
| 6 | +benchmark_irf_computing.py | |
| 7 | + This script performs a benchmark of the response computation for all | |
| 8 | + different analysis methods (unbinned, binned, stacked). Specifically it | |
| 9 | + compares the total number of modelled counts to the expected number from | |
| 10 | + Monte-Carlo simulations. This script is used to validate the absolute | |
| 11 | + normalization of the CTA response computations. | |
| 12 | + | |
| 13 | +benchmark_ml_fitting.py | |
| 14 | + This script performs a benchmark for maximum likelihood fitting of CTA | |
| 15 | + data. | |
| 16 | + | |
| 17 | +test_CTA.cpp | |
| 18 | + Unit test C++ file for CTA specific GammaLib components. | |
| 19 | + | |
| 20 | +test_CTA.py | |
| 21 | + Unit test Python script for CTA specific GammaLib components. | ... | ... |
inst/cta/test/README renamed to inst/cta/test/dev/README.md
| 1 | -This folder contains files used for unit testing and files that serve | |
| 2 | -as example scripts for the CTA interface of GammaLib. | |
| 3 | - | |
| 4 | -benchmark_irf_computing.py | |
| 5 | - This script performs a benchmark of the response computation for all | |
| 6 | - different analysis methods (unbinned, binned, stacked). Specifically it | |
| 7 | - compares the total number of modelled counts to the expected number from | |
| 8 | - Monte-Carlo simulations. This script is used to validate the absolute | |
| 9 | - normalization of the CTA response computations. | |
| 10 | - | |
| 11 | -benchmark_ml_fitting.py | |
| 12 | - This script performs a benchmark for maximum likelihood fitting of CTA | |
| 13 | - data. | |
| 1 | +Developer test scripts | |
| 2 | +====================== | |
| 3 | +This folder contains scripts that are used for various testing purposes | |
| 4 | +during code development. None of the scripts actually needs to work, they | |
| 5 | +may actually be outdated, but could still be useful for further testing | |
| 6 | +if needed. | |
| 14 | 7 | |
| 15 | 8 | example_binned_ml_fit.py |
| 16 | 9 | Illustrates a binned maximum likelihood fit of CTA data. |
| ... | ... | @@ -27,9 +20,6 @@ example_sim_photons.py |
| 27 | 20 | matplotlib is installed, the simulated photons are shown as |
| 28 | 21 | a spectrum. |
| 29 | 22 | |
| 30 | -test_CTA.cpp | |
| 31 | - Unit test C++ file for CTA specific GammaLib components. | |
| 32 | - | |
| 33 | 23 | test_gauss.py |
| 34 | 24 | Test Gaussian. |
| 35 | 25 | ... | ... |
inst/cta/test/dev/example_binned_ml_fit.py
| ... | ... | @@ -209,30 +209,26 @@ def stacked_analysis(model, cntmap, expcube, psfcube, bkgcube): |
| 209 | 209 | # Main routine entry point # |
| 210 | 210 | #==========================# |
| 211 | 211 | if __name__ == '__main__': |
| 212 | - """ | |
| 213 | - Example illustrating binned data analyses. | |
| 214 | - """ | |
| 212 | + | |
| 215 | 213 | # Dump header |
| 216 | - print("") | |
| 217 | - print("**************************************************") | |
| 218 | - print("* Perform maximum likelihood fitting of CTA data *") | |
| 219 | - print("**************************************************") | |
| 220 | - print("... please wait for a few seconds") | |
| 221 | - | |
| 222 | - # Set parameters | |
| 223 | - irf = "cta_dummy_irf" | |
| 224 | - caldb = "../caldb" | |
| 225 | - model = "data/crab.xml" | |
| 226 | - cntmap = "data/crab_cntmap.fits" | |
| 227 | - expcube = "data/expcube.fits" | |
| 228 | - psfcube = "data/psfcube.fits" | |
| 229 | - bkgcube = "data/bkgcube.fits" | |
| 214 | + print('') | |
| 215 | + print('**************************************************') | |
| 216 | + print('* Perform maximum likelihood fitting of CTA data *') | |
| 217 | + print('**************************************************') | |
| 218 | + print('... please wait for a few seconds') | |
| 230 | 219 | |
| 231 | 220 | # Perform binned analysis |
| 232 | - results_binned = binned_analysis(model, cntmap, irf, gammalib.GCaldb(caldb)) | |
| 221 | + results_binned = binned_analysis('../data/crab.xml', | |
| 222 | + '../data/crab_cntmap.fits', | |
| 223 | + 'cta_dummy_irf', | |
| 224 | + gammalib.GCaldb('../caldb')) | |
| 233 | 225 | |
| 234 | 226 | # Perform stacked analysis |
| 235 | - results_cube = stacked_analysis(model, cntmap, expcube, psfcube, bkgcube) | |
| 227 | + results_cube = stacked_analysis('../data/stacked_model.xml', | |
| 228 | + '../data/stacked_cntcube.fits', | |
| 229 | + '../data/stacked_expcube.fits', | |
| 230 | + '../data/stacked_psfcube.fits', | |
| 231 | + '../data/stacked_bkgcube.fits') | |
| 236 | 232 | |
| 237 | 233 | # Print model results |
| 238 | 234 | #print(result) | ... | ... |
inst/cta/test/dev/example_make_model.py
| ... | ... | @@ -56,22 +56,20 @@ def make_model_for_cntmap(cntmap, modname, xmlname, irf, caldb, clobber=True): |
| 56 | 56 | # Main routine entry point # |
| 57 | 57 | #==========================# |
| 58 | 58 | if __name__ == '__main__': |
| 59 | - """ | |
| 60 | - Example illustrating how to create a model map for a counts map. | |
| 61 | - """ | |
| 59 | + | |
| 62 | 60 | # Dump header |
| 63 | - print("") | |
| 64 | - print("***************************************************") | |
| 65 | - print("* Create model map for counts map using XML model *") | |
| 66 | - print("***************************************************") | |
| 67 | - print("... please wait for a few seconds") | |
| 61 | + print('') | |
| 62 | + print('***************************************************') | |
| 63 | + print('* Create model map for counts map using XML model *') | |
| 64 | + print('***************************************************') | |
| 65 | + print('... please wait for a few seconds') | |
| 68 | 66 | |
| 69 | 67 | # Set parameters |
| 70 | - irf = "cta_dummy_irf" | |
| 71 | - caldb = "./caldb" | |
| 72 | - xmlname = "data/crab.xml" | |
| 73 | - cntmap = "data/crab_cntmap.fits" | |
| 74 | - modname = "model.fits" | |
| 68 | + irf = 'cta_dummy_irf' | |
| 69 | + caldb = '../caldb' | |
| 70 | + xmlname = '../data/crab.xml' | |
| 71 | + cntmap = '../data/crab_cntmap.fits' | |
| 72 | + modname = 'model.fits' | |
| 75 | 73 | |
| 76 | 74 | # Make the model |
| 77 | 75 | make_model_for_cntmap(cntmap, modname, xmlname, irf, gammalib.GCaldb(caldb)) | ... | ... |
inst/cta/test/dev/example_sim_photons.py
| ... | ... | @@ -143,20 +143,18 @@ def show_photons(photons, xmlname, e_min, e_max, area, duration, ebins=30): |
| 143 | 143 | # Main routine entry point # |
| 144 | 144 | #==========================# |
| 145 | 145 | if __name__ == '__main__': |
| 146 | - """ | |
| 147 | - Simulate photons. | |
| 148 | - """ | |
| 146 | + | |
| 149 | 147 | # Dump header |
| 150 | - print("") | |
| 151 | - print("********************") | |
| 152 | - print("* Simulate photons *") | |
| 153 | - print("********************") | |
| 148 | + print('') | |
| 149 | + print('********************') | |
| 150 | + print('* Simulate photons *') | |
| 151 | + print('********************') | |
| 154 | 152 | |
| 155 | 153 | # Set XML names |
| 156 | - xmlnames = ["data/crab.xml", | |
| 157 | - "data/crab_eplaw.xml", | |
| 158 | - "data/crab_file_function.xml", | |
| 159 | - "data/crab_file_function_mod.xml"] | |
| 154 | + xmlnames = ['../data/crab.xml', | |
| 155 | + '../data/crab_eplaw.xml'] | |
| 156 | + # '../data/crab_file_function.xml', | |
| 157 | + # '../data/crab_file_function_mod.xml'] | |
| 160 | 158 | |
| 161 | 159 | # Set simulation parameters |
| 162 | 160 | e_min = 0.1 # 0.1 TeV | ... | ... |
inst/cta/test/dev/test_model.py
| ... | ... | @@ -174,9 +174,9 @@ def observation(ra=83.6331, dec=22.0145, emin=0.1, emax=100.0, |
| 174 | 174 | obs = gammalib.GCTAObservation() |
| 175 | 175 | |
| 176 | 176 | # Set response |
| 177 | - exposure = gammalib.GCTACubeExposure("data/expcube.fits") | |
| 178 | - psf = gammalib.GCTACubePsf("data/psfcube.fits") | |
| 179 | - background = gammalib.GCTACubeBackground("data/bkgcube.fits") | |
| 177 | + exposure = gammalib.GCTACubeExposure("../data/stacked_expcube.fits") | |
| 178 | + psf = gammalib.GCTACubePsf("../data/stacked_psfcube.fits") | |
| 179 | + background = gammalib.GCTACubeBackground("../data/stacked_bkgcube.fits") | |
| 180 | 180 | obs.response(exposure, psf, background) |
| 181 | 181 | |
| 182 | 182 | # Set pointing | ... | ... |
inst/cta/test/dev/test_sim_edisp.py
| ... | ... | @@ -144,7 +144,7 @@ if __name__ == '__main__': |
| 144 | 144 | # Load edisp |
| 145 | 145 | #edisp = gammalib.GCTAEdispRmf("./caldb/dc1/rmf.fits") |
| 146 | 146 | #edisp = gammalib.GCTAEdispPerfTable("./caldb/cta_dummy_irf.dat") |
| 147 | - edisp = gammalib.GCTAEdisp2D("./caldb/edisp_matrix.fits") | |
| 147 | + edisp = gammalib.GCTAEdisp2D("../caldb/edisp_matrix.fits") | |
| 148 | 148 | |
| 149 | 149 | # Simulate Edisp |
| 150 | 150 | sim_edisp(edisp, 20.0) # Energy in TeV | ... | ... |
inst/cta/test/dev/test_sim_psf.py
| ... | ... | @@ -121,7 +121,7 @@ if __name__ == '__main__': |
| 121 | 121 | #psf = gammalib.GCTAPsfKing('../caldb/data/cta/e/bcf/IFAE20120510_50h_King/irf_file.fits') |
| 122 | 122 | #psf = gammalib.GCTAPsf2D('../caldb/data/cta/e/bcf/IFAE20120510_50h/irf_file.fits') |
| 123 | 123 | #psf = gammalib.GCTAPsfPerfTable('../caldb/cta_dummy_irf.dat') |
| 124 | - psf = gammalib.GCTAPsfTable('../test/caldb/psf_table.fits[PSF_2D_TABLE]') | |
| 124 | + psf = gammalib.GCTAPsfTable('../caldb/psf_table.fits[PSF_2D_TABLE]') | |
| 125 | 125 | |
| 126 | 126 | # Simulate PSF |
| 127 | 127 | sim_psf(psf, 1.0, r_max=0.5) | ... | ... |
testall.sh
| ... | ... | @@ -19,13 +19,21 @@ |
| 19 | 19 | # ===================================================================== |
| 20 | 20 | base=$PWD |
| 21 | 21 | |
| 22 | +# test/dev | |
| 23 | +# ======== | |
| 24 | +echo | |
| 25 | +echo "=====> test/dev" | |
| 26 | +cd test/dev | |
| 27 | +./example_model_xml_io.py | |
| 28 | +./example_radial_models.py | |
| 29 | +cd $base | |
| 30 | + | |
| 31 | + | |
| 22 | 32 | # examples/python |
| 23 | 33 | # =============== |
| 24 | 34 | echo |
| 25 | 35 | echo "=====> examples/python" |
| 26 | 36 | cd examples/python |
| 27 | -./example_model_xml_io.py | |
| 28 | -./example_radial_models.py | |
| 29 | 37 | ./matrix_howto.py |
| 30 | 38 | ./models_howto.py |
| 31 | 39 | ./xml_howto.py |
| ... | ... | @@ -33,11 +41,11 @@ cd examples/python |
| 33 | 41 | cd $base |
| 34 | 42 | |
| 35 | 43 | |
| 36 | -# inst/cta/test | |
| 37 | -# ============= | |
| 44 | +# inst/cta/test/dev | |
| 45 | +# ================= | |
| 38 | 46 | echo |
| 39 | -echo "=====> inst/cta/test" | |
| 40 | -cd inst/cta/test | |
| 47 | +echo "=====> inst/cta/test/dev" | |
| 48 | +cd inst/cta/test/dev | |
| 41 | 49 | ./example_binned_ml_fit.py |
| 42 | 50 | ./example_make_model.py |
| 43 | 51 | ./example_sim_photons.py | ... | ... |