Commit 24451dd32c995e7fe8180b2be1f12fa6b63a73d2
Merge branch 'integration' into devel
Showing
32 changed files
with
748 additions
and
755 deletions
doc/source/user_manual/getting_started/python.rst
| ... | ... | @@ -22,29 +22,26 @@ To illustrate how to use ctools from Python, below is a working example |
| 22 | 22 | of an event list simulation using the :ref:`ctobssim` class. |
| 23 | 23 | An instance ``sim`` of the :ref:`ctobssim` class is generated and user |
| 24 | 24 | parameters are set for this instance using the ``[ ]`` operator. |
| 25 | -Note that specific methods exist for [file], [string], [real], [integer], | |
| 26 | -and [boolean] parameter types (see the :ref:`reference` for a list of | |
| 27 | -parameters and their types). | |
| 25 | +See the :ref:`reference` for a list of parameters and their types). | |
| 28 | 26 | The ``execute()`` method executes the :ref:`ctobssim` class in the same |
| 29 | 27 | way as if it were executed from the command line. |
| 30 | 28 | |
| 31 | 29 | .. code-block:: python |
| 32 | 30 | |
| 33 | - >>> import gammalib | |
| 34 | - >>> import ctools | |
| 35 | - >>> sim = ctools.ctobssim() | |
| 36 | - >>> sim["inmodel"].filename("${CTOOLS}/share/models/crab.xml") | |
| 37 | - >>> sim["outevents"].filename("events.fits") | |
| 38 | - >>> sim["caldb"].string("prod2") | |
| 39 | - >>> sim["irf"].string("South_50h") | |
| 40 | - >>> sim["ra"].real(83.63) | |
| 41 | - >>> sim["dec"].real(22.01) | |
| 42 | - >>> sim["rad"].real(5.0) | |
| 43 | - >>> sim["tmin"].real(0.0) | |
| 44 | - >>> sim["tmax"].real(1800.0) | |
| 45 | - >>> sim["emin"].real(0.1) | |
| 46 | - >>> sim["emax"].real(100.0) | |
| 47 | - >>> sim.execute() | |
| 31 | + import ctools | |
| 32 | + sim = ctools.ctobssim() | |
| 33 | + sim["inmodel"] = "${CTOOLS}/share/models/crab.xml" | |
| 34 | + sim["outevents"] = "events.fits" | |
| 35 | + sim["caldb"] = "prod2" | |
| 36 | + sim["irf"] = "South_50h" | |
| 37 | + sim["ra"] = 83.63 | |
| 38 | + sim["dec"] = 22.01 | |
| 39 | + sim["rad"] = 5.0 | |
| 40 | + sim["tmin"] = 0 | |
| 41 | + sim["tmax"] = 1800 | |
| 42 | + sim["emin"] = 0.1 | |
| 43 | + sim["emax"] = 100 | |
| 44 | + sim.execute() | |
| 48 | 45 | |
| 49 | 46 | Alternatively, you may "run" the :ref:`ctobssim` tool using |
| 50 | 47 | |
| ... | ... | @@ -364,5 +361,3 @@ You now have learned the basics of using ctools and GammaLib within Python. |
| 364 | 361 | To go beyond these initial steps you may check the Python scripts in the |
| 365 | 362 | ``examples`` folder that provide useful analysis examples. |
| 366 | 363 | Check the ``README`` file in that folder for an explanation of the scripts. |
| 367 | - | |
| 368 | - | ... | ... |
examples/benchmark_cta_analysis.py
| ... | ... | @@ -55,27 +55,27 @@ def unbinned_pipeline(duration): |
| 55 | 55 | |
| 56 | 56 | # Simulate events |
| 57 | 57 | sim = ctools.ctobssim() |
| 58 | - sim["inmodel"].filename(model_name) | |
| 59 | - sim["caldb"].string(caldb) | |
| 60 | - sim["irf"].string(irf) | |
| 61 | - sim["ra"].real(ra) | |
| 62 | - sim["dec"].real(dec) | |
| 63 | - sim["rad"].real(rad_sim) | |
| 64 | - sim["tmin"].real(tstart) | |
| 65 | - sim["tmax"].real(tstop) | |
| 66 | - sim["emin"].real(emin) | |
| 67 | - sim["emax"].real(emax) | |
| 58 | + sim["inmodel"] = model_name | |
| 59 | + sim["caldb"] = caldb | |
| 60 | + sim["irf"] = irf | |
| 61 | + sim["ra"] = ra | |
| 62 | + sim["dec"] = dec | |
| 63 | + sim["rad"] = rad_sim | |
| 64 | + sim["tmin"] = tstart | |
| 65 | + sim["tmax"] = tstop | |
| 66 | + sim["emin"] = emin | |
| 67 | + sim["emax"] = emax | |
| 68 | 68 | sim.run() |
| 69 | 69 | |
| 70 | 70 | # Select events |
| 71 | 71 | select = ctools.ctselect(sim.obs()) |
| 72 | - select["ra"].real(ra) | |
| 73 | - select["dec"].real(dec) | |
| 74 | - select["rad"].real(rad_select) | |
| 75 | - select["tmin"].real(tstart) | |
| 76 | - select["tmax"].real(tstop) | |
| 77 | - select["emin"].real(emin) | |
| 78 | - select["emax"].real(emax) | |
| 72 | + select["ra"] = ra | |
| 73 | + select["dec"] = dec | |
| 74 | + select["rad"] = rad_select | |
| 75 | + select["tmin"] = tstart | |
| 76 | + select["tmax"] = tstop | |
| 77 | + select["emin"] = emin | |
| 78 | + select["emax"] = emax | |
| 79 | 79 | select.run() |
| 80 | 80 | |
| 81 | 81 | # Get ctlike start CPU time |
| ... | ... | @@ -124,31 +124,31 @@ def binned_pipeline(duration): |
| 124 | 124 | |
| 125 | 125 | # Simulate events |
| 126 | 126 | sim = ctools.ctobssim() |
| 127 | - sim["inmodel"].filename(model_name) | |
| 128 | - sim["caldb"].string(caldb) | |
| 129 | - sim["irf"].string(irf) | |
| 130 | - sim["ra"].real(ra) | |
| 131 | - sim["dec"].real(dec) | |
| 132 | - sim["rad"].real(rad_sim) | |
| 133 | - sim["tmin"].real(tstart) | |
| 134 | - sim["tmax"].real(tstop) | |
| 135 | - sim["emin"].real(emin) | |
| 136 | - sim["emax"].real(emax) | |
| 127 | + sim["inmodel"] = model_name | |
| 128 | + sim["caldb"] = caldb | |
| 129 | + sim["irf"] = irf | |
| 130 | + sim["ra"] = ra | |
| 131 | + sim["dec"] = dec | |
| 132 | + sim["rad"] = rad_sim | |
| 133 | + sim["tmin"] = tstart | |
| 134 | + sim["tmax"] = tstop | |
| 135 | + sim["emin"] = emin | |
| 136 | + sim["emax"] = emax | |
| 137 | 137 | sim.run() |
| 138 | 138 | |
| 139 | 139 | # Bin events into counts map |
| 140 | 140 | bin = ctools.ctbin(sim.obs()) |
| 141 | - bin["ebinalg"].string("LOG") | |
| 142 | - bin["emin"].real(emin) | |
| 143 | - bin["emax"].real(emax) | |
| 144 | - bin["enumbins"].integer(enumbins) | |
| 145 | - bin["nxpix"].integer(nxpix) | |
| 146 | - bin["nypix"].integer(nypix) | |
| 147 | - bin["binsz"].real(binsz) | |
| 148 | - bin["coordsys"].string(coordsys) | |
| 149 | - bin["xref"].real(ra) | |
| 150 | - bin["yref"].real(dec) | |
| 151 | - bin["proj"].string(proj) | |
| 141 | + bin["ebinalg"] = "LOG" | |
| 142 | + bin["emin"] = emin | |
| 143 | + bin["emax"] = emax | |
| 144 | + bin["enumbins"] = enumbins | |
| 145 | + bin["nxpix"] = nxpix | |
| 146 | + bin["nypix"] = nypix | |
| 147 | + bin["binsz"] = binsz | |
| 148 | + bin["coordsys"] = coordsys | |
| 149 | + bin["xref"] = ra | |
| 150 | + bin["yref"] = dec | |
| 151 | + bin["proj"] = proj | |
| 152 | 152 | bin.run() |
| 153 | 153 | |
| 154 | 154 | # Get ctlike start CPU time |
| ... | ... | @@ -197,83 +197,83 @@ def stacked_pipeline(duration): |
| 197 | 197 | |
| 198 | 198 | # Simulate events |
| 199 | 199 | sim = ctools.ctobssim() |
| 200 | - sim["inmodel"].filename(model_name) | |
| 201 | - sim["caldb"].string(caldb) | |
| 202 | - sim["irf"].string(irf) | |
| 203 | - sim["ra"].real(ra) | |
| 204 | - sim["dec"].real(dec) | |
| 205 | - sim["rad"].real(rad_sim) | |
| 206 | - sim["tmin"].real(tstart) | |
| 207 | - sim["tmax"].real(tstop) | |
| 208 | - sim["emin"].real(emin) | |
| 209 | - sim["emax"].real(emax) | |
| 200 | + sim["inmodel"] = model_name | |
| 201 | + sim["caldb"] = caldb | |
| 202 | + sim["irf"] = irf | |
| 203 | + sim["ra"] = ra | |
| 204 | + sim["dec"] = dec | |
| 205 | + sim["rad"] = rad_sim | |
| 206 | + sim["tmin"] = tstart | |
| 207 | + sim["tmax"] = tstop | |
| 208 | + sim["emin"] = emin | |
| 209 | + sim["emax"] = emax | |
| 210 | 210 | sim.run() |
| 211 | 211 | |
| 212 | 212 | # Bin events into counts map |
| 213 | 213 | bin = ctools.ctbin(sim.obs()) |
| 214 | - bin["ebinalg"].string("LOG") | |
| 215 | - bin["emin"].real(emin) | |
| 216 | - bin["emax"].real(emax) | |
| 217 | - bin["enumbins"].integer(enumbins) | |
| 218 | - bin["nxpix"].integer(nxpix) | |
| 219 | - bin["nypix"].integer(nypix) | |
| 220 | - bin["binsz"].real(binsz) | |
| 221 | - bin["coordsys"].string(coordsys) | |
| 222 | - bin["proj"].string(proj) | |
| 223 | - bin["xref"].real(ra) | |
| 224 | - bin["yref"].real(dec) | |
| 214 | + bin["ebinalg"] = "LOG" | |
| 215 | + bin["emin"] = emin | |
| 216 | + bin["emax"] = emax | |
| 217 | + bin["enumbins"] = enumbins | |
| 218 | + bin["nxpix"] = nxpix | |
| 219 | + bin["nypix"] = nypix | |
| 220 | + bin["binsz"] = binsz | |
| 221 | + bin["coordsys"] = coordsys | |
| 222 | + bin["proj"] = proj | |
| 223 | + bin["xref"] = ra | |
| 224 | + bin["yref"] = dec | |
| 225 | 225 | bin.run() |
| 226 | 226 | |
| 227 | 227 | # Create exposure cube |
| 228 | 228 | expcube = ctools.ctexpcube(sim.obs()) |
| 229 | - expcube["incube"].filename("NONE") | |
| 230 | - expcube["caldb"].string(caldb) | |
| 231 | - expcube["irf"].string(irf) | |
| 232 | - expcube["ebinalg"].string("LOG") | |
| 233 | - expcube["emin"].real(emin) | |
| 234 | - expcube["emax"].real(emax) | |
| 235 | - expcube["enumbins"].integer(enumbins) | |
| 236 | - expcube["nxpix"].integer(nxpix) | |
| 237 | - expcube["nypix"].integer(nypix) | |
| 238 | - expcube["binsz"].real(binsz) | |
| 239 | - expcube["coordsys"].string(coordsys) | |
| 240 | - expcube["proj"].string(proj) | |
| 241 | - expcube["xref"].real(ra) | |
| 242 | - expcube["yref"].real(dec) | |
| 229 | + expcube["incube"] = "NONE" | |
| 230 | + expcube["caldb"] = caldb | |
| 231 | + expcube["irf"] = irf | |
| 232 | + expcube["ebinalg"] = "LOG" | |
| 233 | + expcube["emin"] = emin | |
| 234 | + expcube["emax"] = emax | |
| 235 | + expcube["enumbins"] = enumbins | |
| 236 | + expcube["nxpix"] = nxpix | |
| 237 | + expcube["nypix"] = nypix | |
| 238 | + expcube["binsz"] = binsz | |
| 239 | + expcube["coordsys"] = coordsys | |
| 240 | + expcube["proj"] = proj | |
| 241 | + expcube["xref"] = ra | |
| 242 | + expcube["yref"] = dec | |
| 243 | 243 | expcube.run() |
| 244 | 244 | |
| 245 | 245 | # Create PSF cube |
| 246 | 246 | psfcube = ctools.ctpsfcube(sim.obs()) |
| 247 | - psfcube["incube"].filename("NONE") | |
| 248 | - psfcube["caldb"].string(caldb) | |
| 249 | - psfcube["irf"].string(irf) | |
| 250 | - psfcube["ebinalg"].string("LOG") | |
| 251 | - psfcube["emin"].real(emin) | |
| 252 | - psfcube["emax"].real(emax) | |
| 253 | - psfcube["enumbins"].integer(enumbins) | |
| 254 | - psfcube["nxpix"].integer(10) | |
| 255 | - psfcube["nypix"].integer(10) | |
| 256 | - psfcube["binsz"].real(1.0) | |
| 257 | - psfcube["coordsys"].string(coordsys) | |
| 258 | - psfcube["proj"].string(proj) | |
| 259 | - psfcube["xref"].real(ra) | |
| 260 | - psfcube["yref"].real(dec) | |
| 247 | + psfcube["incube"] = "NONE" | |
| 248 | + psfcube["caldb"] = caldb | |
| 249 | + psfcube["irf"] = irf | |
| 250 | + psfcube["ebinalg"] = "LOG" | |
| 251 | + psfcube["emin"] = emin | |
| 252 | + psfcube["emax"] = emax | |
| 253 | + psfcube["enumbins"] = enumbins | |
| 254 | + psfcube["nxpix"] = 10 | |
| 255 | + psfcube["nypix"] = 10 | |
| 256 | + psfcube["binsz"] = 1.0 | |
| 257 | + psfcube["coordsys"] = coordsys | |
| 258 | + psfcube["proj"] = proj | |
| 259 | + psfcube["xref"] = ra | |
| 260 | + psfcube["yref"] = dec | |
| 261 | 261 | psfcube.run() |
| 262 | 262 | |
| 263 | 263 | # Create background cube |
| 264 | 264 | bkgcube = ctools.ctbkgcube(sim.obs()) |
| 265 | - bkgcube["incube"].filename("NONE") | |
| 266 | - bkgcube["ebinalg"].string("LOG") | |
| 267 | - bkgcube["emin"].real(emin) | |
| 268 | - bkgcube["emax"].real(emax) | |
| 269 | - bkgcube["enumbins"].integer(enumbins) | |
| 270 | - bkgcube["nxpix"].integer(10) | |
| 271 | - bkgcube["nypix"].integer(10) | |
| 272 | - bkgcube["binsz"].real(1.0) | |
| 273 | - bkgcube["coordsys"].string(coordsys) | |
| 274 | - bkgcube["proj"].string(proj) | |
| 275 | - bkgcube["xref"].real(ra) | |
| 276 | - bkgcube["yref"].real(dec) | |
| 265 | + bkgcube["incube"] = "NONE" | |
| 266 | + bkgcube["ebinalg"] = "LOG" | |
| 267 | + bkgcube["emin"] = emin | |
| 268 | + bkgcube["emax"] = emax | |
| 269 | + bkgcube["enumbins"] = enumbins | |
| 270 | + bkgcube["nxpix"] = 10 | |
| 271 | + bkgcube["nypix"] = 10 | |
| 272 | + bkgcube["binsz"] = 1.0 | |
| 273 | + bkgcube["coordsys"] = coordsys | |
| 274 | + bkgcube["proj"] = proj | |
| 275 | + bkgcube["xref"] = ra | |
| 276 | + bkgcube["yref"] = dec | |
| 277 | 277 | bkgcube.run() |
| 278 | 278 | |
| 279 | 279 | # Attach background model to observation container | ... | ... |
examples/check_models.py
| ... | ... | @@ -61,27 +61,27 @@ def pipeline(model_name): |
| 61 | 61 | |
| 62 | 62 | # Simulate events |
| 63 | 63 | sim = ctools.ctobssim() |
| 64 | - sim["inmodel"].filename(model_name) | |
| 65 | - sim["caldb"].string(caldb) | |
| 66 | - sim["irf"].string(irf) | |
| 67 | - sim["ra"].real(ra) | |
| 68 | - sim["dec"].real(dec) | |
| 69 | - sim["rad"].real(rad_sim) | |
| 70 | - sim["tmin"].real(tstart) | |
| 71 | - sim["tmax"].real(tstop) | |
| 72 | - sim["emin"].real(emin) | |
| 73 | - sim["emax"].real(emax) | |
| 64 | + sim["inmodel"] = model_name | |
| 65 | + sim["caldb"] = caldb | |
| 66 | + sim["irf"] = irf | |
| 67 | + sim["ra"] = ra | |
| 68 | + sim["dec"] = dec | |
| 69 | + sim["rad"] = rad_sim | |
| 70 | + sim["tmin"] = tstart | |
| 71 | + sim["tmax"] = tstop | |
| 72 | + sim["emin"] = emin | |
| 73 | + sim["emax"] = emax | |
| 74 | 74 | sim.run() |
| 75 | 75 | |
| 76 | 76 | # Select events |
| 77 | 77 | select = ctools.ctselect(sim.obs()) |
| 78 | - select["ra"].real(ra) | |
| 79 | - select["dec"].real(dec) | |
| 80 | - select["rad"].real(rad_select) | |
| 81 | - select["tmin"].real(tstart) | |
| 82 | - select["tmax"].real(tstop) | |
| 83 | - select["emin"].real(emin) | |
| 84 | - select["emax"].real(emax) | |
| 78 | + select["ra"] = ra | |
| 79 | + select["dec"] = dec | |
| 80 | + select["rad"] = rad_select | |
| 81 | + select["tmin"] = tstart | |
| 82 | + select["tmax"] = tstop | |
| 83 | + select["emin"] = emin | |
| 84 | + select["emax"] = emax | |
| 85 | 85 | select.run() |
| 86 | 86 | |
| 87 | 87 | # Perform maximum likelihood fitting | ... | ... |
examples/make_spectrum.py
| ... | ... | @@ -48,16 +48,16 @@ def make_spectrum(): |
| 48 | 48 | |
| 49 | 49 | # Simulate events |
| 50 | 50 | sim = ctools.ctobssim() |
| 51 | - sim["inmodel"].filename(model_name) | |
| 52 | - sim["caldb"].string(caldb) | |
| 53 | - sim["irf"].string(irf) | |
| 54 | - sim["ra"].real(ra) | |
| 55 | - sim["dec"].real(dec) | |
| 56 | - sim["rad"].real(rad_sim) | |
| 57 | - sim["tmin"].real(tstart) | |
| 58 | - sim["tmax"].real(tstop) | |
| 59 | - sim["emin"].real(emin) | |
| 60 | - sim["emax"].real(emax) | |
| 51 | + sim["inmodel"] = model_name | |
| 52 | + sim["caldb"] = caldb | |
| 53 | + sim["irf"] = irf | |
| 54 | + sim["ra"] = ra | |
| 55 | + sim["dec"] = dec | |
| 56 | + sim["rad"] = rad_sim | |
| 57 | + sim["tmin"] = tstart | |
| 58 | + sim["tmax"] = tstop | |
| 59 | + sim["emin"] = emin | |
| 60 | + sim["emax"] = emax | |
| 61 | 61 | sim.run() |
| 62 | 62 | |
| 63 | 63 | # Generate an energy binning | ... | ... |
examples/make_ts_distributions.py
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 29 | 29 | # |
| 30 | 30 | # ========================================================================== |
| 31 | -from cstsdist import * | |
| 31 | +from ctools.cstsdist import * | |
| 32 | 32 | import sys |
| 33 | 33 | import time |
| 34 | 34 | |
| ... | ... | @@ -61,22 +61,22 @@ def create_ts(loge, emin, emax, ntrials=100, duration=180000.0, \ |
| 61 | 61 | |
| 62 | 62 | # Setup cstsdist tool |
| 63 | 63 | tsdist = cstsdist() |
| 64 | - tsdist["inmodel"].filename("$CTOOLS/share/models/crab.xml") | |
| 65 | - tsdist["srcname"].string("Crab") | |
| 66 | - tsdist["outfile"].filename(outfile) | |
| 67 | - tsdist["ntrials"].integer(ntrials) | |
| 68 | - tsdist["caldb"].string("prod2") | |
| 69 | - tsdist["irf"].string("South_50h") | |
| 70 | - tsdist["ra"].real(83.63) | |
| 71 | - tsdist["dec"].real(22.01) | |
| 72 | - tsdist["emin"].real(float(emin)) | |
| 73 | - tsdist["emax"].real(float(emax)) | |
| 74 | - tsdist["enumbins"].integer(int(enumbins)) | |
| 75 | - tsdist["tmin"].real(0.0) | |
| 76 | - tsdist["tmax"].real(float(duration)) | |
| 77 | - tsdist["rad"].real(5.0) | |
| 78 | - tsdist["npix"].integer(200) | |
| 79 | - tsdist["binsz"].real(0.05) | |
| 64 | + tsdist["inmodel"] = "$CTOOLS/share/models/crab.xml" | |
| 65 | + tsdist["srcname"] = "Crab" | |
| 66 | + tsdist["outfile"] = outfile | |
| 67 | + tsdist["ntrials"] = ntrials | |
| 68 | + tsdist["caldb"] = "prod2" | |
| 69 | + tsdist["irf"] = "South_50h" | |
| 70 | + tsdist["ra"] = 83.63 | |
| 71 | + tsdist["dec"] = 22.01 | |
| 72 | + tsdist["emin"] = emin | |
| 73 | + tsdist["emax"] = emax | |
| 74 | + tsdist["enumbins"] = enumbins | |
| 75 | + tsdist["tmin"] = 0 | |
| 76 | + tsdist["tmax"] = duration | |
| 77 | + tsdist["rad"] = 5.0 | |
| 78 | + tsdist["npix"] = 200 | |
| 79 | + tsdist["binsz"] = 0.05 | |
| 80 | 80 | #tsdist["debug"].boolean(True) |
| 81 | 81 | |
| 82 | 82 | # Optionally open the log file | ... | ... |
examples/pipeline_binned_disk.py
| ... | ... | @@ -117,8 +117,8 @@ def run_pipeline(obs, emin=0.1, emax=100.0, \ |
| 117 | 117 | """ |
| 118 | 118 | # Simulate events |
| 119 | 119 | sim = ctools.ctobssim(obs) |
| 120 | - sim["debug"].boolean(debug) | |
| 121 | - sim["outevents"].filename("obs.xml") | |
| 120 | + sim["debug"] = debug | |
| 121 | + sim["outevents"] = "obs.xml" | |
| 122 | 122 | sim.execute() |
| 123 | 123 | |
| 124 | 124 | # Bin events by looping over all observations in the container |
| ... | ... | @@ -132,18 +132,18 @@ def run_pipeline(obs, emin=0.1, emax=100.0, \ |
| 132 | 132 | |
| 133 | 133 | # Bin events for that observation |
| 134 | 134 | bin = ctools.ctbin() |
| 135 | - bin["inobs"].filename(eventfile) | |
| 136 | - bin["outcube"].filename(cubefile) | |
| 137 | - bin["ebinalg"].string("LOG") | |
| 138 | - bin["emin"].real(emin) | |
| 139 | - bin["emax"].real(emax) | |
| 140 | - bin["enumbins"].integer(enumbins) | |
| 141 | - bin["nxpix"].integer(nxpix) | |
| 142 | - bin["nypix"].integer(nypix) | |
| 143 | - bin["binsz"].real(binsz) | |
| 144 | - bin["coordsys"].string(coordsys) | |
| 145 | - bin["usepnt"].boolean(True) | |
| 146 | - bin["proj"].string(proj) | |
| 135 | + bin["inobs"] = eventfile | |
| 136 | + bin["outcube"] = cubefile | |
| 137 | + bin["ebinalg"] = "LOG" | |
| 138 | + bin["emin"] = emin | |
| 139 | + bin["emax"] = emax | |
| 140 | + bin["enumbins"] = enumbins | |
| 141 | + bin["nxpix"] = nxpix | |
| 142 | + bin["nypix"] = nypix | |
| 143 | + bin["binsz"] = binsz | |
| 144 | + bin["coordsys"] = coordsys | |
| 145 | + bin["usepnt"] = True | |
| 146 | + bin["proj"] = proj | |
| 147 | 147 | bin.execute() |
| 148 | 148 | |
| 149 | 149 | # Set observation ID |
| ... | ... | @@ -160,15 +160,15 @@ def run_pipeline(obs, emin=0.1, emax=100.0, \ |
| 160 | 160 | |
| 161 | 161 | # Perform maximum likelihood fitting |
| 162 | 162 | like = ctools.ctlike() |
| 163 | - like["inobs"].filename("obs_cube.xml") | |
| 164 | - like["inmodel"].filename(model) | |
| 165 | - like["outmodel"].filename("fit_results.xml") | |
| 166 | - like["expcube"].filename("NONE") | |
| 167 | - like["psfcube"].filename("NONE") | |
| 168 | - like["bkgcube"].filename("NONE") | |
| 169 | - like["caldb"].string(caldb) | |
| 170 | - like["irf"].string(irf) | |
| 171 | - like["debug"].boolean(True) # Switch this always on for results in console | |
| 163 | + like["inobs"] = "obs_cube.xml" | |
| 164 | + like["inmodel"] = model | |
| 165 | + like["outmodel"] = "fit_results.xml" | |
| 166 | + like["expcube"] = "NONE" | |
| 167 | + like["psfcube"] = "NONE" | |
| 168 | + like["bkgcube"] = "NONE" | |
| 169 | + like["caldb"] = caldb | |
| 170 | + like["irf"] = irf | |
| 171 | + like["debug"] = True # Switch this always on for results in console | |
| 172 | 172 | like.execute() |
| 173 | 173 | |
| 174 | 174 | # Return | ... | ... |
examples/pipeline_binned_mem.py
| ... | ... | @@ -111,7 +111,7 @@ def run_pipeline(obs, emin=0.1, emax=100.0, \ |
| 111 | 111 | """ |
| 112 | 112 | # Simulate events |
| 113 | 113 | sim = ctools.ctobssim(obs) |
| 114 | - sim["debug"].boolean(debug) | |
| 114 | + sim["debug"] = debug | |
| 115 | 115 | sim.run() |
| 116 | 116 | |
| 117 | 117 | # Bin events by looping over all observations in the container |
| ... | ... | @@ -125,16 +125,16 @@ def run_pipeline(obs, emin=0.1, emax=100.0, \ |
| 125 | 125 | |
| 126 | 126 | # Bin events for that observation |
| 127 | 127 | bin = ctools.ctbin(container) |
| 128 | - bin["ebinalg"].string("LOG") | |
| 129 | - bin["emin"].real(emin) | |
| 130 | - bin["emax"].real(emax) | |
| 131 | - bin["enumbins"].integer(enumbins) | |
| 132 | - bin["nxpix"].integer(nxpix) | |
| 133 | - bin["nypix"].integer(nypix) | |
| 134 | - bin["binsz"].real(binsz) | |
| 135 | - bin["coordsys"].string(coordsys) | |
| 136 | - bin["usepnt"].boolean(True) | |
| 137 | - bin["proj"].string(proj) | |
| 128 | + bin["ebinalg"] = "LOG" | |
| 129 | + bin["emin"] = emin | |
| 130 | + bin["emax"] = emax | |
| 131 | + bin["enumbins"] = enumbins | |
| 132 | + bin["nxpix"] = nxpix | |
| 133 | + bin["nypix"] = nypix | |
| 134 | + bin["binsz"] = binsz | |
| 135 | + bin["coordsys"] = coordsys | |
| 136 | + bin["usepnt"] = True | |
| 137 | + bin["proj"] = proj | |
| 138 | 138 | bin.run() |
| 139 | 139 | |
| 140 | 140 | # Append result to observations |
| ... | ... | @@ -142,7 +142,7 @@ def run_pipeline(obs, emin=0.1, emax=100.0, \ |
| 142 | 142 | |
| 143 | 143 | # Perform maximum likelihood fitting |
| 144 | 144 | like = ctools.ctlike(obs) |
| 145 | - like["debug"].boolean(True) # Switch this always on for results in console | |
| 145 | + like["debug"] = True # Switch this always on for results in console | |
| 146 | 146 | like.run() |
| 147 | 147 | |
| 148 | 148 | # Return | ... | ... |
examples/pipeline_stacked_disk.py
| ... | ... | @@ -116,104 +116,104 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, \ |
| 116 | 116 | """ |
| 117 | 117 | # Simulate events |
| 118 | 118 | sim = ctools.ctobssim(obs) |
| 119 | - sim["debug"].boolean(debug) | |
| 120 | - sim["outevents"].filename("obs.xml") | |
| 119 | + sim["debug"] = debug | |
| 120 | + sim["outevents"] = "obs.xml" | |
| 121 | 121 | sim.execute() |
| 122 | 122 | |
| 123 | 123 | # Bin events into counts map |
| 124 | 124 | bin = ctools.ctbin() |
| 125 | - bin["inobs"].filename("obs.xml") | |
| 126 | - bin["outcube"].filename("cntcube.fits") | |
| 127 | - bin["ebinalg"].string("LOG") | |
| 128 | - bin["emin"].real(emin) | |
| 129 | - bin["emax"].real(emax) | |
| 130 | - bin["enumbins"].integer(enumbins) | |
| 131 | - bin["nxpix"].integer(nxpix) | |
| 132 | - bin["nypix"].integer(nypix) | |
| 133 | - bin["binsz"].real(binsz) | |
| 134 | - bin["coordsys"].string(coordsys) | |
| 135 | - bin["proj"].string(proj) | |
| 136 | - bin["xref"].real(ra) | |
| 137 | - bin["yref"].real(dec) | |
| 138 | - bin["debug"].boolean(debug) | |
| 125 | + bin["inobs"] = "obs.xml" | |
| 126 | + bin["outcube"] = "cntcube.fits" | |
| 127 | + bin["ebinalg"] = "LOG" | |
| 128 | + bin["emin"] = emin | |
| 129 | + bin["emax"] = emax | |
| 130 | + bin["enumbins"] = enumbins | |
| 131 | + bin["nxpix"] = nxpix | |
| 132 | + bin["nypix"] = nypix | |
| 133 | + bin["binsz"] = binsz | |
| 134 | + bin["coordsys"] = coordsys | |
| 135 | + bin["proj"] = proj | |
| 136 | + bin["xref"] = ra | |
| 137 | + bin["yref"] = dec | |
| 138 | + bin["debug"] = debug | |
| 139 | 139 | bin.execute() |
| 140 | 140 | |
| 141 | 141 | # Create exposure cube |
| 142 | 142 | expcube = ctools.ctexpcube() |
| 143 | - expcube["inobs"].filename("obs.xml") | |
| 144 | - expcube["incube"].filename("cntcube.fits") | |
| 145 | - expcube["outcube"].filename("expcube.fits") | |
| 146 | - expcube["caldb"].string(caldb) | |
| 147 | - expcube["irf"].string(irf) | |
| 148 | - expcube["ebinalg"].string("LOG") | |
| 149 | - expcube["emin"].real(emin) | |
| 150 | - expcube["emax"].real(emax) | |
| 151 | - expcube["enumbins"].integer(enumbins) | |
| 152 | - expcube["nxpix"].integer(nxpix) | |
| 153 | - expcube["nypix"].integer(nypix) | |
| 154 | - expcube["binsz"].real(binsz) | |
| 155 | - expcube["coordsys"].string(coordsys) | |
| 156 | - expcube["proj"].string(proj) | |
| 157 | - expcube["xref"].real(ra) | |
| 158 | - expcube["yref"].real(dec) | |
| 159 | - expcube["debug"].boolean(debug) | |
| 143 | + expcube["inobs"] = "obs.xml" | |
| 144 | + expcube["incube"] = "cntcube.fits" | |
| 145 | + expcube["outcube"] = "expcube.fits" | |
| 146 | + expcube["caldb"] = caldb | |
| 147 | + expcube["irf"] = irf | |
| 148 | + expcube["ebinalg"] = "LOG" | |
| 149 | + expcube["emin"] = emin | |
| 150 | + expcube["emax"] = emax | |
| 151 | + expcube["enumbins"] = enumbins | |
| 152 | + expcube["nxpix"] = nxpix | |
| 153 | + expcube["nypix"] = nypix | |
| 154 | + expcube["binsz"] = binsz | |
| 155 | + expcube["coordsys"] = coordsys | |
| 156 | + expcube["proj"] = proj | |
| 157 | + expcube["xref"] = ra | |
| 158 | + expcube["yref"] = dec | |
| 159 | + expcube["debug"] = debug | |
| 160 | 160 | expcube.execute() |
| 161 | 161 | |
| 162 | 162 | # Create PSF cube |
| 163 | 163 | psfcube = ctools.ctpsfcube() |
| 164 | - psfcube["inobs"].filename("obs.xml") | |
| 165 | - psfcube["incube"].filename("NONE") | |
| 166 | - psfcube["outcube"].filename("psfcube.fits") | |
| 167 | - psfcube["caldb"].string(caldb) | |
| 168 | - psfcube["irf"].string(irf) | |
| 169 | - psfcube["ebinalg"].string("LOG") | |
| 170 | - psfcube["emin"].real(emin) | |
| 171 | - psfcube["emax"].real(emax) | |
| 172 | - psfcube["enumbins"].integer(enumbins) | |
| 173 | - psfcube["nxpix"].integer(10) | |
| 174 | - psfcube["nypix"].integer(10) | |
| 175 | - psfcube["binsz"].real(1.0) | |
| 176 | - psfcube["coordsys"].string(coordsys) | |
| 177 | - psfcube["proj"].string(proj) | |
| 178 | - psfcube["xref"].real(ra) | |
| 179 | - psfcube["yref"].real(dec) | |
| 180 | - psfcube["debug"].boolean(debug) | |
| 164 | + psfcube["inobs"] = "obs.xml" | |
| 165 | + psfcube["incube"] = "NONE" | |
| 166 | + psfcube["outcube"] = "psfcube.fits" | |
| 167 | + psfcube["caldb"] = caldb | |
| 168 | + psfcube["irf"] = irf | |
| 169 | + psfcube["ebinalg"] = "LOG" | |
| 170 | + psfcube["emin"] = emin | |
| 171 | + psfcube["emax"] = emax | |
| 172 | + psfcube["enumbins"] = enumbins | |
| 173 | + psfcube["nxpix"] = 10 | |
| 174 | + psfcube["nypix"] = 10 | |
| 175 | + psfcube["binsz"] = 1.0 | |
| 176 | + psfcube["coordsys"] = coordsys | |
| 177 | + psfcube["proj"] = proj | |
| 178 | + psfcube["xref"] = ra | |
| 179 | + psfcube["yref"] = dec | |
| 180 | + psfcube["debug"] = debug | |
| 181 | 181 | psfcube.execute() |
| 182 | 182 | |
| 183 | 183 | # Create background cube |
| 184 | 184 | bkgcube = ctools.ctbkgcube() |
| 185 | - bkgcube["inobs"].filename("obs.xml") | |
| 186 | - bkgcube["inmodel"].filename(model) | |
| 187 | - bkgcube["incube"].filename("cntcube.fits") | |
| 188 | - bkgcube["outcube"].filename("bkgcube.fits") | |
| 189 | - bkgcube["outmodel"].filename("model_bkg.xml") | |
| 190 | - bkgcube["caldb"].string(caldb) | |
| 191 | - bkgcube["irf"].string(irf) | |
| 192 | - bkgcube["ebinalg"].string("LOG") | |
| 193 | - bkgcube["emin"].real(emin) | |
| 194 | - bkgcube["emax"].real(emax) | |
| 195 | - bkgcube["enumbins"].integer(enumbins) | |
| 196 | - bkgcube["nxpix"].integer(10) | |
| 197 | - bkgcube["nypix"].integer(10) | |
| 198 | - bkgcube["binsz"].real(1.0) | |
| 199 | - bkgcube["coordsys"].string(coordsys) | |
| 200 | - bkgcube["proj"].string(proj) | |
| 201 | - bkgcube["xref"].real(ra) | |
| 202 | - bkgcube["yref"].real(dec) | |
| 203 | - bkgcube["debug"].boolean(debug) | |
| 185 | + bkgcube["inobs"] = "obs.xml" | |
| 186 | + bkgcube["inmodel"] = model | |
| 187 | + bkgcube["incube"] = "cntcube.fits" | |
| 188 | + bkgcube["outcube"] = "bkgcube.fits" | |
| 189 | + bkgcube["outmodel"] = "model_bkg.xml" | |
| 190 | + bkgcube["caldb"] = caldb | |
| 191 | + bkgcube["irf"] = irf | |
| 192 | + bkgcube["ebinalg"] = "LOG" | |
| 193 | + bkgcube["emin"] = emin | |
| 194 | + bkgcube["emax"] = emax | |
| 195 | + bkgcube["enumbins"] = enumbins | |
| 196 | + bkgcube["nxpix"] = 10 | |
| 197 | + bkgcube["nypix"] = 10 | |
| 198 | + bkgcube["binsz"] = 1.0 | |
| 199 | + bkgcube["coordsys"] = coordsys | |
| 200 | + bkgcube["proj"] = proj | |
| 201 | + bkgcube["xref"] = ra | |
| 202 | + bkgcube["yref"] = dec | |
| 203 | + bkgcube["debug"] = debug | |
| 204 | 204 | bkgcube.execute() |
| 205 | 205 | |
| 206 | 206 | # Perform maximum likelihood fitting |
| 207 | 207 | like = ctools.ctlike() |
| 208 | - like["inobs"].filename("cntcube.fits") | |
| 209 | - like["inmodel"].filename("model_bkg.xml") | |
| 210 | - like["outmodel"].filename("fit_results.xml") | |
| 211 | - like["expcube"].filename("expcube.fits") | |
| 212 | - like["psfcube"].filename("psfcube.fits") | |
| 213 | - like["bkgcube"].filename("bkgcube.fits") | |
| 214 | - like["caldb"].string(caldb) | |
| 215 | - like["irf"].string(irf) | |
| 216 | - like["debug"].boolean(True) # Switch this always on for results in console | |
| 208 | + like["inobs"] = "cntcube.fits" | |
| 209 | + like["inmodel"] = "model_bkg.xml" | |
| 210 | + like["outmodel"] = "fit_results.xml" | |
| 211 | + like["expcube"] = "expcube.fits" | |
| 212 | + like["psfcube"] = "psfcube.fits" | |
| 213 | + like["bkgcube"] = "bkgcube.fits" | |
| 214 | + like["caldb"] = caldb | |
| 215 | + like["irf"] = irf | |
| 216 | + like["debug"] = True # Switch this always on for results in console | |
| 217 | 217 | like.execute() |
| 218 | 218 | |
| 219 | 219 | # Return | ... | ... |
examples/pipeline_stacked_mem.py
| ... | ... | @@ -113,74 +113,74 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, \ |
| 113 | 113 | """ |
| 114 | 114 | # Simulate events |
| 115 | 115 | sim = ctools.ctobssim(obs) |
| 116 | - sim["debug"].boolean(debug) | |
| 116 | + sim["debug"] = debug | |
| 117 | 117 | sim.run() |
| 118 | 118 | |
| 119 | 119 | # Bin events into counts map |
| 120 | 120 | bin = ctools.ctbin(sim.obs()) |
| 121 | - bin["ebinalg"].string("LOG") | |
| 122 | - bin["emin"].real(emin) | |
| 123 | - bin["emax"].real(emax) | |
| 124 | - bin["enumbins"].integer(enumbins) | |
| 125 | - bin["nxpix"].integer(nxpix) | |
| 126 | - bin["nypix"].integer(nypix) | |
| 127 | - bin["binsz"].real(binsz) | |
| 128 | - bin["coordsys"].string(coordsys) | |
| 129 | - bin["proj"].string(proj) | |
| 130 | - bin["xref"].real(ra) | |
| 131 | - bin["yref"].real(dec) | |
| 132 | - bin["debug"].boolean(debug) | |
| 121 | + bin["ebinalg"] = "LOG" | |
| 122 | + bin["emin"] = emin | |
| 123 | + bin["emax"] = emax | |
| 124 | + bin["enumbins"] = enumbins | |
| 125 | + bin["nxpix"] = nxpix | |
| 126 | + bin["nypix"] = nypix | |
| 127 | + bin["binsz"] = binsz | |
| 128 | + bin["coordsys"] = coordsys | |
| 129 | + bin["proj"] = proj | |
| 130 | + bin["xref"] = ra | |
| 131 | + bin["yref"] = dec | |
| 132 | + bin["debug"] = debug | |
| 133 | 133 | bin.run() |
| 134 | 134 | |
| 135 | 135 | # Create exposure cube |
| 136 | 136 | expcube = ctools.ctexpcube(sim.obs()) |
| 137 | - expcube["incube"].filename("NONE") | |
| 138 | - expcube["ebinalg"].string("LOG") | |
| 139 | - expcube["emin"].real(emin) | |
| 140 | - expcube["emax"].real(emax) | |
| 141 | - expcube["enumbins"].integer(enumbins) | |
| 142 | - expcube["nxpix"].integer(nxpix) | |
| 143 | - expcube["nypix"].integer(nypix) | |
| 144 | - expcube["binsz"].real(binsz) | |
| 145 | - expcube["coordsys"].string(coordsys) | |
| 146 | - expcube["proj"].string(proj) | |
| 147 | - expcube["xref"].real(ra) | |
| 148 | - expcube["yref"].real(dec) | |
| 149 | - expcube["debug"].boolean(debug) | |
| 137 | + expcube["incube"] = "NONE" | |
| 138 | + expcube["ebinalg"] = "LOG" | |
| 139 | + expcube["emin"] = emin | |
| 140 | + expcube["emax"] = emax | |
| 141 | + expcube["enumbins"] = enumbins | |
| 142 | + expcube["nxpix"] = nxpix | |
| 143 | + expcube["nypix"] = nypix | |
| 144 | + expcube["binsz"] = binsz | |
| 145 | + expcube["coordsys"] = coordsys | |
| 146 | + expcube["proj"] = proj | |
| 147 | + expcube["xref"] = ra | |
| 148 | + expcube["yref"] = dec | |
| 149 | + expcube["debug"] = debug | |
| 150 | 150 | expcube.run() |
| 151 | 151 | |
| 152 | 152 | # Create PSF cube |
| 153 | 153 | psfcube = ctools.ctpsfcube(sim.obs()) |
| 154 | - psfcube["incube"].filename("NONE") | |
| 155 | - psfcube["ebinalg"].string("LOG") | |
| 156 | - psfcube["emin"].real(emin) | |
| 157 | - psfcube["emax"].real(emax) | |
| 158 | - psfcube["enumbins"].integer(enumbins) | |
| 159 | - psfcube["nxpix"].integer(10) | |
| 160 | - psfcube["nypix"].integer(10) | |
| 161 | - psfcube["binsz"].real(1.0) | |
| 162 | - psfcube["coordsys"].string(coordsys) | |
| 163 | - psfcube["proj"].string(proj) | |
| 164 | - psfcube["xref"].real(ra) | |
| 165 | - psfcube["yref"].real(dec) | |
| 166 | - psfcube["debug"].boolean(debug) | |
| 154 | + psfcube["incube"] = "NONE" | |
| 155 | + psfcube["ebinalg"] = "LOG" | |
| 156 | + psfcube["emin"] = emin | |
| 157 | + psfcube["emax"] = emax | |
| 158 | + psfcube["enumbins"] = enumbins | |
| 159 | + psfcube["nxpix"] = 10 | |
| 160 | + psfcube["nypix"] = 10 | |
| 161 | + psfcube["binsz"] = 1.0 | |
| 162 | + psfcube["coordsys"] = coordsys | |
| 163 | + psfcube["proj"] = proj | |
| 164 | + psfcube["xref"] = ra | |
| 165 | + psfcube["yref"] = dec | |
| 166 | + psfcube["debug"] = debug | |
| 167 | 167 | psfcube.run() |
| 168 | 168 | |
| 169 | 169 | # Create background cube |
| 170 | 170 | bkgcube = ctools.ctbkgcube(sim.obs()) |
| 171 | - bkgcube["incube"].filename("NONE") | |
| 172 | - bkgcube["ebinalg"].string("LOG") | |
| 173 | - bkgcube["emin"].real(emin) | |
| 174 | - bkgcube["emax"].real(emax) | |
| 175 | - bkgcube["enumbins"].integer(enumbins) | |
| 176 | - bkgcube["nxpix"].integer(10) | |
| 177 | - bkgcube["nypix"].integer(10) | |
| 178 | - bkgcube["binsz"].real(1.0) | |
| 179 | - bkgcube["coordsys"].string(coordsys) | |
| 180 | - bkgcube["proj"].string(proj) | |
| 181 | - bkgcube["xref"].real(ra) | |
| 182 | - bkgcube["yref"].real(dec) | |
| 183 | - bkgcube["debug"].boolean(debug) | |
| 171 | + bkgcube["incube"] = "NONE" | |
| 172 | + bkgcube["ebinalg"] = "LOG" | |
| 173 | + bkgcube["emin"] = emin | |
| 174 | + bkgcube["emax"] = emax | |
| 175 | + bkgcube["enumbins"] = enumbins | |
| 176 | + bkgcube["nxpix"] = 10 | |
| 177 | + bkgcube["nypix"] = 10 | |
| 178 | + bkgcube["binsz"] = 1.0 | |
| 179 | + bkgcube["coordsys"] = coordsys | |
| 180 | + bkgcube["proj"] = proj | |
| 181 | + bkgcube["xref"] = ra | |
| 182 | + bkgcube["yref"] = dec | |
| 183 | + bkgcube["debug"] = debug | |
| 184 | 184 | bkgcube.run() |
| 185 | 185 | |
| 186 | 186 | # Attach background model to observation container |
| ... | ... | @@ -192,7 +192,7 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, \ |
| 192 | 192 | |
| 193 | 193 | # Perform maximum likelihood fitting |
| 194 | 194 | like = ctools.ctlike(bin.obs()) |
| 195 | - like["debug"].boolean(True) # Switch this always on for results in console | |
| 195 | + like["debug"] = True # Switch this always on for results in console | |
| 196 | 196 | like.run() |
| 197 | 197 | |
| 198 | 198 | # Return | ... | ... |
examples/pipeline_unbinned_disk.py
| ... | ... | @@ -118,32 +118,32 @@ def run_pipeline(obs, ra=83.63, dec=22.01, rad=3.0, \ |
| 118 | 118 | |
| 119 | 119 | # Simulate events |
| 120 | 120 | sim = ctools.ctobssim(obs) |
| 121 | - sim["debug"].boolean(debug) | |
| 122 | - sim["outevents"].filename("obs.xml") | |
| 121 | + sim["debug"] = debug | |
| 122 | + sim["outevents"] = "obs.xml" | |
| 123 | 123 | sim.execute() |
| 124 | 124 | |
| 125 | 125 | # Select events |
| 126 | 126 | select = ctools.ctselect() |
| 127 | - select["inobs"].filename("obs.xml") | |
| 128 | - select["outobs"].filename("obs_selected.xml") | |
| 129 | - select["ra"].real(ra) | |
| 130 | - select["dec"].real(dec) | |
| 131 | - select["rad"].real(rad) | |
| 132 | - select["emin"].real(emin) | |
| 133 | - select["emax"].real(emax) | |
| 134 | - select["tmin"].real(tmin) | |
| 135 | - select["tmax"].real(tmax) | |
| 136 | - select["debug"].boolean(debug) | |
| 127 | + select["inobs"] = "obs.xml" | |
| 128 | + select["outobs"] = "obs_selected.xml" | |
| 129 | + select["ra"] = ra | |
| 130 | + select["dec"] = dec | |
| 131 | + select["rad"] = rad | |
| 132 | + select["emin"] = emin | |
| 133 | + select["emax"] = emax | |
| 134 | + select["tmin"] = tmin | |
| 135 | + select["tmax"] = tmax | |
| 136 | + select["debug"] = debug | |
| 137 | 137 | select.execute() |
| 138 | 138 | |
| 139 | 139 | # Perform maximum likelihood fitting |
| 140 | 140 | like = ctools.ctlike() |
| 141 | - like["inobs"].filename("obs_selected.xml") | |
| 142 | - like["inmodel"].filename(model) | |
| 143 | - like["outmodel"].filename("fit_results.xml") | |
| 144 | - like["caldb"].string(caldb) | |
| 145 | - like["irf"].string(irf) | |
| 146 | - like["debug"].boolean(True) # Switch this always on for results in console | |
| 141 | + like["inobs"] = "obs_selected.xml" | |
| 142 | + like["inmodel"] = model | |
| 143 | + like["outmodel"] = "fit_results.xml" | |
| 144 | + like["caldb"] = caldb | |
| 145 | + like["irf"] = irf | |
| 146 | + like["debug"] = True # Switch this always on for results in console | |
| 147 | 147 | like.execute() |
| 148 | 148 | |
| 149 | 149 | # Return | ... | ... |
examples/pipeline_unbinned_mem.py
| ... | ... | @@ -111,24 +111,24 @@ def run_pipeline(obs, ra=83.63, dec=22.01, rad=3.0, \ |
| 111 | 111 | """ |
| 112 | 112 | # Simulate events |
| 113 | 113 | sim = ctools.ctobssim(obs) |
| 114 | - sim["debug"].boolean(debug) | |
| 114 | + sim["debug"] = debug | |
| 115 | 115 | sim.run() |
| 116 | 116 | |
| 117 | 117 | # Select events |
| 118 | 118 | select = ctools.ctselect(sim.obs()) |
| 119 | - select["ra"].real(ra) | |
| 120 | - select["dec"].real(dec) | |
| 121 | - select["rad"].real(rad) | |
| 122 | - select["emin"].real(emin) | |
| 123 | - select["emax"].real(emax) | |
| 124 | - select["tmin"].real(tmin) | |
| 125 | - select["tmax"].real(tmax) | |
| 126 | - select["debug"].boolean(debug) | |
| 119 | + select["ra"] = ra | |
| 120 | + select["dec"] = dec | |
| 121 | + select["rad"] = rad | |
| 122 | + select["emin"] = emin | |
| 123 | + select["emax"] = emax | |
| 124 | + select["tmin"] = tmin | |
| 125 | + select["tmax"] = tmax | |
| 126 | + select["debug"] = debug | |
| 127 | 127 | select.run() |
| 128 | 128 | |
| 129 | 129 | # Perform maximum likelihood fitting |
| 130 | 130 | like = ctools.ctlike(select.obs()) |
| 131 | - like["debug"].boolean(True) # Switch this always on for results in console | |
| 131 | + like["debug"] = True # Switch this always on for results in console | |
| 132 | 132 | like.run() |
| 133 | 133 | |
| 134 | 134 | # Return | ... | ... |
pyext/ctools/analysisutils.py
| ... | ... | @@ -260,17 +260,17 @@ class Analyser(base): |
| 260 | 260 | bin = ct.ctbin() |
| 261 | 261 | bin["evfile"] = self.m_evtfile |
| 262 | 262 | bin["outfile"] = self.m_cntfile |
| 263 | - bin["ebinalg"].string(self.m_ebinalg) | |
| 264 | - bin["emin"].real(self.m_emin) | |
| 265 | - bin["emax"].real(self.m_emax) | |
| 263 | + bin["ebinalg"] = self.m_ebinalg | |
| 264 | + bin["emin"] = self.m_emin | |
| 265 | + bin["emax"] = self.m_emax | |
| 266 | 266 | Nbdecade = log10(self.m_emax)-log10(self.m_emin)#Compute the number of decade |
| 267 | - bin["enumbins"].integer(int(self.m_enumbins*Nbdecade)) | |
| 268 | - bin["usepnt"].boolean(self.m_usepnt) # Use pointing for map centre | |
| 269 | - bin["nxpix"].integer(self.m_nxpix) | |
| 270 | - bin["nypix"].integer(self.m_nypix) | |
| 271 | - bin["binsz"].real(self.m_binsz) | |
| 272 | - bin["coordsys"].string(self.m_coordsys) | |
| 273 | - bin["proj"].string(self.m_proj) | |
| 267 | + bin["enumbins"] = int(self.m_enumbins*Nbdecade) | |
| 268 | + bin["usepnt"] = self.m_usepnt # Use pointing for map centre | |
| 269 | + bin["nxpix"] = self.m_nxpix | |
| 270 | + bin["nypix"] = self.m_nypix | |
| 271 | + bin["binsz"] = self.m_binsz | |
| 272 | + bin["coordsys"] = self.m_coordsys | |
| 273 | + bin["proj"] = self.m_proj | |
| 274 | 274 | |
| 275 | 275 | # Optionally open the log file |
| 276 | 276 | if log: |
| ... | ... | @@ -278,7 +278,7 @@ class Analyser(base): |
| 278 | 278 | |
| 279 | 279 | # Optionally switch-on debugging model |
| 280 | 280 | if debug: |
| 281 | - bin["debug"].boolean(True) | |
| 281 | + bin["debug"] = True | |
| 282 | 282 | |
| 283 | 283 | # Run ctbin application. This will loop over all observations in |
| 284 | 284 | # the container and bin the events in counts maps |
| ... | ... | @@ -302,11 +302,11 @@ class Analyser(base): |
| 302 | 302 | else: |
| 303 | 303 | self.like["infile"] = self.m_evtfile |
| 304 | 304 | |
| 305 | - self.like["stat"].string(self.m_stat) | |
| 306 | - self.like["caldb"].string(self.m_caldb) | |
| 307 | - self.like["irf"].string(self.m_irf) | |
| 305 | + self.like["stat"] = self.m_stat | |
| 306 | + self.like["caldb"] = self.m_caldb | |
| 307 | + self.like["irf"] = self.m_irf | |
| 308 | 308 | self.like["srcmdl"] = self.m_xml |
| 309 | - self.like["edisp"].boolean(self.m_edisp) | |
| 309 | + self.like["edisp"] = self.m_edisp | |
| 310 | 310 | self.like["outmdl"] = self.m_xml_out |
| 311 | 311 | |
| 312 | 312 | # Optionally open the log file |
| ... | ... | @@ -314,7 +314,7 @@ class Analyser(base): |
| 314 | 314 | self.like.logFileOpen() |
| 315 | 315 | # Optionally switch-on debugging model |
| 316 | 316 | if debug: |
| 317 | - self.like["debug"].boolean(True) | |
| 317 | + self.like["debug"] = True | |
| 318 | 318 | |
| 319 | 319 | def fit(self,log=False,debug=False): |
| 320 | 320 | self.validate() | ... | ... |
pyext/ctools/obsutils.py
| ... | ... | @@ -45,8 +45,8 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, nbins=0, |
| 45 | 45 | |
| 46 | 46 | # Allocate ctobssim application and set parameters |
| 47 | 47 | sim = ctools.ctobssim(obs) |
| 48 | - sim["seed"].integer(seed) | |
| 49 | - sim["edisp"].boolean(edisp) | |
| 48 | + sim["seed"] = seed | |
| 49 | + sim["edisp"] = edisp | |
| 50 | 50 | |
| 51 | 51 | # Optionally open the log file |
| 52 | 52 | if log: |
| ... | ... | @@ -54,10 +54,10 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, nbins=0, |
| 54 | 54 | |
| 55 | 55 | # Optionally switch-on debugging model |
| 56 | 56 | if debug: |
| 57 | - sim["debug"].boolean(True) | |
| 57 | + sim["debug"] = True | |
| 58 | 58 | |
| 59 | 59 | # Set chatter level |
| 60 | - sim["chatter"].integer(chatter) | |
| 60 | + sim["chatter"] = chatter | |
| 61 | 61 | |
| 62 | 62 | # Run ctobssim application. This will loop over all observations in the |
| 63 | 63 | # container and simulation the events for each observation. Note that |
| ... | ... | @@ -85,16 +85,16 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, nbins=0, |
| 85 | 85 | |
| 86 | 86 | # Allocate ctbin application and set parameters |
| 87 | 87 | bin = ctools.ctbin(sim.obs()) |
| 88 | - bin["ebinalg"].string("LOG") | |
| 89 | - bin["emin"].real(emin) | |
| 90 | - bin["emax"].real(emax) | |
| 91 | - bin["enumbins"].integer(nbins) | |
| 92 | - bin["usepnt"].boolean(True) # Use pointing for map centre | |
| 93 | - bin["nxpix"].integer(npix) | |
| 94 | - bin["nypix"].integer(npix) | |
| 95 | - bin["binsz"].real(binsz) | |
| 96 | - bin["coordsys"].string(coord) | |
| 97 | - bin["proj"].string(proj) | |
| 88 | + bin["ebinalg"] = "LOG" | |
| 89 | + bin["emin"] = emin | |
| 90 | + bin["emax"] = emax | |
| 91 | + bin["enumbins"] = nbins | |
| 92 | + bin["usepnt"] = True # Use pointing for map centre | |
| 93 | + bin["nxpix"] = npix | |
| 94 | + bin["nypix"] = npix | |
| 95 | + bin["binsz"] = binsz | |
| 96 | + bin["coordsys"] = coord | |
| 97 | + bin["proj"] = proj | |
| 98 | 98 | |
| 99 | 99 | # Optionally open the log file |
| 100 | 100 | if log: |
| ... | ... | @@ -102,10 +102,10 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, nbins=0, |
| 102 | 102 | |
| 103 | 103 | # Optionally switch-on debugging model |
| 104 | 104 | if debug: |
| 105 | - bin["debug"].boolean(True) | |
| 105 | + bin["debug"] = True | |
| 106 | 106 | |
| 107 | 107 | # Set chatter level |
| 108 | - bin["chatter"].integer(chatter) | |
| 108 | + bin["chatter"] = chatter | |
| 109 | 109 | |
| 110 | 110 | # Run ctbin application. This will loop over all observations in |
| 111 | 111 | # the container and bin the events in counts maps |
| ... | ... | @@ -154,13 +154,13 @@ def fit(obs, log=False, debug=False, chatter=2, edisp=False): |
| 154 | 154 | |
| 155 | 155 | # Optionally switch-on debugging model |
| 156 | 156 | if debug: |
| 157 | - like["debug"].boolean(True) | |
| 157 | + like["debug"] = True | |
| 158 | 158 | |
| 159 | 159 | # Set chatter level |
| 160 | - like["chatter"].integer(chatter) | |
| 160 | + like["chatter"] = chatter | |
| 161 | 161 | |
| 162 | 162 | # Optionally apply energy dispersion |
| 163 | - like["edisp"].boolean(edisp) | |
| 163 | + like["edisp"] = edisp | |
| 164 | 164 | |
| 165 | 165 | # Run ctlike application. |
| 166 | 166 | like.run() |
| ... | ... | @@ -189,7 +189,7 @@ def cterror(obs, srcname, log=False, debug=False, chatter=2): |
| 189 | 189 | error = ctools.cterror(obs) |
| 190 | 190 | |
| 191 | 191 | # Set cterror parameters |
| 192 | - error["srcname"].string(srcname) | |
| 192 | + error["srcname"] = srcname | |
| 193 | 193 | |
| 194 | 194 | # Optionally open the log file |
| 195 | 195 | if log: |
| ... | ... | @@ -197,10 +197,10 @@ def cterror(obs, srcname, log=False, debug=False, chatter=2): |
| 197 | 197 | |
| 198 | 198 | # Optionally switch-on debugging model |
| 199 | 199 | if debug: |
| 200 | - error["debug"].boolean(True) | |
| 200 | + error["debug"] = True | |
| 201 | 201 | |
| 202 | 202 | # Set chatter level |
| 203 | - error["chatter"].integer(chatter) | |
| 203 | + error["chatter"] = chatter | |
| 204 | 204 | |
| 205 | 205 | # Run cterror application. |
| 206 | 206 | error.run() |
| ... | ... | @@ -625,13 +625,13 @@ def spectrum(obs, source, ebounds): |
| 625 | 625 | |
| 626 | 626 | # Clone observations and reset energy thresholds |
| 627 | 627 | select = ctools.ctselect(obs) |
| 628 | - select["ra"].value("UNDEF") | |
| 629 | - select["dec"].value("UNDEF") | |
| 630 | - select["rad"].value("UNDEF") | |
| 631 | - select["tmin"].real(0.0) | |
| 632 | - select["tmax"].real(0.0) | |
| 633 | - select["emin"].real(ebounds.emin(i).TeV()) | |
| 634 | - select["emax"].real(ebounds.emax(i).TeV()) | |
| 628 | + select["ra"] = "UNDEF" | |
| 629 | + select["dec"] = "UNDEF" | |
| 630 | + select["rad"] = "UNDEF" | |
| 631 | + select["tmin"] = 0 | |
| 632 | + select["tmax"] = 0 | |
| 633 | + select["emin"] = ebounds.emin(i).TeV() | |
| 634 | + select["emax"] = ebounds.emax(i).TeV() | |
| 635 | 635 | select.run() |
| 636 | 636 | |
| 637 | 637 | # Refit and write out to spectrum | ... | ... |
scripts/cslightcrv.py
| ... | ... | @@ -112,7 +112,6 @@ class cslightcrv(ctools.cscript): |
| 112 | 112 | pars.append(gammalib.GApplicationPar("tmax","r","a","51544.6","","days","Lightcurve stop time [MJD]")) |
| 113 | 113 | pars.append(gammalib.GApplicationPar("tbins","i","a","5","","","Number of time bins")) |
| 114 | 114 | pars.append(gammalib.GApplicationPar("tbinfile","f","a","tbins.fits","","", "File defining the time binning")) |
| 115 | - #pars.append(gammalib.GApplicationPar("binned","b","a","no","yes|no","","Use binned analysis in each time bin")) | |
| 116 | 115 | pars.append(gammalib.GApplicationPar("enumbins","i","a","0","","","Number of energy bins per light curve bin (0=unbinned)")) |
| 117 | 116 | pars.append(gammalib.GApplicationPar("emin","r","a","0.1","","","Lower energy limit of events (TeV)")) |
| 118 | 117 | pars.append(gammalib.GApplicationPar("emax","r","a","100.0","","","Upper energy limit of events (TeV)")) |
| ... | ... | @@ -205,7 +204,6 @@ class cslightcrv(ctools.cscript): |
| 205 | 204 | self.m_emax = self["emax"].real() |
| 206 | 205 | |
| 207 | 206 | # Get binning flag |
| 208 | - #self.m_binned = self["binned"].boolean() | |
| 209 | 207 | if self.m_binned: |
| 210 | 208 | self.m_coordsys = self["coordsys"].string() |
| 211 | 209 | self.m_proj = self["proj"].string() |
| ... | ... | @@ -214,9 +212,6 @@ class cslightcrv(ctools.cscript): |
| 214 | 212 | self.m_nxpix = self["nxpix"].integer() |
| 215 | 213 | self.m_nypix = self["nypix"].integer() |
| 216 | 214 | self.m_binsz = self["binsz"].real() |
| 217 | - #self.m_ebins = self["enumbins"].integer() | |
| 218 | - #self.m_emin = self["emin"].real() | |
| 219 | - #self.m_emax = self["emax"].real() | |
| 220 | 215 | |
| 221 | 216 | # Read other parameters |
| 222 | 217 | self.m_outfile = self["outfile"].filename() |
| ... | ... | @@ -378,13 +373,13 @@ class cslightcrv(ctools.cscript): |
| 378 | 373 | |
| 379 | 374 | # Select events |
| 380 | 375 | select = ctools.ctselect(self.obs) |
| 381 | - select["emin"].real(self.m_emin) | |
| 382 | - select["emax"].real(self.m_emax) | |
| 383 | - select["tmin"].real(tmin.convert(select.time_reference())) | |
| 384 | - select["tmax"].real(tmax.convert(select.time_reference())) | |
| 385 | - select["rad"].value("UNDEFINED") | |
| 386 | - select["ra"].value("UNDEFINED") | |
| 387 | - select["dec"].value("UNDEFINED") | |
| 376 | + select["emin"] = self.m_emin | |
| 377 | + select["emax"] = self.m_emax | |
| 378 | + select["tmin"] = tmin.convert(select.time_reference()) | |
| 379 | + select["tmax"] = tmax.convert(select.time_reference()) | |
| 380 | + select["rad"] = "UNDEFINED" | |
| 381 | + select["ra"] = "UNDEFINED" | |
| 382 | + select["dec"] = "UNDEFINED" | |
| 388 | 383 | select.run() |
| 389 | 384 | |
| 390 | 385 | # Retrieve observation |
| ... | ... | @@ -399,18 +394,18 @@ class cslightcrv(ctools.cscript): |
| 399 | 394 | |
| 400 | 395 | # Bin events |
| 401 | 396 | bin = ctools.ctbin(select.obs()) |
| 402 | - bin["usepnt"].boolean(False) | |
| 403 | - bin["ebinalg"].string("LOG") | |
| 404 | - bin["xref"].real(self.m_xref) | |
| 405 | - bin["yref"].real(self.m_yref) | |
| 406 | - bin["binsz"].real(self.m_binsz) | |
| 407 | - bin["nxpix"].integer(self.m_nxpix) | |
| 408 | - bin["nypix"].integer(self.m_nypix) | |
| 409 | - bin["enumbins"].integer(self.m_ebins) | |
| 410 | - bin["emin"].real(self.m_emin) | |
| 411 | - bin["emax"].real(self.m_emax) | |
| 412 | - bin["coordsys"].string(self.m_coordsys) | |
| 413 | - bin["proj"].string(self.m_proj) | |
| 397 | + bin["usepnt"] = False | |
| 398 | + bin["ebinalg"] = "LOG" | |
| 399 | + bin["xref"] = self.m_xref | |
| 400 | + bin["yref"] = self.m_yref | |
| 401 | + bin["binsz"] = self.m_binsz | |
| 402 | + bin["nxpix"] = self.m_nxpix | |
| 403 | + bin["nypix"] = self.m_nypix | |
| 404 | + bin["enumbins"] = self.m_ebins | |
| 405 | + bin["emin"] = self.m_emin | |
| 406 | + bin["emax"] = self.m_emax | |
| 407 | + bin["coordsys"] = self.m_coordsys | |
| 408 | + bin["proj"] = self.m_proj | |
| 414 | 409 | bin.run() |
| 415 | 410 | |
| 416 | 411 | # Header |
| ... | ... | @@ -419,19 +414,19 @@ class cslightcrv(ctools.cscript): |
| 419 | 414 | |
| 420 | 415 | # Create exposure cube |
| 421 | 416 | expcube = ctools.ctexpcube(select.obs()) |
| 422 | - expcube["incube"].filename("NONE") | |
| 423 | - expcube["usepnt"].boolean(False) | |
| 424 | - expcube["ebinalg"].string("LOG") | |
| 425 | - expcube["xref"].real(self.m_xref) | |
| 426 | - expcube["yref"].real(self.m_yref) | |
| 427 | - expcube["binsz"].real(self.m_binsz) | |
| 428 | - expcube["nxpix"].integer(self.m_nxpix) | |
| 429 | - expcube["nypix"].integer(self.m_nypix) | |
| 430 | - expcube["enumbins"].integer(self.m_ebins) | |
| 431 | - expcube["emin"].real(self.m_emin) | |
| 432 | - expcube["emax"].real(self.m_emax) | |
| 433 | - expcube["coordsys"].string(self.m_coordsys) | |
| 434 | - expcube["proj"].string(self.m_proj) | |
| 417 | + expcube["incube"] = "NONE" | |
| 418 | + expcube["usepnt"] = False | |
| 419 | + expcube["ebinalg"] = "LOG" | |
| 420 | + expcube["xref"] = self.m_xref | |
| 421 | + expcube["yref"] = self.m_yref | |
| 422 | + expcube["binsz"] = self.m_binsz | |
| 423 | + expcube["nxpix"] = self.m_nxpix | |
| 424 | + expcube["nypix"] = self.m_nypix | |
| 425 | + expcube["enumbins"] = self.m_ebins | |
| 426 | + expcube["emin"] = self.m_emin | |
| 427 | + expcube["emax"] = self.m_emax | |
| 428 | + expcube["coordsys"] = self.m_coordsys | |
| 429 | + expcube["proj"] = self.m_proj | |
| 435 | 430 | expcube.run() |
| 436 | 431 | |
| 437 | 432 | # Header |
| ... | ... | @@ -440,19 +435,19 @@ class cslightcrv(ctools.cscript): |
| 440 | 435 | |
| 441 | 436 | # Create psf cube |
| 442 | 437 | psfcube = ctools.ctpsfcube(select.obs()) |
| 443 | - psfcube["incube"].filename("NONE") | |
| 444 | - psfcube["usepnt"].boolean(False) | |
| 445 | - psfcube["ebinalg"].string("LOG") | |
| 446 | - psfcube["xref"].real(self.m_xref) | |
| 447 | - psfcube["yref"].real(self.m_yref) | |
| 448 | - psfcube["binsz"].real(self.m_binsz) | |
| 449 | - psfcube["nxpix"].integer(self.m_nxpix) | |
| 450 | - psfcube["nypix"].integer(self.m_nypix) | |
| 451 | - psfcube["enumbins"].integer(self.m_ebins) | |
| 452 | - psfcube["emin"].real(self.m_emin) | |
| 453 | - psfcube["emax"].real(self.m_emax) | |
| 454 | - psfcube["coordsys"].string(self.m_coordsys) | |
| 455 | - psfcube["proj"].string(self.m_proj) | |
| 438 | + psfcube["incube"] = "NONE" | |
| 439 | + psfcube["usepnt"] = False | |
| 440 | + psfcube["ebinalg"] = "LOG" | |
| 441 | + psfcube["xref"] = self.m_xref | |
| 442 | + psfcube["yref"] = self.m_yref | |
| 443 | + psfcube["binsz"] = self.m_binsz | |
| 444 | + psfcube["nxpix"] = self.m_nxpix | |
| 445 | + psfcube["nypix"] = self.m_nypix | |
| 446 | + psfcube["enumbins"] = self.m_ebins | |
| 447 | + psfcube["emin"] = self.m_emin | |
| 448 | + psfcube["emax"] = self.m_emax | |
| 449 | + psfcube["coordsys"] = self.m_coordsys | |
| 450 | + psfcube["proj"] = self.m_proj | |
| 456 | 451 | psfcube.run() |
| 457 | 452 | |
| 458 | 453 | # Header |
| ... | ... | @@ -461,19 +456,19 @@ class cslightcrv(ctools.cscript): |
| 461 | 456 | |
| 462 | 457 | # Create background cube |
| 463 | 458 | bkgcube = ctools.ctbkgcube(select.obs()) |
| 464 | - bkgcube["incube"].filename("NONE") | |
| 465 | - bkgcube["usepnt"].boolean(False) | |
| 466 | - bkgcube["ebinalg"].string("LOG") | |
| 467 | - bkgcube["xref"].real(self.m_xref) | |
| 468 | - bkgcube["yref"].real(self.m_yref) | |
| 469 | - bkgcube["binsz"].real(self.m_binsz) | |
| 470 | - bkgcube["nxpix"].integer(self.m_nxpix) | |
| 471 | - bkgcube["nypix"].integer(self.m_nypix) | |
| 472 | - bkgcube["enumbins"].integer(self.m_ebins) | |
| 473 | - bkgcube["emin"].real(self.m_emin) | |
| 474 | - bkgcube["emax"].real(self.m_emax) | |
| 475 | - bkgcube["coordsys"].string(self.m_coordsys) | |
| 476 | - bkgcube["proj"].string(self.m_proj) | |
| 459 | + bkgcube["incube"] = "NONE" | |
| 460 | + bkgcube["usepnt"] = False | |
| 461 | + bkgcube["ebinalg"] = "LOG" | |
| 462 | + bkgcube["xref"] = self.m_xref | |
| 463 | + bkgcube["yref"] = self.m_yref | |
| 464 | + bkgcube["binsz"] = self.m_binsz | |
| 465 | + bkgcube["nxpix"] = self.m_nxpix | |
| 466 | + bkgcube["nypix"] = self.m_nypix | |
| 467 | + bkgcube["enumbins"] = self.m_ebins | |
| 468 | + bkgcube["emin"] = self.m_emin | |
| 469 | + bkgcube["emax"] = self.m_emax | |
| 470 | + bkgcube["coordsys"] = self.m_coordsys | |
| 471 | + bkgcube["proj"] = self.m_proj | |
| 477 | 472 | bkgcube.run() |
| 478 | 473 | |
| 479 | 474 | # Set new binned observation |
| ... | ... | @@ -531,8 +526,8 @@ class cslightcrv(ctools.cscript): |
| 531 | 526 | |
| 532 | 527 | # Create upper limit object |
| 533 | 528 | ulimit = ctools.ctulimit(like.obs()) |
| 534 | - ulimit["srcname"].string(self.m_srcname) | |
| 535 | - ulimit["eref"].real(1.0) | |
| 529 | + ulimit["srcname"] = self.m_srcname | |
| 530 | + ulimit["eref"] = 1.0 | |
| 536 | 531 | |
| 537 | 532 | # Try to run upper limit and catch exceptions |
| 538 | 533 | try: | ... | ... |
scripts/cspull.py
| ... | ... | @@ -305,13 +305,16 @@ class cspull(ctools.cscript): |
| 305 | 305 | |
| 306 | 306 | # Fit model |
| 307 | 307 | if self.m_profile: |
| 308 | - models = obs.models() | |
| 308 | + models = obs.models() | |
| 309 | + new_models = gammalib.GModels() | |
| 309 | 310 | for i in range(models.size()): |
| 310 | 311 | model_name = models[i].name() |
| 311 | 312 | like = obsutils.cterror(obs, model_name, \ |
| 312 | 313 | log=self.m_log, \ |
| 313 | 314 | debug=self.m_debug, |
| 314 | 315 | chatter=self.m_chatter) |
| 316 | + new_models.append(like.obs().models()[i]) | |
| 317 | + like.obs().models(new_models) | |
| 315 | 318 | else: |
| 316 | 319 | like = obsutils.fit(obs, edisp=self.m_edisp, \ |
| 317 | 320 | log=self.m_log, \ | ... | ... |
scripts/csresmap.py
| ... | ... | @@ -217,20 +217,20 @@ class csresmap(ctools.cscript): |
| 217 | 217 | |
| 218 | 218 | # Create countsmap |
| 219 | 219 | bin = ctools.ctbin(self.obs) |
| 220 | - bin["nxpix"].integer(self.m_nxpix) | |
| 221 | - bin["nypix"].integer(self.m_nypix) | |
| 222 | - bin["proj"].string(self.m_proj) | |
| 223 | - bin["coordsys"].string(self.m_coordsys) | |
| 224 | - bin["xref"].real(self.m_xref) | |
| 225 | - bin["yref"].real(self.m_yref) | |
| 226 | - bin["enumbins"].integer(self.m_enumbins) | |
| 227 | - bin["ebinalg"].string(self.m_ebinalg) | |
| 228 | - bin["emin"].real(self.m_emin) | |
| 229 | - bin["emax"].real(self.m_emax) | |
| 230 | - bin["binsz"].real(self.m_binsz) | |
| 231 | - bin["chatter"].integer(self.m_chatter) | |
| 232 | - bin["clobber"].boolean(self.m_clobber) | |
| 233 | - bin["debug"].boolean(self.m_debug) | |
| 220 | + bin["nxpix"] = self.m_nxpix | |
| 221 | + bin["nypix"] = self.m_nypix | |
| 222 | + bin["proj"] = self.m_proj | |
| 223 | + bin["coordsys"] = self.m_coordsys | |
| 224 | + bin["xref"] = self.m_xref | |
| 225 | + bin["yref"] = self.m_yref | |
| 226 | + bin["enumbins"] = self.m_enumbins | |
| 227 | + bin["ebinalg"] = self.m_ebinalg | |
| 228 | + bin["emin"] = self.m_emin | |
| 229 | + bin["emax"] = self.m_emax | |
| 230 | + bin["binsz"] = self.m_binsz | |
| 231 | + bin["chatter"] = self.m_chatter | |
| 232 | + bin["clobber"] = self.m_clobber | |
| 233 | + bin["debug"] = self.m_debug | |
| 234 | 234 | bin.run() |
| 235 | 235 | |
| 236 | 236 | # Store counts map as residual map. Note that we need a |
| ... | ... | @@ -250,9 +250,9 @@ class csresmap(ctools.cscript): |
| 250 | 250 | # Create model map |
| 251 | 251 | model = ctools.ctmodel(self.obs) |
| 252 | 252 | model.cube(bin.cube()) |
| 253 | - model["chatter"].integer(self.m_chatter) | |
| 254 | - model["clobber"].boolean(self.m_clobber) | |
| 255 | - model["debug"].boolean(self.m_debug) | |
| 253 | + model["chatter"] = self.m_chatter | |
| 254 | + model["clobber"] = self.m_clobber | |
| 255 | + model["debug"] = self.m_debug | |
| 256 | 256 | model.run() |
| 257 | 257 | |
| 258 | 258 | # Get model map into GSkymap object | ... | ... |
scripts/csspec.py
| ... | ... | @@ -322,13 +322,13 @@ class csspec(ctools.cscript): |
| 322 | 322 | |
| 323 | 323 | # Select events |
| 324 | 324 | select = ctools.ctselect(self.obs) |
| 325 | - select["emin"].real(emin.TeV()) | |
| 326 | - select["emax"].real(emax.TeV()) | |
| 327 | - select["tmin"].value("UNDEFINED") | |
| 328 | - select["tmax"].value("UNDEFINED") | |
| 329 | - select["rad"].value("UNDEFINED") | |
| 330 | - select["ra"].value("UNDEFINED") | |
| 331 | - select["dec"].value("UNDEFINED") | |
| 325 | + select["emin"] = emin.TeV() | |
| 326 | + select["emax"] = emax.TeV() | |
| 327 | + select["tmin"] = "UNDEFINED" | |
| 328 | + select["tmax"] = "UNDEFINED" | |
| 329 | + select["rad"] = "UNDEFINED" | |
| 330 | + select["ra"] = "UNDEFINED" | |
| 331 | + select["dec"] = "UNDEFINED" | |
| 332 | 332 | select.run() |
| 333 | 333 | |
| 334 | 334 | # Retrieve observation |
| ... | ... | @@ -343,18 +343,18 @@ class csspec(ctools.cscript): |
| 343 | 343 | |
| 344 | 344 | # Bin events |
| 345 | 345 | bin = ctools.ctbin(select.obs()) |
| 346 | - bin["usepnt"].boolean(False) | |
| 347 | - bin["ebinalg"].string("LOG") | |
| 348 | - bin["xref"].real(self.m_xref) | |
| 349 | - bin["yref"].real(self.m_yref) | |
| 350 | - bin["binsz"].real(self.m_binsz) | |
| 351 | - bin["nxpix"].integer(self.m_nxpix) | |
| 352 | - bin["nypix"].integer(self.m_nypix) | |
| 353 | - bin["enumbins"].integer(self.m_ebins) | |
| 354 | - bin["emin"].real(emin.TeV()) | |
| 355 | - bin["emax"].real(emax.TeV()) | |
| 356 | - bin["coordsys"].string(self.m_coordsys) | |
| 357 | - bin["proj"].string(self.m_proj) | |
| 346 | + bin["usepnt"] = False | |
| 347 | + bin["ebinalg"] = "LOG" | |
| 348 | + bin["xref"] = self.m_xref | |
| 349 | + bin["yref"] = self.m_yref | |
| 350 | + bin["binsz"] = self.m_binsz | |
| 351 | + bin["nxpix"] = self.m_nxpix | |
| 352 | + bin["nypix"] = self.m_nypix | |
| 353 | + bin["enumbins"] = self.m_ebins | |
| 354 | + bin["emin"] = emin.TeV() | |
| 355 | + bin["emax"] = emax.TeV() | |
| 356 | + bin["coordsys"] = self.m_coordsys | |
| 357 | + bin["proj"] = self.m_proj | |
| 358 | 358 | bin.run() |
| 359 | 359 | |
| 360 | 360 | # Header |
| ... | ... | @@ -363,19 +363,19 @@ class csspec(ctools.cscript): |
| 363 | 363 | |
| 364 | 364 | # Create exposure cube |
| 365 | 365 | expcube = ctools.ctexpcube(select.obs()) |
| 366 | - expcube["incube"].filename("NONE") | |
| 367 | - expcube["usepnt"].boolean(False) | |
| 368 | - expcube["ebinalg"].string("LOG") | |
| 369 | - expcube["xref"].real(self.m_xref) | |
| 370 | - expcube["yref"].real(self.m_yref) | |
| 371 | - expcube["binsz"].real(self.m_binsz) | |
| 372 | - expcube["nxpix"].integer(self.m_nxpix) | |
| 373 | - expcube["nypix"].integer(self.m_nypix) | |
| 374 | - expcube["enumbins"].integer(self.m_ebins) | |
| 375 | - expcube["emin"].real(emin.TeV()) | |
| 376 | - expcube["emax"].real(emax.TeV()) | |
| 377 | - expcube["coordsys"].string(self.m_coordsys) | |
| 378 | - expcube["proj"].string(self.m_proj) | |
| 366 | + expcube["incube"] = "NONE" | |
| 367 | + expcube["usepnt"] = False | |
| 368 | + expcube["ebinalg"] = "LOG" | |
| 369 | + expcube["xref"] = self.m_xref | |
| 370 | + expcube["yref"] = self.m_yref | |
| 371 | + expcube["binsz"] = self.m_binsz | |
| 372 | + expcube["nxpix"] = self.m_nxpix | |
| 373 | + expcube["nypix"] = self.m_nypix | |
| 374 | + expcube["enumbins"] = self.m_ebins | |
| 375 | + expcube["emin"] = emin.TeV() | |
| 376 | + expcube["emax"] = emax.TeV() | |
| 377 | + expcube["coordsys"] = self.m_coordsys | |
| 378 | + expcube["proj"] = self.m_proj | |
| 379 | 379 | expcube.run() |
| 380 | 380 | |
| 381 | 381 | # Header |
| ... | ... | @@ -384,19 +384,19 @@ class csspec(ctools.cscript): |
| 384 | 384 | |
| 385 | 385 | # Create psf cube |
| 386 | 386 | psfcube = ctools.ctpsfcube(select.obs()) |
| 387 | - psfcube["incube"].filename("NONE") | |
| 388 | - psfcube["usepnt"].boolean(False) | |
| 389 | - psfcube["ebinalg"].string("LOG") | |
| 390 | - psfcube["xref"].real(self.m_xref) | |
| 391 | - psfcube["yref"].real(self.m_yref) | |
| 392 | - psfcube["binsz"].real(self.m_binsz) | |
| 393 | - psfcube["nxpix"].integer(self.m_nxpix) | |
| 394 | - psfcube["nypix"].integer(self.m_nypix) | |
| 395 | - psfcube["enumbins"].integer(self.m_ebins) | |
| 396 | - psfcube["emin"].real(emin.TeV()) | |
| 397 | - psfcube["emax"].real(emax.TeV()) | |
| 398 | - psfcube["coordsys"].string(self.m_coordsys) | |
| 399 | - psfcube["proj"].string(self.m_proj) | |
| 387 | + psfcube["incube"] = "NONE" | |
| 388 | + psfcube["usepnt"] = False | |
| 389 | + psfcube["ebinalg"] = "LOG" | |
| 390 | + psfcube["xref"] = self.m_xref | |
| 391 | + psfcube["yref"] = self.m_yref | |
| 392 | + psfcube["binsz"] = self.m_binsz | |
| 393 | + psfcube["nxpix"] = self.m_nxpix | |
| 394 | + psfcube["nypix"] = self.m_nypix | |
| 395 | + psfcube["enumbins"] = self.m_ebins | |
| 396 | + psfcube["emin"] = emin.TeV() | |
| 397 | + psfcube["emax"] = emax.TeV() | |
| 398 | + psfcube["coordsys"] = self.m_coordsys | |
| 399 | + psfcube["proj"] = self.m_proj | |
| 400 | 400 | psfcube.run() |
| 401 | 401 | |
| 402 | 402 | # Header |
| ... | ... | @@ -405,19 +405,19 @@ class csspec(ctools.cscript): |
| 405 | 405 | |
| 406 | 406 | # Create background cube |
| 407 | 407 | bkgcube = ctools.ctbkgcube(select.obs()) |
| 408 | - bkgcube["incube"].filename("NONE") | |
| 409 | - bkgcube["usepnt"].boolean(False) | |
| 410 | - bkgcube["ebinalg"].string("LOG") | |
| 411 | - bkgcube["xref"].real(self.m_xref) | |
| 412 | - bkgcube["yref"].real(self.m_yref) | |
| 413 | - bkgcube["binsz"].real(self.m_binsz) | |
| 414 | - bkgcube["nxpix"].integer(self.m_nxpix) | |
| 415 | - bkgcube["nypix"].integer(self.m_nypix) | |
| 416 | - bkgcube["enumbins"].integer(self.m_ebins) | |
| 417 | - bkgcube["emin"].real(emin.TeV()) | |
| 418 | - bkgcube["emax"].real(emax.TeV()) | |
| 419 | - bkgcube["coordsys"].string(self.m_coordsys) | |
| 420 | - bkgcube["proj"].string(self.m_proj) | |
| 408 | + bkgcube["incube"] = "NONE" | |
| 409 | + bkgcube["usepnt"] = False | |
| 410 | + bkgcube["ebinalg"] = "LOG" | |
| 411 | + bkgcube["xref"] = self.m_xref | |
| 412 | + bkgcube["yref"] = self.m_yref | |
| 413 | + bkgcube["binsz"] = self.m_binsz | |
| 414 | + bkgcube["nxpix"] = self.m_nxpix | |
| 415 | + bkgcube["nypix"] = self.m_nypix | |
| 416 | + bkgcube["enumbins"] = self.m_ebins | |
| 417 | + bkgcube["emin"] = emin.TeV() | |
| 418 | + bkgcube["emax"] = emax.TeV() | |
| 419 | + bkgcube["coordsys"] = self.m_coordsys | |
| 420 | + bkgcube["proj"] = self.m_proj | |
| 421 | 421 | bkgcube.run() |
| 422 | 422 | |
| 423 | 423 | # Set new binned observation |
| ... | ... | @@ -475,8 +475,8 @@ class csspec(ctools.cscript): |
| 475 | 475 | |
| 476 | 476 | # Create upper limit object |
| 477 | 477 | ulimit = ctools.ctulimit(like.obs()) |
| 478 | - ulimit["srcname"].string(self.m_srcname) | |
| 479 | - ulimit["eref"].real(elogmean.TeV()) | |
| 478 | + ulimit["srcname"] = self.m_srcname | |
| 479 | + ulimit["eref"] = elogmean.TeV() | |
| 480 | 480 | |
| 481 | 481 | # Try to run upper limit and catch exceptions |
| 482 | 482 | try: | ... | ... |
test/test_ctbin.py
| ... | ... | @@ -64,19 +64,19 @@ class Test(gammalib.GPythonTestSuite): |
| 64 | 64 | """ |
| 65 | 65 | # Set-up ctbin |
| 66 | 66 | bin = ctools.ctbin() |
| 67 | - bin["inobs"].filename(self.events_name) | |
| 68 | - bin["outcube"].filename("cntmap.fits") | |
| 69 | - bin["ebinalg"].string("LOG") | |
| 70 | - bin["emin"].real(0.1) | |
| 71 | - bin["emax"].real(100.0) | |
| 72 | - bin["enumbins"].integer(20) | |
| 73 | - bin["nxpix"].integer(200) | |
| 74 | - bin["nypix"].integer(200) | |
| 75 | - bin["binsz"].real(0.02) | |
| 76 | - bin["coordsys"].string("CEL") | |
| 77 | - bin["proj"].string("CAR") | |
| 78 | - bin["xref"].real(83.63) | |
| 79 | - bin["yref"].real(22.01) | |
| 67 | + bin["inobs"] = self.events_name | |
| 68 | + bin["outcube"] = "cntmap.fits" | |
| 69 | + bin["ebinalg"] = "LOG" | |
| 70 | + bin["emin"] = 0.1 | |
| 71 | + bin["emax"] = 100.0 | |
| 72 | + bin["enumbins"] = 20 | |
| 73 | + bin["nxpix"] = 200 | |
| 74 | + bin["nypix"] = 200 | |
| 75 | + bin["binsz"] = 0.02 | |
| 76 | + bin["coordsys"] = "CEL" | |
| 77 | + bin["proj"] = "CAR" | |
| 78 | + bin["xref"] = 83.63 | |
| 79 | + bin["yref"] = 22.01 | |
| 80 | 80 | |
| 81 | 81 | # Run tool |
| 82 | 82 | self.test_try("Run ctbin") | ... | ... |
test/test_ctbkgcube.py
| ... | ... | @@ -67,24 +67,24 @@ class Test(gammalib.GPythonTestSuite): |
| 67 | 67 | """ |
| 68 | 68 | # Set-up ctbkgcube |
| 69 | 69 | bkgcube = ctools.ctbkgcube() |
| 70 | - bkgcube["inobs"].filename(self.events_name) | |
| 71 | - bkgcube["inmodel"].filename(self.bkg_model) | |
| 72 | - bkgcube["incube"].filename("NONE") | |
| 73 | - bkgcube["outcube"].filename("bkgcube.fits") | |
| 74 | - bkgcube["outmodel"].filename("bkgcube.xml") | |
| 75 | - bkgcube["caldb"].string(self.caldb) | |
| 76 | - bkgcube["irf"].string(self.irf) | |
| 77 | - bkgcube["ebinalg"].string("LOG") | |
| 78 | - bkgcube["emin"].real(0.1) | |
| 79 | - bkgcube["emax"].real(100.0) | |
| 80 | - bkgcube["enumbins"].integer(20) | |
| 81 | - bkgcube["nxpix"].integer(10) | |
| 82 | - bkgcube["nypix"].integer(10) | |
| 83 | - bkgcube["binsz"].real(0.4) | |
| 84 | - bkgcube["coordsys"].string("CEL") | |
| 85 | - bkgcube["proj"].string("CAR") | |
| 86 | - bkgcube["xref"].real(83.63) | |
| 87 | - bkgcube["yref"].real(22.01) | |
| 70 | + bkgcube["inobs"] = self.events_name | |
| 71 | + bkgcube["inmodel"] = self.bkg_model | |
| 72 | + bkgcube["incube"] = "NONE" | |
| 73 | + bkgcube["outcube"] = "bkgcube.fits" | |
| 74 | + bkgcube["outmodel"] = "bkgcube.xml" | |
| 75 | + bkgcube["caldb"] = self.caldb | |
| 76 | + bkgcube["irf"] = self.irf | |
| 77 | + bkgcube["ebinalg"] = "LOG" | |
| 78 | + bkgcube["emin"] = 0.1 | |
| 79 | + bkgcube["emax"] = 100 | |
| 80 | + bkgcube["enumbins"] = 20 | |
| 81 | + bkgcube["nxpix"] = 10 | |
| 82 | + bkgcube["nypix"] = 10 | |
| 83 | + bkgcube["binsz"] = 0.4 | |
| 84 | + bkgcube["coordsys"] = "CEL" | |
| 85 | + bkgcube["proj"] = "CAR" | |
| 86 | + bkgcube["xref"] = 83.63 | |
| 87 | + bkgcube["yref"] = 22.01 | |
| 88 | 88 | |
| 89 | 89 | # Run tool |
| 90 | 90 | self.test_try("Run ctbkgcube") | ... | ... |
test/test_ctbutterfly.py
| ... | ... | @@ -67,14 +67,14 @@ class Test(gammalib.GPythonTestSuite): |
| 67 | 67 | """ |
| 68 | 68 | # Set-up ctbutterfly |
| 69 | 69 | butterfly = ctools.ctbutterfly() |
| 70 | - butterfly["inobs"].filename(self.events_name) | |
| 71 | - butterfly["inmodel"].filename(self.model_name) | |
| 72 | - butterfly["srcname"].string("Crab") | |
| 73 | - butterfly["caldb"].string(self.caldb) | |
| 74 | - butterfly["irf"].string(self.irf) | |
| 75 | - butterfly["emin"].real(0.1) | |
| 76 | - butterfly["emax"].real(100) | |
| 77 | - butterfly["outfile"].filename("butterfly.txt") | |
| 70 | + butterfly["inobs"] = self.events_name | |
| 71 | + butterfly["inmodel"] = self.model_name | |
| 72 | + butterfly["srcname"] = "Crab" | |
| 73 | + butterfly["caldb"] = self.caldb | |
| 74 | + butterfly["irf"] = self.irf | |
| 75 | + butterfly["emin"] = 0.1 | |
| 76 | + butterfly["emax"] = 100 | |
| 77 | + butterfly["outfile"] = "butterfly.txt" | |
| 78 | 78 | |
| 79 | 79 | # Run tool |
| 80 | 80 | self.test_try("Run ctbutterfly") | ... | ... |
test/test_ctcubemask.py
| ... | ... | @@ -65,14 +65,14 @@ class Test(gammalib.GPythonTestSuite): |
| 65 | 65 | """ |
| 66 | 66 | # Set-up ctcubemask |
| 67 | 67 | mask = ctools.ctcubemask() |
| 68 | - mask["inobs"].filename(self.cntmap_name) | |
| 69 | - mask["regfile"].filename(self.regfile) | |
| 70 | - mask["outcube"].filename("filtered_cntmap.fits") | |
| 71 | - mask["ra"].real(83.63) | |
| 72 | - mask["dec"].real(22.01) | |
| 73 | - mask["rad"].real(2.0) | |
| 74 | - mask["emin"].real(0.1) | |
| 75 | - mask["emax"].real(100.0) | |
| 68 | + mask["inobs"] = self.cntmap_name | |
| 69 | + mask["regfile"] = self.regfile | |
| 70 | + mask["outcube"] = "filtered_cntmap.fits" | |
| 71 | + mask["ra"] = 83.63 | |
| 72 | + mask["dec"] = 22.01 | |
| 73 | + mask["rad"] = 2.0 | |
| 74 | + mask["emin"] = 0.1 | |
| 75 | + mask["emax"] = 100 | |
| 76 | 76 | |
| 77 | 77 | # Run tool |
| 78 | 78 | self.test_try("Run ctcubemask") | ... | ... |
test/test_cterror.py
| ... | ... | @@ -68,12 +68,12 @@ class Test(gammalib.GPythonTestSuite): |
| 68 | 68 | """ |
| 69 | 69 | # Set-up cterror |
| 70 | 70 | error = ctools.cterror() |
| 71 | - error["inobs"].filename(self.events_name) | |
| 72 | - error["inmodel"].filename(self.model_name) | |
| 73 | - error["outmodel"].filename(self.result_name) | |
| 74 | - error["srcname"].string("Crab") | |
| 75 | - error["caldb"].string(self.caldb) | |
| 76 | - error["irf"].string(self.irf) | |
| 71 | + error["inobs"] = self.events_name | |
| 72 | + error["inmodel"] = self.model_name | |
| 73 | + error["outmodel"] = self.result_name | |
| 74 | + error["srcname"] = "Crab" | |
| 75 | + error["caldb"] = self.caldb | |
| 76 | + error["irf"] = self.irf | |
| 77 | 77 | |
| 78 | 78 | # Run tool |
| 79 | 79 | self.test_try("Run cterror") | ... | ... |
test/test_ctexpcube.py
| ... | ... | @@ -66,22 +66,22 @@ class Test(gammalib.GPythonTestSuite): |
| 66 | 66 | """ |
| 67 | 67 | # Set-up ctexpcube |
| 68 | 68 | expcube = ctools.ctexpcube() |
| 69 | - expcube["inobs"].filename(self.events_name) | |
| 70 | - expcube["incube"].filename("NONE") | |
| 71 | - expcube["outcube"].filename("expcube.fits") | |
| 72 | - expcube["caldb"].string(self.caldb) | |
| 73 | - expcube["irf"].string(self.irf) | |
| 74 | - expcube["ebinalg"].string("LOG") | |
| 75 | - expcube["emin"].real(0.1) | |
| 76 | - expcube["emax"].real(100.0) | |
| 77 | - expcube["enumbins"].integer(20) | |
| 78 | - expcube["nxpix"].integer(200) | |
| 79 | - expcube["nypix"].integer(200) | |
| 80 | - expcube["binsz"].real(0.02) | |
| 81 | - expcube["coordsys"].string("CEL") | |
| 82 | - expcube["proj"].string("CAR") | |
| 83 | - expcube["xref"].real(83.63) | |
| 84 | - expcube["yref"].real(22.01) | |
| 69 | + expcube["inobs"] = self.events_name | |
| 70 | + expcube["incube"] = "NONE" | |
| 71 | + expcube["outcube"] = "expcube.fits" | |
| 72 | + expcube["caldb"] = self.caldb | |
| 73 | + expcube["irf"] = self.irf | |
| 74 | + expcube["ebinalg"] = "LOG" | |
| 75 | + expcube["emin"] = 0.1 | |
| 76 | + expcube["emax"] = 100 | |
| 77 | + expcube["enumbins"] = 20 | |
| 78 | + expcube["nxpix"] = 200 | |
| 79 | + expcube["nypix"] = 200 | |
| 80 | + expcube["binsz"] = 0.02 | |
| 81 | + expcube["coordsys"] = "CEL" | |
| 82 | + expcube["proj"] = "CAR" | |
| 83 | + expcube["xref"] = 83.63 | |
| 84 | + expcube["yref"] = 22.01 | |
| 85 | 85 | |
| 86 | 86 | # Run tool |
| 87 | 87 | self.test_try("Run ctexpcube") | ... | ... |
test/test_ctlike.py
| ... | ... | @@ -67,11 +67,11 @@ class Test(gammalib.GPythonTestSuite): |
| 67 | 67 | """ |
| 68 | 68 | # Set-up ctlike |
| 69 | 69 | like = ctools.ctlike() |
| 70 | - like["inobs"].filename(self.events_name) | |
| 71 | - like["inmodel"].filename(self.model_name) | |
| 72 | - like["caldb"].string(self.caldb) | |
| 73 | - like["irf"].string(self.irf) | |
| 74 | - like["outmodel"].filename("result.xml") | |
| 70 | + like["inobs"] = self.events_name | |
| 71 | + like["inmodel"] = self.model_name | |
| 72 | + like["caldb"] = self.caldb | |
| 73 | + like["irf"] = self.irf | |
| 74 | + like["outmodel"] = "result.xml" | |
| 75 | 75 | |
| 76 | 76 | # Run tool |
| 77 | 77 | self.test_try("Run ctlike") | ... | ... |
test/test_ctmodel.py
| ... | ... | @@ -66,30 +66,30 @@ class Test(gammalib.GPythonTestSuite): |
| 66 | 66 | """ |
| 67 | 67 | # Set-up ctmodel from scratch |
| 68 | 68 | model = ctools.ctmodel() |
| 69 | - model["incube"].filename("NONE") | |
| 70 | - model["outcube"].filename("modmap.fits") | |
| 71 | - model["inmodel"].filename(self.model_name) | |
| 72 | - model["inobs"].filename("NONE") | |
| 73 | - model["expcube"].filename("NONE") | |
| 74 | - model["psfcube"].filename("NONE") | |
| 75 | - model["bkgcube"].filename("NONE") | |
| 76 | - model["caldb"].string(self.caldb) | |
| 77 | - model["irf"].string(self.irf) | |
| 78 | - model["rad"].real(5.0) | |
| 79 | - model["ra"].real(83.63) | |
| 80 | - model["dec"].real(22.01) | |
| 81 | - model["tmin"].real(0.0) | |
| 82 | - model["tmax"].real(1800.0) | |
| 83 | - model["emin"].real(0.1) | |
| 84 | - model["emax"].real(100.0) | |
| 85 | - model["enumbins"].integer(20) | |
| 86 | - model["nxpix"].integer(200) | |
| 87 | - model["nypix"].integer(200) | |
| 88 | - model["binsz"].real(0.02) | |
| 89 | - model["coordsys"].string("CEL") | |
| 90 | - model["proj"].string("CAR") | |
| 91 | - model["xref"].real(83.63) | |
| 92 | - model["yref"].real(22.01) | |
| 69 | + model["incube"] = "NONE" | |
| 70 | + model["outcube"] = "modmap.fits" | |
| 71 | + model["inmodel"] = self.model_name | |
| 72 | + model["inobs"] = "NONE" | |
| 73 | + model["expcube"] = "NONE" | |
| 74 | + model["psfcube"] = "NONE" | |
| 75 | + model["bkgcube"] = "NONE" | |
| 76 | + model["caldb"] = self.caldb | |
| 77 | + model["irf"] = self.irf | |
| 78 | + model["rad"] = 5 | |
| 79 | + model["ra"] = 83.63 | |
| 80 | + model["dec"] = 22.01 | |
| 81 | + model["tmin"] = 0 | |
| 82 | + model["tmax"] = 1800 | |
| 83 | + model["emin"] = 0.1 | |
| 84 | + model["emax"] = 100 | |
| 85 | + model["enumbins"] = 20 | |
| 86 | + model["nxpix"] = 200 | |
| 87 | + model["nypix"] = 200 | |
| 88 | + model["binsz"] = 0.02 | |
| 89 | + model["coordsys"] = "CEL" | |
| 90 | + model["proj"] = "CAR" | |
| 91 | + model["xref"] = 83.63 | |
| 92 | + model["yref"] = 22.01 | |
| 93 | 93 | |
| 94 | 94 | # Run tool |
| 95 | 95 | self.test_try("Run ctmodel") | ... | ... |
test/test_ctobssim.py
| ... | ... | @@ -67,17 +67,17 @@ class Test(gammalib.GPythonTestSuite): |
| 67 | 67 | """ |
| 68 | 68 | # Set-up ctobssim |
| 69 | 69 | sim = ctools.ctobssim() |
| 70 | - sim["inmodel"].filename(self.model_name) | |
| 71 | - sim["outevents"].filename("events.fits") | |
| 72 | - sim["caldb"].string(self.caldb) | |
| 73 | - sim["irf"].string(self.irf) | |
| 74 | - sim["ra"].real(83.63) | |
| 75 | - sim["dec"].real(22.01) | |
| 76 | - sim["rad"].real(10.0) | |
| 77 | - sim["tmin"].real(0.0) | |
| 78 | - sim["tmax"].real(1800.0) | |
| 79 | - sim["emin"].real(0.1) | |
| 80 | - sim["emax"].real(100.0) | |
| 70 | + sim["inmodel"] = self.model_name | |
| 71 | + sim["outevents"] = "events.fits" | |
| 72 | + sim["caldb"] = self.caldb | |
| 73 | + sim["irf"] = self.irf | |
| 74 | + sim["ra"] = 83.63 | |
| 75 | + sim["dec"] = 22.01 | |
| 76 | + sim["rad"] = 10.0 | |
| 77 | + sim["tmin"] = 0.0 | |
| 78 | + sim["tmax"] = 1800.0 | |
| 79 | + sim["emin"] = 0.1 | |
| 80 | + sim["emax"] = 100.0 | |
| 81 | 81 | |
| 82 | 82 | # Run tool |
| 83 | 83 | self.test_try("Run ctobssim") |
| ... | ... | @@ -117,8 +117,8 @@ class Test(gammalib.GPythonTestSuite): |
| 117 | 117 | |
| 118 | 118 | # Set-up ctobssim |
| 119 | 119 | sim = ctools.ctobssim(obs) |
| 120 | - sim["outevents"].filename("sim_events.xml") | |
| 121 | - sim["inmodel"].filename(self.model_name) | |
| 120 | + sim["outevents"] = "sim_events.xml" | |
| 121 | + sim["inmodel"] = self.model_name | |
| 122 | 122 | # Run tool |
| 123 | 123 | self.test_try("Run ctobssim") |
| 124 | 124 | try: | ... | ... |
test/test_ctpsfcube.py
| ... | ... | @@ -66,24 +66,24 @@ class Test(gammalib.GPythonTestSuite): |
| 66 | 66 | """ |
| 67 | 67 | # Set-up ctpsfcube |
| 68 | 68 | psfcube = ctools.ctpsfcube() |
| 69 | - psfcube["inobs"].filename(self.events_name) | |
| 70 | - psfcube["incube"].filename("NONE") | |
| 71 | - psfcube["outcube"].filename("psfcube.fits") | |
| 72 | - psfcube["caldb"].string(self.caldb) | |
| 73 | - psfcube["irf"].string(self.irf) | |
| 74 | - psfcube["ebinalg"].string("LOG") | |
| 75 | - psfcube["emin"].real(0.1) | |
| 76 | - psfcube["emax"].real(100.0) | |
| 77 | - psfcube["enumbins"].integer(20) | |
| 78 | - psfcube["nxpix"].integer(10) | |
| 79 | - psfcube["nypix"].integer(10) | |
| 80 | - psfcube["binsz"].real(0.4) | |
| 81 | - psfcube["coordsys"].string("CEL") | |
| 82 | - psfcube["proj"].string("CAR") | |
| 83 | - psfcube["xref"].real(83.63) | |
| 84 | - psfcube["yref"].real(22.01) | |
| 85 | - psfcube["amax"].real(0.3) | |
| 86 | - psfcube["anumbins"].integer(10) | |
| 69 | + psfcube["inobs"] = self.events_name | |
| 70 | + psfcube["incube"] = "NONE" | |
| 71 | + psfcube["outcube"] = "psfcube.fits" | |
| 72 | + psfcube["caldb"] = self.caldb | |
| 73 | + psfcube["irf"] = self.irf | |
| 74 | + psfcube["ebinalg"] = "LOG" | |
| 75 | + psfcube["emin"] = 0.1 | |
| 76 | + psfcube["emax"] = 100 | |
| 77 | + psfcube["enumbins"] = 20 | |
| 78 | + psfcube["nxpix"] = 10 | |
| 79 | + psfcube["nypix"] = 10 | |
| 80 | + psfcube["binsz"] = 0.4 | |
| 81 | + psfcube["coordsys"] = "CEL" | |
| 82 | + psfcube["proj"] = "CAR" | |
| 83 | + psfcube["xref"] = 83.63 | |
| 84 | + psfcube["yref"] = 22.01 | |
| 85 | + psfcube["amax"] = 0.3 | |
| 86 | + psfcube["anumbins"] = 10 | |
| 87 | 87 | |
| 88 | 88 | # Run tool |
| 89 | 89 | self.test_try("Run ctpsfcube") | ... | ... |
test/test_ctselect.py
| ... | ... | @@ -64,15 +64,15 @@ class Test(gammalib.GPythonTestSuite): |
| 64 | 64 | """ |
| 65 | 65 | # Set-up ctselect |
| 66 | 66 | select = ctools.ctselect() |
| 67 | - select["inobs"].filename(self.events_name) | |
| 68 | - select["outobs"].filename("selected_events.fits") | |
| 69 | - select["ra"].real(83.63) | |
| 70 | - select["dec"].real(22.01) | |
| 71 | - select["rad"].real(3.0) | |
| 72 | - select["tmin"].real(0.0) | |
| 73 | - select["tmax"].real(1800.0) | |
| 74 | - select["emin"].real(0.1) | |
| 75 | - select["emax"].real(100.0) | |
| 67 | + select["inobs"] = self.events_name | |
| 68 | + select["outobs"] = "selected_events.fits" | |
| 69 | + select["ra"] = 83.63 | |
| 70 | + select["dec"] = 22.01 | |
| 71 | + select["rad"] = 3 | |
| 72 | + select["tmin"] = 0 | |
| 73 | + select["tmax"] = 1800 | |
| 74 | + select["emin"] = 0.1 | |
| 75 | + select["emax"] = 100 | |
| 76 | 76 | |
| 77 | 77 | # Run tool |
| 78 | 78 | self.test_try("Run ctselect") | ... | ... |
test/test_ctskymap.py
| ... | ... | @@ -64,17 +64,17 @@ class Test(gammalib.GPythonTestSuite): |
| 64 | 64 | """ |
| 65 | 65 | # Set-up ctskymap |
| 66 | 66 | skymap = ctools.ctskymap() |
| 67 | - skymap["inobs"].filename(self.events_name) | |
| 68 | - skymap["outmap"].filename("skymap.fits") | |
| 69 | - skymap["emin"].real(0.1) | |
| 70 | - skymap["emax"].real(100.0) | |
| 71 | - skymap["nxpix"].integer(200) | |
| 72 | - skymap["nypix"].integer(200) | |
| 73 | - skymap["binsz"].real(0.02) | |
| 74 | - skymap["coordsys"].string("CEL") | |
| 75 | - skymap["proj"].string("CAR") | |
| 76 | - skymap["xref"].real(83.63) | |
| 77 | - skymap["yref"].real(22.01) | |
| 67 | + skymap["inobs"] = self.events_name | |
| 68 | + skymap["outmap"] = "skymap.fits" | |
| 69 | + skymap["emin"] = 0.1 | |
| 70 | + skymap["emax"] = 100 | |
| 71 | + skymap["nxpix"] = 200 | |
| 72 | + skymap["nypix"] = 200 | |
| 73 | + skymap["binsz"] = 0.02 | |
| 74 | + skymap["coordsys"] = "CEL" | |
| 75 | + skymap["proj"] = "CAR" | |
| 76 | + skymap["xref"] = 83.63 | |
| 77 | + skymap["yref"] = 22.01 | |
| 78 | 78 | |
| 79 | 79 | # Run tool |
| 80 | 80 | self.test_try("Run ctskymap") | ... | ... |
test/test_cttsmap.py
| ... | ... | @@ -63,23 +63,23 @@ class Test(gammalib.GPythonTestSuite): |
| 63 | 63 | # Test cttsmap functionnality |
| 64 | 64 | def test_functional(self): |
| 65 | 65 | """ |
| 66 | - Test cttsmap functionnality. | |
| 66 | + Test cttsmap functionality. | |
| 67 | 67 | """ |
| 68 | 68 | # Set-up cttsmap |
| 69 | 69 | tsmap = ctools.cttsmap() |
| 70 | - tsmap["inobs"].filename(self.events_name) | |
| 71 | - tsmap["inmodel"].filename(self.model_name) | |
| 72 | - tsmap["srcname"].string("Crab") | |
| 73 | - tsmap["caldb"].string(self.caldb) | |
| 74 | - tsmap["irf"].string(self.irf) | |
| 75 | - tsmap["outmap"].filename("tsmap.fits") | |
| 76 | - tsmap["nxpix"].integer(5) | |
| 77 | - tsmap["nypix"].integer(5) | |
| 78 | - tsmap["binsz"].real(0.02) | |
| 79 | - tsmap["coordsys"].string("CEL") | |
| 80 | - tsmap["proj"].string("CAR") | |
| 81 | - tsmap["xref"].real(83.63) | |
| 82 | - tsmap["yref"].real(22.01) | |
| 70 | + tsmap["inobs"] = self.events_name | |
| 71 | + tsmap["inmodel"] = self.model_name | |
| 72 | + tsmap["srcname"] = "Crab" | |
| 73 | + tsmap["caldb"] = self.caldb | |
| 74 | + tsmap["irf"] = self.irf | |
| 75 | + tsmap["outmap"] = "tsmap.fits" | |
| 76 | + tsmap["nxpix"] = 5 | |
| 77 | + tsmap["nypix"] = 5 | |
| 78 | + tsmap["binsz"] = 0.02 | |
| 79 | + tsmap["coordsys"] = "CEL" | |
| 80 | + tsmap["proj"] = "CAR" | |
| 81 | + tsmap["xref"] = 83.63 | |
| 82 | + tsmap["yref"] = 22.01 | |
| 83 | 83 | |
| 84 | 84 | # Run tool |
| 85 | 85 | self.test_try("Run cttsmap") | ... | ... |
test/test_ctulimit.py
| ... | ... | @@ -67,11 +67,11 @@ class Test(gammalib.GPythonTestSuite): |
| 67 | 67 | """ |
| 68 | 68 | # Set-up cttsmap |
| 69 | 69 | ulimit = ctools.ctulimit() |
| 70 | - ulimit["inobs"].filename(self.events_name) | |
| 71 | - ulimit["inmodel"].filename(self.model_name) | |
| 72 | - ulimit["srcname"].string("Crab") | |
| 73 | - ulimit["caldb"].string(self.caldb) | |
| 74 | - ulimit["irf"].string(self.irf) | |
| 70 | + ulimit["inobs"] = self.events_name | |
| 71 | + ulimit["inmodel"] = self.model_name | |
| 72 | + ulimit["srcname"] = "Crab" | |
| 73 | + ulimit["caldb"] = self.caldb | |
| 74 | + ulimit["irf"] = self.irf | |
| 75 | 75 | |
| 76 | 76 | # Run tool |
| 77 | 77 | self.test_try("Run ctulimit") | ... | ... |
test/test_pipelines.py
| ... | ... | @@ -78,17 +78,17 @@ class Test(gammalib.GPythonTestSuite): |
| 78 | 78 | |
| 79 | 79 | # Simulate events |
| 80 | 80 | sim = ctools.ctobssim() |
| 81 | - sim["inmodel"].filename(model_name) | |
| 82 | - sim["outevents"].filename(events_name) | |
| 83 | - sim["caldb"].string(caldb) | |
| 84 | - sim["irf"].string(irf) | |
| 85 | - sim["ra"].real(ra) | |
| 86 | - sim["dec"].real(dec) | |
| 87 | - sim["rad"].real(rad_sim) | |
| 88 | - sim["tmin"].real(tstart) | |
| 89 | - sim["tmax"].real(tstop) | |
| 90 | - sim["emin"].real(emin) | |
| 91 | - sim["emax"].real(emax) | |
| 81 | + sim["inmodel"] = model_name | |
| 82 | + sim["outevents"] = events_name | |
| 83 | + sim["caldb"] = caldb | |
| 84 | + sim["irf"] = irf | |
| 85 | + sim["ra"] = ra | |
| 86 | + sim["dec"] = dec | |
| 87 | + sim["rad"] = rad_sim | |
| 88 | + sim["tmin"] = tstart | |
| 89 | + sim["tmax"] = tstop | |
| 90 | + sim["emin"] = emin | |
| 91 | + sim["emax"] = emax | |
| 92 | 92 | self.test_try("Execute ctobssim") |
| 93 | 93 | try: |
| 94 | 94 | sim.execute() |
| ... | ... | @@ -98,15 +98,15 @@ class Test(gammalib.GPythonTestSuite): |
| 98 | 98 | |
| 99 | 99 | # Select events |
| 100 | 100 | select = ctools.ctselect() |
| 101 | - select["inobs"].filename(events_name) | |
| 102 | - select["outobs"].filename(selected_events_name) | |
| 103 | - select["ra"].real(ra) | |
| 104 | - select["dec"].real(dec) | |
| 105 | - select["rad"].real(rad_select) | |
| 106 | - select["tmin"].real(tstart) | |
| 107 | - select["tmax"].real(tstop) | |
| 108 | - select["emin"].real(emin) | |
| 109 | - select["emax"].real(emax) | |
| 101 | + select["inobs"] = events_name | |
| 102 | + select["outobs"] = selected_events_name | |
| 103 | + select["ra"] = ra | |
| 104 | + select["dec"] = dec | |
| 105 | + select["rad"] = rad_select | |
| 106 | + select["tmin"] = tstart | |
| 107 | + select["tmax"] = tstop | |
| 108 | + select["emin"] = emin | |
| 109 | + select["emax"] = emax | |
| 110 | 110 | self.test_try("Execute ctselect") |
| 111 | 111 | try: |
| 112 | 112 | select.execute() |
| ... | ... | @@ -116,11 +116,11 @@ class Test(gammalib.GPythonTestSuite): |
| 116 | 116 | |
| 117 | 117 | # Perform maximum likelihood fitting |
| 118 | 118 | like = ctools.ctlike() |
| 119 | - like["inobs"].filename(selected_events_name) | |
| 120 | - like["inmodel"].filename(model_name) | |
| 121 | - like["outmodel"].filename(result_name) | |
| 122 | - like["caldb"].string(caldb) | |
| 123 | - like["irf"].string(irf) | |
| 119 | + like["inobs"] = selected_events_name | |
| 120 | + like["inmodel"] = model_name | |
| 121 | + like["outmodel"] = result_name | |
| 122 | + like["caldb"] = caldb | |
| 123 | + like["irf"] = irf | |
| 124 | 124 | self.test_try("Execute ctlike") |
| 125 | 125 | try: |
| 126 | 126 | like.execute() |
| ... | ... | @@ -149,16 +149,16 @@ class Test(gammalib.GPythonTestSuite): |
| 149 | 149 | |
| 150 | 150 | # Simulate events |
| 151 | 151 | sim = ctools.ctobssim() |
| 152 | - sim["inmodel"].filename(model_name) | |
| 153 | - sim["caldb"].string(caldb) | |
| 154 | - sim["irf"].string(irf) | |
| 155 | - sim["ra"].real(ra) | |
| 156 | - sim["dec"].real(dec) | |
| 157 | - sim["rad"].real(rad_sim) | |
| 158 | - sim["tmin"].real(tstart) | |
| 159 | - sim["tmax"].real(tstop) | |
| 160 | - sim["emin"].real(emin) | |
| 161 | - sim["emax"].real(emax) | |
| 152 | + sim["inmodel"] = model_name | |
| 153 | + sim["caldb"] = caldb | |
| 154 | + sim["irf"] = irf | |
| 155 | + sim["ra"] = ra | |
| 156 | + sim["dec"] = dec | |
| 157 | + sim["rad"] = rad_sim | |
| 158 | + sim["tmin"] = tstart | |
| 159 | + sim["tmax"] = tstop | |
| 160 | + sim["emin"] = emin | |
| 161 | + sim["emax"] = emax | |
| 162 | 162 | self.test_try("Run ctobssim") |
| 163 | 163 | try: |
| 164 | 164 | sim.run() |
| ... | ... | @@ -168,13 +168,13 @@ class Test(gammalib.GPythonTestSuite): |
| 168 | 168 | |
| 169 | 169 | # Select events |
| 170 | 170 | select = ctools.ctselect(sim.obs()) |
| 171 | - select["ra"].real(ra) | |
| 172 | - select["dec"].real(dec) | |
| 173 | - select["rad"].real(rad_select) | |
| 174 | - select["tmin"].real(tstart) | |
| 175 | - select["tmax"].real(tstop) | |
| 176 | - select["emin"].real(emin) | |
| 177 | - select["emax"].real(emax) | |
| 171 | + select["ra"] = ra | |
| 172 | + select["dec"] = dec | |
| 173 | + select["rad"] = rad_select | |
| 174 | + select["tmin"] = tstart | |
| 175 | + select["tmax"] = tstop | |
| 176 | + select["emin"] = emin | |
| 177 | + select["emax"] = emax | |
| 178 | 178 | self.test_try("Run ctselect") |
| 179 | 179 | try: |
| 180 | 180 | select.run() | ... | ... |