@@ 409-431 (lines=23) @@ | ||
406 | ||
407 | return {"norm_ul": result["errp"] + norm.value} |
|
408 | ||
409 | def estimate_norm_ts(self, datasets): |
|
410 | """Estimate ts and sqrt(ts) for the flux point. |
|
411 | ||
412 | Parameters |
|
413 | ---------- |
|
414 | datasets : `~gammapy.modeling.Datasets` |
|
415 | the list of dataset object |
|
416 | ||
417 | Returns |
|
418 | ------- |
|
419 | result : dict |
|
420 | Dict with ts and sqrt(ts) for the flux point. |
|
421 | """ |
|
422 | stat = datasets.stat_sum() |
|
423 | ||
424 | # store best fit amplitude, set amplitude of fit model to zero |
|
425 | self.model.norm.value = 0 |
|
426 | self.model.norm.frozen = True |
|
427 | ||
428 | if self.reoptimize: |
|
429 | _ = self.fit.optimize() |
|
430 | ||
431 | stat_null = datasets.stat_sum() |
|
432 | ||
433 | # compute sqrt TS |
|
434 | ts = np.abs(stat_null - stat) |
@@ 1077-1102 (lines=26) @@ | ||
1074 | ||
1075 | return {"norm_ul": result["errp"] + norm.value} |
|
1076 | ||
1077 | def estimate_norm_ts(self): |
|
1078 | """Estimate ts and sqrt(ts) for the flux point. |
|
1079 | ||
1080 | Returns |
|
1081 | ------- |
|
1082 | result : dict |
|
1083 | Dict with ts and sqrt(ts) for the flux point. |
|
1084 | """ |
|
1085 | if not self._contribute_to_stat: |
|
1086 | return {"sqrt_ts": np.nan, "ts": np.nan} |
|
1087 | ||
1088 | stat = self.datasets.stat_sum() |
|
1089 | ||
1090 | # store best fit amplitude, set amplitude of fit model to zero |
|
1091 | self.model.norm.value = 0 |
|
1092 | self.model.norm.frozen = True |
|
1093 | ||
1094 | if self.reoptimize: |
|
1095 | _ = self.fit.optimize() |
|
1096 | ||
1097 | stat_null = self.datasets.stat_sum() |
|
1098 | ||
1099 | # compute sqrt TS |
|
1100 | ts = np.abs(stat_null - stat) |
|
1101 | sqrt_ts = np.sqrt(ts) |
|
1102 | return {"sqrt_ts": sqrt_ts, "ts": ts} |
|
1103 | ||
1104 | def estimate_norm_scan(self): |
|
1105 | """Estimate fit statistic profile for the norm parameter. |