Commit bcae3ed6ca49e53cbcdb93c79b9fe8c6803a07ef
1 parent
fc2a1c1d
correct formatting
Showing
1 changed file
with
18 additions
and
18 deletions
test/test_python.py
| @@ -17,11 +17,11 @@ import sys | @@ -17,11 +17,11 @@ import sys | ||
| 17 | def pipeline_v1(): | 17 | def pipeline_v1(): |
| 18 | """ | 18 | """ |
| 19 | Unbinned analysis pipeline - save intermediate results. | 19 | Unbinned analysis pipeline - save intermediate results. |
| 20 | - | ||
| 21 | - This function implements an analysis pipeline that successively calls | ||
| 22 | - ctobssim, ctselect and ctlike by saving the intermediate results as FITS | ||
| 23 | - files on disk. This replicates the way how the analysis would be done | ||
| 24 | - in a ftools-like approach. | 20 | + |
| 21 | + This function implements an analysis pipeline that successively calls | ||
| 22 | + ctobssim, ctselect and ctlike by saving the intermediate results as FITS | ||
| 23 | + files on disk. This replicates the way how the analysis would be done | ||
| 24 | + in a ftools-like approach. | ||
| 25 | """ | 25 | """ |
| 26 | # Set script parameters | 26 | # Set script parameters |
| 27 | model_name = "data/crab.xml" | 27 | model_name = "data/crab.xml" |
| @@ -38,11 +38,11 @@ def pipeline_v1(): | @@ -38,11 +38,11 @@ def pipeline_v1(): | ||
| 38 | emin = 0.1 | 38 | emin = 0.1 |
| 39 | emax = 100.0 | 39 | emax = 100.0 |
| 40 | rad_select = 3.0 | 40 | rad_select = 3.0 |
| 41 | - | 41 | + |
| 42 | # Initialise timing | 42 | # Initialise timing |
| 43 | wall_seconds = 0.0 | 43 | wall_seconds = 0.0 |
| 44 | cpu_seconds = 0.0 | 44 | cpu_seconds = 0.0 |
| 45 | - | 45 | + |
| 46 | # Simulate events | 46 | # Simulate events |
| 47 | sim = ctobssim() | 47 | sim = ctobssim() |
| 48 | sim.logFileOpen() | 48 | sim.logFileOpen() |
| @@ -59,7 +59,7 @@ def pipeline_v1(): | @@ -59,7 +59,7 @@ def pipeline_v1(): | ||
| 59 | sim["emax"].real(emax) | 59 | sim["emax"].real(emax) |
| 60 | sim.execute() | 60 | sim.execute() |
| 61 | sys.stdout.write(".") | 61 | sys.stdout.write(".") |
| 62 | - | 62 | + |
| 63 | # Select events | 63 | # Select events |
| 64 | select = ctselect() | 64 | select = ctselect() |
| 65 | select.logFileOpen() | 65 | select.logFileOpen() |
| @@ -74,7 +74,7 @@ def pipeline_v1(): | @@ -74,7 +74,7 @@ def pipeline_v1(): | ||
| 74 | select["emax"].real(emax) | 74 | select["emax"].real(emax) |
| 75 | select.execute() | 75 | select.execute() |
| 76 | sys.stdout.write(".") | 76 | sys.stdout.write(".") |
| 77 | - | 77 | + |
| 78 | # Perform maximum likelihood fitting | 78 | # Perform maximum likelihood fitting |
| 79 | like = ctlike() | 79 | like = ctlike() |
| 80 | like.logFileOpen() | 80 | like.logFileOpen() |
| @@ -86,7 +86,7 @@ def pipeline_v1(): | @@ -86,7 +86,7 @@ def pipeline_v1(): | ||
| 86 | like["irf"].string(irf) | 86 | like["irf"].string(irf) |
| 87 | like.execute() | 87 | like.execute() |
| 88 | sys.stdout.write(".") | 88 | sys.stdout.write(".") |
| 89 | - | 89 | + |
| 90 | # Return | 90 | # Return |
| 91 | return | 91 | return |
| 92 | 92 | ||
| @@ -97,9 +97,9 @@ def pipeline_v1(): | @@ -97,9 +97,9 @@ def pipeline_v1(): | ||
| 97 | def pipeline_v2(): | 97 | def pipeline_v2(): |
| 98 | """ | 98 | """ |
| 99 | Unbinned analysis pipeline - keep intermediate results in memory. | 99 | Unbinned analysis pipeline - keep intermediate results in memory. |
| 100 | - | ||
| 101 | - This function implements an analysis pipeline that successively calls | ||
| 102 | - ctobssim, ctselect and ctlike without saving the intermediate results as | 100 | + |
| 101 | + This function implements an analysis pipeline that successively calls | ||
| 102 | + ctobssim, ctselect and ctlike without saving the intermediate results as | ||
| 103 | FITS files on disk. All data is only hold in memory. | 103 | FITS files on disk. All data is only hold in memory. |
| 104 | """ | 104 | """ |
| 105 | # Set script parameters | 105 | # Set script parameters |
| @@ -114,11 +114,11 @@ def pipeline_v2(): | @@ -114,11 +114,11 @@ def pipeline_v2(): | ||
| 114 | emin = 0.1 | 114 | emin = 0.1 |
| 115 | emax = 100.0 | 115 | emax = 100.0 |
| 116 | rad_select = 3.0 | 116 | rad_select = 3.0 |
| 117 | - | 117 | + |
| 118 | # Initialise timing | 118 | # Initialise timing |
| 119 | wall_seconds = 0.0 | 119 | wall_seconds = 0.0 |
| 120 | cpu_seconds = 0.0 | 120 | cpu_seconds = 0.0 |
| 121 | - | 121 | + |
| 122 | # Simulate events | 122 | # Simulate events |
| 123 | sim = ctobssim() | 123 | sim = ctobssim() |
| 124 | sim["infile"].filename(model_name) | 124 | sim["infile"].filename(model_name) |
| @@ -133,7 +133,7 @@ def pipeline_v2(): | @@ -133,7 +133,7 @@ def pipeline_v2(): | ||
| 133 | sim["emax"].real(emax) | 133 | sim["emax"].real(emax) |
| 134 | sim.run() | 134 | sim.run() |
| 135 | sys.stdout.write(".") | 135 | sys.stdout.write(".") |
| 136 | - | 136 | + |
| 137 | # Select events | 137 | # Select events |
| 138 | select = ctselect(sim.obs()) | 138 | select = ctselect(sim.obs()) |
| 139 | select["ra"].real(ra) | 139 | select["ra"].real(ra) |
| @@ -145,12 +145,12 @@ def pipeline_v2(): | @@ -145,12 +145,12 @@ def pipeline_v2(): | ||
| 145 | select["emax"].real(emax) | 145 | select["emax"].real(emax) |
| 146 | select.run() | 146 | select.run() |
| 147 | sys.stdout.write(".") | 147 | sys.stdout.write(".") |
| 148 | - | 148 | + |
| 149 | # Perform maximum likelihood fitting | 149 | # Perform maximum likelihood fitting |
| 150 | like = ctlike(select.obs()) | 150 | like = ctlike(select.obs()) |
| 151 | like.run() | 151 | like.run() |
| 152 | sys.stdout.write(".") | 152 | sys.stdout.write(".") |
| 153 | - | 153 | + |
| 154 | # Return | 154 | # Return |
| 155 | return | 155 | return |
| 156 | 156 |