Commit 4e77fe0586ff0aa1176c1a376feecc601d0a9703
1 parent
b691cf06
Adapt to new GModelPar and model interface
Showing
4 changed files
with
12 additions
and
26 deletions
examples/make_unbinned_analysis.py
| ... | ... | @@ -255,13 +255,8 @@ def plot_counts(observations): |
| 255 | 255 | list = obs.events() |
| 256 | 256 | |
| 257 | 257 | # Create energy axis |
| 258 | - ebounds = GEbounds() | |
| 259 | - emin = GEnergy() | |
| 260 | - emax = GEnergy() | |
| 261 | - emin.TeV(0.1) | |
| 262 | - emax.TeV(100.0) | |
| 263 | - ebounds.setlog(emin, emax, 10) | |
| 264 | - energy = [ebounds.elogmean(i).TeV() for i in range(ebounds.size())] | |
| 258 | + ebounds = GEbounds(10, GEnergy(0.1, "TeV"), GEnergy(100.0, "TeV")) | |
| 259 | + energy = [ebounds.elogmean(i).TeV() for i in range(ebounds.size())] | |
| 265 | 260 | |
| 266 | 261 | # Create spectrum |
| 267 | 262 | print("Extract data:") | ... | ... |
scripts/cspull.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This script generates the pull distribution for all model parameters. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2011-2012 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2011-2013 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by | ... | ... |
scripts/cstsdist.py
| ... | ... | @@ -313,10 +313,7 @@ class cstsdist(GApplication): |
| 313 | 313 | location.lb_deg(l, b) |
| 314 | 314 | |
| 315 | 315 | # Set source spectrum |
| 316 | - spectrum = GModelSpectralPlaw(flux, index) | |
| 317 | - spectrum["Prefactor"].scale(5.7e-16) | |
| 318 | - spectrum["PivotEnergy"].value(0.3) | |
| 319 | - spectrum["PivotEnergy"].scale(1.0e6) | |
| 316 | + spectrum = GModelSpectralPlaw(flux*5.7e-16, index, 3.0e5) | |
| 320 | 317 | if fitidx: |
| 321 | 318 | spectrum["Index"].free() |
| 322 | 319 | else: | ... | ... |
test/example_survey.py
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | # This script simulates CTA surveys. It can be considered as the master |
| 4 | 4 | # script for CTA science simulations. Please modify as needed. |
| 5 | 5 | # |
| 6 | -# Copyright (C) 2011-2012 Jurgen Knodlseder | |
| 6 | +# Copyright (C) 2011-2013 Juergen Knoedlseder | |
| 7 | 7 | # |
| 8 | 8 | # This program is free software: you can redistribute it and/or modify |
| 9 | 9 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -192,10 +192,7 @@ def add_background_model(obs): |
| 192 | 192 | |
| 193 | 193 | # Define background model |
| 194 | 194 | bgd_radial = GCTAModelRadialGauss(3.0) |
| 195 | - bgd_spectrum = GModelSpectralPlaw(61.8, -1.85) | |
| 196 | - bgd_spectrum["Prefactor"].scale(1.0e-6) | |
| 197 | - bgd_spectrum["PivotEnergy"].value(1.0) | |
| 198 | - bgd_spectrum["PivotEnergy"].scale(1.0e6) | |
| 195 | + bgd_spectrum = GModelSpectralPlaw(61.8e-6, -1.85, 1.0e6) | |
| 199 | 196 | bgd_model = GCTAModelRadialAcceptance(bgd_radial, bgd_spectrum) |
| 200 | 197 | bgd_model.name("Background") |
| 201 | 198 | bgd_model.instruments("CTA") |
| ... | ... | @@ -219,10 +216,7 @@ def crab_spec(): |
| 219 | 216 | (Albert et al. 2008, ApJ, 674, 1037) |
| 220 | 217 | """ |
| 221 | 218 | # Set parameters |
| 222 | - spectrum = GModelSpectralPlaw(5.7, -2.48) | |
| 223 | - spectrum["Prefactor"].scale(1.0e-16) | |
| 224 | - spectrum["PivotEnergy"].value(0.3) | |
| 225 | - spectrum["PivotEnergy"].scale(1.0e6) | |
| 219 | + spectrum = GModelSpectralPlaw(5.7e-16, -2.48, 3.0e5) | |
| 226 | 220 | |
| 227 | 221 | # Return spectrum |
| 228 | 222 | return spectrum |
| ... | ... | @@ -248,9 +242,9 @@ def survey_single(): |
| 248 | 242 | # Define single point source with Crab flux at galactic centre |
| 249 | 243 | center = GSkyDir() |
| 250 | 244 | center.lb_deg(0.0, 0.0) |
| 251 | - point_spatial = GModelSpatialPtsrc(center) | |
| 245 | + point_spatial = GModelSpatialPointSource(center) | |
| 252 | 246 | point_spectrum = crab_spec() |
| 253 | - point = GModelPointSource(point_spatial, point_spectrum) | |
| 247 | + point = GModelSky(point_spatial, point_spectrum) | |
| 254 | 248 | point.name('GC source') |
| 255 | 249 | |
| 256 | 250 | # Create model container |
| ... | ... | @@ -289,9 +283,9 @@ def survey_gplane(lrange=10, lstep=2): |
| 289 | 283 | # Define single point source with Crab flux at galactic centre |
| 290 | 284 | center = GSkyDir() |
| 291 | 285 | center.lb_deg(0.0, 0.0) |
| 292 | - point_spatial = GModelSpatialPtsrc(center) | |
| 286 | + point_spatial = GModelSpatialPointSource(center) | |
| 293 | 287 | point_spectrum = crab_spec() |
| 294 | - point = GModelPointSource(point_spatial, point_spectrum) | |
| 288 | + point = GModelSky(point_spatial, point_spectrum) | |
| 295 | 289 | point.name('GC source') |
| 296 | 290 | |
| 297 | 291 | # Create model container |
| ... | ... | @@ -354,7 +348,7 @@ if __name__ == '__main__': |
| 354 | 348 | cntmap = obsutils.cntmap(obs) |
| 355 | 349 | |
| 356 | 350 | # Fit observations |
| 357 | - print("Fit observatins") | |
| 351 | + print("Fit observations") | |
| 358 | 352 | like = obsutils.fit(obs) |
| 359 | 353 | #print like.opt() |
| 360 | 354 | #print like.obs().models() | ... | ... |