Commit f59f73ff10ef59393f84860ff6d88beb02884dc1
1 parent
1c0d6ef3
Move some example scripts in test/dev and add Prod3 IRF generation to unit tests
Showing
5 changed files
with
59 additions
and
16 deletions
examples/generate_prod3_irfs.py
| ... | ... | @@ -30,12 +30,21 @@ def set_prod3_desy(): |
| 30 | 30 | Set Prod3 DESY database. |
| 31 | 31 | """ |
| 32 | 32 | # Set database attributes |
| 33 | - path = "/project-data/cta/performance/prod3" | |
| 34 | - psftype = "Gauss" | |
| 33 | + #path = '/project-data/cta/performance/prod3' | |
| 34 | + #file = 'DESY.d20160304.V5.ID0NIM2.prod3-paranalp05-NN.S.3HB1-ND-3.180000s.root' | |
| 35 | + path = 'data' | |
| 36 | + file = 'irf.root' | |
| 37 | + psftype = 'Gauss' | |
| 38 | + oversample = 3 | |
| 39 | + norm1d = True | |
| 40 | + bgdinfill = False | |
| 41 | + bgdethres = 10.0 | |
| 35 | 42 | |
| 36 | 43 | # Set database content |
| 37 | - db = [{'inst': "prod3", 'id': "South_50h", 'psftype': psftype, 'path': path, | |
| 38 | - 'file': "DESY.d20160304.V5.ID0NIM2.prod3-paranalp05-NN.S.3HB1-ND-3.180000s.root"} | |
| 44 | + db = [{'inst': 'prod3', 'id': 'South_50h', 'psftype': psftype, | |
| 45 | + 'oversample': oversample, 'norm1d': norm1d, | |
| 46 | + 'bgdinfill': bgdinfill, 'bgdethres': bgdethres, | |
| 47 | + 'path': path, 'file': file} | |
| 39 | 48 | ] |
| 40 | 49 | |
| 41 | 50 | # Return database |
| ... | ... | @@ -66,23 +75,43 @@ if __name__ == '__main__': |
| 66 | 75 | bgdscale = entry['bgdscale'] |
| 67 | 76 | else: |
| 68 | 77 | bgdscale = 1.0 |
| 78 | + if entry.has_key('bgdethres'): | |
| 79 | + bgdethres = entry['bgdethres'] | |
| 80 | + else: | |
| 81 | + bgdethres = 1000.0 | |
| 82 | + if entry.has_key('bgdinfill'): | |
| 83 | + bgdinfill = entry['bgdinfill'] | |
| 84 | + else: | |
| 85 | + bgdinfill = False | |
| 86 | + if entry.has_key('oversample'): | |
| 87 | + oversample = entry['oversample'] | |
| 88 | + else: | |
| 89 | + oversample = 1 | |
| 90 | + if entry.has_key('norm1d'): | |
| 91 | + norm1d = entry['norm1d'] | |
| 92 | + else: | |
| 93 | + norm1d = False | |
| 69 | 94 | |
| 70 | 95 | # Set filename |
| 71 | - filename = entry['path']+"/"+entry['file'] | |
| 96 | + filename = entry['path']+'/'+entry['file'] | |
| 72 | 97 | |
| 73 | 98 | # Set-up csroot2caldb |
| 74 | 99 | caldb = cscripts.csroot2caldb() |
| 75 | - caldb["infile"] = filename | |
| 76 | - caldb["outdir"] = "prod3" | |
| 77 | - caldb["inst"] = entry['inst'] | |
| 78 | - caldb["id"] = entry['id'] | |
| 79 | - caldb["version"] = entry['inst'] | |
| 80 | - caldb["analysis"] = "DESY" | |
| 81 | - caldb["psftype"] = entry['psftype'] | |
| 82 | - caldb["rebin"] = rebin | |
| 83 | - caldb["eascale"] = eascale | |
| 84 | - caldb["bgdscale"] = bgdscale | |
| 85 | - caldb["logfile"] = "generate_prod3_irfs.log" | |
| 100 | + caldb['infile'] = filename | |
| 101 | + caldb['outdir'] = 'prod3' | |
| 102 | + caldb['inst'] = entry['inst'] | |
| 103 | + caldb['id'] = entry['id'] | |
| 104 | + caldb['version'] = entry['inst'] | |
| 105 | + caldb['analysis'] = 'DESY' | |
| 106 | + caldb['psftype'] = entry['psftype'] | |
| 107 | + caldb['norm1d'] = norm1d | |
| 108 | + caldb['rebin'] = rebin | |
| 109 | + caldb['eascale'] = eascale | |
| 110 | + caldb['bgdscale'] = bgdscale | |
| 111 | + caldb['bgdoversample'] = oversample | |
| 112 | + caldb['bgdethres'] = bgdethres | |
| 113 | + caldb['bgdinfill'] = bgdinfill | |
| 114 | + caldb['logfile'] = 'generate_prod3_irfs.log' | |
| 86 | 115 | |
| 87 | 116 | # Add CALDB entry |
| 88 | 117 | caldb.execute() | ... | ... |
examples/benchmark_cta_analysis.py renamed to test/dev/benchmark_cta_analysis.py
examples/check_models.py renamed to test/dev/check_models.py
examples/simulate_events.py renamed to test/dev/simulate_events.py
test/test_examples.py
| ... | ... | @@ -77,6 +77,7 @@ class Test(gammalib.GPythonTestSuite): |
| 77 | 77 | self.name('examples') |
| 78 | 78 | |
| 79 | 79 | # Append tests |
| 80 | + self.append(self.test_generate_prod3_irfs, 'Test generate_prod3_irfs') | |
| 80 | 81 | self.append(self.test_pipeline_binned_disk, 'Test pipeline_binned_disk') |
| 81 | 82 | self.append(self.test_pipeline_binned_mem, 'Test pipeline_binned_mem') |
| 82 | 83 | self.append(self.test_pipeline_stacked_disk, 'Test pipeline_stacked_disk') |
| ... | ... | @@ -87,6 +88,19 @@ class Test(gammalib.GPythonTestSuite): |
| 87 | 88 | # Return |
| 88 | 89 | return |
| 89 | 90 | |
| 91 | + # Test generate_prod3_irfs | |
| 92 | + def test_generate_prod3_irfs(self): | |
| 93 | + """ | |
| 94 | + Test generate_prod3_irfs | |
| 95 | + """ | |
| 96 | + # Execute script | |
| 97 | + self._execute_python('generate_prod3_irfs') | |
| 98 | + | |
| 99 | + #TODO: Do any testing | |
| 100 | + | |
| 101 | + # Return | |
| 102 | + return | |
| 103 | + | |
| 90 | 104 | # Test pipeline_binned_disk |
| 91 | 105 | def test_pipeline_binned_disk(self): |
| 92 | 106 | """ | ... | ... |