Commit 9c5ea3237a69a6e8b7dfb0fba3eff760fd780da0
1 parent
64e71e40
Solve conflicts from merging.
Showing
1 changed file
with
6 additions
and
82 deletions
scripts/cspull.py
| @@ -78,68 +78,6 @@ class cspull(GApplication): | @@ -78,68 +78,6 @@ class cspull(GApplication): | ||
| 78 | # Return | 78 | # Return |
| 79 | return | 79 | return |
| 80 | 80 | ||
| 81 | -<<<<<<< HEAD | ||
| 82 | - def parfile(self): | ||
| 83 | - """ | ||
| 84 | - Check if parfile exists. If parfile does not exist then create a | ||
| 85 | - default parfile. This kluge avoids shipping the cscript with a parfile. | ||
| 86 | - """ | ||
| 87 | - # Set parfile name | ||
| 88 | - parfile = self.name+".par" | ||
| 89 | - | ||
| 90 | - try: | ||
| 91 | - pars = GApplicationPars(parfile) | ||
| 92 | - except: | ||
| 93 | - # Signal if parfile was not found | ||
| 94 | - sys.stdout.write("Parfile "+parfile+" not found. Create default parfile.\n") | ||
| 95 | - | ||
| 96 | - # Create default parfile | ||
| 97 | - pars = GApplicationPars() | ||
| 98 | - pars.append(GApplicationPar("srcmdl","f","a","$CTOOLS/share/models/crab.xml","","","Source model")) | ||
| 99 | - pars.append(GApplicationPar("outfile","f","a","pull.dat","","","Output file name")) | ||
| 100 | - pars.append(GApplicationPar("ntrials","i","a","10","","","Number of trials")) | ||
| 101 | - pars.append(GApplicationPar("caldb","s","h","","","","Calibration database")) | ||
| 102 | - pars.append(GApplicationPar("irf","s","a","cta_dummy_irf","","","Instrument response function")) | ||
| 103 | - pars.append(GApplicationPar("edisp","b","h","no","","","Apply energy dispersion?")) | ||
| 104 | - pars.append(GApplicationPar("ra","r","a","83.6331","0","360","RA of pointing (deg)")) | ||
| 105 | - pars.append(GApplicationPar("dec","r","a","22.0145","-90","90","Dec of pointing (deg)")) | ||
| 106 | - pars.append(GApplicationPar("emin","r","a","0.1","0.0","","Lower energy limit (TeV)")) | ||
| 107 | - pars.append(GApplicationPar("emax","r","a","100.0","0.0","","Upper energy limit (TeV)")) | ||
| 108 | - pars.append(GApplicationPar("enumbins","i","a","0","","","Number of energy bins (0=unbinned)")) | ||
| 109 | - pars.append(GApplicationPar("duration","r","a","180000.0","","","Effective exposure time (s)")) | ||
| 110 | - pars.append(GApplicationPar("deadc","r","h","0.95","","","Deadtime correction factor")) | ||
| 111 | - pars.append(GApplicationPar("rad","r","h","5.0","","","Radius of ROI (deg)")) | ||
| 112 | - pars.append(GApplicationPar("npix","i","h","200","","","Number of pixels for binned")) | ||
| 113 | - pars.append(GApplicationPar("binsz","r","h","0.05","","","Pixel size for binned (deg/pixel)")) | ||
| 114 | - pars.append_standard() | ||
| 115 | - pars.save(parfile) | ||
| 116 | - | ||
| 117 | - # Return | ||
| 118 | - return | ||
| 119 | - | ||
| 120 | - def get_parameters(self): | ||
| 121 | - """ | ||
| 122 | - Get parameters from parfile and setup the observation. | ||
| 123 | - """ | ||
| 124 | - # Get parameters | ||
| 125 | - if self.model == None: | ||
| 126 | - self.m_srcmdl = self["srcmdl"].filename() | ||
| 127 | - self.m_outfile = self["outfile"].filename() | ||
| 128 | - self.m_ntrials = self["ntrials"].integer() | ||
| 129 | - self.m_caldb = self["caldb"].string() | ||
| 130 | - self.m_irf = self["irf"].string() | ||
| 131 | - self.m_edisp = self["edisp"].boolean() | ||
| 132 | - self.m_ra = self["ra"].real() | ||
| 133 | - self.m_dec = self["dec"].real() | ||
| 134 | - self.m_emin = self["emin"].real() | ||
| 135 | - self.m_emax = self["emax"].real() | ||
| 136 | - self.m_enumbins = self["enumbins"].integer() | ||
| 137 | - self.m_duration = self["duration"].real() | ||
| 138 | - self.m_deadc = self["deadc"].real() | ||
| 139 | - self.m_rad = self["rad"].real() | ||
| 140 | - self.m_npix = self["npix"].integer() | ||
| 141 | - self.m_binsz = self["binsz"].real() | ||
| 142 | -======= | ||
| 143 | def parfile(self): | 81 | def parfile(self): |
| 144 | """ | 82 | """ |
| 145 | Check if parfile exists. If parfile does not exist then create a | 83 | Check if parfile exists. If parfile does not exist then create a |
| @@ -156,11 +94,12 @@ class cspull(GApplication): | @@ -156,11 +94,12 @@ class cspull(GApplication): | ||
| 156 | 94 | ||
| 157 | # Create default parfile | 95 | # Create default parfile |
| 158 | pars = GApplicationPars() | 96 | pars = GApplicationPars() |
| 159 | - pars.append(GApplicationPar("srcmdl","f","a","$GAMMALIB/share/models/crab.xml","","","Source model")) | 97 | + pars.append(GApplicationPar("srcmdl","f","a","$CTOOLS/share/models/crab.xml","","","Source model")) |
| 160 | pars.append(GApplicationPar("outfile","f","a","pull.dat","","","Output file name")) | 98 | pars.append(GApplicationPar("outfile","f","a","pull.dat","","","Output file name")) |
| 161 | pars.append(GApplicationPar("ntrials","i","a","10","","","Number of trials")) | 99 | pars.append(GApplicationPar("ntrials","i","a","10","","","Number of trials")) |
| 162 | pars.append(GApplicationPar("caldb","s","h","","","","Calibration database")) | 100 | pars.append(GApplicationPar("caldb","s","h","","","","Calibration database")) |
| 163 | pars.append(GApplicationPar("irf","s","a","cta_dummy_irf","","","Instrument response function")) | 101 | pars.append(GApplicationPar("irf","s","a","cta_dummy_irf","","","Instrument response function")) |
| 102 | + pars.append(GApplicationPar("edisp","b","h","no","","","Apply energy dispersion?")) | ||
| 164 | pars.append(GApplicationPar("ra","r","a","83.6331","0","360","RA of pointing (deg)")) | 103 | pars.append(GApplicationPar("ra","r","a","83.6331","0","360","RA of pointing (deg)")) |
| 165 | pars.append(GApplicationPar("dec","r","a","22.0145","-90","90","Dec of pointing (deg)")) | 104 | pars.append(GApplicationPar("dec","r","a","22.0145","-90","90","Dec of pointing (deg)")) |
| 166 | pars.append(GApplicationPar("emin","r","a","0.1","0.0","","Lower energy limit (TeV)")) | 105 | pars.append(GApplicationPar("emin","r","a","0.1","0.0","","Lower energy limit (TeV)")) |
| @@ -188,6 +127,7 @@ class cspull(GApplication): | @@ -188,6 +127,7 @@ class cspull(GApplication): | ||
| 188 | self.m_ntrials = self["ntrials"].integer() | 127 | self.m_ntrials = self["ntrials"].integer() |
| 189 | self.m_caldb = self["caldb"].string() | 128 | self.m_caldb = self["caldb"].string() |
| 190 | self.m_irf = self["irf"].string() | 129 | self.m_irf = self["irf"].string() |
| 130 | + self.m_edisp = self["edisp"].boolean() | ||
| 191 | self.m_ra = self["ra"].real() | 131 | self.m_ra = self["ra"].real() |
| 192 | self.m_dec = self["dec"].real() | 132 | self.m_dec = self["dec"].real() |
| 193 | self.m_emin = self["emin"].real() | 133 | self.m_emin = self["emin"].real() |
| @@ -198,7 +138,6 @@ class cspull(GApplication): | @@ -198,7 +138,6 @@ class cspull(GApplication): | ||
| 198 | self.m_rad = self["rad"].real() | 138 | self.m_rad = self["rad"].real() |
| 199 | self.m_npix = self["npix"].integer() | 139 | self.m_npix = self["npix"].integer() |
| 200 | self.m_binsz = self["binsz"].real() | 140 | self.m_binsz = self["binsz"].real() |
| 201 | ->>>>>>> 00-07-02 | ||
| 202 | 141 | ||
| 203 | # Set some fixed parameters | 142 | # Set some fixed parameters |
| 204 | self.m_log = False # Logging in client tools | 143 | self.m_log = False # Logging in client tools |
| @@ -325,24 +264,14 @@ class cspull(GApplication): | @@ -325,24 +264,14 @@ class cspull(GApplication): | ||
| 325 | if self.logExplicit(): | 264 | if self.logExplicit(): |
| 326 | self.log.header2("Trial "+str(seed+1)) | 265 | self.log.header2("Trial "+str(seed+1)) |
| 327 | 266 | ||
| 328 | -<<<<<<< HEAD | ||
| 329 | - # Simulate events | ||
| 330 | - obs = obsutils.sim(self.obs, \ | ||
| 331 | - nbins=self.m_enumbins, \ | ||
| 332 | - seed=seed, \ | ||
| 333 | - binsz=self.m_binsz, \ | ||
| 334 | - npix=self.m_npix, \ | ||
| 335 | - edisp=self.m_edisp, \ | ||
| 336 | - log=self.m_log, debug=self.m_debug) | ||
| 337 | -======= | ||
| 338 | # Simulate events | 267 | # Simulate events |
| 339 | obs = obsutils.sim(self.obs, \ | 268 | obs = obsutils.sim(self.obs, \ |
| 340 | nbins=self.m_enumbins, \ | 269 | nbins=self.m_enumbins, \ |
| 341 | seed=seed, \ | 270 | seed=seed, \ |
| 342 | binsz=self.m_binsz, \ | 271 | binsz=self.m_binsz, \ |
| 343 | npix=self.m_npix, \ | 272 | npix=self.m_npix, \ |
| 273 | + edisp=self.m_edisp, \ | ||
| 344 | log=self.m_log, debug=self.m_debug) | 274 | log=self.m_log, debug=self.m_debug) |
| 345 | ->>>>>>> 00-07-02 | ||
| 346 | 275 | ||
| 347 | # Determine number of events in simulation | 276 | # Determine number of events in simulation |
| 348 | nevents = 0.0 | 277 | nevents = 0.0 |
| @@ -356,14 +285,9 @@ class cspull(GApplication): | @@ -356,14 +285,9 @@ class cspull(GApplication): | ||
| 356 | self.log(nevents) | 285 | self.log(nevents) |
| 357 | self.log("\n") | 286 | self.log("\n") |
| 358 | 287 | ||
| 359 | -<<<<<<< HEAD | ||
| 360 | - # Fit model | ||
| 361 | - like = obsutils.fit(obs, edisp=self.m_edisp, \ | ||
| 362 | - log=self.m_log, debug=self.m_debug) | ||
| 363 | -======= | ||
| 364 | # Fit model | 288 | # Fit model |
| 365 | - like = obsutils.fit(obs, log=self.m_log, debug=self.m_debug) | ||
| 366 | ->>>>>>> 00-07-02 | 289 | + like = obsutils.fit(obs, edisp=self.m_edisp, \ |
| 290 | + log=self.m_log, debug=self.m_debug) | ||
| 367 | 291 | ||
| 368 | # Store results | 292 | # Store results |
| 369 | logL = like.opt().value() | 293 | logL = like.opt().value() |